git: 4ec3ca55f9a7 - main - hastd: Add rudimentary tests
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 05 Sep 2026 15:44:46 UTC
The branch main has been updated by des:
URL: https://cgit.FreeBSD.org/src/commit/?id=4ec3ca55f9a790192152fedb356ffd68fc1b8926
commit 4ec3ca55f9a790192152fedb356ffd68fc1b8926
Author: Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-09-05 15:44:15 +0000
Commit: Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-09-05 15:44:35 +0000
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
---
etc/mtree/BSD.tests.dist | 2 ++
sbin/hastd/Makefile | 3 +++
sbin/hastd/tests/Makefile | 4 ++++
sbin/hastd/tests/hastd_test.sh | 36 ++++++++++++++++++++++++++++++++++++
4 files changed, 45 insertions(+)
diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist
index 20f3b36ab40b..30cb61b7a19d 100644
--- a/etc/mtree/BSD.tests.dist
+++ b/etc/mtree/BSD.tests.dist
@@ -495,6 +495,8 @@
..
growfs
..
+ hastd
+ ..
ifconfig
..
ipfw
diff --git a/sbin/hastd/Makefile b/sbin/hastd/Makefile
index 8a79320fb665..ee64143ead70 100644
--- a/sbin/hastd/Makefile
+++ b/sbin/hastd/Makefile
@@ -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>
diff --git a/sbin/hastd/tests/Makefile b/sbin/hastd/tests/Makefile
new file mode 100644
index 000000000000..bce6f3842579
--- /dev/null
+++ b/sbin/hastd/tests/Makefile
@@ -0,0 +1,4 @@
+PACKAGE= tests
+ATF_TESTS_SH= hastd_test
+
+.include <bsd.test.mk>
diff --git a/sbin/hastd/tests/hastd_test.sh b/sbin/hastd/tests/hastd_test.sh
new file mode 100644
index 000000000000..065626f22bc6
--- /dev/null
+++ b/sbin/hastd/tests/hastd_test.sh
@@ -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
+}