aboutsummaryrefslogtreecommitdiffstats
path: root/prog/prio_test.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-08-30 06:58:05 -0700
committerDmitry Vyukov <dvyukov@google.com>2018-08-30 21:44:00 -0700
commitee42876f958cee5e90c650618fe994307a260397 (patch)
tree96251ad4b4652e8b8016dcac36e567dd547b20bb /prog/prio_test.go
parent938220fdbbf294b00b3c62efa06e82aa63fca33c (diff)
prog: fix corner case in normalizePrio
Based on twitter bug report: https://twitter.com/panicaII/status/1035058001269248000
Diffstat (limited to 'prog/prio_test.go')
-rw-r--r--prog/prio_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/prog/prio_test.go b/prog/prio_test.go
new file mode 100644
index 000000000..06a72f75b
--- /dev/null
+++ b/prog/prio_test.go
@@ -0,0 +1,28 @@
+// Copyright 2018 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 prog
+
+import (
+ "reflect"
+ "testing"
+)
+
+func TestNormalizePrio(t *testing.T) {
+ prios := [][]float32{
+ {2, 2, 2},
+ {1, 2, 4},
+ {1, 2, 0},
+ }
+ want := [][]float32{
+ {1, 1, 1},
+ {0.1, 0.4, 1},
+ {0.4, 1, 0.1},
+ }
+ t.Logf("had: %+v", prios)
+ normalizePrio(prios)
+ if !reflect.DeepEqual(prios, want) {
+ t.Logf("got: %+v", prios)
+ t.Errorf("want: %+v", want)
+ }
+}