citrun

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

commit 6cc8a040bb2deb288fe20d47664a2f03abb426fd
parent a450194264ab7405600a3c3469e2cea761437a4b
Author: Kyle Milz <kyle@0x30.net>
Date:   Thu, 18 Aug 2016 18:56:05 -0600

t: replace remaining two runtime tests with shell

Diffstat:
Msrc/dump_main.cc | 18++++++++++++++++--
Mt/rt_dynamic.t | 78+++++++++++++++++++++---------------------------------------------------------
Dt/rt_reconnect.t | 24------------------------
3 files changed, 37 insertions(+), 83 deletions(-)

diff --git a/src/dump_main.cc b/src/dump_main.cc @@ -11,7 +11,7 @@ static void usage() { - std::cerr << "usage: citrun-dump [-f]" << std::endl; + std::cerr << "usage: citrun-dump [-ft]" << std::endl; exit(1); } @@ -20,12 +20,16 @@ main(int argc, char *argv[]) { int ch; int fflag = 0; + int tflag = 0; - while ((ch = getopt(argc, argv, "f")) != -1) { + while ((ch = getopt(argc, argv, "ft")) != -1) { switch (ch) { case 'f': fflag = 1; break; + case 't': + tflag = 1; + break; default: usage(); break; @@ -46,6 +50,16 @@ main(int argc, char *argv[]) return 0; } + if (tflag) { + uint64_t total = 0; + for (auto &t : rt.m_tus) + for (int i = 0; i < t.num_lines; ++i) + total += t.exec_diffs[i]; + std::cout << total << std::endl; + + return 0; + } + std::cout << "Version: " << unsigned(rt.m_major) << "." << unsigned(rt.m_minor) << "\n" diff --git a/t/rt_dynamic.t b/t/rt_dynamic.t @@ -1,58 +1,22 @@ -use strict; -use Test::More tests => 121; -use test::project; -use test::viewer; -use Time::HiRes qw( usleep ); - -my $project = test::project->new(); -my $viewer = test::viewer->new(); - -$project->run(45); - -$viewer->accept(); -$viewer->cmp_static_data([ - [ "one.c", 34 ], - [ "three.c", 9 ], - [ "two.c", 11 ], -]); - -# Check initial execution counts +#!/bin/sh # -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..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); -cmp_ok ( $lines[$_], ">", 10, "src 1 line $_ check" ) for (3..6); -is( $lines[7], 0, "src 1 line 7 check" ); -cmp_ok( $lines[8], ">", 10, "src 1 line 8 check" ); -is( $lines[9], 0, "src 1 line 9 check" ); - -my @lines = @{ $data->{$s1} }; -is( $lines[$_], 0, "src 2 line $_ check" ) for (0..8); - -for (1..60) { - usleep(10 * 1000); - $viewer->cmp_dynamic_data(); -} - -$project->kill(); -my ($ret, $err) = $project->wait(); -is( $ret, 0, "instrumented program check return code" ); -is( $err, undef, "instrumented program check stderr" ); +# Test that we can count an executing program as its running. +# +echo 1..61 +. test/project.sh + +./program 45 & +pid=$! + +let n=0 +let lst=0 +let cur=0 +while [ $n -lt 60 ]; do + cur=`$TEST_TOOLS/citrun-dump -t` + [ $cur -gt $lst ] && echo ok + let lst=cur + let n++ +done + +kill -USR1 $pid +wait diff --git a/t/rt_reconnect.t b/t/rt_reconnect.t @@ -1,24 +0,0 @@ -use strict; -use Test::More tests => 9; -use test::project; -use test::viewer; - -my $project = test::project->new(); - -$project->run(45); - -# Give the runtime a chance to reconnect -sleep(1); - -my $viewer = test::viewer->new(); -$viewer->accept(); -$viewer->cmp_static_data([ - [ "one.c", 34 ], - [ "three.c", 9 ], - [ "two.c", 11 ], -]); - -$project->kill(); -my ($ret, $err) = $project->wait(); -is( $ret, 0, "instrumented program check return code" ); -is( $err, undef, "instrumented program check stderr" );