[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 4 of 4] xl: add "check-xl-vif-parse" test script
This test script runs "xl -N network-attach 0 <foobar>" against various rate syntax and checks that the output is as expected. Signed-off-by: Mathieu Gagnà <mgagne@xxxxxxxx> diff --git a/tools/libxl/check-xl-vif-parse b/tools/libxl/check-xl-vif-parse new file mode 100755 --- /dev/null +++ b/tools/libxl/check-xl-vif-parse @@ -0,0 +1,233 @@ +#!/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 "$@" </dev/null >$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=1 + + +#---------- test data ---------- + +expected </dev/null +one $e foo + +# test invalid rate +expected <<END +vif: { + "backend_domid": 0, + "devid": 0, + "mtu": 0, + "model": null, + "mac": "00:00:00:00:00:00", + "ip": null, + "bridge": null, + "ifname": null, + "script": null, + "nictype": null, + "rate_bytes_per_interval": 214748364, + "rate_interval_usecs": 50000 +} + +END +one 0 rate=foo +one 0 rate=10MB +one 0 rate=10MB/m +one 0 rate=10ZB +one 0 rate=10ZB/s +one 0 rate=10ZB/m + +# test Kb/s unit +expected <<END +vif: { + "backend_domid": 0, + "devid": 0, + "mtu": 0, + "model": null, + "mac": "00:00:00:00:00:00", + "ip": null, + "bridge": null, + "ifname": null, + "script": null, + "nictype": null, + "rate_bytes_per_interval": 100, + "rate_interval_usecs": 50000 +} + +END +one 0 rate=16Kb/s +one 0 rate=16Kb/s@50ms +one 0 rate=2KB/s +one 0 rate=2KB/s@50ms + +# test Mb/s unit +expected <<END +vif: { + "backend_domid": 0, + "devid": 0, + "mtu": 0, + "model": null, + "mac": "00:00:00:00:00:00", + "ip": null, + "bridge": null, + "ifname": null, + "script": null, + "nictype": null, + "rate_bytes_per_interval": 100000, + "rate_interval_usecs": 50000 +} + +END +one 0 rate=16Mb/s +one 0 rate=16Mb/s@50ms +one 0 rate=2MB/s +one 0 rate=2MB/s@50ms + +# test Gb/s unit +expected <<END +vif: { + "backend_domid": 0, + "devid": 0, + "mtu": 0, + "model": null, + "mac": "00:00:00:00:00:00", + "ip": null, + "bridge": null, + "ifname": null, + "script": null, + "nictype": null, + "rate_bytes_per_interval": 50000000, + "rate_interval_usecs": 50000 +} + +END +one 0 rate=8Gb/s +one 0 rate=8Gb/s@50ms +one 0 rate=1GB/s +one 0 rate=1GB/s@50ms + +# test bytes/s overflow +expected <<END +vif: { + "backend_domid": 0, + "devid": 0, + "mtu": 0, + "model": null, + "mac": "00:00:00:00:00:00", + "ip": null, + "bridge": null, + "ifname": null, + "script": null, + "nictype": null, + "rate_bytes_per_interval": 214748364, + "rate_interval_usecs": 50000 +} + +END +one 0 rate=40Gb/s +one 0 rate=40Gb/s@50ms +one 0 rate=40GB/s +one 0 rate=40GB/s@50ms + +# test bytes/s and interval +expected <<END +vif: { + "backend_domid": 0, + "devid": 0, + "mtu": 0, + "model": null, + "mac": "00:00:00:00:00:00", + "ip": null, + "bridge": null, + "ifname": null, + "script": null, + "nictype": null, + "rate_bytes_per_interval": 10000000, + "rate_interval_usecs": 1000000 +} + +END +one 0 rate=80Mb/s@1s +one 0 rate=10MB/s@1s + +# test invalid interval +expected <<END +vif: { + "backend_domid": 0, + "devid": 0, + "mtu": 0, + "model": null, + "mac": "00:00:00:00:00:00", + "ip": null, + "bridge": null, + "ifname": null, + "script": null, + "nictype": null, + "rate_bytes_per_interval": 4294967295, + "rate_interval_usecs": 0 +} + +END +one 0 rate=10Mb/s@foo +one 0 rate=10Mb/s@10h +one 0 rate=10MB/s@foo +one 0 rate=10MB/s@10h + +# test bytes/s with interval overflow +expected <<END +vif: { + "backend_domid": 0, + "devid": 0, + "mtu": 0, + "model": null, + "mac": "00:00:00:00:00:00", + "ip": null, + "bridge": null, + "ifname": null, + "script": null, + "nictype": null, + "rate_bytes_per_interval": 4294967295, + "rate_interval_usecs": 0 +} + +END +one 0 rate=200Gb/s@10s +one 0 rate=25GB/s@10s + +complete _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |