citrun

watch C/C++ source code execute
Log | Files | Refs | LICENSE

commit 5c86c6e8b19ab7bd08a926603e682f5b57c8f806
parent 10c755f0c116cd6aa54fbab901a0e75e8619da21
Author: Kyle Milz <kyle@getaddrinfo.net>
Date:   Thu, 17 Mar 2016 20:23:47 -0600

t/runtime_counters_increase: make test program more portable

Diffstat:
Mt/runtime_counters_increase.t | 37++++++++++++++++---------------------
1 file changed, 16 insertions(+), 21 deletions(-)

diff --git a/t/runtime_counters_increase.t b/t/runtime_counters_increase.t @@ -1,7 +1,7 @@ use strict; use SCV::Project; use SCV::Viewer; -use Test::More tests => 38; +use Test::More tests => 33; use Test::Differences; use Time::HiRes qw( usleep ); @@ -9,10 +9,8 @@ my $project = SCV::Project->new(); my $viewer = SCV::Viewer->new(); unified_diff; -$project->add_src( -<<EOF +$project->add_src(<<EOF #include <err.h> -#include <limits.h> #include <stdio.h> #include <stdlib.h> @@ -31,14 +29,11 @@ int main(int argc, char *argv[]) { long long n; - const char *errstr = NULL; if (argc != 2) errx(1, "argc != 2"); - n = strtonum(argv[1], LONG_MIN, LONG_MAX, &errstr); - if (errstr) - err(1, "%s", errstr); + n = atoi(argv[1]); fprintf(stderr, "%lli", fib(n)); return 0; @@ -57,26 +52,26 @@ my $metadata = $viewer->get_metadata(); is( scalar(@{ $metadata }), 1, "runtime check for a single tu" ); my $source_0 = $metadata->[0]; -like ($source_0->{filename}, qr/tmp\/.*source_0\.c/, "runtime filename check"); -is( $source_0->{lines}, 33, "runtime lines count" ); +like ($source_0->{filename}, qr/.*source_0\.c/, "runtime filename check"); +is( $source_0->{lines}, 29, "runtime lines count" ); usleep(100 * 1000); my $data = $viewer->get_execution_data(); my @lines = @{ $data->[0] }; # Do a pretty thorough coverage check -is ( $lines[$_], 0, "line $_ check" ) for (0..8); -cmp_ok ( $lines[$_], ">", 0, "line $_ check" ) for (9..12); -is ( $lines[13], 0, "line 13 check" ); -cmp_ok ( $lines[14], ">", 0, "line 14 check" ); -is ( $lines[$_], 0, "line $_ check" ) for (15..22); -is ( $lines[23], 1, "line 23 check" ); -is ( $lines[$_], 0, "line $_ check" ) for (24..25); -is ( $lines[$_], 1, "line $_ check" ) for (26..27); -is ( $lines[$_], 0, "line $_ check" ) for (28..29); -is ( $lines[30], 2, "line 30 check" ); +is ( $lines[$_], 0, "line $_ check" ) for (1..7); +cmp_ok ( $lines[$_], ">", 0, "line $_ check" ) for (8..11); +is ( $lines[12], 0, "line 12 check" ); +cmp_ok ( $lines[13], ">", 0, "line 13 check" ); +is ( $lines[$_], 0, "line $_ check" ) for (14..20); +is ( $lines[21], 1, "line 21 check" ); +is ( $lines[$_], 0, "line $_ check" ) for (22..23); +is ( $lines[24], 1, "line 24 check" ); +is ( $lines[25], 0, "line 25 check" ); +is ( $lines[26], 2, "line 26 check" ); # Make sure return code hasn't fired yet -is ( $lines[$_], 0, "line $_ check" ) for (31..32); +is ( $lines[$_], 0, "line $_ check" ) for (27..28); $project->kill(); my ($ret, $err) = $project->wait();