From 5a60c9c012b245aa0afa6d9ad680662302cc4e4f Mon Sep 17 00:00:00 2001 From: Mathieu Gagne Date: Tue, 24 Apr 2012 17:12:22 +0100 Subject: xl: add "check-xl-vif-parse" test script This test script runs "xl -N network-attach 0 " against various rate syntax and checks that the output is as expected. [ Added entries to .hgignore and .gitignore for tools/libxl/tmp.* -iwj ] Signed-off-by: Mathieu Gagne Acked-by: Ian Campbell Signed-off-by: Ian Jackson Committed-by: Ian Jackson --- .gitignore | 1 + .hgignore | 1 + tools/libxl/check-xl-vif-parse | 209 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 211 insertions(+) create mode 100755 tools/libxl/check-xl-vif-parse diff --git a/.gitignore b/.gitignore index cd12b568a8..7770e54d6b 100644 --- a/.gitignore +++ b/.gitignore @@ -186,6 +186,7 @@ tools/libxl/libxlu_cfg_y.output tools/libxl/xl tools/libxl/testenum tools/libxl/testenum.c +tools/libxl/tmp.* tools/libaio/src/*.ol tools/libaio/src/*.os tools/misc/cpuperf/cpuperf-perfcntr diff --git a/.hgignore b/.hgignore index 2764b69af3..27d8f794ae 100644 --- a/.hgignore +++ b/.hgignore @@ -182,6 +182,7 @@ ^tools/libxl/xl$ ^tools/libxl/testidl$ ^tools/libxl/testidl\.c$ +^tools/libxl/tmp\..*$ ^tools/libvchan/vchan-node[12]$ ^tools/libaio/src/.*\.ol$ ^tools/libaio/src/.*\.os$ diff --git a/tools/libxl/check-xl-vif-parse b/tools/libxl/check-xl-vif-parse new file mode 100755 index 0000000000..0473182a4d --- /dev/null +++ b/tools/libxl/check-xl-vif-parse @@ -0,0 +1,209 @@ +#!/bin/bash + +set -e + +if [ -x ./xl ] ; then + export LD_LIBRARY_PATH=. + XL=./xl +else + XL=xl +fi + +fprefix=tmp.check-xl-vif-parse + +expected () { + cat >$fprefix.expected +} + +failures=0 + +one () { + expected_rc=$1; shift + printf "test case %s...\n" "$*" + set +e + ${XL} -N network-attach 0 "$@" $fprefix.actual 2>/dev/null + actual_rc=$? + diff -u $fprefix.expected $fprefix.actual + diff_rc=$? + set -e + if [ $actual_rc != $expected_rc ] || [ $diff_rc != 0 ]; then + echo >&2 "test case \`$*' failed ($actual_rc $diff_rc)" + failures=$(( $failures + 1 )) + fi +} + +complete () { + if [ "$failures" = 0 ]; then + echo all ok.; exit 0 + else + echo "$failures tests failed."; exit 1 + fi +} + +e=255 + + +#---------- test data ---------- + +# test invalid vif config +expected