Skip to content

Commit 805686c

Browse files
committed
pass random data to file
1 parent 87306fb commit 805686c

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

foo.rb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
s = 0
2-
10.times do |x|
3-
s += x
1+
def run(num)
2+
if num == 45
3+
p :ok
4+
else
5+
p :ng
6+
end
47
end
58

6-
if s == 45
7-
p :ok
8-
else
9-
p :ng
9+
def fuzz(bytes)
10+
run(bytes[0])
1011
end

run.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
require 'coverage'
44

5-
Coverage.start(:all)
6-
# Coverage.start(branches: true)
7-
# Coverage.start(methods: true)
8-
# Coverage.start(lines: true)
9-
load('foo.rb', true)
10-
p Coverage.result
5+
fork do
6+
Coverage.start(:all)
7+
load('foo.rb')
8+
9+
fuzz(Random.new.bytes(10))
10+
11+
p Coverage.result
12+
end
13+
14+
Process.wait

0 commit comments

Comments
 (0)