forked from arduino/arduino-cli
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtools_test.go
98 lines (89 loc) · 2.99 KB
/
tools_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
/*
* This file is part of arduino-cli.
*
* Copyright 2018 ARDUINO SA (http://www.arduino.cc/)
*
* This software is released under the GNU General Public License version 3,
* which covers the main part of arduino-cli.
* The terms of this license can be found at:
* https://www.gnu.org/licenses/gpl-3.0.en.html
*
* You can be released from the requirements of the above licenses by purchasing
* a commercial license. Buying such a license is mandatory if you want to modify or
* otherwise use the software for commercial activities involving the Arduino
* software without disclosing the source code of your own applications. To purchase
* a commercial license, send an email to [email protected].
*/
package cores
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestFlavorCompatibility(t *testing.T) {
type os struct {
Os string
Arch string
}
windowsi386 := &os{"windows", "386"}
windowsx8664 := &os{"windows", "amd64"}
linuxi386 := &os{"linux", "386"}
linuxamd64 := &os{"linux", "amd64"}
linuxarm := &os{"linux", "arm"}
linuxarmbe := &os{"linux", "armbe"}
linuxarm64 := &os{"linux", "arm64"}
darwini386 := &os{"darwin", "386"}
darwinamd64 := &os{"darwin", "amd64"}
freebsdi386 := &os{"freebsd", "386"}
freebsdamd64 := &os{"freebsd", "amd64"}
oses := []*os{
windowsi386,
windowsx8664,
linuxi386,
linuxamd64,
linuxarm,
linuxarmbe,
linuxarm64,
darwini386,
darwinamd64,
freebsdi386,
freebsdamd64,
}
type test struct {
Flavour *Flavor
Positives []*os
}
tests := []*test{
{&Flavor{OS: "i686-mingw32"}, []*os{windowsi386, windowsx8664}},
{&Flavor{OS: "i386-apple-darwin11"}, []*os{darwini386, darwinamd64}},
{&Flavor{OS: "x86_64-apple-darwin"}, []*os{darwinamd64}},
// Raspberry PI, BBB or other ARM based host
// PI: "arm-linux-gnueabihf"
// Raspbian on PI2: "arm-linux-gnueabihf"
// Ubuntu Mate on PI2: "arm-linux-gnueabihf"
// Debian 7.9 on BBB: "arm-linux-gnueabihf"
// Raspbian on PI Zero: "arm-linux-gnueabihf"
{&Flavor{OS: "arm-linux-gnueabihf"}, []*os{linuxarm, linuxarmbe}},
// Arch-linux on PI2: "armv7l-unknown-linux-gnueabihf"
{&Flavor{OS: "armv7l-unknown-linux-gnueabihf"}, []*os{linuxarm, linuxarmbe}},
{&Flavor{OS: "i686-linux-gnu"}, []*os{linuxi386}},
{&Flavor{OS: "i686-pc-linux-gnu"}, []*os{linuxi386}},
{&Flavor{OS: "x86_64-linux-gnu"}, []*os{linuxamd64}},
{&Flavor{OS: "x86_64-pc-linux-gnu"}, []*os{linuxamd64}},
{&Flavor{OS: "aarch64-linux-gnu"}, []*os{linuxarm64}},
{&Flavor{OS: "arm64-linux-gnu"}, []*os{linuxarm64}},
}
check := func(test *test, os *os) {
for _, positiveOs := range test.Positives {
if positiveOs == os {
require.True(t, test.Flavour.isCompatibleWith(os.Os, os.Arch), "'%s' tag compatible with '%s,%s' pair", test.Flavour.OS, os.Os, os.Arch)
return
}
}
require.False(t, test.Flavour.isCompatibleWith(os.Os, os.Arch), "'%s' tag compatible with '%s,%s' pair", test.Flavour.OS, os.Os, os.Arch)
}
for _, test := range tests {
for _, os := range oses {
check(test, os)
}
}
}