diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-11-20 16:39:02 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-11-21 08:46:20 +0100 |
| commit | 9bc78a846441516a33a7fd3b245380f463ba88ed (patch) | |
| tree | d3dcbfeee91311d01bb1d81325c476d0e58f96a6 /pkg | |
| parent | 680688040fc26d17a49a9663fbbd6a716c6247b6 (diff) | |
pkg/ifuzz: use sub-tests for arches
Testing different arches is a good use for sub-tests.
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/ifuzz/ifuzz_test.go | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/pkg/ifuzz/ifuzz_test.go b/pkg/ifuzz/ifuzz_test.go index 173c7aec6..5d02f8d1e 100644 --- a/pkg/ifuzz/ifuzz_test.go +++ b/pkg/ifuzz/ifuzz_test.go @@ -16,7 +16,17 @@ import ( _ "github.com/google/syzkaller/pkg/ifuzz/x86/generated" ) -func testmodearch(t *testing.T, arch string) { +var allArches = []string{ifuzz.ArchX86, ifuzz.ArchPowerPC} + +func TestMode(t *testing.T) { + for _, arch := range allArches { + t.Run(arch, func(t *testing.T) { + testMode(t, arch) + }) + } +} + +func testMode(t *testing.T, arch string) { all := make(map[ifuzz.Insn]bool) for mode := 0; mode < ifuzz.ModeLast; mode++ { for priv := 0; priv < 2; priv++ { @@ -38,12 +48,15 @@ func testmodearch(t *testing.T, arch string) { t.Logf("total: %v instructions", len(all)) } -func TestMode(t *testing.T) { - testmodearch(t, ifuzz.ArchX86) - testmodearch(t, ifuzz.ArchPowerPC) +func TestDecode(t *testing.T) { + for _, arch := range allArches { + t.Run(arch, func(t *testing.T) { + testDecode(t, arch) + }) + } } -func testdecodearch(t *testing.T, arch string) { +func testDecode(t *testing.T, arch string) { insnset := ifuzzimpl.Types[arch] xedEnabled := false if _, err := insnset.DecodeExt(0, nil); err == nil { @@ -117,8 +130,3 @@ func testdecodearch(t *testing.T, arch string) { } } } - -func TestDecode(t *testing.T) { - testdecodearch(t, ifuzz.ArchX86) - testdecodearch(t, ifuzz.ArchPowerPC) -} |
