test(handoff): require ENOEXEC for an ELF stub; skip the namespace run without binfmt

This commit is contained in:
Kurt Himebauch committed 2026-11-28 12:04:38 -05:00
1 parent ab3d7d96fe
commit 8c9904d016
1 file changed
+6 -3
+6 -3
View File
@@ -798,8 +798,11 @@ class NativeHookHandoffTest(unittest.TestCase):
stub.write_bytes(b"\x7fELF")
stub.chmod(0o755)
result, requests, out = self.run_parent("spawn", "6", "/bin/stub", handoff="stub")
self.assertEqual(0, out.returncode, out.stderr)
self.assertEqual([], requests)
self.assertNotEqual("0", result.get("spawned"), out.stdout)
self.assertEqual(str(errno.ENOEXEC), result.get("spawned"), out.stdout)
self.assertNotIn("exit", result, out.stdout)
self.assertNotIn("signal", result, out.stdout)
def test_wnothread_child_goes_to_the_first_live_thread(self):
# The forking thread and the main one both ended. Which thread the kernel gives the child to
@@ -824,6 +827,8 @@ class NativeHookHandoffTest(unittest.TestCase):
self.assertEqual("7", result.get("exit"), out.stdout)
def test_a_late_record_of_a_spawned_child_keeps_a_handoffs_owner(self):
if self.child_status != "3":
self.skipTest("a child here cannot exec an aarch64 program (no binfmt_misc), so nothing can be spawned")
# the pid has to be given again, which only a pid namespace of the test's own allows
if not os.environ.get("DDH_TEST_PIDNS"):
unshare = shutil.which("unshare")
@@ -838,8 +843,6 @@ class NativeHookHandoffTest(unittest.TestCase):
self.assertEqual(0, out.returncode, out.stderr)
self.assertNotIn("skipped", out.stderr, out.stderr)
return
if self.child_status != "3":
self.skipTest("a child here cannot exec an aarch64 program (no binfmt_misc), so nothing can be spawned")
result, requests, out = self.run_parent("laterecord", "sleep")
self.assertEqual("1", result.get("reused"), out.stdout + out.stderr)
self.assertEqual("0", result.get("spawned"), out.stdout)