`test-redirection` fails for HTTP/2
Hello!
test-redirection fails for HTTP/2 because:
if (system("if [ \"$(grep -c 'HTTP ERROR response 501' ../test-redirection.log)\" != 2 ]; then exit 1; fi"))
https://gitlab.com/gnuwget/wget2/-/blob/master/tests/test-redirection.c#L156
this check fails since on environment which has libmicrohttpd-http2 installed there are two separate tests being run: 1. For HTTP/1.1 and 2. For HTTP/2. Each run trying 2 tries (for the failing test which passes --tries=2
). And so there are total 4 'HTTP ERROR response 501' in test-redirection.log if libmicrohttpd-http2 is installed otherwise there are only 2 'HTTP ERROR response 501' (2 tries with HTTP/1.1)
A quick "fix" is to check grep -c % 2
being 0 or grep -c == 2 || grep -c == 4
(explicit check).
But this poses some questions. What if (for some unknown reasons) HTTP/1.1 run performed 3 tries and HTTP/2 run performed 1 totaling 4 'HTTP ERROR response 501' in log file? The test will pass even though the tries are incorrect.
It feels like that this test fail-success check should be moved in wget_test()/libtest.c
. Maybe with an extra options like WGET_TEST_PATTERN
and WGET_TEST_PATTERN_COUNT
. This way any test which needs to check the pattern in .log file to decide success/failure can do so separately for HTTP/1.1 and HTTP/2 runs.
But then again, this is the only one test in test-suite so far which needs to check the log file so maybe it's okay to have this test check in test-redirection.c?