File: root.go

package info (click to toggle)
mtail 3.2.24-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,384 kB
  • sloc: yacc: 647; makefile: 226; sh: 78; lisp: 77; awk: 17
file content (18 lines) | stat: -rw-r--r-- 289 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package testutil

import (
	"fmt"
	"os/user"
	"testing"
)

func SkipIfRoot(tb testing.TB) {
	tb.Helper()
	u, err := user.Current()
	if err != nil {
		tb.Skip(fmt.Sprintf("Couldn't determine current user id: %s", err))
	}
	if u.Uid == "0" {
		tb.Skip("Skipping test when run as root")
	}
}