ref: 864967de9471dc425eddd468a5312d1a0bd0461a
parent: 9e70c266983bce105b2d998ab990c0b4a4d42798
author: Natanael Copa <ncopa@alpinelinux.org>
date: Tue Apr 25 03:43:57 CDT 2023
Add initial kyua test suite
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,5 @@
nlplug-findfs/nlplug-findfs
*.[17]
mkinitfs.conf
+Kyuafile
+tests/Kyuafile
--- a/Makefile
+++ b/Makefile
@@ -117,15 +117,34 @@
nlplug-findfs/nlplug-findfs: nlplug-findfs/nlplug-findfs.o
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
-check: nlplug-findfs/build
+check-nlplug-findfs: nlplug-findfs/build
nlplug-findfs/test.sh run
nlplug-findfs/build: nlplug-findfs/init.sh nlplug-findfs/nlplug-findfs nlplug-findfs/test.sh
nlplug-findfs/test.sh build
+tests/Kyuafile: $(wildcard tests/*.test)
+ echo "syntax(2)" > $@.tmp
+ echo "test_suite('mkinitfs')" >> $@.tmp
+ for i in $(notdir $(wildcard tests/*.test)); do \
+ echo "atf_test_program{name='$$i',timeout=5}" >> $@.tmp ; \
+ done
+ mv $@.tmp $@
+
+Kyuafile:
+ echo "syntax(2)" > $@.tmp
+ echo "test_suite('mkinitfs')" >> $@.tmp
+ echo "include('tests/Kyuafile')" >> $@.tmp
+ mv $@.tmp $@
+
+check: tests/Kyuafile Kyuafile mkinitfs
+ kyua test || { kyua report --verbose && exit 1 ; }
+
.SUFFIXES: .in
.in:
- ${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@
+ ${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@.tmp
+ chmod +x $@.tmp
+ mv $@.tmp $@
install: $(SBIN_FILES) $(SHARE_FILES) $(CONF_FILES)
install -d -m755 $(DESTDIR)/$(sbindir)
--- /dev/null
+++ b/tests/mkinitfs.test
@@ -1,0 +1,10 @@
+#!/usr/bin/env atf-sh
+
+. $(atf_get_srcdir)/test_env.sh
+
+init_tests \
+ mkinitfs_help
+
+mkinitfs_help_body() {
+ atf_check -o match:"usage:" mkinitfs -h
+}
--- /dev/null
+++ b/tests/test_env.sh
@@ -1,0 +1,23 @@
+# shellcheck shell=sh
+
+atf_srcdir="$(atf_get_srcdir)"
+srcdir="$atf_srcdir/.."
+PATH="$srcdir:$PATH"
+
+export ROOT="$PWD"
+
+init_tests() {
+ TESTS=
+ for t; do
+ TESTS="$TESTS $t"
+ atf_test_case "$t"
+ done
+ export TESTS
+}
+
+atf_init_test_cases() {
+ for t in $TESTS; do
+ atf_add_test_case "$t"
+ done
+}
+