Files
slocker-lite/tests
ceamac cadea945e4 Fix [integration][net] rootless tests to not assume kernel capability
Found via real-device testing (the actual Android target), not assumed:
both tests hardcoded assumptions that don't hold on every kernel.

1. "a fresh network namespace has only loopback" assumed exactly 3 lines
   of /proc/net/dev (2-line header + one "lo" entry) -- the real target
   device's kernel auto-creates several harmless placeholder tunnel
   interfaces (sit0, ip6tnl0, ip_vti0, ip6_vti0) in *every* fresh network
   namespace, alongside loopback. The namespace is still genuinely
   isolated (confirmed: none of the *host's* real interfaces leak in) --
   the test's assumption was just wrong for this kernel. Replaced the
   exact-count check with a readlink-based /proc/self/ns/net identity
   comparison (proves genuine isolation regardless of kernel config) plus
   a simple "loopback is present" check, dropping the brittle count
   assertion entirely.

2. "pid/uts/ipc namespaces differ from this process's own" assumed all
   three are always readable via /proc/self/ns/<type>. The real target
   device has neither PID nor IPC namespace support *as a kernel feature
   at all* -- confirmed directly: even this test process's own `readlink
   /proc/self/ns/pid`, run completely outside any container, fails
   outright there. This matches this project's own already-documented
   standing lesson (neither CONFIG_CHECKPOINT_RESTORE nor pid namespace
   support on this target). Comparing against a namespace type the kernel
   doesn't expose at all wouldn't prove anything either way.

Both tests now build their expectations from detect_bwrap_unshare_args()
(bwrap.h) -- this host's own live kernel-capability probe, the exact same
one build_bwrap_args() itself already gates on -- rather than assuming a
fixed set of namespace types is always available. "user" is deliberately
excluded from the generic per-type check: build_bwrap_args() never
requests --unshare-user when running as root, so asserting on it would be
wrong specifically when these tests are run as root (as they are on the
real device).

Verified: passes repeatably on this dev machine (all 6 namespace types
supported, 8 assertions/2 test cases either way -- same coverage as
before, just derived instead of hardcoded), full combined suite and
meson test both still clean.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gv3s5jckJKzh6JkMoi2Akz
2026-09-04 15:09:08 +00:00
..