diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-04-17 15:55:15 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-04-24 15:23:14 +0000 |
| commit | 8bdc0f220628c9347b3581fead4c026272439799 (patch) | |
| tree | ec8b29e4f9acca76860392841053dcf9e3efa393 /prog/target_test.go | |
| parent | 7009aebcd4c978e0f9d7cbb1f45c482104ff3019 (diff) | |
pkg/host: move glob parsing to host
Move more complex glob processing to the host (into prog package).
Make fuzzer just read and return globs if requested.
This moves us closer to #1541
Diffstat (limited to 'prog/target_test.go')
| -rw-r--r-- | prog/target_test.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/prog/target_test.go b/prog/target_test.go new file mode 100644 index 000000000..4db6fdef1 --- /dev/null +++ b/prog/target_test.go @@ -0,0 +1,36 @@ +// Copyright 2024 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 prog + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestRequiredGlobs(t *testing.T) { + assert.Equal(t, requiredGlobs("aa/bb"), []string{"aa/bb"}) + assert.Equal(t, requiredGlobs("aa:bb"), []string{"aa", "bb"}) + assert.Equal(t, requiredGlobs("aa:bb:-cc:dd"), []string{"aa", "bb", "dd"}) +} + +func TestPopulateGlob(t *testing.T) { + assert.Empty(t, populateGlob("aa", map[string][]string{ + "bb": {"c"}, + })) + assert.Equal(t, populateGlob("aa", map[string][]string{ + "aa": {"d", "e"}, + "bb": {"c"}, + }), []string{"d", "e"}) + assert.Equal(t, populateGlob("aa:cc", map[string][]string{ + "aa": {"d", "e"}, + "bb": {"c"}, + "cc": {"f", "d"}, + }), []string{"d", "e", "f"}) + assert.Equal(t, populateGlob("aa:cc:-e", map[string][]string{ + "aa": {"d", "e"}, + "bb": {"c"}, + "cc": {"f", "d"}, + }), []string{"d", "f"}) +} |
