citrun

watch C/C++ source code execute
Log | Files | Refs | LICENSE

commit 2c004efc083a3c316530532648177c2064db7ffe
parent b6df7abf550cbefd14c5e0936a1c964d0b554caf
Author: Kyle Milz <kyle@0x30.net>
Date:   Sun, 15 Jan 2017 14:27:31 -0700

tt: snapshot work in progress

Diffstat:
Mtt/git.sh | 25+++++++++++++++----------
Mtt/mutt.sh | 6+++++-
Mtt/openssl.sh | 9++++-----
Mtt/package.subr | 77+++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------
4 files changed, 81 insertions(+), 36 deletions(-)

diff --git a/tt/git.sh b/tt/git.sh @@ -3,16 +3,23 @@ # Instruments git, checks logs, and makes sure the resulting program still # works. # -. tt/package.subr "devel/git" -plan 9 +. tt/package.subr 'devel' 'git' +plan 1 pkg_check_deps pkg_clean pkg_build +cp $workdist/config.log /tmp/config.log.good + +pkg_clean +pkg_build_instrumented + +exit 0 +diag diff -u $workdist/config.log /tmp/config.log.good # Writes too many shared memory files and quickly fills /tmp. #pkg_test -cat <<EOF > check.good +cat <<EOF > $workdir/check.good Summary: 383 Source files used as input 84 Application link commands @@ -36,8 +43,9 @@ Totals: 1531 Errors rewriting source EOF pkg_check +exit 0 -cat <<EOF > tu_list.good +cat <<EOF > $workdir/tu_list.good abspath.c 181 advice.c 120 alias.c 78 @@ -309,12 +317,9 @@ xdiff/xutils.c 496 zlib.c 274 EOF -$workdir/git < /dev/null > /dev/null - -ok "is write_tus.pl exit code 0" \ - perl -I$treedir $treedir/tt/write_tus.pl ${CITRUN_PROCDIR}git_* +$workdist/git < /dev/null > /dev/null -sort -o tu_list.out tu_list.out -ok "translation unit manifest" diff -u tu_list.good tu_list.out +ok "is write_tus.pl exit code 0" tt/write_tus.pl $workdir/tu_list.out ${CITRUN_PROCDIR}git_* +ok "translation unit manifest" diff -u $workdir/tu_list.good $workdir/tu_list.out pkg_clean diff --git a/tt/mutt.sh b/tt/mutt.sh @@ -2,12 +2,16 @@ # # Test that building Mutt works. # -. tt/package.subr "mail/mutt" +. tt/package.subr 'mail' 'mutt' plan 11 pkg_check_deps pkg_clean pkg_build + +pkg_clean +pkg_build_instrumented +exit 0 pkg_test cat <<EOF > check.good diff --git a/tt/openssl.sh b/tt/openssl.sh @@ -10,7 +10,7 @@ pkg_check_deps pkg_clean pkg_build -cat <<EOF > check.good +cat <<EOF > $tmpdir/check.good Summary: 752 Source files used as input 58 Application link commands @@ -33,7 +33,7 @@ Totals: EOF pkg_check -cat <<EOF > tu_list.good +cat <<EOF > $tmpdir/tu_list.good a_bitstr.c 263 a_bool.c 112 a_bytes.c 307 @@ -721,8 +721,7 @@ EOF LD_LIBRARY_PATH="$workdir" $workdir/apps/openssl < /dev/null > /dev/null -ok "is write_tus.pl exit code 0" \ - perl -I$treedir $treedir/tt/write_tus.pl ${CITRUN_PROCDIR}openssl_* -pkg_check_manifest +ok "is write_tus.pl exit code 0" tt/write_tus.pl $tmpdir/tu_list.out ${CITRUN_PROCDIR}openssl_* +ok "is tu manifest complete" diff -u $tmpdir/tu_list.good $tmpdir/tu_list.out pkg_clean diff --git a/tt/package.subr b/tt/package.subr @@ -1,47 +1,84 @@ -. t/utils.subr +. tt/libtap.subr if [ `uname` != "OpenBSD" ]; then skip_all "test not supported on this platform." fi -portdir="/usr/ports/$1" -workdir=`make -C $portdir show=WRKDIST` +# Script arguments give the path in the OpenBSD ports system. +portdir="/usr/ports/$1/$2" +workdist=`make -C $portdir show=WRKDIST` +workdir=`make -C $portdir show=WRKDIR` + +# This is used by the OpenBSD /usr/ports/infratstucture/. +# PWD is evaluated right now, WRKDIR is deferred. +portpath="${PWD}/compilers:\${WRKDIR}/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11R6/bin" + +diag "Current workdir is: $workdir" + +export CITRUN_PROCDIR="$workdir/procdir/" + +time_ok() +{ + start=`date +%s` + ok "$@" +} pkg_check_deps() { - make -C $portdir full-build-depends > deps - make -C $portdir full-test-depends >> deps - sort deps | uniq > deps.uniq - pkg_info -q > installed - comm -2 -3 deps.uniq installed > deps_needed + mkdir -p $workdir + + make -C $portdir full-all-depends > $workdir/deps + make -C $portdir full-test-depends >> $workdir/deps + sort $workdir/deps | uniq > $workdir/deps.uniq - ok "are dependencies met" diff -u /dev/null deps_needed + pkg_info -q > $workdir/installed + comm -2 -3 $workdir/deps.uniq $workdir/installed > $workdir/deps_needed + + diff -u /dev/null $workdir/deps_needed || bail "dependencies not met" } pkg_build() { - ok "is built" make -C $portdir PORTPATH="$treedir/src:\${WRKDIR}/bin:$PATH" build + mkdir -p $workdir + start=`date +%s` + make -C $portdir build > $workdir/build.stdout 2> $workdir/build.stderr + ok 'is make build exit code 0' test $? -eq 0 + + diag Vanilla build took $((`date +%s` - start)) sec +} + +pkg_build_instrumented() +{ + mkdir -p $workdir + start=`date +%s` + make -C $portdir PORTPATH="$portpath" build \ + > $workdir/build_instrumented.stdout \ + 2> $workdir/build_instrumented.stderr + ok 'is instrumented make build exit code 0' test $? -eq 0 + + diag Instrumented build took $((`date +%s` - start)) sec } pkg_test() { - ok "port test" make -C $portdir PORTPATH="$treedir/src:\${WRKDIR}/bin:$PATH" test + time_ok 'is test successful' make -C $portdir test } -pkg_check() +pkg_test_instrumented() { - ok "is citrun_check successful" citrun_check -o check.out $workdir - strip_millis check.out - ok "citrun_check output diff" diff -u check.good check.out + ok 'is test with instrumentation successful' \ + make -C $portdir PORTPATH="${portpath}" test } -pkg_clean() +pkg_check() { - ok "port clean" make -C $portdir clean + ok "is citrun_check successful" citrun_check $workdist + #ok "is 'Milliseconds' sanitized" sed -i -e "/Milliseconds spent/d" $1 + #ok "citrun_check output diff" diff -u check.good check.out } -pkg_check_manifest() +pkg_clean() { - ok "is manifest sort exit code 0" sort -o tu_list.out tu_list.out - ok "is tu manifest correct" diff -u tu_list.good tu_list.out + make -C $portdir clean=all > /dev/null + ok 'is make clean exit code 0' test $? -eq 0 }