File: fix-test-for-mips

package info (click to toggle)
libperl5i-perl 2.13.2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 996 kB
  • ctags: 343
  • sloc: perl: 6,259; makefile: 5
file content (50 lines) | stat: -rw-r--r-- 1,454 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Description: Fix test for mips
 This patch fix a test issue that occurs only on mips architecture.
 .
 The faulty tests times actions done by a forked child process. 
 .
 The child process does:
 .
 say "A";
 flush;
 say "B" ;
 sleep 5;
 flush;
 .
 The test verifies that A and B are read with several seconds interval even 
 though there's no delay between say A and say B in the child process. (this is 
 a kind of buffer bloat test ;-) )
 .
 Weird thing: the test may fail even if there's indeed more than 2 seconds 
 between receiving A and B (verified with my stopwatch).
 .
 After several time measurement manips, it turns out that there's an 
 interaction between time() call, fork and autoflush.
 .
 The only way to have the test successful is to call time before calling fork 
 (i.e. before $child->start). 
Bug-Debian: https://bugs.debian.org/650806
Author: Dominique Dumont <dod@debian.org>
Reviewed-By: Xavier Guimard <x.guimard@free.fr>
Last-Update: 2013-01-02

--- a/t/Child.t
+++ b/t/Child.t
@@ -84,13 +84,16 @@
     $self->flush;
 }, pipe => 1 );
 
+my $fork_time = time ;
 $proc = $child->start;
 is( $proc->read(), "A\n", "A" );
 my $start = time;
 is( $proc->read(), "B\n", "B" );
 my $end = time;
 
-ok( $end - $start > 2, "No autoflush" );
+my $delta = $end - $start ;
+my $delta_fork = $start - $fork_time ;
+ok( $delta > 2, "No autoflush (read delta time $delta, fork delta $delta_fork)" );
 
 SKIP: {
     if ($^O eq 'MSWin32') {