aboutsummaryrefslogtreecommitdiffstats
path: root/prog/parse_test.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2024-08-19 15:49:59 +0200
committerAleksandr Nogikh <nogikh@google.com>2024-08-21 09:10:23 +0000
commit9bc3f3e965005cc642cef73466c9653a1c30c67f (patch)
tree97f7248b23dca5c2f3a9532481e471d0c063c58d /prog/parse_test.go
parentdb5852f9fc9006ecee80291c7b1676b4b8fec0c1 (diff)
prog: test new log format parsing
A few months ago, we have changed the execution log format. Let's test whether we correctly parse both the old and the new ones.
Diffstat (limited to 'prog/parse_test.go')
-rw-r--r--prog/parse_test.go48
1 files changed, 42 insertions, 6 deletions
diff --git a/prog/parse_test.go b/prog/parse_test.go
index c1a6aa6aa..1dcaa95d8 100644
--- a/prog/parse_test.go
+++ b/prog/parse_test.go
@@ -46,18 +46,33 @@ func TestParseMulti(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- entries := target.ParseLog([]byte(execLog))
+ entries := target.ParseLog([]byte(execLogNew))
+ validateProgs(t, entries, len(execLogNew))
+}
+
+func TestParseMultiLegacy(t *testing.T) {
+ t.Parallel()
+ target, err := GetTarget("linux", "amd64")
+ if err != nil {
+ t.Fatal(err)
+ }
+ entries := target.ParseLog([]byte(execLogOld))
+ validateProgs(t, entries, len(execLogOld))
+}
+
+func validateProgs(t *testing.T, entries []*LogEntry, logLen int) {
+ for i, ent := range entries {
+ t.Logf("program #%v: %v", i, ent.P)
+ }
if len(entries) != 5 {
- for i, ent := range entries {
- t.Logf("program #%v: %v", i, ent.P)
- }
t.Fatalf("got %v programs, want 5", len(entries))
}
off := 0
for _, ent := range entries {
- if off > ent.Start || ent.Start > ent.End || ent.End > len(execLog) {
+ if off > ent.Start || ent.Start > ent.End || ent.End > logLen {
t.Fatalf("bad offsets")
}
+ off = ent.End
}
if entries[0].Proc != 0 ||
entries[1].Proc != 1 ||
@@ -88,7 +103,28 @@ func TestParseMulti(t *testing.T) {
}
}
-const execLog = `
+const execLogNew = `
+getpid()
+gettid()
+15.133581935s ago: executing program 1 (id=70):
+getpid()
+[ 2351.935478] Modules linked in:
+gettid()
+munlockall()
+14.133581935s ago: executing program 2 (id=75):
+[ 2351.935478] Modules linked in:
+getpid()
+gettid()
+13.133581935s ago: executing program 33 (id=80):
+gettid()
+getpid()
+[ 2351.935478] Modules linked in:
+12.133581935s ago: executing program 9 (id=85):
+munlockall()
+`
+
+// Logs before the introduction of rpcserver.LastExecuting.
+const execLogOld = `
getpid()
gettid()
2015/12/21 12:18:05 executing program 1: