REGTESTS: add more complex check conditions to check_conditions.vtc

Now that we support logic expressions, variables and parenthesis, let's
add a few more tests to check_conditions.vtc. The tests are conditionned
by the version being at least 2.5-dev2 so that it will not cause failures
during a possible later bisect session or if backported.

The test verifies that exported variables are seen, that operators precedence
works as expected, that parenthesis work at least through two levels, that an
empty condition is false while a negative number is true, and that extraneous
chars in an expression, or unfinished strings are properly caught.
This commit is contained in:
Willy Tarreau 2021-07-17 10:43:33 +02:00
parent b333db3fd2
commit f2e44d4e87

View File

@ -10,4 +10,23 @@ shell {
$HAPROXY_PROGRAM -cc "streq(foo,'foo')"
$HAPROXY_PROGRAM -cc "streq(\"foo bar\",'foo bar')"
! $HAPROXY_PROGRAM -cc "streq(foo,bar)"
if $HAPROXY_PROGRAM -cc "version_atleast(2.5-dev2)"; then
export TESTVAR=1
$HAPROXY_PROGRAM -cc 'defined(TESTVAR) && streq("$TESTVAR","1")'
$HAPROXY_PROGRAM -cc 'feature(OPENSSL) || !feature(OPENSSL)'
$HAPROXY_PROGRAM -cc '1&&!0&&!((streq(a,b)||!streq(a,a)&&1)||strneq(a,a))'
$HAPROXY_PROGRAM -cc '1 &&! 0&& !((streq(a,b)||!streq(a,a)&&1)||strneq(a,a))'
$HAPROXY_PROGRAM -cc '1 && !0 && !((streq(a,b) || !streq(a,a) && 1) || strneq(a,a))'
! $HAPROXY_PROGRAM -cc '1 && !0 && !((streq(a,b) || !streq(a,a) && 1) || strneq(a,b))'
! $HAPROXY_PROGRAM -cc '1 && !0 && !((streq(a,a) || !streq(a,a) && 1) || strneq(a,a))'
# empty string is always false
! $HAPROXY_PROGRAM -cc ''
# non-zero is true
$HAPROXY_PROGRAM -cc '-1000 && 200'
# check for various parsing errors (extra/missing chars)
! $HAPROXY_PROGRAM -cc '200rrr'
! $HAPROXY_PROGRAM -cc '!(0))'
! $HAPROXY_PROGRAM -cc 'streq(a,"a)'
fi
} -run