aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--prog/resources_test.go26
-rw-r--r--sys/test/test.txt25
2 files changed, 51 insertions, 0 deletions
diff --git a/prog/resources_test.go b/prog/resources_test.go
index f0ba81adf..8db8dbd17 100644
--- a/prog/resources_test.go
+++ b/prog/resources_test.go
@@ -98,6 +98,32 @@ func TestTransitivelyEnabledCallsLinux(t *testing.T) {
}
}
+func TestGetInputResources(t *testing.T) {
+ expectedRequiredResources := map[string]bool{
+ "required_res1": false,
+ }
+
+ t.Parallel()
+ target, err := GetTarget("test", "64")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ resources := target.getInputResources(target.SyscallMap["test$optional_res"])
+ for _, resource := range resources {
+ if _, ok := expectedRequiredResources[resource.Name]; ok {
+ expectedRequiredResources[resource.Name] = true
+ } else {
+ t.Fatalf(" unexpected %v", resource.Name)
+ }
+ }
+ for expectedRes, found := range expectedRequiredResources {
+ if !found {
+ t.Fatalf(" missing %v", expectedRes)
+ }
+ }
+}
+
func TestClockGettime(t *testing.T) {
t.Parallel()
target, err := GetTarget("linux", "amd64")
diff --git a/sys/test/test.txt b/sys/test/test.txt
index 86be743d1..85e3f4ac8 100644
--- a/sys/test/test.txt
+++ b/sys/test/test.txt
@@ -866,3 +866,28 @@ syz_r103_r104_s {
opt0 r103 (out)
opt1 r104 (in)
}
+
+# Optional resources
+
+resource optional_res1[int32]
+resource optional_res2[int32]
+resource required_res1[int32]
+
+test_args2 {
+ a array[optional_res2]
+}
+
+test_args1 {
+ a1 ptr64[in, array[optional_res1], opt]
+ a2 ptr64[in, test_args2, opt]
+ a3 ptr64[in, required_res1]
+}
+
+test_args0 {
+ a1 optional_res1
+ a2 optional_res2
+ a3 required_res1
+}
+
+test$output_res(arg ptr[out, test_args0])
+test$optional_res(arg ptr[in, test_args1])