]> xenbits.xensource.com Git - libvirt.git/commitdiff
virnetdevbandwidthtest: Introduce some more tests
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 31 Jan 2014 14:04:03 +0000 (15:04 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 31 Jan 2014 15:52:27 +0000 (16:52 +0100)
And while doing this, fix one error raised by coverity. With
current code, @actual_cmd is allowed to be NULL for the whole
run of testVirNetDevBandwidthSet. However, if something else
was expected, the @actal_cmd is passed to virtTestDifference
which dereference it immediately.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
tests/virnetdevbandwidthtest.c

index 5bcab12ae07db744e048ace574942a95985b690a..073fdf88b69b4b286bb643b9689c5f8bcba72703 100644 (file)
@@ -92,7 +92,9 @@ testVirNetDevBandwidthSet(const void *data)
     }
 
     if (STRNEQ_NULLABLE(info->exp_cmd, actual_cmd)) {
-        virtTestDifference(stderr, info->exp_cmd, actual_cmd);
+        virtTestDifference(stderr,
+                           NULLSTR(info->exp_cmd),
+                           NULLSTR(actual_cmd));
         goto cleanup;
     }
 
@@ -121,6 +123,31 @@ mymain(void)
     } while (0)
 
 
+    DO_TEST_SET(NULL, NULL);
+
+    DO_TEST_SET(("<bandwidth/>"),
+                (TC " qdisc del dev eth0 root\n"
+                 TC " qdisc del dev eth0 ingress\n"));
+
+    DO_TEST_SET(("<bandwidth>"
+                 "  <inbound average='1024'/>"
+                 "</bandwidth>"),
+                (TC " qdisc del dev eth0 root\n"
+                 TC " qdisc del dev eth0 ingress\n"
+                 TC " qdisc add dev eth0 root handle 1: htb default 1\n"
+                 TC " class add dev eth0 parent 1: classid 1:1 htb rate 1024kbps\n"
+                 TC " qdisc add dev eth0 parent 1:1 handle 2: sfq perturb 10\n"
+                 TC " filter add dev eth0 parent 1:0 protocol ip handle 1 fw flowid 1\n"));
+
+    DO_TEST_SET(("<bandwidth>"
+                 "  <outbound average='1024'/>"
+                 "</bandwidth>"),
+                (TC " qdisc del dev eth0 root\n"
+                 TC " qdisc del dev eth0 ingress\n"
+                 TC " qdisc add dev eth0 ingress\n"
+                 TC " filter add dev eth0 parent ffff: protocol ip u32 match ip src 0.0.0.0/0 "
+                 "police rate 1024kbps burst 1024kb mtu 64kb drop flowid :1\n"));
+
     DO_TEST_SET(("<bandwidth>"
                  "  <inbound average='1' peak='2' floor='3' burst='4'/>"
                  "  <outbound average='5' peak='6' burst='7'/>"