test/: Add three basic self tests

* true-001.sh: Always returns true - this should never ever fail.

* run-test-001.sh: Invokes run-test, passing itself as a parameter.
  Subsequently, it outputs the very same (hardcoded) expected and actual
  values.

* run-test-002.sh: Tests run-test's negative assertion feature in a way
  similar to run-test-001.sh. However, output different (hardcoded)
  expected and actual values and invoke run-test with the negative test
  prefix ('!').

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2012-01-21 14:11:37 +01:00
parent d34e6502e9
commit 31b4c71eb2
4 changed files with 25 additions and 0 deletions

View File

@ -1,6 +1,12 @@
AUTOMAKE_OPTIONS = foreign
TESTS = \
true-001.sh \
run-test-001.sh \
run-test-002.sh
check_PROGRAMS = run-test
check_SCRIPTS = $(TESTS)
run_test_SOURCES = run-test.c

7
test/run-test-001.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
if [ "$1" = 'actual' -o "$1" = 'expected' ]; then
echo 42
else
./run-test "$0"
fi

9
test/run-test-002.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
if [ "$1" = 'actual' ]; then
echo 23
elif [ "$1" = 'expected' ]; then
echo 42
else
./run-test "!$0"
fi

3
test/true-001.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
true