aboutsummaryrefslogtreecommitdiffstats
path: root/syz-manager/hub_test.go
blob: a83204e728404cb88b7bde532903dcd5f80c15af (plain)
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
// Copyright 2020 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

package main

import (
	"fmt"
	"testing"
)

func TestMatchDomains(t *testing.T) {
	type Test struct {
		self      string
		input     string
		minimized bool
		smashed   bool
	}
	tests := []Test{
		{"", "", true, true},
		{"linux", "", true, true},
		{"linux/", "", true, true},
		{"linux/upstream/kasan", "", true, true},
		{"", "linux", true, true},
		{"", "linux/", true, true},
		{"linux", "linux/", false, false},
		{"linux/", "linux/", false, false},
		{"linux", "linuz", true, true},
		{"linux/upstream/kasan", "linuz", true, true},
		{"linux/upstream", "linux/upstream", false, false},
		{"linux/upstream", "linux/upstreax", true, true},
		{"linux/upstream/", "linux/upstream", false, false},
		{"linux/upstream", "linux/upstreax/", true, true},
		{"linux/upstream", "linux/upstream/kasan", false, true},
		{"linux/upstream/kasan", "linux/upstream", false, true},
		{"linux/upstream/kasan", "linux/upstream/xasan", false, true},
		{"linux/upstream/kasan", "linux/upstream/kasan", false, false},
		{"linux/upstreax/kasan", "linux/upstream/kasan", true, true},
		{"linux/upstreax/kasan", "linux/upstream/xasan", true, true},
		{"linux/upstream/kasan", "linuz/upstream/xasan", true, true},
	}
	for i, test := range tests {
		t.Run(fmt.Sprint(i), func(t *testing.T) {
			minimized, smashed := matchDomains(test.self, test.input)
			if minimized != test.minimized || smashed != test.smashed {
				t.Fatalf("(%q, %q) = %v/%v, want %v/%v",
					test.self, test.input, minimized, smashed, test.minimized, test.smashed)
			}
		})
	}
}