tstest: add RequireRoot helper

Start using a common helper for tests to declare that they require root.

This is step 1. A later step will then make this helper track which tests were
skipped so a subsequent pass will run these test as root.

Updates tailscale/corp#40007

Change-Id: I4979e1def0fa3691d38c83f48c89aaa443e7f62e
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2026-04-10 14:35:50 +00:00
committed by Brad Fitzpatrick
parent 399f048332
commit 5e81840b57
4 changed files with 15 additions and 18 deletions
@@ -1157,9 +1157,7 @@ func (lt *linuxTest) Close() error {
}
func newLinuxRootTest(t *testing.T) (*linuxTest, *eventbus.Bus) {
if os.Getuid() != 0 {
t.Skip("test requires root")
}
tstest.RequireRoot(t)
lt := new(linuxTest)
lt.tun = createTestTUN(t)