xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Mathieu Gagné" <mgagne@iweb.com>
To: xen-devel@lists.xensource.com
Cc: ian.jackson@eu.citrix.com, stefano.stabellini@eu.citrix.com
Subject: [PATCH 4 of 4 v3 RESEND] xl: add "check-xl-vif-parse" test script
Date: Tue, 24 Apr 2012 11:07:13 -0400	[thread overview]
Message-ID: <cf61db286077f7b09866.1335280033@mgagne.users.dev.iweb.com> (raw)
In-Reply-To: <patchbomb.1335280029@mgagne.users.dev.iweb.com>

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@iweb.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>

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,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-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

      parent reply	other threads:[~2012-04-24 15:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-24 15:07 [PATCH 0 of 4 v3 RESEND] xl: add support for vif rate limiting Mathieu Gagné
2012-04-24 15:07 ` [PATCH 1 of 4 v3 RESEND] xl: cleanup indentation Mathieu Gagné
2012-04-24 15:07 ` [PATCH 2 of 4 v3 RESEND] xl: xl network-attach -N (dry run) option Mathieu Gagné
2012-04-24 15:07 ` [PATCH 3 of 4 v3 RESEND] xl: add support for vif rate limiting Mathieu Gagné
2012-04-24 15:07 ` Mathieu Gagné [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cf61db286077f7b09866.1335280033@mgagne.users.dev.iweb.com \
    --to=mgagne@iweb.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).