linux-bench/app_test.go
Liz Rice 80aaa6b6e8 Don't rely on test ordering
Tests can be run in parallel so we can't rely on the state of a global
variable that is modified in one test being ready when we run another
2020-12-21 15:19:40 +00:00

50 lines
897 B
Go

package main
import (
"os"
"testing"
)
var (
cfgdir = "./cfg"
ver = "1.1.0"
)
// Tests all standard linux-bench defintion files
func TestGetDefinitionFilePath(t *testing.T) {
d, err := os.Open(cfgdir)
if err != nil {
t.Errorf("unexpected error: %s\n", err)
}
vers, err := d.Readdirnames(-1)
if err != nil {
t.Errorf("unexpected error: %s\n", err)
}
for _, ver := range vers {
_, err := getDefinitionFilePath(ver)
if err != nil {
t.Errorf("unexpected error: %s\n", err)
}
}
}
func TestRunControls(t *testing.T) {
path, err := getDefinitionFilePath(ver)
if err != nil {
t.Errorf("unexpected error: %s\n", err)
}
control, err := getControls(path, nil)
if err != nil {
t.Errorf("unexpected error: %s\n", err)
}
// Run all checks
_ = runControls(control, "")
// Run only specified checks
checkList := "1.2, 2.1"
_ = runControls(control, checkList)
}