From 6dc47718fdbb634024bcfe47cbc4d7cc781b4cc4 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 3 Apr 2025 10:27:09 +0200 Subject: tools/syz-declextract: allow to run on subset of arches This may be useful for downstream kernels that only build and are supposed to be used with a subset of arches. Some esoteric arches may be broken on such kernels. Allow to ignore them. --- pkg/tool/flags_test.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'pkg/tool/flags_test.go') diff --git a/pkg/tool/flags_test.go b/pkg/tool/flags_test.go index 0503c48fc..df642bca6 100644 --- a/pkg/tool/flags_test.go +++ b/pkg/tool/flags_test.go @@ -4,6 +4,7 @@ package tool import ( + "errors" "flag" "fmt" "io" @@ -11,6 +12,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" + "github.com/stretchr/testify/assert" ) func TestParseFlags(t *testing.T) { @@ -84,3 +86,40 @@ func TestCfgsFlagAlreadySet(t *testing.T) { t.Errorf("cfgs.Set got: nil, want: error") } } + +func TestParseArchList(t *testing.T) { + type Test struct { + OS string + In string + Out []string + Err error + } + tests := []Test{ + { + OS: "foo", + Err: errors.New(`bad OS "foo"`), + }, + { + OS: "linux", + In: "amd64,bar", + Err: errors.New(`bad arch "bar" for OS "linux" in arches flag`), + }, + { + OS: "linux", + In: "", + Out: []string{"386", "amd64", "arm", "arm64", "mips64le", "ppc64le", "riscv64", "s390x"}, + }, + { + OS: "linux", + In: "ppc64le,386", + Out: []string{"386", "ppc64le"}, + }, + } + for i, test := range tests { + t.Run(fmt.Sprint(i), func(t *testing.T) { + got, err := ParseArchList(test.OS, test.In) + assert.Equal(t, err, test.Err) + assert.Equal(t, got, test.Out) + }) + } +} -- cgit mrf-deployment