added --timefmt tests

This commit is contained in:
Dima Kogan 2013-10-19 23:55:47 -07:00
parent 74e95d8e6f
commit 54862ec2fd

643
t/plots.t
View File

@ -15,7 +15,7 @@ BEGIN {
} }
} }
use Test::More tests => 42; use Test::More tests => 52;
use File::Temp 'tempfile'; use File::Temp 'tempfile';
use IPC::Run 'run'; use IPC::Run 'run';
use String::ShellQuote; use String::ShellQuote;
@ -823,13 +823,157 @@ tryplot( testname => 'Monotonicity check',
EOF EOF
tryplot( testname => 'basic --timefmt plot',
cmd => q{seq 5 | awk '{print strftime("%d %b %Y %T",1382249107+$1,1),$1}'},
options => ['--domain', '--timefmt', '%d %b %Y %H:%M:%S'],
refplot => <<'EOF' );
5 ++--+---+--+---+---+---+--+--+A
+ + + + + + + + +
| |
| |
4.5 ++ ++
| |
| |
| |
| |
4 ++ A ++
| |
| |
| |
3.5 ++ ++
| |
| |
| |
3 ++ A ++
| |
| |
| |
| |
2.5 ++ ++
| |
| |
| |
2 ++ A ++
| |
| |
| |
| |
1.5 ++ ++
| |
| |
+ + + + + + + + +
1 A+--+---+--+---+---+---+--+--++
05:085:085:09:095:105:105:11:115:12
EOF
tryplot( testname => '--timefmt plot with bounds',
cmd => q{seq 5 | awk '{print strftime("%d %b %Y %T",1382249107+$1,1),$1}'},
options => ['--domain', '--timefmt', '%d %b %Y %H:%M:%S',
'--xmin', '20 Oct 2013 06:05:00',
'--xmax', '20 Oct 2013 06:05:20'],
refplot => <<'EOF' );
5 ++++-++-++-++-++-+A-++-++-++-++
+ + + + +
| |
| |
4.5 ++ ++
| |
| |
| |
| |
4 ++ A ++
| |
| |
| |
3.5 ++ ++
| |
| |
| |
3 ++ A ++
| |
| |
| |
| |
2.5 ++ ++
| |
| |
| |
2 ++ A ++
| |
| |
| |
| |
1.5 ++ ++
| |
| |
+ + + + +
1 ++++-++-++-+A-++-++-++-++-++-++
05:00 05:05 05:10 05:15 05:20
EOF
tryplot( testname => '--timefmt plot with --monotonic',
cmd => q{seq 10 | awk '{x=(NR-1)%5; print strftime("%d %b %Y %T",1382249107+x,1),$1}'},
options => ['--domain', '--timefmt', '%d %b %Y %H:%M:%S',
'--monotonic'],
refplot => <<'EOF' );
10 ++--+---+--+---+---+---+--+--+A
+ + + + + + + + +
| |
| |
9.5 ++ ++
| |
| |
| |
| |
9 ++ A ++
| |
| |
| |
8.5 ++ ++
| |
| |
| |
8 ++ A ++
| |
| |
| |
| |
7.5 ++ ++
| |
| |
| |
7 ++ A ++
| |
| |
| |
| |
6.5 ++ ++
| |
| |
+ + + + + + + + +
6 A+--+---+--+---+---+---+--+--++
05:075:075:08:085:095:095:10:105:11
EOF
note( "Starting to run streaming tests. These will take several seconds each" ); note( "Starting to run streaming tests. These will take several seconds each" );
# replotting every 1.0 seconds. Data comes in every 1.1 seconds. Two data # replotting every 1.0 seconds. Data comes in every 1.1 seconds. Two data
# points, and then "exit", so I should have two frames worth of data plotted. I # points, and then "exit", so I should have two frames worth of data plotted. I
# pre-send a 0 so that the gnuplot autoscaling is always well-defined # pre-send a 0 so that the gnuplot autoscaling is always well-defined
tryplot( testname => 'basic streaming test', tryplot( testname => 'basic streaming test',
cmd => q{seq 500 | awk 'BEGIN{ print 0; } {print (NR==3)? "exit" : $0; fflush(); system("sleep 1.1");}'}, cmd => q{seq 500 | awk 'BEGIN{ print 0; } {print (NR==3)? "exit" : $0; fflush(); system("sleep 1.2");}'},
options => [qw(--lines --points --stream)], options => [qw(--lines --points --stream)],
refplot => <<'EOF' ); refplot => <<'EOF' );
@ -1493,6 +1637,501 @@ tryplot( testname => 'streaming with --monotonic',
EOF EOF
tryplot( testname => '--timefmt streaming plot with --xlen',
cmd => q{seq 5 | awk 'BEGIN{ print strftime("%d %b %Y %T",1382249107-1,1),-4;} {if(NR==3) {print "exit";} else{ print strftime("%d %b %Y %T",1382249107+$1,1),$1;} fflush(); system("sleep 0.6")}'},
options => ['--points', '--lines',
'--domain', '--timefmt', '%d %b %Y %H:%M:%S',
qw(--stream 0.4 --xlen 3)],
refplot => <<'EOF' );
1 ++---+-----+----+----+-----+---+A
+ + + + + + *+
| *|
| * |
| * |
| * |
| * |
0 ++ * ++
| * |
| * |
| * |
| * |
| * |
| * |
-1 ++ * ++
| * |
| * |
| * |
| * |
| * |
| * |
-2 ++ * ++
| * |
| * |
| * |
| * |
| * |
| * |
-3 ++ * ++
| * |
| * |
| * |
| * |
| * |
+ + +* + + + +
-4 ++---+-----A----+----+-----+---++
05:0505:05 05:0605:0605:07 05:0705:08
2 ++---+-----+----+----+-----+---+A
+ + + + + + **+
| ** |
| ** |
| ** |
| ** |
1 ++ A ++
| * |
| * |
| * |
| * |
| * |
0 ++ * ++
| * |
| * |
| * |
| * |
-1 ++ * ++
| * |
| * |
| * |
| * |
| * |
-2 ++ * ++
| * |
| * |
| * |
| * |
| * |
-3 ++ * ++
| * |
| * |
| * |
|* |
+* + + + + + +
-4 A+---+-----+----+----+-----+---++
05:0605:06 05:0705:0705:08 05:0805:09
EOF
tryplot( testname => '--timefmt streaming plot with --monotonic',
cmd => q{seq 10 | awk '{x=(NR-1)%5; if(x==0) {print strftime("%d %b %Y %T",1382249107-1,-4),-4;} print strftime("%d %b %Y %T",1382249107+x,1),NR; fflush(); system("sleep 0.6")}'},
options => ['--points', '--lines',
'--domain', '--timefmt', '%d %b %Y %H:%M:%S',
qw(--stream 0.4 --monotonic)],
refplot => <<'EOF' );
1 ++----+------+-----+------+----+A
+ + + + + *+
| * |
| * |
| * |
| * |
| * |
0 ++ * ++
| * |
| * |
| * |
| * |
| * |
| * |
-1 ++ * ++
| * |
| * |
| * |
| * |
| * |
| * |
-2 ++ * ++
| * |
| * |
| * |
| * |
| * |
| * |
-3 ++ * ++
| * |
| * |
| * |
| * |
| * |
+* + + + + +
-4 A+----+------+-----+------+----++
05:06 05:06 05:06 05:06 05:06 05:07
2 ++------+-------+-------+------*A
+ + + + *** +
| ** |
| *** |
| *** |
| ** |
1 ++ A* ++
| * |
| * |
| * |
| * |
| * |
0 ++ * ++
| * |
| * |
| * |
| * |
-1 ++ * ++
| * |
| * |
| * |
| * |
| * |
-2 ++ * ++
| * |
| * |
| * |
| * |
| * |
-3 ++ * ++
| * |
| * |
| * |
|* |
+* + + + +
-4 A+------+-------+-------+------++
05:06 05:06 05:07 05:07 05:08
3 ++---+-----+----+----+-----+---*A
+ + + + + + ** +
| ** |
| ** |
| ** |
2 ++ *A* ++
| ** |
| ** |
| ** |
| ** |
1 ++ A ++
| * |
| * |
| * |
| * |
0 ++ * ++
| * |
| * |
| * |
| * |
-1 ++ * ++
| * |
| * |
| * |
| * |
-2 ++ * ++
| * |
| * |
| * |
| * |
-3 ++* ++
| * |
|* |
|* |
* + + + + + +
-4 A+---+-----+----+----+-----+---++
05:0605:06 05:0705:0705:08 05:0805:09
4 ++--+---+---+---+---+---+---+--*A
+ + + + + + + +** +
| ** |
| ** |
3 ++ A ++
| ** |
| ** |
| * |
| ** |
2 ++ *A ++
| ** |
| ** |
| ** |
1 ++ A ++
| * |
| * |
| * |
0 ++ * ++
| * |
| * |
| * |
| * |
-1 ++ * ++
| * |
| * |
| * |
-2 ++ * ++
| * |
| * |
| * |
| * |
-3 +* ++
|* |
|* |
* + + + + + + + +
-4 A+--+---+---+---+---+---+---+--++
05:065:065:075:075:085:085:095:095:10
5 ++----+------+-----+------+----+A
+ + + + + **+
| * |
| ** |
4 ++ A ++
| ** |
| ** |
| ** |
3 ++ A ++
| ** |
| * |
| ** |
2 ++ A ++
| ** |
| ** |
| ** |
1 ++ A ++
| * |
| * |
0 ++ * ++
| * |
| * |
| * |
-1 ++ * ++
| * |
| * |
| * |
-2 ++ * ++
| * |
| * |
| * |
-3 +* ++
|* |
|* |
* + + + + +
-4 A+----+------+-----+------+----++
05:06 05:07 05:08 05:09 05:10 05:11
6 ++----+------+-----+------+----+A
+ + + + + *+
| * |
| * |
| * |
| * |
| * |
4 ++ * ++
| * |
| * |
| * |
| * |
| * |
| * |
2 ++ * ++
| * |
| * |
| * |
| * |
| * |
| * |
0 ++ * ++
| * |
| * |
| * |
| * |
| * |
| * |
-2 ++ * ++
| * |
| * |
| * |
| * |
| * |
+* + + + + +
-4 A+----+------+-----+------+----++
05:06 05:06 05:06 05:06 05:06 05:07
8 ++------+-------+-------+------++
+ + + + +
| |
| **A
| ****** |
| ***** |
6 ++ A** ++
| * |
| * |
| * |
| * |
| * |
4 ++ * ++
| * |
| * |
| * |
| * |
2 ++ * ++
| * |
| * |
| * |
| * |
| * |
0 ++ * ++
| * |
| * |
| * |
| * |
| * |
-2 ++ * ++
| * |
| * |
| * |
|* |
+* + + + +
-4 A+------+-------+-------+------++
05:06 05:06 05:07 05:07 05:08
8 ++---+-----+----+----+-----+---*A
+ + + + + **** +
| **** |
| *A* |
| **** |
| *** |
6 ++ A* ++
| * |
| * |
| * |
| * |
| * |
4 ++ * ++
| * |
| * |
| * |
| * |
2 ++ * ++
| * |
| * |
| * |
| * |
| * |
0 ++ * ++
| * |
| * |
| * |
| * |
| * |
-2 ++* ++
| * |
| * |
|* |
|* |
* + + + + + +
-4 A+---+-----+----+----+-----+---++
05:0605:06 05:0705:0705:08 05:0805:09
10 ++--+---+---+---+--+---+---+--++
+ + + + + + + + +
| *A
| *** |
| ** |
8 ++ *A* ++
| **** |
| *A* |
| *** |
| ** |
6 ++ A* ++
| * |
| * |
| * |
| * |
4 ++ * ++
| * |
| * |
| * |
| * |
2 ++ * ++
| * |
| * |
| * |
| * |
0 ++ * ++
| * |
| * |
| * |
| * |
-2 ++* ++
|* |
|* |
|* |
* + + + + + + + +
-4 A+--+---+---+---+--+---+---+--++
05:065:065:075:075:08:085:095:095:10
10 ++----+-----+------+-----+----*A
+ + + + + *** +
| *A* |
| ** |
| ** |
8 ++ *A ++
| **** |
| *A* |
| ** |
| ** |
6 ++ A ++
| * |
| * |
| * |
| * |
4 ++ * ++
| * |
| * |
| * |
| * |
2 ++ * ++
| * |
| * |
| * |
| * |
0 ++* ++
| * |
| * |
| * |
|* |
-2 +* ++
|* |
|* |
* |
* + + + + +
-4 A+----+-----+------+-----+----++
05:06 05:07 05:08 05:09 05:10 05:11
EOF