]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Provide and suggest update-test.sh in CONTRIBUTING 635/head
authorUlrich Windl <[email protected]>
Thu, 28 Sep 2017 07:14:50 +0000 (09:14 +0200)
committerUlrich Windl <[email protected]>
Thu, 28 Sep 2017 07:14:50 +0000 (09:14 +0200)
Provide shell script to update the output for a single test, and suggest
using it in CONTRIBUTING.

CONTRIBUTING
update-test.sh [new file with mode: 0755]

index 0f4a5d859fa921c1da76d7c37bc8f9a0ecc4973f..cc312dff9caae790343dfe0d93ef7b881018aabb 100644 (file)
@@ -80,9 +80,11 @@ How to add new code and to update existing code
    Each line in this file has the following format:
    test-name   sample.pcap   sample.out   tcpdump-options
 
-   the sample.out file can be build by:
+   The sample.out file can be build by:
    (cd tests && ../tcpdump -n -t -r sample.pcap tcpdump-options > sample.out)
 
+   Or, for convenience, use "./update-test.sh test-name"
+
    It is often useful to have test outputs with different verbosity levels
    (none, -v, -vv, -vvv, etc.) depending on the code.
 
diff --git a/update-test.sh b/update-test.sh
new file mode 100755 (executable)
index 0000000..60359d4
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh
+TEST="$1"
+PREFIX=tests
+MATCH=0
+while read name input output options
+do
+    [ _$name = _ ] && continue         # ignore empty lines
+    [ _${name#\#} != _$name ] && continue      # ignore comment lines
+    [ $name != "$TEST" ] && continue   # not the requested test
+    [ _$output = _ ] && continue       # ignore incomplete lines
+    MATCH=1
+    ./tcpdump -n -t -r "$PREFIX/$input" $options >"$PREFIX/$output"
+done < $PREFIX/TESTLIST
+[ $MATCH = 0 ] && echo "test $TEST not found" >&2