From bf94ebf423931f6cd848126372fe558c8b956dcc Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Tue, 28 Sep 2021 07:13:51 -0600 Subject: System tests: tighten 'is' operator Fix day-one sloppiness: when I first wrote this framework it compared strings using 'expr', not '=', to be more forgiving of extra cruft in output. This was a bad decision. It means that warnings or additional text are ignored: is "all is ok, NOT!" "all is ok" <-- this would pass Solution: tighten up the 'is' check. Use '=' (direct compare) first. If it fails, look for wild cards ('*') or character classes ('[') in the expect string. If so, and only then, use 'expr'. And, thanks to a clever suggestion from Luap99, include '(using expr)' in the error message when we do so; this could make it easier for a developer to understand a string mismatch. This change exposes a lot of instances in which we weren't doing proper comparisons. Fix those. Thankfully, there weren't as many as I'd feared. Also, and completely unrelated, add '-T' flag to bats helper, for showing timing results. (I will open this as a separate PR if requested. I too find it offensive to jumble together unrelated commits.) Signed-off-by: Ed Santiago --- test/system/500-networking.bats | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/system/500-networking.bats') diff --git a/test/system/500-networking.bats b/test/system/500-networking.bats index 548f2d764..29fa309f3 100644 --- a/test/system/500-networking.bats +++ b/test/system/500-networking.bats @@ -417,7 +417,7 @@ load helpers # check network alias for container short id run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").Aliases}}" - is "$output" "\[${cid:0:12}\]" "short container id in network aliases" + is "$output" "[${cid:0:12}]" "short container id in network aliases" run_podman network disconnect $netname $cid @@ -449,7 +449,7 @@ load helpers # check network2 alias for container short id run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname2\").Aliases}}" - is "$output" "\[${cid:0:12}\]" "short container id in network aliases" + is "$output" "[${cid:0:12}]" "short container id in network aliases" # curl should work run curl --max-time 3 -s $SERVER/index.txt -- cgit v1.2.3-54-g00ecf