aboutsummaryrefslogtreecommitdiffstats
path: root/prog/parse_test.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-05-25 16:07:10 +0200
committerDmitry Vyukov <dvyukov@google.com>2017-05-26 17:22:57 +0200
commit220dc49106d66ff912db835004c88f8c9e2d1707 (patch)
treef271acbb95f7b96d1da3d6fb6af80d2e95f9d727 /prog/parse_test.go
parent8f58526cb8e159721342f3880658a1a2547adab8 (diff)
csource: reproduce crashes with fault injection
Diffstat (limited to 'prog/parse_test.go')
-rw-r--r--prog/parse_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/prog/parse_test.go b/prog/parse_test.go
index 9492b997e..2f5dd75d6 100644
--- a/prog/parse_test.go
+++ b/prog/parse_test.go
@@ -25,6 +25,9 @@ gettid()
if ent.Proc != 0 {
t.Fatalf("proc %v, want 0", ent.Proc)
}
+ if ent.Fault || ent.FaultCall != 0 || ent.FaultNth != 0 {
+ t.Fatalf("fault injection enabled")
+ }
want := "getpid-gettid"
got := ent.P.String()
if got != want {
@@ -53,6 +56,11 @@ func TestParseMulti(t *testing.T) {
entries[4].Proc != 9 {
t.Fatalf("bad procs")
}
+ for i, ent := range entries {
+ if ent.Fault || ent.FaultCall != 0 || ent.FaultNth != 0 {
+ t.Fatalf("prog %v has fault injection enabled", i)
+ }
+ }
if s := entries[0].P.String(); s != "getpid-gettid" {
t.Fatalf("bad program 0: %s", s)
}
@@ -89,3 +97,29 @@ getpid()
2015/12/21 12:18:05 executing program 9:
munlockall()
`
+
+func TestParseFault(t *testing.T) {
+ const execLog = `2015/12/21 12:18:05 executing program 1 (fault-call:1 fault-nth:55):
+gettid()
+getpid()
+`
+ entries := ParseLog([]byte(execLog))
+ if len(entries) != 1 {
+ 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)
+ }
+ want := "gettid-getpid"
+ got := ent.P.String()
+ if got != want {
+ t.Fatalf("bad program: %s, want %s", got, want)
+ }
+}