[hackers] [sbase] tests: Add initial support for tests || Roberto E. Vargas Caballero
commit 4593bfb3596df8e69a178329283c9d07ed0eddbd
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.net>
AuthorDate: Wed Nov 5 18:41:15 2025 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.net>
CommitDate: Mon Nov 10 09:12:00 2025 +0100
tests: Add initial support for tests
diff --git a/.gitignore b/.gitignore
index f338199..0060cdd 100644
--- a/.gitignore
+++ b/.gitignore
_AT_@ -104,3 +104,5 @@
/xargs
/xinstall
/yes
+/tests/test.log
+/tests/test.lst
diff --git a/Makefile b/Makefile
index 6596063..c478a2f 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -202,7 +202,7 @@ MAKEOBJ =\
OBJ = $(LIBUTFOBJ) $(LIBUTILOBJ) $(MAKEOBJ)
all: scripts/make
- $(SMAKE) $(BIN)
+ +_AT_$(SMAKE) $(BIN)
scripts/make:
$(CC) -o $_AT_ make/*.c
_AT_@ -252,9 +252,13 @@ sbase-box-uninstall: sbase-box proto
$(DESTDIR)$(PREFIX)/bin/sbase-box -d $(DESTDIR)$(PREFIX)/bin/
scripts/uninstall proto
+tests: all
+ _AT_cd $@ && $(MAKE)
+
dist: clean
mkdir -p sbase
- cp -R LICENSE Makefile README TODO config.mk *.c *.1 *.h libutf libutil make scripts sbase
+ cp LICENSE Makefile README TODO config.mk *.c *.1 *.h sbase
+ cp -R libutf libutil make scripts tests sbase
mv sbase sbase-$(VERSION)
tar -cf sbase-$(VERSION).tar sbase-$(VERSION)
gzip sbase-$(VERSION).tar
_AT_@ -265,6 +269,7 @@ sbase-box: $(BIN)
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $_AT_ build/*.c $(LIB)
clean:
+ _AT_cd tests && $(MAKE) clean
rm -f $(BIN) $(OBJ) $(LIB) sbase-box sbase-$(VERSION).tar.gz
rm -f scripts/make
rm -f getconf.h
diff --git a/tests/0001-echo.sh b/tests/0001-echo.sh
new file mode 100755
index 0000000..7eb961f
--- /dev/null
+++ b/tests/0001-echo.sh
_AT_@ -0,0 +1,23 @@
+#!/bin/sh
+
+set -e
+
+tmp1=tmp1.$$
+tmp2=tmp2.$$
+
+cleanup()
+{
+ st=$?
+ rm -f $tmp1 $tmp2
+ exit $st
+}
+
+trap cleanup EXIT HUP INT TERM
+
+cat <<'EOF' | tr -d '\n' > $tmp1
+--hello-- --world--!
+EOF
+
+../echo -n --hello-- --world--! > $tmp2
+
+diff -u $tmp1 $tmp2
diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644
index 0000000..1311918
--- /dev/null
+++ b/tests/Makefile
_AT_@ -0,0 +1,6 @@
+all:
+ _AT_./runtests.sh
+
+clean:
+ rm -f test.log
+ rm -f tmp*
diff --git a/tests/runtests.sh b/tests/runtests.sh
new file mode 100755
index 0000000..9433ae2
--- /dev/null
+++ b/tests/runtests.sh
_AT_@ -0,0 +1,22 @@
+#!/bin/sh
+
+export TZ=UTC
+
+cleanup()
+{
+ st=$?
+ rm -f test.res
+ exit $st
+}
+
+trap cleanup EXIT HUP INT TERM
+
+for i in *-*.sh
+do
+ printf "Test: %s\n\n" $i >> test.log
+ (./$i >> test.log 2>&1 && printf '[PASS]\t' || printf '[FAIL]\t'
+ echo "$i") | tee -a test.log
+done |
+tee test.res
+
+! grep FAIL test.res >/dev/null
Received on Mon Nov 10 2025 - 20:51:23 CET
This archive was generated by hypermail 2.3.0
: Mon Nov 10 2025 - 21:00:40 CET