[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] xl: add "check-xl-vif-parse" test script
# HG changeset patch # User Mathieu Gagne <mgagne@xxxxxxxx> # Date 1335283942 -3600 # Node ID fb39cccb50e5430dce1ec612fd745b85061ebb10 # Parent 46aad1a3ab3fc5888f7dcc365dd9f90832667a67 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. [ Added entries to .hgignore and .gitignore for tools/libxl/tmp.* -iwj ] Signed-off-by: Mathieu Gagne <mgagne@xxxxxxxx> Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx> Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> --- diff -r 46aad1a3ab3f -r fb39cccb50e5 .gitignore --- a/.gitignore Tue Apr 24 17:09:22 2012 +0100 +++ b/.gitignore Tue Apr 24 17:12:22 2012 +0100 @@ -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 -r 46aad1a3ab3f -r fb39cccb50e5 .hgignore --- a/.hgignore Tue Apr 24 17:09:22 2012 +0100 +++ b/.hgignore Tue Apr 24 17:12:22 2012 +0100 @@ -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 -r 46aad1a3ab3f -r fb39cccb50e5 tools/libxl/check-xl-vif-parse --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/libxl/check-xl-vif-parse Tue Apr 24 17:12:22 2012 +0100 @@ -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 "$@" </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=255 + + +#---------- test data ---------- + +# test invalid vif config +expected </dev/null +one 1 foo + +# test invalid rate units +expected </dev/null +one $e rate=foo +one $e rate=foo +one $e rate=10MB +one $e rate=10MB/m +one $e rate=10ZB +one $e rate=10ZB/s +one $e rate=10ZB/m + +# test b/s and B/s rate units +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=16000000b/s +one 0 rate=16000000b/s@50ms +one 0 rate=2000000B/s +one 0 rate=2000000B/s@50ms + +# test Kb/s and KB/s rate units +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 and MB/s rate units +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 and GB/s rate units +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 rate overflow +expected </dev/null +one $e rate=4294967296b/s +one $e rate=4294967296Kb/s +one $e rate=4294967296Mb/s +one $e rate=4294967296Gb/s + +# test rate underflow +expected </dev/null +one $e rate=0B/s + +# test invalid replenishment interval +expected </dev/null +one $e rate=10Mb/s@foo +one $e rate=10Mb/s@10h +one $e rate=10MB/s@foo +one $e rate=10MB/s@10h + +# test replenishment interval in seconds +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 replenishment interval overflow +expected </dev/null +one $e rate=1B/s@4294967296us +one $e rate=1B/s@4294968ms +one $e rate=1B/s@4295s + +# test replenishment interval underflow +expected </dev/null +one $e rate=1B/s@0us + +# test rate limiting resulting in overflow +expected </dev/null +one $e rate=4294967295GB/s@5us +one $e rate=4296MB/s@4294s + +complete _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |