aboutsummaryrefslogtreecommitdiffstats
path: root/prog/parse_test.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2021-09-03 16:20:07 +0000
committerAleksandr Nogikh <wp32pw@gmail.com>2021-09-22 15:40:02 +0200
commit1c202847db0380015a8920bfd21375c2d9f28ddb (patch)
tree6693da3a936398a9ac6678842ac181c5f0e3e429 /prog/parse_test.go
parenta7ce77be27d8e3728b97122a005bc5b23298cfc3 (diff)
all: refactor fault injection into call props
Now that call properties mechanism is implemented, we can refactor fault injection. Unfortunately, it is impossible to remove all traces of the previous apprach. In reprolist and while performing syz-ci jobs, syzkaller still needs to parse the old format. Remove the old prog options-based approach whenever possible and replace it with the use of call properties.
Diffstat (limited to 'prog/parse_test.go')
-rw-r--r--prog/parse_test.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/prog/parse_test.go b/prog/parse_test.go
index 48e3cd203..8de2e36da 100644
--- a/prog/parse_test.go
+++ b/prog/parse_test.go
@@ -30,7 +30,7 @@ gettid()
if ent.Proc != 0 {
t.Fatalf("proc %v, want 0", ent.Proc)
}
- if ent.Fault || ent.FaultCall != 0 || ent.FaultNth != 0 {
+ if ent.P.HasFaultInjection() {
t.Fatalf("fault injection enabled")
}
want := "getpid-gettid"
@@ -67,7 +67,7 @@ func TestParseMulti(t *testing.T) {
t.Fatalf("bad procs")
}
for i, ent := range entries {
- if ent.Fault || ent.FaultCall != 0 || ent.FaultNth != 0 {
+ if ent.P.HasFaultInjection() {
t.Fatalf("prog %v has fault injection enabled", i)
}
}
@@ -123,14 +123,14 @@ getpid()
t.Fatalf("got %v programs, want 1", len(entries))
}
ent := entries[0]
- if !ent.Fault {
- t.Fatalf("fault injection is not enabled")
- }
- if ent.FaultCall != 1 {
- t.Fatalf("fault call: got %v, want 1", ent.FaultCall)
- }
- if ent.FaultNth != 55 {
- t.Fatalf("fault nth: got %v, want 55", ent.FaultNth)
+ faultCall := ent.P.Calls[1]
+ normalCall := ent.P.Calls[0]
+ if faultCall.Props.FailNth != 56 {
+ // We want 56 (not 55!) because the number is now not 0-based.
+ t.Fatalf("fault nth on the 2nd call: got %v, want 56", faultCall.Props.FailNth)
+ }
+ if normalCall.Props.FailNth != 0 {
+ t.Fatalf("fault nth on the 1st call: got %v, want 0", normalCall.Props.FailNth)
}
want := "gettid-getpid"
got := ent.P.String()