script: Add test script for traffic_summary.pl
authorGary Lockyer <gary@catalyst.net.nz>
Fri, 17 Feb 2017 01:55:10 +0000 (14:55 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Wed, 1 Mar 2017 08:01:07 +0000 (09:01 +0100)
Add the test script for traffic_summary.pl, test data in previous
commit.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Wed Mar  1 09:01:07 CET 2017 on sn-devel-144

script/tests/test_traffic_summary.sh [new file with mode: 0755]
selftest/tests.py

diff --git a/script/tests/test_traffic_summary.sh b/script/tests/test_traffic_summary.sh
new file mode 100755 (executable)
index 0000000..2dc7bed
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+if [ $# -lt 1 ]; then
+cat <<EOF
+Usage: test_traffic_summary.sh
+EOF
+exit 1;
+fi
+
+PREFIX="$1"
+shift 1
+ARGS=$@
+
+. `dirname $0`/../../testprogs/blackbox/subunit.sh
+
+script_dir=`dirname $0`/..
+input="$script_dir/testdata/traffic_summary.pdml"
+expected="$script_dir/testdata/traffic_summary.expected"
+output="$(mktemp $TMPDIR/traffic_summary.XXXXXXXXXXX)"
+ts="$script_dir/traffic_summary.pl"
+
+traffic_summary() {
+
+    $ts $input >$output
+    if [ "$?" != "0" ]; then
+        return 1
+    fi
+
+    diff $output $expected
+    if [ "$?" != "0" ]; then
+        return 1
+    fi
+}
+
+# Check the required perl modules for traffic_summary
+# skip the tests if they are not installed
+perl -MXML::Twig -e 1
+if [ "$?" != "0" ]; then
+    subunit_start_test "traffic_summary"
+    subunit_skip_test "traffic_summary" <<EOF
+perl module XML::Twig not installed
+EOF
+else
+    testit "traffic_summary" traffic_summary
+fi
+
+exit $failed
index eabe71401fcfa7dfc9f39c44e89f7c595d11eaed..103508bdddbeaee5bd8b588efdea1b38d64afb72 100644 (file)
@@ -130,6 +130,10 @@ planpythontestsuite("none", "samba.tests.kcc.graph_utils")
 planpythontestsuite("none", "samba.tests.kcc.kcc_utils")
 planpythontestsuite("none", "samba.tests.kcc.ldif_import_export")
 plantestsuite("wafsamba.duplicate_symbols", "none", [os.path.join(srcdir(), "buildtools/wafsamba/test_duplicate_symbol.sh")])
+plantestsuite(
+    "script.traffic_summary", "none",
+    [os.path.join(srcdir(), "script/tests/test_traffic_summary.sh"),
+     configuration])
 
 if with_cmocka:
     plantestsuite("samba.unittests.krb5samba", "none",