From dcbbc7cef526c539da08299aee586902b7fedd9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sat, 6 May 2023 11:49:31 +0200 Subject: [PATCH] test/run-unit-tests, TEST-02: skip tests where the interpeter is not installed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the interpeter is missing, we get an exit code of 127. Let's treat those tests as skipped too. If we could run the test far enough so that it could do the check itself, it would return 77 anyway. $ test/asdf; echo $? exec: Failed to execute process 'test/asdf': The file specified the interpreter '/bin/asdf', which is not an executable command. 127 $ test/asdf; echo $? /usr/bin/env: ‘/bin/asdf’: No such file or directory 127 This should resolve the problem that TEST-02 fails or Debian's 'unit-tests' fail when python3 is not installed. Installing python3 via the mechanism that is used to construct TEST images, i.e. the dracut dependency chasing scheme, would be a lot of work for python with its modules in multiple locations and hundreds of little files. So I think it OK to just skip the test there, and also in other cases where python is not available. --- test/run-unit-tests.py | 3 +++ test/units/testsuite-02.sh | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/test/run-unit-tests.py b/test/run-unit-tests.py index 2d6709b703c..7bb904ddd11 100755 --- a/test/run-unit-tests.py +++ b/test/run-unit-tests.py @@ -52,6 +52,9 @@ for test in tests: elif ex.returncode == 77: print(f'{YELLOW}SKIP: {name}{RESET_ALL}') total.skip += 1 + elif ex.returncode == 127: + print(f'{YELLOW}SKIP: {name} (no interpeter) {RESET_ALL}') + total.skip += 1 else: print(f'{RED}FAIL: {name}{RESET_ALL}') total.fail += 1 diff --git a/test/units/testsuite-02.sh b/test/units/testsuite-02.sh index 61f6d063970..211bd105471 100755 --- a/test/units/testsuite-02.sh +++ b/test/units/testsuite-02.sh @@ -24,7 +24,7 @@ function report_result() { local name="${1##*/}" local ret=$2 - if [[ $ret -ne 0 && $ret != 77 ]]; then + if [[ $ret -ne 0 && $ret != 77 && $ret != 127 ]]; then echo "$name failed with $ret" echo "$name" >>/failed-tests { @@ -32,7 +32,7 @@ function report_result() { cat "/$name.log" echo "--- $name end ---" } >>/failed - elif [[ $ret == 77 ]]; then + elif [[ $ret == 77 || $ret == 127 ]]; then echo "$name skipped" echo "$name" >>/skipped-tests {