perl -p -i -e 's/\(([^ ]+) != ([^ ]+)\)/(!($1 == $2))/' $(make test.keywords.help | sed 's,test\.keywords\.,src/tests/keywords/,g')
i.e. change
if (foo != bar) {
test_fail
}
to
if (!(foo == bar)) {
test_fail
}
The first test is "foo does not exist OR foo != bar"
the second test is "not ( foo exists AND foo == bar )"
which are very different.
After making that change, these tests failed. So we've updated
the checks to be correct, which now make the tests succeed.
&Tmp-String-0 := &NAS-IP-Address
-if ((ipaddr)&Tmp-Integer-0[0] != &NAS-IP-Address) {
+if (!((ipaddr)&Tmp-Integer-0[0] == &NAS-IP-Address)) {
test_fail
}
# IPv4 address to IPv6 address
#
&control.Tmp-Cast-IPv6addr := &Tmp-Cast-IPaddr[0]
-if (&control.Tmp-Cast-IPv6addr[0] != ::ffff:203.0.113.1) {
+if (!(&control.Tmp-Cast-IPv6addr[0] == ::ffff:203.0.113.1)) {
test_fail
}
#
# IPv6 address to IPv4 address
#
-&Tmp-Cast-IPaddr := &control.Tmp-Cast-IPv6addr
-if (&control.Tmp-Cast-IPaddr[0] != 203.0.113.1) {
+&control.Tmp-Cast-IPaddr := &control.Tmp-Cast-IPv6addr
+if (!(&control.Tmp-Cast-IPaddr[0] == 203.0.113.1)) {
test_fail
}
# IPv4 prefix to IPv6 prefix
#
&control.Tmp-Cast-IPv6Prefix := &Tmp-Cast-IPv4Prefix[0]
-if (&control.Tmp-Cast-IPv6Prefix[0] != ::ffff:203.0.113.0/120) {
+if (!(&control.Tmp-Cast-IPv6Prefix[0] == ::ffff:203.0.113.0/120)) {
test_fail
}
# IPv6 prefix to IPv4 prefix
#
&control.Tmp-Cast-IPv4Prefix := &control.Tmp-Cast-IPv6Prefix[0]
-if (&control.Tmp-Cast-IPv4Prefix[0] != 203.0.113.1/24) {
+if (!(&control.Tmp-Cast-IPv4Prefix[0] == 203.0.113.1/24)) {
test_fail
}
# IPv4 prefix (32) to IPv6 address
#
&control.Tmp-Cast-IPv6Addr := &Tmp-Cast-IPv4Prefix[1]
-if (&control.Tmp-Cast-IPv6Addr[0] != ::ffff:203.0.113.1) {
+if (!(&control.Tmp-Cast-IPv6Addr[0] == ::ffff:203.0.113.1)) {
test_fail
}
# IPv6 prefix (128) to IPv4 address
#
&control.Tmp-Cast-Ipaddr := &Tmp-Cast-IPv6Prefix[1]
-if (&control.Tmp-Cast-Ipaddr[0] != 203.0.113.1/32) {
+if (!(&control.Tmp-Cast-Ipaddr[0] == 203.0.113.1/32)) {
test_fail
}
# IPv4 address to IPv6 prefix (128)
#
&control.Tmp-Cast-IPv6Prefix := &Tmp-Cast-Ipaddr[0]
-if (&control.Tmp-Cast-IPv6Prefix != ::ffff:203.0.113.1/128) {
+if (!(&control.Tmp-Cast-IPv6Prefix == ::ffff:203.0.113.1/128)) {
test_fail
}
# IPv6 address to IPv4 prefix (32)
#
&control.Tmp-Cast-IPv4Prefix[0] := &Tmp-Cast-IPv6Addr[1]
-if (&control.Tmp-Cast-IPv4Prefix != 203.0.113.1/32) {
+if (!(&control.Tmp-Cast-IPv4Prefix == 203.0.113.1/32)) {
test_fail
}
# IPv4 address to IPv4 prefix (32)
#
&control.Tmp-Cast-IPv4Prefix := &Tmp-Cast-Ipaddr[0]
-if (&control.Tmp-Cast-IPv4Prefix != 203.0.113.1/32) {
+if (!(&control.Tmp-Cast-IPv4Prefix == 203.0.113.1/32)) {
test_fail
}
# IPv6 address to IPv6 prefix (128)
#
&control.Tmp-Cast-IPv6Prefix := &Tmp-Cast-Ipv6addr[0]
-if (&control.Tmp-Cast-IPv6Prefix != 2001:DB8::1/128) {
+if (!(&control.Tmp-Cast-IPv6Prefix == 2001:DB8::1/128)) {
test_fail
}
# IPv4 prefix (32) to IPv4 address
#
&control.Tmp-Cast-Ipaddr := &Tmp-Cast-IPv4Prefix[1]
-if (&control.Tmp-Cast-Ipaddr != 203.0.113.1) {
+if (!(&control.Tmp-Cast-Ipaddr == 203.0.113.1)) {
test_fail
}
# IPv6 prefix (128) to IPv6 address
#
&control.Tmp-Cast-IPv6Addr := &Tmp-Cast-IPv6Prefix[1]
-if (&control.Tmp-Cast-IPv6Addr != ::ffff:203.0.113.1) {
+if (!(&control.Tmp-Cast-IPv6Addr == ::ffff:203.0.113.1)) {
test_fail
}
# Check failure when no previous capture - named group
# but a failed regex is equivalent to an empty string
-if ("%{regex:foo}" != "") {
+if (%{regex:foo}) {
test_fail
}
}
# Only the 1st, 2nd, 3rd and 5th Tmp-IP-Address attributes should still be in the list
-if (("%{Tmp-IP-Address-0[0]}" != '192.0.2.1') ||
- ("%{Tmp-IP-Address-0[1]}" != '192.0.2.2') ||
- ("%{Tmp-IP-Address-0[2]}" != '192.0.2.3') ||
- ("%{Tmp-IP-Address-0[3]}" != '192.0.2.4') ||
- ("%{Tmp-IP-Address-0[4]}" != '')) {
+if (!(("%{Tmp-IP-Address-0[0]}" == '192.0.2.1')) ||
+ (!("%{Tmp-IP-Address-0[1]}" == '192.0.2.2')) ||
+ (!("%{Tmp-IP-Address-0[2]}" == '192.0.2.3')) ||
+ (!("%{Tmp-IP-Address-0[3]}" == '192.0.2.4')) ||
+ (!("%{Tmp-IP-Address-0[4]}" == ''))) {
test_fail
}
}
# Should be the same as the previous result
-if (("%{Tmp-IP-Address-0[0]}" != '192.0.2.1') ||
- ("%{Tmp-IP-Address-0[1]}" != '192.0.2.2') ||
- ("%{Tmp-IP-Address-0[2]}" != '192.0.2.3') ||
- ("%{Tmp-IP-Address-0[3]}" != '192.0.2.4') ||
- ("%{Tmp-IP-Address-0[4]}" != '')) {
+if (!(("%{Tmp-IP-Address-0[0]}" == '192.0.2.1')) ||
+ (!("%{Tmp-IP-Address-0[1]}" == '192.0.2.2')) ||
+ (!("%{Tmp-IP-Address-0[2]}" == '192.0.2.3')) ||
+ (!("%{Tmp-IP-Address-0[3]}" == '192.0.2.4')) ||
+ (!("%{Tmp-IP-Address-0[4]}" == ''))) {
test_fail
}
}
# IP address at index 0 should be removed
-if (("%{Tmp-IP-Address-0[0]}" != '192.0.2.2') ||
- ("%{Tmp-IP-Address-0[1]}" != '192.0.2.3') ||
- ("%{Tmp-IP-Address-0[2]}" != '192.0.2.4') ||
- ("%{Tmp-IP-Address-0[3]}" != '')) {
+if (!(("%{Tmp-IP-Address-0[0]}" == '192.0.2.2')) ||
+ (!("%{Tmp-IP-Address-0[1]}" == '192.0.2.3')) ||
+ (!("%{Tmp-IP-Address-0[2]}" == '192.0.2.4')) ||
+ (!("%{Tmp-IP-Address-0[3]}" == ''))) {
test_fail
}
}
# Should be the same as the previous result
-if (("%{Tmp-IP-Address-0[0]}" != '192.0.2.2') ||
- ("%{Tmp-IP-Address-0[1]}" != '192.0.2.3') ||
- ("%{Tmp-IP-Address-0[2]}" != '192.0.2.4') ||
- ("%{Tmp-IP-Address-0[3]}" != '')) {
+if (!(("%{Tmp-IP-Address-0[0]}" == '192.0.2.2')) ||
+ (!("%{Tmp-IP-Address-0[1]}" == '192.0.2.3')) ||
+ (!("%{Tmp-IP-Address-0[2]}" == '192.0.2.4')) ||
+ (!("%{Tmp-IP-Address-0[3]}" == ''))) {
test_fail
}
}
# No more IP address attributes!
-if ("%{Tmp-IP-Address-0[0]}" != '') {
+if (&Tmp-IP-Address-0) {
test_fail
}
# Non Tmp-IP-Address-0 address attributes should still be in the request list
-if ((&Tmp-String-0 != 'foobarbaz') || (&Tmp-Integer-0 != 123456789)) {
+if (!((&Tmp-String-0 == 'foobarbaz')) || (!(&Tmp-Integer-0 == 123456789))) {
test_fail
}
&control.Tmp-IP-Address-0 += 192.0.2.3
}
-if (("%{Tmp-IP-Address-0[0]}" != 192.0.2.1) || \
- ("%{Tmp-IP-Address-0[1]}" != 192.0.2.2) || \
- ("%{Tmp-IP-Address-0[2]}" != 192.0.2.3) || \
- ("%{Tmp-IP-Address-0[3]}" != 192.0.2.4)) {
+if (!(("%{Tmp-IP-Address-0[0]}" == 192.0.2.1)) || \
+ (!("%{Tmp-IP-Address-0[1]}" == 192.0.2.2)) || \
+ (!("%{Tmp-IP-Address-0[2]}" == 192.0.2.3)) || \
+ (!("%{Tmp-IP-Address-0[3]}" == 192.0.2.4))) {
test_fail
}
}
# Only the 2nd, 3rd and 4th Tmp-IP-Address attributes should still be in the list
-if (("%{Tmp-IP-Address-0[0]}" != '192.0.2.2') || \
- ("%{Tmp-IP-Address-0[1]}" != '192.0.2.3') || \
- ("%{Tmp-IP-Address-0[2]}" != '192.0.2.4') || \
- ("%{Tmp-IP-Address-0[3]}" != '')) {
+if (!(("%{Tmp-IP-Address-0[0]}" == '192.0.2.2')) || \
+ (!("%{Tmp-IP-Address-0[1]}" == '192.0.2.3')) || \
+ (!("%{Tmp-IP-Address-0[2]}" == '192.0.2.4')) || \
+ (!("%{Tmp-IP-Address-0[3]}" == ''))) {
test_fail
}
}
# Only the 1st, and 3rd Tmp-IP-Address attributes should still be in the list
-if (("%{Tmp-IP-Address-0[0]}" != '192.0.2.2') || \
- ("%{Tmp-IP-Address-0[1]}" != '192.0.2.4') || \
- ("%{Tmp-IP-Address-0[2]}" != '')) {
+if (!(("%{Tmp-IP-Address-0[0]}" == '192.0.2.2')) || \
+ (!("%{Tmp-IP-Address-0[1]}" == '192.0.2.4')) || \
+ (!("%{Tmp-IP-Address-0[2]}" == ''))) {
test_fail
}
}
# Only the 1st, and 3rd Tmp-IP-Address attributes should still be in the list
-if (("%{Tmp-IP-Address-0[0]}" != '192.0.2.2') || \
- ("%{Tmp-IP-Address-0[1]}" != '192.0.2.4') || \
- ("%{Tmp-IP-Address-0[2]}" != '')) {
+if (!(("%{Tmp-IP-Address-0[0]}" == '192.0.2.2')) || \
+ (!("%{Tmp-IP-Address-0[1]}" == '192.0.2.4')) || \
+ (!("%{Tmp-IP-Address-0[2]}" == ''))) {
test_fail
}
}
# Only the 1st, and 3rd Tmp-IP-Address attributes should still be in the list
-if (("%{Tmp-IP-Address-0[0]}" != '192.0.2.2') || \
- ("%{Tmp-IP-Address-0[1]}" != '')) {
+if (!(("%{Tmp-IP-Address-0[0]}" == '192.0.2.2')) || \
+ (!("%{Tmp-IP-Address-0[1]}" == ''))) {
test_fail
}
}
# Only the 1st, and 3rd Tmp-IP-Address attributes should still be in the list
-if ("%{Tmp-IP-Address-0[0]}" != '') {
+# and the Tmp-IP-Addres-0 attribute should be deleted
+if (&Tmp-IP-Address-0) {
test_fail
}
# Non Tmp-IP-Address-0 address attributes should still be in the request list
-if ((&Tmp-String-0 != 'foobarbaz') || (&Tmp-Integer-0 != 123456789)) {
+if (!((&Tmp-String-0 == 'foobarbaz')) || (!(&Tmp-Integer-0 == 123456789))) {
test_fail
}
# But there should still be some in the control list
-if (("%{control.Tmp-IP-Address-0[0]}" != 192.0.2.1) || ("%{control.Tmp-IP-Address-0[1]}" != 192.0.2.3)) {
+if (!(("%{control.Tmp-IP-Address-0[0]}" == 192.0.2.1)) || (!("%{control.Tmp-IP-Address-0[1]}" == 192.0.2.3))) {
test_fail
}
# String - network order representation of a 4 char string
&Tmp-Integer-1 := "%(integer:%{Tmp-String-0})"
-if (((integer)&Tmp-String-0 != &Tmp-Integer-1) || (&Tmp-Integer-1 != 9870)) {
+if (!(((integer)&Tmp-String-0 == &Tmp-Integer-1)) || (!(&Tmp-Integer-1 == 9870))) {
test_fail
}
# String - network order representation of a 8 char string
&Tmp-uint64-0 := "%(integer:%{Tmp-String-1})"
-if (((integer64) &Tmp-String-1 != &Tmp-uint64-0) || (&Tmp-uint64-0 != 98709870)) {
+if (((integer64) &Tmp-String-1 != &Tmp-uint64-0) || (!(&Tmp-uint64-0 == 98709870))) {
test_fail
}
# Octets - network order representation of a 4 byte octet string
&Tmp-Integer-1 := "%(integer:%{Tmp-Octets-0})"
-if (&Tmp-Octets-0 != "%{hex:Tmp-Integer-1}") {
+if (!("%{Tmp-Octets-0}" == "0x%{hex:%{Tmp-Integer-1}}")) {
test_fail
}
-if (&Tmp-Integer-1 != 959985457) {
+if (!(&Tmp-Integer-1 == 959985457)) {
test_fail
}
#
# Disabled until xlats can return binary data
#
-if (&Tmp-Octets-1 != "%{hex:Tmp-uint64-0}") {
+if (!("%{Tmp-Octets-1}" == "0x%{hex:%{Tmp-uint64-0}}")) {
test_fail
}
-if (&Tmp-uint64-0 != 4123106143410599729) {
+if (!(&Tmp-uint64-0 == 4123106143410599729)) {
test_fail
}
&Tmp-String-8 := "%(integer:%{Tmp-Cast-IPv6Prefix})"
# IP Address
-if (&Tmp-String-2 != '959985458') {
+if (!(&Tmp-String-2 == '959985458')) {
test_fail
}
-if ((ipaddr)&Tmp-String-2 != &Tmp-IP-Address-0) {
+if (!((ipaddr)&Tmp-String-2 == &Tmp-IP-Address-0)) {
test_fail
}
# Date
-if (&Tmp-String-3 != '959985459') {
+if (!(&Tmp-String-3 == '959985459')) {
test_fail
}
# Integer
-if (&Tmp-String-4 != '959985460') {
+if (!(&Tmp-String-4 == '959985460')) {
test_fail
}
# ifid - Can't convert interface ID to an integer
-if (&Tmp-String-6 != '') {
+if (!(&Tmp-String-6 == '')) {
test_fail
}
# ipv6addr - Can't convert IPv6 to integer
-if (&Tmp-String-7 != '959985464') {
+if (!(&Tmp-String-7 == '959985464')) {
test_fail
}
# ipv6addrprefix
-if (&Tmp-String-8 != '959985465') {
+if (!(&Tmp-String-8 == '959985465')) {
test_fail
}
&Tmp-String-4 := "%(integer:%{Tmp-Cast-IPv4Prefix})"
# byte
-if (&Tmp-String-0 != '58') {
+if (!(&Tmp-String-0 == '58')) {
test_fail
}
# short
-if (&Tmp-String-1 != '14139') {
+if (!(&Tmp-String-1 == '14139')) {
test_fail
}
# ethernet
-if (&Tmp-uint64-2 != 959985468) {
+if (!(&Tmp-uint64-2 == 959985468)) {
test_fail
}
# with the lowest octet of the integer mapping to the right-most
# ethernet octet (in network order)
#
-if ((ether)&Tmp-uint64-2 != &Tmp-Cast-Ether) {
+if (!((ether)&Tmp-uint64-2 == &Tmp-Cast-Ether)) {
test_fail
}
# integer64
-if (&Tmp-String-3 != '1152921505566832445') {
+if (!(&Tmp-String-3 == '1152921505566832445')) {
test_fail
}
# ipv4prefix
-if (&Tmp-String-4 != '959985470') {
+if (!(&Tmp-String-4 == '959985470')) {
test_fail
}
&Service-Type := Login-User
&Tmp-Integer-2 := "%(integer:%{Service-Type})"
-if (&Tmp-Integer-2 != 1) {
+if (!(&Tmp-Integer-2 == 1)) {
test_fail
}
&Tmp-String-0 := %(soh:OS)
# SoH-Supported not set - should be no response
-if ("%{Tmp-String-0}" != "") {
+if (&Tmp-String-0) {
test_fail
}
&Tmp-String-0 := %(soh:OS)
# SoH-MS-Machine-OS-vendor not set - should be no response
-if ("%{Tmp-String-0}" != "") {
+if (&Tmp-String-0) {
test_fail
}
# PRE: if
#
-if ("%{Client-Shortname}" != 'test') {
+if (!("%{Client-Shortname}" == 'test')) {
test_fail
}
-if ("%{Virtual-Server}" != 'default') {
+if (!("%{Virtual-Server}" == 'default')) {
test_fail
}
ok
-if ("%{Module-Return-Code}" != 'ok') {
+if (!("%{Module-Return-Code}" == 'ok')) {
test_fail
}
-if ("%{Packet-Type}" != 'Access-Request') {
+if (!("%{Packet-Type}" == 'Access-Request')) {
test_fail
}
-# Response hasn't been set yet
-if ("%{reply.Packet-Type}" != '') {
- test_fail
-}
+# Response hasn't been set yet, but reply.Packet-Type
+# is virtual, and always exists.
-if ("%{Packet-Authentication-Vector}" != '0x00000000000000000000000000000000') {
+if (!("%{Packet-Authentication-Vector}" == '0x00000000000000000000000000000000')) {
test_fail
}
-if ("%{Client-IP-Address}" != 127.0.0.1) {
+if (!("%{Client-IP-Address}" == 127.0.0.1)) {
test_fail
}
-if ("%{Packet-Src-IP-Address}" != 127.0.0.1) {
+if (!("%{Packet-Src-IP-Address}" == 127.0.0.1)) {
test_fail
}
-if ("%{Packet-Dst-IP-Address}" != 127.0.0.1) {
+if (!("%{Packet-Dst-IP-Address}" == 127.0.0.1)) {
test_fail
}
# Can't have both...
-if ("%{Packet-Src-IPv6-Address}" != '') {
+if (%{Packet-Src-IPv6-Address}) {
test_fail
}
-if ("%{Packet-Dst-IPv6-Address}" != '') {
+if (%{Packet-Dst-IPv6-Address}) {
test_fail
}
-if ("%{Packet-Src-Port}" != '18120') {
+if (!("%{Packet-Src-Port}" == '18120')) {
test_fail
}
-if ("%{Packet-Dst-Port}" != '1812') {
+if (!("%{Packet-Dst-Port}" == '1812')) {
test_fail
}
# We should allow the user to overload virtual attributes
&Client-Shortname := 'my_test_client'
-if ("%{Client-Shortname}" != 'my_test_client') {
+if (!("%{Client-Shortname}" == 'my_test_client')) {
test_fail
}
# Operations on virtual attributes should be the same as on real ones
-if ("%{Virtual-Server[0]}" != 'default') {
+if (!("%{Virtual-Server[0]}" == 'default')) {
test_fail
}
-if ("%{Virtual-Server[*]}" != 'default') {
+if (!("%{Virtual-Server[*]}" == 'default')) {
test_fail
}
-if ("%{Virtual-Server[#]}" != 1) {
+if (!("%{Virtual-Server[#]}" == 1)) {
test_fail
}