Skip to content

Commit 76c8ad0

Browse files
committed
Fix various race conditions in test with io_uring.
1 parent b6c5fe5 commit 76c8ad0

3 files changed

Lines changed: 9 additions & 19 deletions

File tree

test/async/barrier.rb

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,22 @@
1818

1919
with "#async" do
2020
let(:repeats) {40}
21-
let(:delay) {0.01}
2221

2322
it "should wait for all jobs to complete" do
2423
finished = 0
2524

2625
repeats.times.map do |i|
2726
barrier.async do |task|
28-
sleep(delay)
27+
task.yield
2928
finished += 1
30-
31-
# This task is a child task but not part of the barrier.
32-
task.async do
33-
sleep(delay*3)
34-
end
3529
end
3630
end
3731

3832
expect(barrier).not.to be(:empty?)
39-
expect(finished).to be < repeats
33+
expect(finished).to be <= repeats
4034

41-
duration = Async::Clock.measure{barrier.wait}
35+
barrier.wait
4236

43-
expect(duration).to be_within(repeats * Sus::Fixtures::Time::QUANTUM).of(delay)
4437
expect(finished).to be == repeats
4538
expect(barrier).to be(:empty?)
4639
end

test/async/limited_queue.rb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,16 @@ def before
8787
with "#close" do
8888
it "signals tasks waiting to enqueue items when closed" do
8989
queue.enqueue(:item1)
90-
90+
9191
# This task will block as the queue is full:
9292
waiting_task = reactor.async do
93-
queue.enqueue(:item2)
93+
expect do
94+
queue.enqueue(:item2)
95+
end.to raise_exception(Async::Queue::ClosedError)
9496
end
95-
97+
9698
queue.close
97-
98-
expect do
99-
waiting_task.wait
100-
end.to raise_exception(Async::Queue::ClosedError)
99+
waiting_task.wait
101100
end
102101
end
103102
end

test/async/notification.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
expect(task.status).to be == :running
3333

34-
sequence << :yielding
3534
reactor.yield
3635
sequence << :finished
3736

@@ -41,7 +40,6 @@
4140
:waiting,
4241
:running,
4342
:signalled,
44-
:yielding,
4543
:resumed,
4644
:finished
4745
]

0 commit comments

Comments
 (0)