Skip to content

Commit 99f5819

Browse files
musamaanjumkees
authored andcommitted
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 <[email protected]> Reviewed-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent 725d502 commit 99f5819

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tools/testing/selftests/exec/binfmt_script.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
NAME_MAX=int(subprocess.check_output(["getconf", "NAME_MAX", "."]))
1717

1818
test_num=0
19+
pass_num=0
20+
fail_num=0
1921

2022
code='''#!/usr/bin/perl
2123
print "Executed interpreter! Args:\n";
@@ -42,7 +44,7 @@
4244
# ...
4345
def test(name, size, good=True, leading="", root="./", target="/perl",
4446
fill="A", arg="", newline="\n", hashbang="#!"):
45-
global test_num, tests, NAME_MAX
47+
global test_num, pass_num, fail_num, tests, NAME_MAX
4648
test_num += 1
4749
if test_num > tests:
4850
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",
8082
if good:
8183
print("ok %d - binfmt_script %s (successful good exec)"
8284
% (test_num, name))
85+
pass_num += 1
8386
else:
8487
print("not ok %d - binfmt_script %s succeeded when it should have failed"
8588
% (test_num, name))
89+
fail_num = 1
8690
else:
8791
if good:
8892
print("not ok %d - binfmt_script %s failed when it should have succeeded (rc:%d)"
8993
% (test_num, name, proc.returncode))
94+
fail_num = 1
9095
else:
9196
print("ok %d - binfmt_script %s (correctly failed bad exec)"
9297
% (test_num, name))
98+
pass_num += 1
9399

94100
# Clean up crazy binaries
95101
os.unlink(script)
@@ -166,6 +172,8 @@ def test(name, size, good=True, leading="", root="./", target="/perl",
166172
test(name="two-under-leading", size=int(SIZE/2), leading=" ")
167173
test(name="two-under-lead-trunc-arg", size=int(SIZE/2), leading=" ", arg=" ")
168174

175+
print("# Totals: pass:%d fail:%d xfail:0 xpass:0 skip:0 error:0" % (pass_num, fail_num))
176+
169177
if test_num != tests:
170178
raise ValueError("fewer binfmt_script tests than expected! (ran %d, expected %d"
171179
% (test_num, tests))

0 commit comments

Comments
 (0)