hastd: Add rudimentary tests

Test that we can start and stop hastd with an empty configuration.

Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D59345
This commit is contained in:
Dag-Erling Smørgrav committed 2026-09-05 17:44:35 +02:00
1 parent 7dfadd78ba
commit 4ec3ca55f9
4 files changed
+45

No files matched your search

+2
View File
@@ -495,6 +495,8 @@
..
growfs
..
hastd
..
ifconfig
..
ipfw
+3
View File
@@ -35,4 +35,7 @@ YFLAGS+=-v
CLEANFILES=y.tab.c y.tab.h y.output
HAS_TESTS=
SUBDIR.${MK_TESTS}= tests
.include <bsd.prog.mk>
+4
View File
@@ -0,0 +1,4 @@
PACKAGE= tests
ATF_TESTS_SH= hastd_test
.include <bsd.test.mk>
+36
View File
@@ -0,0 +1,36 @@
#
# Copyright (c) 2026 Dag-Erling Smørgrav
#
# SPDX-License-Identifier: BSD-2-Clause
#
atf_test_case ctl cleanup
ctl_head()
{
atf_set descr "Test that hastd can start, stop, and "\
"communicate with hastctl"
atf_set require.user "root"
}
ctl_body()
{
cat >hast.conf <<EOF
control $PWD/hastctl
pidfile $PWD/hastd.pid
listen $PWD/hastd.sock
EOF
atf_check hastd -c $PWD/hast.conf
atf_check -o ignore hastctl status -c $PWD/hast.conf
atf_check -o ignore hastctl stop -c $PWD/hast.conf
rm -f hastd.pid
}
ctl_cleanup()
{
if [ -s hastd.pid ]; then
kill -9 "$(cat hastd.pid)" || true
fi
}
atf_init_test_cases()
{
atf_add_test_case ctl
}