aboutsummaryrefslogtreecommitdiff
path: root/tests/legacy/build_constraints/build_constraints_test.go
blob: b2ac474eff80ea416ce78fc5d8a8899eb367cd92 (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
51
52
53
54
55
package build_constraints

import (
	"runtime"
	"testing"
)

func check(value string, t *testing.T) {
	var want string
	if runtime.GOOS == "linux" {
		want = "linux"
	} else {
		want = "unknown"
	}
	if value != want {
		t.Errorf("got %s; want %s", value, want)
	}
}

func TestSuffix(t *testing.T) {
	check(suffix, t)
}

func TestTag(t *testing.T) {
	check(tag, t)
}

func asm() int

func TestAsm(t *testing.T) {
	got := asm()
	var want int
	if runtime.GOOS == "linux" {
		want = 12
	} else if runtime.GOARCH == "arm64" {
		want = 75
	} else {
		want = 34
	}
	if got != want {
		t.Errorf("got %d; want %d", got, want)
	}
}

func TestCgoGo(t *testing.T) {
	check(cgoGo, t)
}

func TestCgoC(t *testing.T) {
	check(cgoC, t)
}

func TestCgoCGroup(t *testing.T) {
	check(cgoCGroup, t)
}