]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
Run the tests twice, with and without validation. 520/head
authorMartin Vidner <mvidner@suse.cz>
Mon, 27 Jan 2020 14:37:27 +0000 (15:37 +0100)
committerMartin Vidner <mvidner@suse.cz>
Mon, 27 Jan 2020 14:37:27 +0000 (15:37 +0100)
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
zypp-plugin/testsuite/1-happy.test
zypp-plugin/testsuite/test-helper.sh

index 696cc7935b5ccefb916c69bfa446ad2cabcc64af..9d3640f9143fbb6fb561f4acb9d8f55893130617 100644 (file)
@@ -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:
index 11961522974f9b3a7a17af3f08c2dea878972d31..2db1d14c44afc6b97278014209aef045cd049d3c 100755 (executable)
@@ -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
index c77a40715cb1885b8a4bcaa4af6c09b125409571..5392e84f8f1e16a18f085657132ca9730c95eeaa 100644 (file)
@@ -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
 }