[master] dc1059d Add a rudimentary number comparison feature, to avoid failures like:

Poul-Henning Kamp phk at FreeBSD.org
Tue Jan 27 11:51:29 CET 2015


commit dc1059daf2c83e05468aea2f72692e6e1a63bf70
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Jan 27 10:50:56 2015 +0000

    Add a rudimentary number comparison feature, to avoid failures like:
    
    	---- c1   11.6 EXPECT resp.http.ageB (11.867) >= "8.000" failed

diff --git a/bin/varnishtest/tests/r00956.vtc b/bin/varnishtest/tests/r00956.vtc
index a00f001..d656b84 100644
--- a/bin/varnishtest/tests/r00956.vtc
+++ b/bin/varnishtest/tests/r00956.vtc
@@ -36,9 +36,9 @@ client c1 {
 	expect resp.bodylen == 40
 	expect resp.http.fooA == 19.000
 	expect resp.http.fooB == 10.000
-	expect resp.http.foo <= 8.000
+	expect resp.http.foo .LE. 8.000
 	expect resp.http.ageA == 4.000
-	expect resp.http.ageB >= 6.000
+	expect resp.http.ageB .GE. 6.000
 
 	delay 2
 	txreq
@@ -46,7 +46,7 @@ client c1 {
 	expect resp.bodylen == 40
 	expect resp.http.fooA == 19.000
 	expect resp.http.fooB == 10.000
-	expect resp.http.foo <= 6.000
+	expect resp.http.foo .LE. 6.000
 	expect resp.http.ageA == 4.000
-	expect resp.http.ageB >= 8.000
+	expect resp.http.ageB .GE. 8.000
 } -run
diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c
index c397cb7..0612397 100644
--- a/bin/varnishtest/vtc_http.c
+++ b/bin/varnishtest/vtc_http.c
@@ -279,6 +279,14 @@ cmd_http_expect(CMD_ARGS)
 		retval = strcmp(lhs, rhs) >= 0;
 	} else if (!strcmp(cmp, ">")) {
 		retval = strcmp(lhs, rhs) > 0;
+	} else if (!strcmp(cmp, ".LT.")) {
+		retval = strtod(lhs, NULL) < strtod(rhs, NULL);
+	} else if (!strcmp(cmp, ".GT.")) {
+		retval = strtod(lhs, NULL) > strtod(rhs, NULL);
+	} else if (!strcmp(cmp, ".LE.")) {
+		retval = strtod(lhs, NULL) <= strtod(rhs, NULL);
+	} else if (!strcmp(cmp, ".GE.")) {
+		retval = strtod(lhs, NULL) >= strtod(rhs, NULL);
 	}
 
 	if (retval == -1)



More information about the varnish-commit mailing list