commit bfe82376981307d7cc2eb21242705ee620965178
parent 422b9f50a494cc1866b54de535432a746b1d2b38
Author: Kyle Milz <kyle@0x30.net>
Date: Wed, 31 Aug 2016 20:06:18 -0600
tt: start converting e2e tests to use libtap.sh
Diffstat:
6 files changed, 80 insertions(+), 89 deletions(-)
diff --git a/test/package.sh b/test/package.sh
@@ -1,12 +1,14 @@
-# exports CITRUN_TOOLS and puts us in a temporary directory.
+# exports CITRUN_TOOLS and sources libtap.sh.
. test/utils.sh
-# $1 is passed in by the source ('.') statements in the tests.
-port="/usr/ports/${1}"
-wrkdist=`make -C $port show=WRKDIST`
+function pkg_set
+{
+ port="/usr/ports/$1"
+ wrkdist=`make -C $port show=WRKDIST`
-export TEST_PORT="$port"
-export TEST_WRKDIST="$wrkdist"
+ export TEST_PORT="$port"
+ export TEST_WRKDIST="$wrkdist"
+}
function pkg_check_deps
{
@@ -14,15 +16,14 @@ function pkg_check_deps
make -C $TEST_PORT full-test-depends >> deps
sort deps | uniq > deps.uniq
pkg_info -q > installed
-
comm -2 -3 deps.uniq installed > deps_needed
- test_diff ${1} "build and test dependencies" /dev/null deps_needed
+
+ ok "build and test dependencies" diff -u /dev/null deps_needed
}
function pkg_build
{
- make -C $TEST_PORT PORTPATH="$CITRUN_TOOLS:\${WRKDIR}/bin:$PATH" build
- test_ret ${1} "instrumented build exit code" $?
+ ok "port build" make -C $TEST_PORT PORTPATH="$CITRUN_TOOLS:\${WRKDIR}/bin:$PATH" build
}
function pkg_test
@@ -32,26 +33,28 @@ function pkg_test
function pkg_check
{
- $CITRUN_TOOLS/citrun-check $TEST_WRKDIST > check.out
- check_diff ${1}
+ $CITRUN_TOOLS/citrun-check -o check.out $TEST_WRKDIST
+ strip_millis check.out
+ ok "citrun-check output diff" diff -u check.good check.out
}
function pkg_clean
{
- make -C $TEST_PORT clean=all
- test_ret ${1} "clean exit code" $?
+ ok "port clean" make -C $TEST_PORT clean=all
}
-function test_ret
+function pkg_write_tus
{
- test_num=${1}
- test_desc="${2}"
- int=${3}
-
- if [ $int -eq 0 ]; then
- echo ok $test_num - $test_desc
- else
- echo not ok $test_num - $test_desc
- echo === got $int, expected 0
- fi
+ cat <<'EOF' > tu_printer.pl
+use strict;
+use warnings;
+use test::shm;
+
+open(my $out, '>', 'filelist.out') or die $!;
+my $shm = test::shm->new();
+
+select $out;
+$shm->print_tus();
+EOF
+ ok "is tu printer exit code 0" perl -I $CITRUN_TOOLS/.. tu_printer.pl
}
diff --git a/tt/bash.sh b/tt/bash.sh
@@ -1,16 +1,17 @@
+#!/bin/sh
#
# Check that Bash can be instrumented and still works after.
#
-echo 1..5
-. test/package.sh "shells/bash"
+. test/package.sh
+plan 5
-pkg_check_deps 2
-pkg_clean 3
-pkg_build 4
+pkg_set "shells/bash"
+pkg_check_deps
+pkg_clean
+pkg_build
cat <<EOF > check.good
Summary:
- 384 Calls to the rewrite tool
347 Source files used as input
96 Application link commands
190 Rewrite parse warnings
@@ -34,9 +35,9 @@ Totals:
18704 Binary operators
549 Errors rewriting source
EOF
-pkg_check 5
+pkg_check
-#$TEST_WRKDIST/bash &
+#$TEST_WRKDIST/bash > out
#echo ok 5 - bash started
#
#sleep 1
diff --git a/tt/git.sh b/tt/git.sh
@@ -2,16 +2,16 @@
# Instruments git, checks logs, and makes sure the resulting program still
# works.
#
-echo 1..8
-. test/package.sh "devel/git"
+. test/package.sh
+plan 8
-pkg_check_deps 2
-pkg_clean 3
-pkg_build 4
+pkg_set "devel/git"
+pkg_check_deps
+pkg_clean
+pkg_build
cat <<EOF > check.good
Summary:
- 448 Calls to the rewrite tool
381 Source files used as input
82 Application link commands
45 Rewrite parse warnings
@@ -35,18 +35,14 @@ Totals:
34625 Binary operators
1530 Errors rewriting source
EOF
-pkg_check 5
+pkg_check
# Start git doing something that will take a while. At my own expense.
$TEST_WRKDIST/git clone http://git.0x30.net/citrun citrun_TEST_CLONE &
pid=$!
-echo ok 6 - started git clone
sleep 1
-cat <<EOF > dump.good
-EOF
-
cat <<EOF > filelist.good
abspath.c 181
advice.c 120
@@ -319,11 +315,14 @@ xdiff/xutils.c 496
zlib.c 274
EOF
-$CITRUN_TOOLS/citrun-dump
-$CITRUN_TOOLS/citrun-dump -f > filelist.out
-filelist_diff 7
+# Writes filelist.out
+pkg_write_tus
+
+# man page says output file can be same as input file
+sort -o filelist.out filelist.out
+ok "translation unit manifest" diff -u filelist.good filelist.out
kill $pid
wait
-pkg_clean 8
+pkg_clean
diff --git a/tt/mutt.sh b/tt/mutt.sh
@@ -1,16 +1,16 @@
#
# Test that building Mutt works.
#
-echo 1..5
-. test/package.sh "mail/mutt"
+. test/package.sh
+plan 5
-pkg_check_deps 2
-pkg_clean 3
-pkg_build 4
+pkg_set "mail/mutt"
+pkg_check_deps
+pkg_clean
+pkg_build
cat <<EOF > check.good
Summary:
- 262 Calls to the rewrite tool
218 Source files used as input
73 Application link commands
339 Rewrite parse warnings
@@ -18,7 +18,7 @@ Summary:
209 Rewrite successes
9 Rewrite failures
194 Rewritten source compile successes
- 15 Rewritten source compile failues
+ 15 Rewritten source compile failures
Totals:
94664 Lines of source code
@@ -34,4 +34,4 @@ Totals:
12082 Binary operators
558 Errors rewriting source
EOF
-pkg_check 5
+pkg_check
diff --git a/tt/nvi.sh b/tt/nvi.sh
@@ -1,12 +1,13 @@
#
# Tests that nvi works with C It Run.
#
-echo 1..7
-. test/package.sh "editors/nvi"
+. test/package.sh
+plan 6
-pkg_check_deps 2
-pkg_clean 3
-pkg_build 4
+pkg_set "editors/nvi"
+pkg_check_deps
+pkg_clean
+pkg_build
cat <<EOF > check.good
Summary:
@@ -30,24 +31,13 @@ Totals:
4008 Binary operators
353 Errors rewriting source
EOF
-pkg_check 5
+pkg_check
$TEST_WRKDIST/build/nvi > out
-cat <<EOF > dump.good
-Found dead program with PID ''
- Runtime version: 0.0
- Translation units: 114
- Lines of code: 47268
- Working directory: ''
-EOF
-
-$CITRUN_TOOLS/citrun-dump | sed -e "s,'.*',''," > dump.out
-test_diff 6 "citrun-dump output" dump.good dump.out
-
# Compiler file names are full paths so this is useless atm.
#cat <<EOF > filelist.good
#EOF
#$CITRUN_TOOLS/citrun-dump -f > filelist.out
-pkg_clean 7
+pkg_clean
diff --git a/tt/openssl.sh b/tt/openssl.sh
@@ -2,13 +2,13 @@
# Instrument openssl, run its testsuite, check the logs and do a quick runtime
# sanity test on it.
#
-echo 1..8
+. test/package.sh
+plan 8
-. test/package.sh "security/openssl"
-
-pkg_check_deps 2
-pkg_clean 3
-pkg_build 4
+pkg_set "security/openssl"
+pkg_check_deps
+pkg_clean
+pkg_build
cat <<EOF > check.good
Summary:
@@ -33,17 +33,13 @@ Totals:
27553 Binary operators
2912 Errors rewriting source
EOF
-pkg_check 5
+pkg_check
LD_LIBRARY_PATH="$TEST_WRKDIST" \
$TEST_WRKDIST/apps/openssl genrsa -out KEY 16384 &
pid=$!
-sleep 3
-
-$CITRUN_TOOLS/citrun-dump
-
-test_total_execs 6
+sleep 1
cat <<EOF >filelist.good
a_bitstr.c 263
@@ -730,10 +726,12 @@ x_x509a.c 197
xcbc_enc.c 217
xts128.c 205
EOF
-$CITRUN_TOOLS/citrun-dump -f > filelist.out
-filelist_diff 7
+
+pkg_write_tus
+sort -o filelist.out filelist.out
+ok "translation unit manifest" diff -u filelist.good filelist.out
kill -INT $pid
wait
-pkg_clean 8
+pkg_clean