commit 89fea712fbfcccf5054cacc17371469206a8a92e
parent 794f4d44620d0ccc40eb78f97057dfd4944df0ac
Author: Kyle Milz <kyle@0x30.net>
Date: Sat, 13 Aug 2016 03:34:42 -0600
t: add signal to test program so it can hopefully exit clean
Diffstat:
4 files changed, 33 insertions(+), 14 deletions(-)
diff --git a/t/rt_dynamic.t b/t/rt_dynamic.t
@@ -1,5 +1,5 @@
use strict;
-use Test::More tests => 107;
+use Test::More tests => 121;
use test::project;
use test::viewer;
use Time::HiRes qw( usleep );
@@ -11,7 +11,7 @@ $project->run(45);
$viewer->accept();
$viewer->cmp_static_data([
- [ "one.c", 20 ],
+ [ "one.c", 34 ],
[ "three.c", 9 ],
[ "two.c", 11 ],
]);
@@ -22,15 +22,20 @@ my $data = $viewer->get_dynamic_data();
my ($s0, $s1, $s2) = sort keys %$data;
my @lines = @{ $data->{$s0} };
-is( $lines[$_], 0, "src 0 line $_ check" ) for (0..5);
-is( $lines[$_], 1, "src 0 line $_ check" ) for (6..8);
-is( $lines[$_], 0, "src 0 line $_ check" ) for (9..10);
-is( $lines[11], 2, "src 0 line 11 check" );
-is( $lines[$_], 0, "src 0 line $_ check" ) for (12..13);
-is( $lines[14], 2, "src 0 line 14 check" );
-is( $lines[15], 0, "src 0 line 15 check" );
-is( $lines[16], 2, "src 0 line 16 check" );
-is( $lines[$_], 0, "src 0 line $_ check" ) for (17..18);
+is( $lines[$_], 0, "src 0 line $_ check" ) for (0..12);
+is( $lines[$_], 1, "src 0 line $_ check" ) for (13..15);
+is( $lines[$_], 0, "src 0 line $_ check" ) for (16..18);
+is( $lines[19], 2, "src 0 line 19 check" );
+is( $lines[$_], 0, "src 0 line $_ check" ) for (20..21);
+is( $lines[$_], 1, "src 0 line $_ check" ) for (22);
+is( $lines[$_], 0, "src 0 line $_ check" ) for (23);
+is( $lines[$_], 1, "src 0 line $_ check" ) for (24);
+is( $lines[$_], 3, "src 0 line $_ check" ) for (25);
+is( $lines[$_], 0, "src 0 line $_ check" ) for (26..27);
+is( $lines[$_], 2, "src 0 line $_ check" ) for (28);
+is( $lines[$_], 0, "src 0 line $_ check" ) for (29);
+is( $lines[$_], 2, "src 0 line $_ check" ) for (30);
+is( $lines[$_], 0, "src 0 line $_ check" ) for (31..32);
my @lines = @{ $data->{$s2} };
cmp_ok ( $lines[$_], ">", 1, "src 1 line $_ check" ) for (0..2);
diff --git a/t/rt_reconnect.t b/t/rt_reconnect.t
@@ -13,7 +13,7 @@ sleep(1);
my $viewer = test::viewer->new();
$viewer->accept();
$viewer->cmp_static_data([
- [ "one.c", 20 ],
+ [ "one.c", 34 ],
[ "three.c", 9 ],
[ "two.c", 11 ],
]);
diff --git a/t/rt_static.t b/t/rt_static.t
@@ -24,7 +24,7 @@ cmp_ok( $viewer->{pids}->[2], ">", 1, "pgrp check lower" );
cmp_ok( $viewer->{pids}->[2], "<", 100000, "pgrp check upper" );
$viewer->cmp_static_data([
- [ "one.c", 20 ],
+ [ "one.c", 34 ],
[ "three.c", 9 ],
[ "two.c", 11 ],
]);
diff --git a/test/project.pm b/test/project.pm
@@ -21,19 +21,33 @@ sub new {
write_file("one.c", <<EOF);
#include <err.h>
+#include <signal.h>
#include <stdlib.h>
long long fib(long long);
void print_output(long long);
+void
+usr1_sig(int signal)
+{
+ exit(0);
+}
+
int
main(int argc, char *argv[])
{
+ struct sigaction sa;
long long n;
if (argc != 2)
errx(1, "argc != 2");
+ sa.sa_handler = &usr1_sig;
+ sa.sa_flags = SA_RESTART;
+ sigfillset(&sa.sa_mask);
+ if (sigaction(SIGUSR1, &sa, NULL) == -1)
+ err(1, "sigaction");
+
n = atoi(argv[1]);
print_output(fib(n));
@@ -89,7 +103,7 @@ sub run {
sub kill {
my ($self) = @_;
- kill 'TERM', $self->{pid};
+ kill 'USR1', $self->{pid};
}
sub wait {