Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/exec: binfmt_script: Add the overall result line according to TAP

The following line is missing from the test's execution. Add it to make
it fully TAP conformant:
# Totals: pass:27 fail:0 xfail:0 xpass:0 skip:0 error:0

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20240304155928.1818928-1-usama.anjum@collabora.com
Signed-off-by: Kees Cook <keescook@chromium.org>

authored by

Muhammad Usama Anjum and committed by
Kees Cook
99f5819b 725d5026

+9 -1
+9 -1
tools/testing/selftests/exec/binfmt_script.py
··· 16 16 NAME_MAX=int(subprocess.check_output(["getconf", "NAME_MAX", "."])) 17 17 18 18 test_num=0 19 + pass_num=0 20 + fail_num=0 19 21 20 22 code='''#!/usr/bin/perl 21 23 print "Executed interpreter! Args:\n"; ··· 44 42 # ... 45 43 def test(name, size, good=True, leading="", root="./", target="/perl", 46 44 fill="A", arg="", newline="\n", hashbang="#!"): 47 - global test_num, tests, NAME_MAX 45 + global test_num, pass_num, fail_num, tests, NAME_MAX 48 46 test_num += 1 49 47 if test_num > tests: 50 48 raise ValueError("more binfmt_script tests than expected! (want %d, expected %d)" ··· 82 80 if good: 83 81 print("ok %d - binfmt_script %s (successful good exec)" 84 82 % (test_num, name)) 83 + pass_num += 1 85 84 else: 86 85 print("not ok %d - binfmt_script %s succeeded when it should have failed" 87 86 % (test_num, name)) 87 + fail_num = 1 88 88 else: 89 89 if good: 90 90 print("not ok %d - binfmt_script %s failed when it should have succeeded (rc:%d)" 91 91 % (test_num, name, proc.returncode)) 92 + fail_num = 1 92 93 else: 93 94 print("ok %d - binfmt_script %s (correctly failed bad exec)" 94 95 % (test_num, name)) 96 + pass_num += 1 95 97 96 98 # Clean up crazy binaries 97 99 os.unlink(script) ··· 171 165 test(name="two-under-trunc-arg", size=int(SIZE/2), arg=" ") 172 166 test(name="two-under-leading", size=int(SIZE/2), leading=" ") 173 167 test(name="two-under-lead-trunc-arg", size=int(SIZE/2), leading=" ", arg=" ") 168 + 169 + print("# Totals: pass:%d fail:%d xfail:0 xpass:0 skip:0 error:0" % (pass_num, fail_num)) 174 170 175 171 if test_num != tests: 176 172 raise ValueError("fewer binfmt_script tests than expected! (ran %d, expected %d"