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:
committed by
Brad Fitzpatrick
parent
399f048332
commit
5e81840b57
@@ -73,9 +73,7 @@ func TestMain(m *testing.M) {
|
||||
// https://github.com/tailscale/tailscale/issues/7894
|
||||
func TestTUNMode(t *testing.T) {
|
||||
tstest.Shard(t)
|
||||
if os.Getuid() != 0 {
|
||||
t.Skip("skipping when not root")
|
||||
}
|
||||
tstest.RequireRoot(t)
|
||||
tstest.Parallel(t)
|
||||
env := NewTestEnv(t)
|
||||
env.tunMode = true
|
||||
@@ -1565,9 +1563,7 @@ func testAutoUpdateDefaults(t *testing.T, useCap bool) {
|
||||
// https://github.com/tailscale/corp/issues/22511
|
||||
func TestDNSOverTCPIntervalResolver(t *testing.T) {
|
||||
tstest.Shard(t)
|
||||
if os.Getuid() != 0 {
|
||||
t.Skip("skipping when not root")
|
||||
}
|
||||
tstest.RequireRoot(t)
|
||||
env := NewTestEnv(t)
|
||||
env.tunMode = true
|
||||
n1 := NewTestNode(t, env)
|
||||
@@ -1637,9 +1633,7 @@ func TestDNSOverTCPIntervalResolver(t *testing.T) {
|
||||
// directions.
|
||||
func TestNetstackTCPLoopback(t *testing.T) {
|
||||
tstest.Shard(t)
|
||||
if os.Getuid() != 0 {
|
||||
t.Skip("skipping when not root")
|
||||
}
|
||||
tstest.RequireRoot(t)
|
||||
|
||||
env := NewTestEnv(t)
|
||||
env.tunMode = true
|
||||
@@ -1779,9 +1773,7 @@ func TestNetstackTCPLoopback(t *testing.T) {
|
||||
// directions.
|
||||
func TestNetstackUDPLoopback(t *testing.T) {
|
||||
tstest.Shard(t)
|
||||
if os.Getuid() != 0 {
|
||||
t.Skip("skipping when not root")
|
||||
}
|
||||
tstest.RequireRoot(t)
|
||||
|
||||
env := NewTestEnv(t)
|
||||
env.tunMode = true
|
||||
|
||||
Reference in New Issue
Block a user