From 8bdc0f220628c9347b3581fead4c026272439799 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 17 Apr 2024 15:55:15 +0200 Subject: 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 --- prog/target_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 prog/target_test.go (limited to 'prog/target_test.go') 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"}) +} -- cgit mrf-deployment