aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMara Mihali <maramihali@google.com>2021-07-16 08:38:35 +0000
committermaramihali <maramihali@google.com>2021-07-19 14:47:11 +0300
commitbb08309d45a5e52acc389ed77d26952d89ed1382 (patch)
tree34aa3ff1f3f3bf3a69631c7dac52693d1b8e1085
parent8e377639318c59220478c96262a1319ee8e37e7d (diff)
syz-verifier/stats: keep track of kernel return states
-rw-r--r--syz-verifier/stats/stats.go8
-rw-r--r--syz-verifier/stats/stats_test.go20
2 files changed, 16 insertions, 12 deletions
diff --git a/syz-verifier/stats/stats.go b/syz-verifier/stats/stats.go
index 0a96b7f71..f0607f63a 100644
--- a/syz-verifier/stats/stats.go
+++ b/syz-verifier/stats/stats.go
@@ -34,6 +34,9 @@ type CallStats struct {
// Occurrences is the number of times the system call appeared in a
// verified program.
Occurrences int
+ // States stores all possible kernel return values identified for the
+ // system call.
+ States map[int]bool
}
// InitStats creates a stats object that will report verification
@@ -65,8 +68,9 @@ func (s *Stats) ReportCallStats(call string) string {
data := fmt.Sprintf("statistics for %s:\n"+
"\t↳ mismatches of %s / occurrences of %s: %d / %d (%0.2f %%)\n"+
"\t↳ mismatches of %s / total number of mismatches: "+
- "%d / %d (%0.2f %%)\n", name, name, name, m, o,
- getPercentage(m, o), name, m, s.TotalMismatches, getPercentage(m, s.TotalMismatches))
+ "%d / %d (%0.2f %%)\n"+
+ "\t↳ %d distinct states identified\n", name, name, name, m, o,
+ getPercentage(m, o), name, m, s.TotalMismatches, getPercentage(m, s.TotalMismatches), len(cs.States))
return data
}
diff --git a/syz-verifier/stats/stats_test.go b/syz-verifier/stats/stats_test.go
index 4bc3f9149..cfef1f910 100644
--- a/syz-verifier/stats/stats_test.go
+++ b/syz-verifier/stats/stats_test.go
@@ -12,12 +12,12 @@ import (
func getTestStats() *Stats {
return &Stats{
- TotalMismatches: 11,
+ TotalMismatches: 10,
Calls: map[string]*CallStats{
- "foo": {"foo", 2, 8},
- "bar": {"bar", 5, 6},
- "tar": {"tar", 3, 4},
- "biz": {"biz", 0, 2},
+ "foo": {"foo", 2, 8, map[int]bool{11: true, 3: true}},
+ "bar": {"bar", 5, 6, map[int]bool{10: true, 22: true}},
+ "tar": {"tar", 3, 4, map[int]bool{31: true, 100: true, 101: true}},
+ "biz": {"biz", 0, 2, map[int]bool{4: true}},
},
}
}
@@ -36,7 +36,7 @@ func TestReportCallStats(t *testing.T) {
call: "foo",
report: "statistics for foo:\n" +
"\t↳ mismatches of foo / occurrences of foo: 2 / 8 (25.00 %)\n" +
- "\t↳ mismatches of foo / total number of mismatches: 2 / 11 (18.18 %)\n",
+ "\t↳ mismatches of foo / total number of mismatches: 2 / 10 (20.00 %)\n" + "\t↳ 2 distinct states identified\n",
},
}
@@ -57,16 +57,16 @@ func TestReportGlobalStats(t *testing.T) {
s.ReportGlobalStats(&out)
got, want := out.String(),
"total number of mismatches / total number of calls "+
- "executed: 11 / 20 (55.00 %)\n\n"+
+ "executed: 10 / 20 (50.00 %)\n\n"+
"statistics for bar:\n"+
"\t↳ mismatches of bar / occurrences of bar: 5 / 6 (83.33 %)\n"+
- "\t↳ mismatches of bar / total number of mismatches: 5 / 11 (45.45 %)\n\n"+
+ "\t↳ mismatches of bar / total number of mismatches: 5 / 10 (50.00 %)\n"+"\t↳ 2 distinct states identified\n\n"+
"statistics for tar:\n"+
"\t↳ mismatches of tar / occurrences of tar: 3 / 4 (75.00 %)\n"+
- "\t↳ mismatches of tar / total number of mismatches: 3 / 11 (27.27 %)\n\n"+
+ "\t↳ mismatches of tar / total number of mismatches: 3 / 10 (30.00 %)\n"+"\t↳ 3 distinct states identified\n\n"+
"statistics for foo:\n"+
"\t↳ mismatches of foo / occurrences of foo: 2 / 8 (25.00 %)\n"+
- "\t↳ mismatches of foo / total number of mismatches: 2 / 11 (18.18 %)\n\n"
+ "\t↳ mismatches of foo / total number of mismatches: 2 / 10 (20.00 %)\n"+"\t↳ 2 distinct states identified\n\n"
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("s.ReportGlobalStats mismatch (-want +got):\n%s", diff)