-
Notifications
You must be signed in to change notification settings - Fork 5
/
skipgen_test.go
141 lines (125 loc) · 3.1 KB
/
skipgen_test.go
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package main
import (
"testing"
)
func TestStringInSlicePositive(t *testing.T) {
slice := []string{"one", "two", "three", "four", "five"}
result := stringInSlice("one", slice)
if ! result {
t.Errorf("'one' not found in %s", slice)
}
}
func TestStringInSliceNegative(t *testing.T) {
slice := []string{"one", "two", "three", "four", "five"}
result := stringInSlice("zero", slice)
if result {
t.Errorf("'zero' found in %s", slice)
}
}
func TestSkipAll(t *testing.T) {
skipAll := `
skiplist:
- reason: kernel tests baselining
url: https://projects.linaro.org/projects/CTT/queues/issue/CTT-585
environments: all # Test this form
boards:
- all # And test this form
branches:
- all
tests:
- test_maps
- test_lru_map
- test_lpm_map
- test_progs
- reason: "LKFT: linux-next: vm compaction_test : ERROR: Less that 1/730 of memory
is available"
url: https://bugs.linaro.org/show_bug.cgi?id=3145
environments:
- production
- staging
boards:
- x15
- juno
- hikey
branches:
- "4.4"
- 4.9
- mainline
tests:
- run_vmtests
- reason: duplicate skip for specific board combination
url: https://bugs.linaro.org/show_bug.cgi?id=3145
environments:
- production
boards:
- x86
branches:
- 4.14
tests:
- run_vmtests
`
skips, err := parseSkipfile([]byte(skipAll))
if err != nil {
t.Errorf("Unexpected error parsing yaml, %s", err)
}
t.Run("parseSkipfile spotcheck", func(t *testing.T) {
if skips.Skiplist[0].Reason != "kernel tests baselining" {
t.Errorf("Parsing error, skiplist is wrong")
}
})
t.Run("getSkipfileContents", func(t *testing.T) {
if getSkipfileContents("x15", "4.4", "production", skips) !=
`run_vmtests
test_lpm_map
test_lru_map
test_maps
test_progs
`{
t.Errorf("Incorrect Skipfile Contents")
}
})
// Test deduplication, and 'all'
t.Run("getSkipfileContents", func(t *testing.T) {
if getSkipfileContents("all", "all", "all", skips) !=
`run_vmtests
test_lpm_map
test_lru_map
test_maps
test_progs
`{
t.Errorf("Incorrect Skipfile Contents")
}
})
}
func TestSkipMinimum(t *testing.T) {
skipAll := `
skiplist:
- reason: Some test reason
url: https://bugs.linaro.org/show_bug.cgi?id=3145
environments: production # Test UnmarshallYAML
boards: x15 # Test UnmarshallYAML
branches: "4.4" # Test UnmarshallYAML
tests: run_vmtests # Test UnmarshallYAML
`
skips, err := parseSkipfile([]byte(skipAll))
if err != nil {
t.Errorf("Unexpected error parsing yaml, %s", err)
}
t.Run("parseSkipfile spotcheck", func(t *testing.T) {
if skips.Skiplist[0].Reason != "Some test reason" {
t.Errorf("Parsing error, skiplist is wrong")
}
})
t.Run("getSkipfileContents positive", func(t *testing.T) {
if getSkipfileContents("x15", "4.4", "production", skips) !=
`run_vmtests
` {
t.Errorf("Incorrect Skipfile Contents")
}
})
t.Run("getSkipfileContents empty", func(t *testing.T) {
if getSkipfileContents("x15", "4.9", "production", skips) != "" {
t.Errorf("Incorrect Skipfile Contents")
}
})
}