-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathapp_test.go
More file actions
51 lines (43 loc) · 997 Bytes
/
app_test.go
File metadata and controls
51 lines (43 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"os"
"testing"
)
// Tests all standard linux-bench defintion files
func TestGetDefinitionFilePath(t *testing.T) {
d, err := os.Open("./cfg")
if err != nil {
t.Errorf("unexpected error: %s\n", err)
}
vers, err := d.Readdir(-1)
if err != nil {
t.Errorf("unexpected error: %s\n", err)
}
for _, ver := range vers {
if !ver.IsDir() {
t.Logf("Skipping non-directory: %v", ver.Name())
continue
}
t.Logf("%v", ver)
_, err := getDefinitionFilePath(ver.Name())
if err != nil {
t.Errorf("unexpected error: %s\n", err)
}
}
}
func TestRunControls(t *testing.T) {
cfgDir = "./hack"
path, err := getDefinitionFilePath("test-definitions")
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)
}