Commit 99f5819b authored by Muhammad Usama Anjum's avatar Muhammad Usama Anjum Committed by Kees Cook

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: default avatarMuhammad Usama Anjum <usama.anjum@collabora.com>
Reviewed-by: default avatarKees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20240304155928.1818928-1-usama.anjum@collabora.comSigned-off-by: default avatarKees Cook <keescook@chromium.org>
parent 725d5026
...@@ -16,6 +16,8 @@ SIZE=256 ...@@ -16,6 +16,8 @@ SIZE=256
NAME_MAX=int(subprocess.check_output(["getconf", "NAME_MAX", "."])) NAME_MAX=int(subprocess.check_output(["getconf", "NAME_MAX", "."]))
test_num=0 test_num=0
pass_num=0
fail_num=0
code='''#!/usr/bin/perl code='''#!/usr/bin/perl
print "Executed interpreter! Args:\n"; print "Executed interpreter! Args:\n";
...@@ -42,7 +44,7 @@ foreach my $a (@ARGV) { ...@@ -42,7 +44,7 @@ foreach my $a (@ARGV) {
# ... # ...
def test(name, size, good=True, leading="", root="./", target="/perl", def test(name, size, good=True, leading="", root="./", target="/perl",
fill="A", arg="", newline="\n", hashbang="#!"): fill="A", arg="", newline="\n", hashbang="#!"):
global test_num, tests, NAME_MAX global test_num, pass_num, fail_num, tests, NAME_MAX
test_num += 1 test_num += 1
if test_num > tests: if test_num > tests:
raise ValueError("more binfmt_script tests than expected! (want %d, expected %d)" raise ValueError("more binfmt_script tests than expected! (want %d, expected %d)"
...@@ -80,16 +82,20 @@ def test(name, size, good=True, leading="", root="./", target="/perl", ...@@ -80,16 +82,20 @@ def test(name, size, good=True, leading="", root="./", target="/perl",
if good: if good:
print("ok %d - binfmt_script %s (successful good exec)" print("ok %d - binfmt_script %s (successful good exec)"
% (test_num, name)) % (test_num, name))
pass_num += 1
else: else:
print("not ok %d - binfmt_script %s succeeded when it should have failed" print("not ok %d - binfmt_script %s succeeded when it should have failed"
% (test_num, name)) % (test_num, name))
fail_num = 1
else: else:
if good: if good:
print("not ok %d - binfmt_script %s failed when it should have succeeded (rc:%d)" print("not ok %d - binfmt_script %s failed when it should have succeeded (rc:%d)"
% (test_num, name, proc.returncode)) % (test_num, name, proc.returncode))
fail_num = 1
else: else:
print("ok %d - binfmt_script %s (correctly failed bad exec)" print("ok %d - binfmt_script %s (correctly failed bad exec)"
% (test_num, name)) % (test_num, name))
pass_num += 1
# Clean up crazy binaries # Clean up crazy binaries
os.unlink(script) os.unlink(script)
...@@ -166,6 +172,8 @@ test(name="two-under-trunc-arg", size=int(SIZE/2), arg=" ") ...@@ -166,6 +172,8 @@ test(name="two-under-trunc-arg", size=int(SIZE/2), arg=" ")
test(name="two-under-leading", size=int(SIZE/2), leading=" ") test(name="two-under-leading", size=int(SIZE/2), leading=" ")
test(name="two-under-lead-trunc-arg", size=int(SIZE/2), leading=" ", arg=" ") test(name="two-under-lead-trunc-arg", size=int(SIZE/2), leading=" ", arg=" ")
print("# Totals: pass:%d fail:%d xfail:0 xpass:0 skip:0 error:0" % (pass_num, fail_num))
if test_num != tests: if test_num != tests:
raise ValueError("fewer binfmt_script tests than expected! (ran %d, expected %d" raise ValueError("fewer binfmt_script tests than expected! (ran %d, expected %d"
% (test_num, tests)) % (test_num, tests))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment