Skip to content

Commit

Permalink
Tests improved. Fixes #170.
Browse files Browse the repository at this point in the history
  • Loading branch information
ngolovleva committed Oct 15, 2018
1 parent fa78f52 commit d855576
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion LibTest/io/RawDatagramSocket/any_A03_t01.dart
Expand Up @@ -35,7 +35,6 @@ check([bool no_write_events = false]) {
if (sent > 3) {
timer.cancel();
producer.close();
receiver.close();
}
});

Expand All @@ -62,6 +61,7 @@ check([bool no_write_events = false]) {
Expect.equals(2, count);
}
}).whenComplete(() {
receiver.close();
asyncEnd();
});
});
Expand Down
2 changes: 1 addition & 1 deletion LibTest/io/RawDatagramSocket/timeout_A03_t01.dart
Expand Up @@ -46,7 +46,7 @@ check(dataExpected, [bool no_write_events = false]) {
list.add(event);
receiver.receive();
}, onDone: () {
Expect.listEquals(dataExpected, list);

This comment has been minimized.

Copy link
@mkustermann

mkustermann Oct 15, 2018

Member

It's no longer tested whether a read or write event came and in which order, since only the list length is tested now!

This comment has been minimized.

Copy link
@ngolovleva

ngolovleva Oct 15, 2018

Author Contributor

I cannot reproduce test timeout_A03_t01.dart failure and didn't see the result of failure.
If you believe that the fix is not correct, let's reopen the issue. And it would be good to see the failure result.

This comment has been minimized.

Copy link
@mkustermann

mkustermann Oct 15, 2018

Member

I think the failure result was [RawSocketEvent.write, RawSocketEvent.read], so it basically missed one event.

My hypothesis was that the data wasn't sent and send(..) returned null (indicating that it wasn't sent). So the fix should check the return value of send(...).

This comment has been minimized.

Copy link
@ngolovleva

ngolovleva Oct 15, 2018

Author Contributor

The producer sends three datagrams, and receiver receives while sink is closed. Trying to reproduce failure I receive:
unittest-suite-wait-for-done
false RawSocketEvent.write [0]
false RawSocketEvent.read [1]
false RawSocketEvent.read [2]
true sink close
true 0
false sink close
false 3
unittest-suite-success
where true and false are parameter 'no_write_events' of method check.
Looks like the result check should be:
int list_length = list.length;
Expect.listEquals(dataExpected.sublist(0, list_length), list);

This comment has been minimized.

Copy link
@mkustermann

mkustermann Oct 15, 2018

Member

sould be good to see the failure result

Actually I've added the failure result in the original bug report: #170

the producer sends three datagrams,

It tries to send three datagrams, but it doesn't check if they got actually sent:

  producer.send([sent++], address, receiver.port);

instead of

  int bytesSent = producer.send([sent++], address, receiver.port);
  if (bytesSent == 0) { // should try again }

This comment has been minimized.

Copy link
@ngolovleva

ngolovleva Oct 15, 2018

Author Contributor

I had fixed the test, and if it will fail again the new investigation should be done.
Your note about not sent datagrams is interesting. I never check that send really sent data, because never saw that
data was not sent.

Expect.isTrue(list.length <= dataExpected.length);
asyncEnd();
});
new Timer(const Duration(milliseconds: 200), () {
Expand Down

0 comments on commit d855576

Please sign in to comment.