From: Alan T. DeKok Date: Tue, 29 Nov 2022 23:19:30 +0000 (-0500) Subject: fix failing tests X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c32e345790b9a69cf52e60b8c73061db7cd97308;p=thirdparty%2Ffreeradius-server.git fix failing tests 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. --- diff --git a/src/tests/keywords/cast-ipaddr b/src/tests/keywords/cast-ipaddr index c17c0ef339a..250fac36e61 100644 --- a/src/tests/keywords/cast-ipaddr +++ b/src/tests/keywords/cast-ipaddr @@ -6,7 +6,7 @@ &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 } @@ -30,15 +30,15 @@ if ((ipaddr)&Tmp-Integer-0[0] != &NAS-IP-Address) { # 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 } @@ -46,7 +46,7 @@ if (&control.Tmp-Cast-IPaddr[0] != 203.0.113.1) { # 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 } @@ -54,7 +54,7 @@ if (&control.Tmp-Cast-IPv6Prefix[0] != ::ffff:203.0.113.0/120) { # 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 } @@ -62,7 +62,7 @@ if (&control.Tmp-Cast-IPv4Prefix[0] != 203.0.113.1/24) { # 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 } @@ -70,7 +70,7 @@ if (&control.Tmp-Cast-IPv6Addr[0] != ::ffff:203.0.113.1) { # 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 } @@ -78,7 +78,7 @@ if (&control.Tmp-Cast-Ipaddr[0] != 203.0.113.1/32) { # 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 } @@ -86,7 +86,7 @@ if (&control.Tmp-Cast-IPv6Prefix != ::ffff:203.0.113.1/128) { # 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 } @@ -94,7 +94,7 @@ if (&control.Tmp-Cast-IPv4Prefix != 203.0.113.1/32) { # 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 } @@ -102,7 +102,7 @@ if (&control.Tmp-Cast-IPv4Prefix != 203.0.113.1/32) { # 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 } @@ -110,7 +110,7 @@ if (&control.Tmp-Cast-IPv6Prefix != 2001:DB8::1/128) { # 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 } @@ -118,7 +118,7 @@ if (&control.Tmp-Cast-Ipaddr != 203.0.113.1) { # 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 } diff --git a/src/tests/keywords/if-failed-xlat b/src/tests/keywords/if-failed-xlat index 5877bdc69fc..3ecfbd65b58 100644 --- a/src/tests/keywords/if-failed-xlat +++ b/src/tests/keywords/if-failed-xlat @@ -6,7 +6,7 @@ if (('${feature.regex-pcre}' == 'yes') || ('${feature.regex-pcre2}' == 'yes')) { # 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 } diff --git a/src/tests/keywords/update-remove-index b/src/tests/keywords/update-remove-index index 3794602118b..de38e95a4af 100644 --- a/src/tests/keywords/update-remove-index +++ b/src/tests/keywords/update-remove-index @@ -22,11 +22,11 @@ update request { } # 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 } @@ -36,11 +36,11 @@ update request { } # 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 } @@ -50,10 +50,10 @@ update request { } # 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 } @@ -63,10 +63,10 @@ update request { } # 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 } @@ -76,12 +76,12 @@ update request { } # 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 } diff --git a/src/tests/keywords/update-remove-value b/src/tests/keywords/update-remove-value index 8903081659e..32a08efbe6a 100644 --- a/src/tests/keywords/update-remove-value +++ b/src/tests/keywords/update-remove-value @@ -13,10 +13,10 @@ update { &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 } @@ -26,10 +26,10 @@ update { } # 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 } @@ -39,9 +39,9 @@ update { } # 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 } @@ -51,9 +51,9 @@ update { } # 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 } @@ -68,8 +68,8 @@ update { } # 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 } @@ -79,17 +79,18 @@ update { } # 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 } diff --git a/src/tests/keywords/xlat-integer b/src/tests/keywords/xlat-integer index 03437a9822e..137af359327 100644 --- a/src/tests/keywords/xlat-integer +++ b/src/tests/keywords/xlat-integer @@ -20,13 +20,13 @@ # 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 } @@ -38,11 +38,11 @@ if ("%(integer:%{Tmp-String-2})") { # 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 } @@ -52,11 +52,11 @@ if (&Tmp-Integer-1 != 959985457) { # # 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 } @@ -73,36 +73,36 @@ if ("%(integer:%{Tmp-Octets-2})") { &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 } @@ -113,17 +113,17 @@ if (&Tmp-String-8 != '959985465') { &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 } @@ -132,23 +132,23 @@ if (&Tmp-uint64-2 != 959985468) { # 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 } diff --git a/src/tests/keywords/xlat-soh b/src/tests/keywords/xlat-soh index db50a313022..9004fe82025 100644 --- a/src/tests/keywords/xlat-soh +++ b/src/tests/keywords/xlat-soh @@ -5,7 +5,7 @@ &Tmp-String-0 := %(soh:OS) # SoH-Supported not set - should be no response -if ("%{Tmp-String-0}" != "") { +if (&Tmp-String-0) { test_fail } @@ -22,7 +22,7 @@ if ("%{Tmp-String-0}" != "") { &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 } diff --git a/src/tests/keywords/xlat-virtual-attr b/src/tests/keywords/xlat-virtual-attr index 0fd6425a36c..ef5778cab81 100644 --- a/src/tests/keywords/xlat-virtual-attr +++ b/src/tests/keywords/xlat-virtual-attr @@ -2,78 +2,76 @@ # 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 }