aboutsummaryrefslogtreecommitdiffstats
path: root/prog/resources_test.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2024-05-07 19:18:48 +0200
committerDmitry Vyukov <dvyukov@google.com>2024-05-08 07:59:24 +0000
commit9473be88c063129babde23303d74596fabcc6332 (patch)
treed3979323ded2b2707e980b7588f66f6006d2d9bb /prog/resources_test.go
parent4cf3f9b3f15d248d052cd369d23308c953d657d9 (diff)
prog: fix episodic failures to generate a call
Tests sometimes fail as: --- FAIL: TestCreateResourceRotation (0.97s) ... resources_test.go:181: testing call syz_io_uring_submit resources_test.go:187: failed to create resource fd_dir FAIL Almost always it's related to fd_dir resource. The problem is with no_generate syscalls (we have lots of no_generate mount syscalls that produce fd_dif). Rotator considers them as legit resource ctors, but the actual code in createResource does not. As the result Rotator creates subsets of syscalls where not all resources can be created. The same problem affects TransitivelyEnabledCalls. It may leave syscalls that require resources produced only by no_generate syscalls. We won't be able to produce such resources during fuzzing. Split Syscall.outputResources to createResources (can actually be used to create, excludes no_generate) and usesResources, this includes no_generate syscalls.
Diffstat (limited to 'prog/resources_test.go')
-rw-r--r--prog/resources_test.go19
1 files changed, 12 insertions, 7 deletions
diff --git a/prog/resources_test.go b/prog/resources_test.go
index 180cfe1d6..334f9bbe5 100644
--- a/prog/resources_test.go
+++ b/prog/resources_test.go
@@ -18,7 +18,8 @@ func TestResourceCtors(t *testing.T) {
}
testEachTarget(t, func(t *testing.T, target *Target) {
for _, res := range target.Resources {
- if len(target.calcResourceCtors(res, true)) == 0 && !strings.HasPrefix(res.Name, "ANY") {
+ if len(target.calcResourceCtors(res, true)) == 0 && !strings.HasPrefix(res.Name, "ANY") &&
+ res.Name != "disabled_resource" {
t.Errorf("resource %v can't be created", res.Name)
}
}
@@ -29,6 +30,9 @@ func TestTransitivelyEnabledCalls(t *testing.T) {
testEachTarget(t, func(t *testing.T, target *Target) {
calls := make(map[*Syscall]bool)
for _, c := range target.Syscalls {
+ if c.Attrs.Disabled {
+ continue
+ }
calls[c] = true
}
enabled, disabled := target.TransitivelyEnabledCalls(calls)
@@ -49,13 +53,11 @@ func TestTransitivelyEnabledCalls(t *testing.T) {
}
}
} else {
- if len(enabled) != len(target.Syscalls) {
- t.Errorf("some calls are disabled: %v/%v", len(enabled), len(target.Syscalls))
+ if len(enabled) != len(calls) {
+ t.Errorf("some calls are disabled: %v/%v", len(enabled), len(calls))
}
- if len(disabled) != 0 {
- for c, reason := range disabled {
- t.Errorf("disabled %v: %v", c.Name, reason)
- }
+ for c, reason := range disabled {
+ t.Errorf("disabled %v: %v", c.Name, reason)
}
}
})
@@ -69,6 +71,9 @@ func TestTransitivelyEnabledCallsLinux(t *testing.T) {
}
calls := make(map[*Syscall]bool)
for _, c := range target.Syscalls {
+ if c.Attrs.Disabled {
+ continue
+ }
calls[c] = true
}
delete(calls, target.SyscallMap["epoll_create"])