diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-06-18 19:45:48 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-06-18 19:45:48 +0200 |
| commit | dcb1eebb7ffdd179de39e7cb89ca085368ee69d5 (patch) | |
| tree | 00cd2f8591f0dbb82cade9531b5af050a303127d /prog/decl_test.go | |
| parent | 920b18be87d248413f549d978d7dd68495a6ea7c (diff) | |
prog: more precise constructor calculation
Currently a call that both accepts and creates a resource
self-justifies itself and thus is always enabled.
A good example is accept call. Accepts are always self-enable
and thus enable all other syscalls that work with the socket.
Calculate TransitivelyEnabledCalls in the opposite direction
to resolve this. Start with empty set of enable syscalls,
then enable syscalls that don't accept any resources,
then enable syscalls that accept resources created by the
previous batch of syscalls, and so on.
This prevents self-enablement of accept.
Diffstat (limited to 'prog/decl_test.go')
| -rw-r--r-- | prog/decl_test.go | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/prog/decl_test.go b/prog/decl_test.go index 0f727aa7f..ac353e66a 100644 --- a/prog/decl_test.go +++ b/prog/decl_test.go @@ -14,11 +14,11 @@ func TestResourceCtors(t *testing.T) { } testEachTarget(t, func(t *testing.T, target *Target) { for _, c := range target.Syscalls { - for _, res := range c.inputResources() { - if len(target.calcResourceCtors(res.Desc.Kind, true)) == 0 { + for _, res := range target.inputResources(c) { + if len(target.calcResourceCtors(res.Kind, true)) == 0 { t.Errorf("call %v requires input resource %v,"+ " but there are no calls that can create this resource", - c.Name, res.Desc.Name) + c.Name, res.Name) } } } @@ -31,18 +31,29 @@ func TestTransitivelyEnabledCalls(t *testing.T) { for _, c := range target.Syscalls { calls[c] = true } - if trans, disabled := target.TransitivelyEnabledCalls(calls); len(disabled) != 0 { + enabled, disabled := target.TransitivelyEnabledCalls(calls) + for c, ok := range enabled { + if !ok { + t.Fatalf("syscalls %v is false in enabled map", c.Name) + } + } + if target.OS == "test" { + for c := range enabled { + if c.CallName == "unsupported" { + t.Errorf("call %v is not disabled", c.Name) + } + } for c, reason := range disabled { - t.Logf("disabled %v: %v", c.Name, reason) + if c.CallName != "unsupported" { + t.Errorf("call %v is disabled: %v", c.Name, reason) + } } - t.Fatalf("can't create some resource") - } else if len(trans) != len(calls) { - t.Fatalf("transitive syscalls are not full") } else { - for c, ok := range trans { - if !ok { - t.Fatalf("syscalls %v is false in transitive map", c.Name) - } + if len(enabled) != len(target.Syscalls) { + t.Errorf("some calls are disabled: %v/%v", len(enabled), len(target.Syscalls)) + } + for c, reason := range disabled { + t.Errorf("disabled %v: %v", c.Name, reason) } } }) |
