Project Info Name.......: gnu-hello
Description: GNU Hello


gnu-hello       
Info
Commit...:c7eeaf4e3097463c1b4b1941a0b18bbe0b83efa6
Author...:Sami Kerola
Committer:Sami Kerola
Date.....:Sun Jan 20 22:02:46 2019 +0000
Parents..:c0c3f2053fcb85377cd0b8923cd69a03e0a4336c

Message
tests: add two new tests

* tests/atexit-1: Check atexit handling works correctly.
* tests/operand-1: Check extra operand failure.
* Makefile.am: Make autotools aware of the new tests.

Changes
diff --git a/Makefile.am b/Makefile.am
line changes: +2/-0
index 1361dca..6200efb
--- a/Makefile.am
+++ b/Makefile.am
@@ -60,11 +60,13 @@ CLEANFILES += $(man_MANS)
 endif
 
 TESTS = \
+	tests/atexit-1 \
 	tests/greeting-1 \
 	tests/greeting-2 \
 	tests/hello-1 \
 	tests/last-1 \
 	tests/multibyte-1 \
+	tests/operand-1 \
 	tests/traditional-1
 
 EXTRA_DIST += $(TESTS)

diff --git a/tests/atexit-1 b/tests/atexit-1
line changes: +36/-0
index 0000000..e10fb41
--- /dev/null
+++ b/tests/atexit-1
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Test atexit handling.
+#
+# Copyright (C) 2019 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+if ! [ -c /dev/full ]; then
+  # no such character device, skip this check
+  exit 77
+fi
+
+tmpfiles="atexit-test1.ok"
+cat <<EOF >atexit-test1.ok
+hello: write error: No space left on device
+EOF
+
+tmpfiles="$tmpfiles atexit-test1.out"
+: ${HELLO=hello}
+${HELLO} 2>&1 1>/dev/full | tr -d '\r' >atexit-test1.out
+
+# remove \r (CR) characters from the output, so that the tests work on
+# platforms with CRLF line endings.  There is apparently no reliable
+# method (across Cygwin, MingW, etc.) to force an eol style.
+
+: ${DIFF=diff}
+${DIFF} atexit-test1.ok atexit-test1.out
+result=$?
+
+rm -fr $tmpfiles
+
+exit $result

diff --git a/tests/operand-1 b/tests/operand-1
line changes: +32/-0
index 0000000..a777600
--- /dev/null
+++ b/tests/operand-1
@@ -0,0 +1,32 @@
+#! /bin/sh
+# Test extra operands fail correct way.
+#
+# Copyright (C) 2019 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+tmpfiles="operand-test1.ok"
+cat <<EOF >operand-test1.ok
+hello: extra operand: first
+Try 'hello --help' for more information.
+EOF
+
+tmpfiles="$tmpfiles operand-test1.out"
+: ${HELLO=hello}
+${HELLO} first second 2>&1 | tr -d '\r' >operand-test1.out
+
+# remove \r (CR) characters from the output, so that the tests work on
+# platforms with CRLF line endings.  There is apparently no reliable
+# method (across Cygwin, MingW, etc.) to force an eol style.
+
+: ${DIFF=diff}
+${DIFF} operand-test1.ok operand-test1.out
+result=$?
+
+rm -fr $tmpfiles
+
+exit $result

This website is licensed under AGPL-3.0. Feel free to copy!