diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2024-03-21 12:11:11 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2024-03-21 16:42:53 +0000 |
| commit | f61173d242590d5ebf0d1ef9fd516e8977db1674 (patch) | |
| tree | 8bb47887f17a9983552eb6229cd3849266a2c2ab | |
| parent | 6af1f94a698da45d69e83632a9a06fae10739d1c (diff) | |
tools/syz-testbed: fix relative value change computation
It's perfectly normal for a column value not to be present -- e.g. when
we compare syzkaller branches that don't use the same statistics.
| -rw-r--r-- | tools/syz-testbed/table.go | 2 | ||||
| -rw-r--r-- | tools/syz-testbed/table_test.go | 27 |
2 files changed, 28 insertions, 1 deletions
diff --git a/tools/syz-testbed/table.go b/tools/syz-testbed/table.go index d170b2b8c..ee3ffd0e7 100644 --- a/tools/syz-testbed/table.go +++ b/tools/syz-testbed/table.go @@ -161,7 +161,7 @@ func (t *Table) SetRelativeValues(baseColumn string) error { for rowName, row := range t.Cells { baseCell := t.Get(rowName, baseColumn) if baseCell == nil { - return fmt.Errorf("base column %s not found in row %s", baseColumn, rowName) + continue } baseValueCell, ok := baseCell.(*ValueCell) if !ok { diff --git a/tools/syz-testbed/table_test.go b/tools/syz-testbed/table_test.go new file mode 100644 index 000000000..fb07e7804 --- /dev/null +++ b/tools/syz-testbed/table_test.go @@ -0,0 +1,27 @@ +// Copyright 2024 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +package main + +import ( + "testing" + + "github.com/google/syzkaller/pkg/stats" + "github.com/stretchr/testify/assert" +) + +func TestRelativeValues(t *testing.T) { + table := NewTable("", "A", "B") + table.Set("row1", "A", NewValueCell(&stats.Sample{Xs: []float64{2, 2}})) + table.Set("row1", "B", NewValueCell(&stats.Sample{Xs: []float64{3, 3}})) + // Don't set row2/A. + table.Set("row2", "B", NewValueCell(&stats.Sample{Xs: []float64{1, 1}})) + + err := table.SetRelativeValues("A") + assert.NoError(t, err) + + assert.InDelta(t, 50.0, *table.Get("row1", "B").(*ValueCell).PercentChange, 0.1) + assert.Nil(t, table.Get("row1", "A").(*ValueCell).PercentChange) + assert.Nil(t, table.Get("row2", "A")) + assert.Nil(t, table.Get("row2", "B").(*ValueCell).PercentChange) +} |
