linux-bench/app_test.go

51 lines
897 B
Go
Raw Normal View History

2019-01-27 16:12:29 +02:00
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)
2019-01-27 16:12:29 +02:00
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)
}