From f9520bd9cfc1e25f484bdc74d1460ce806927bc9 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Mon, 27 Jan 2020 15:37:27 +0100 Subject: [PATCH] Run the tests twice, with and without validation. Why make it so complicated? Before, coverage measurement gets messed up (the numbers go down and I look, and feel, like a fool). It's because forwarding-zypp-plugin and snapper-zypp-plugin run at the same time and both want to write to the same GCOV data files. The GCOV instrumentation will merge the data, but only if the programs run in sequence. Being run in parallel, the simpler plugin somehow wins, having covered much less code :-( ( There is a way to tell GCOV to write to a different location, with GCOV_PREFIX and GCOV_PREFIX_STRIP, but that seems less workable than this. https://gcc.gnu.org/onlinedocs/gcc/Cross-profiling.html#Cross-profiling ) --- Makefile.am | 3 ++ zypp-plugin/testsuite/1-happy.test | 59 ++++++++++++++++------------ zypp-plugin/testsuite/test-helper.sh | 11 +++++- 3 files changed, 46 insertions(+), 27 deletions(-) diff --git a/Makefile.am b/Makefile.am index 696cc793..9d3640f9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -53,6 +53,9 @@ coverage: lcov --capture --no-external --exclude '*/testsuite*/*' --output-file $(COVERAGE_INFO) --directory . --quiet lcov --list $(COVERAGE_INFO) genhtml --output-directory coverage --legend --title "Snapper code coverage" -q $(COVERAGE_INFO) + +clean-local: + find -name '*.gcda' -o -name '*.gcno' | xargs rm endif # Create all the files necessary for building the package with OBS: diff --git a/zypp-plugin/testsuite/1-happy.test b/zypp-plugin/testsuite/1-happy.test index 11961522..2db1d14c 100755 --- a/zypp-plugin/testsuite/1-happy.test +++ b/zypp-plugin/testsuite/1-happy.test @@ -8,33 +8,40 @@ dbus_session_setup || { echo "1..0 # SKIP"; exit; } mock_snapperd_setup || { echo "1..0 # SKIP"; exit; } # http://testanything.org/ -echo 1..4 +COUNT=0 +echo 1..8 -TEST="1 - It wants to make pre and post snapshots" -rm -f mock-snapperd.log -test_pre_post_snapshots | runit zypp-plugin-maxcover.conf > /dev/null -if [ "${PIPESTATUS[1]}" != 0 ]; then - echo -n "not " -fi -echo "ok $TEST" +for VALIDATION in "" --validate; do + COUNT=$((COUNT + 1)) + TEST="$COUNT - It wants to make pre and post snapshots $VALIDATION" + rm -f mock-snapperd.log + test_pre_post_snapshots | runit $VALIDATION zypp-plugin-maxcover.conf > /dev/null + if [ "${PIPESTATUS[1]}" != 0 ]; then + echo -n "not " + fi + echo "ok $TEST" -TEST="2 - It tells snapperd so" -grep "Mock CreatePreSnapshot" mock-snapperd.log \ - && grep "Mock CreatePostSnapshot" mock-snapperd.log \ - || echo -n "not " -echo "ok $TEST" + COUNT=$((COUNT + 1)) + TEST="$COUNT - It tells snapperd so" + grep "Mock CreatePreSnapshot" mock-snapperd.log \ + && grep "Mock CreatePostSnapshot" mock-snapperd.log \ + || echo -n "not " + echo "ok $TEST" -TEST="3 - It wants to make and delete pre snapshot" -rm -f mock-snapperd.log -test_pre_del_snapshots | runit zypp-plugin-maxcover.conf > /dev/null -if [ "${PIPESTATUS[1]}" != 0 ]; then - echo -n "not " -fi -echo "ok $TEST" + COUNT=$((COUNT + 1)) + TEST="$COUNT - It wants to make and delete pre snapshot $VALIDATION" + rm -f mock-snapperd.log + test_pre_del_snapshots | runit $VALIDATION zypp-plugin-maxcover.conf > /dev/null + if [ "${PIPESTATUS[1]}" != 0 ]; then + echo -n "not " + fi + echo "ok $TEST" -TEST="4 - It tells snapperd so" -grep "Mock CreatePreSnapshot" mock-snapperd.log \ - && grep "Mock DeleteSnapshots" mock-snapperd.log \ - || echo -n "not " -rm -f mock-snapperd.log -echo "ok $TEST" + COUNT=$((COUNT + 1)) + TEST="$COUNT - It tells snapperd so" + grep "Mock CreatePreSnapshot" mock-snapperd.log \ + && grep "Mock DeleteSnapshots" mock-snapperd.log \ + || echo -n "not " + rm -f mock-snapperd.log + echo "ok $TEST" +done diff --git a/zypp-plugin/testsuite/test-helper.sh b/zypp-plugin/testsuite/test-helper.sh index c77a4071..5392e84f 100644 --- a/zypp-plugin/testsuite/test-helper.sh +++ b/zypp-plugin/testsuite/test-helper.sh @@ -3,7 +3,16 @@ MYDIR=$(dirname "$0") +# usage: echo "message..." | runit [--validate] > /dev/null runit() { + # with --validate, insert a validating plugin + # into the communication pipeline + if [ "$1" = "--validate" ]; then + local VALIDATE=("$MYDIR"/../forwarding-zypp-plugin) + shift + else + local VALIDATE=() + fi local CONFIG="${1:-../../data/zypp-plugin.conf}" local STRACE="" # STRACE="strace -efile" @@ -12,7 +21,7 @@ runit() { SNAPPER_ZYPP_PLUGIN_SNAPPER_CONFIG=testsuite \ SNAPPER_ZYPP_PLUGIN_DBUS_SESSION=1 \ $STRACE \ - "$MYDIR"/../forwarding-zypp-plugin \ + "${VALIDATE[@]}" \ "$MYDIR"/../snapper-zypp-plugin } -- 2.47.3