aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/signal
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2024-04-09 10:53:37 +0200
committerAleksandr Nogikh <nogikh@google.com>2024-04-09 12:07:22 +0000
commite38e134c4df9e4b637ba5140cff0904ebe5491b1 (patch)
tree81f108aec5b42b66a1451f604977bbc9678131a6 /pkg/signal
parent2b6d9d2d4f7c9240e676ed043867fa382fbc7146 (diff)
pkg/fuzzer: deflake against new signal
We don't want to reach just any stable signal, we know the specific new signal that we target. The previous approach might have reduced the efficiency of the new deflake() approach.
Diffstat (limited to 'pkg/signal')
-rw-r--r--pkg/signal/signal.go9
-rw-r--r--pkg/signal/signal_test.go8
2 files changed, 17 insertions, 0 deletions
diff --git a/pkg/signal/signal.go b/pkg/signal/signal.go
index f7f7899b2..48686de54 100644
--- a/pkg/signal/signal.go
+++ b/pkg/signal/signal.go
@@ -92,6 +92,15 @@ func (s Signal) DiffRaw(raw []uint32, prio uint8) Signal {
return res
}
+func (s Signal) IntersectsWith(other Signal) bool {
+ for e, p := range s {
+ if p1, ok := other[e]; ok && p1 >= p {
+ return true
+ }
+ }
+ return false
+}
+
func (s Signal) Intersection(s1 Signal) Signal {
if s1.Empty() {
return nil
diff --git a/pkg/signal/signal_test.go b/pkg/signal/signal_test.go
index f5582698f..efd53d2ea 100644
--- a/pkg/signal/signal_test.go
+++ b/pkg/signal/signal_test.go
@@ -31,3 +31,11 @@ func TestSubtract(t *testing.T) {
base.Subtract(FromRaw([]uint32{1}, 0))
assert.Equal(t, 3, base.Len())
}
+
+func TestIntersectsWith(t *testing.T) {
+ base := FromRaw([]uint32{0, 1, 2, 3, 4}, 1)
+ assert.True(t, base.IntersectsWith(FromRaw([]uint32{0, 5, 10}, 1)))
+ assert.False(t, base.IntersectsWith(FromRaw([]uint32{5, 10, 15}, 1)))
+ // The other signal has a lower priority.
+ assert.False(t, base.IntersectsWith(FromRaw([]uint32{0, 1, 2}, 0)))
+}