1
0
mirror of https://github.com/etcd-io/bbolt.git synced 2025-05-03 14:09:58 +00:00
bbolt/tests/utils/helpers.go
Wei Fu 300e72ab8a tests/robustness: init with powerfailure case
Add `Robustness Test` pipeline for robustness test cases.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2023-12-08 09:48:57 +08:00

27 lines
450 B
Go

package utils
import (
"flag"
"fmt"
"os"
)
var enableRoot bool
func init() {
flag.BoolVar(&enableRoot, "test.root", false, "enable tests that require root")
}
// RequiresRoot requires root and the test.root flag has been set.
func RequiresRoot() {
if !enableRoot {
fmt.Fprintln(os.Stderr, "Skip tests that require root")
os.Exit(0)
}
if os.Getuid() != 0 {
fmt.Fprintln(os.Stderr, "This test must be run as root.")
os.Exit(1)
}
}