citrun

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

lib_deadcount.t (1129B)


      1 #
      2 # Test that a ran program outputs a memory file with correct line execution
      3 # counts.
      4 #
      5 use Modern::Perl;
      6 use Test::Cmd;
      7 use Test::Differences;
      8 use Test::More tests => 8;
      9 
     10 use lib 't';
     11 require mem;
     12 require utils;
     13 
     14 
     15 my $dir = utils::setup_projdir();
     16 
     17 $dir->run( prog => $dir->workdir . '/program', args => '10',
     18 	chdir => $dir->curdir );
     19 is( $dir->stdout,	'55',	'inst program stdout correct' );
     20 isnt( $dir->stderr,	'',	'inst program stderr not silent' );
     21 is( $? >> 8,		0,	'inst program exit code 0' );
     22 
     23 my $shm = mem->new();
     24 
     25 my %tus = %{ $shm->{trans_units} };
     26 my ($tu1, $tu2, $tu3) = sort keys %tus;
     27 
     28 # Diff format test chosen here because these numbers are related to source code.
     29 my @fib_good = qw(
     30 177
     31 177
     32 177
     33 354
     34 34
     35 286
     36 55
     37 0
     38 528
     39 0
     40 0
     41 );
     42 
     43 my @main_good = qw(
     44 0
     45 0
     46 0
     47 0
     48 0
     49 0
     50 1
     51 1
     52 1
     53 0
     54 0
     55 2
     56 0
     57 0
     58 0
     59 0
     60 2
     61 0
     62 2
     63 1
     64 0
     65 0
     66 );
     67 
     68 my @print_good = qw(
     69 0
     70 0
     71 1
     72 1
     73 1
     74 1
     75 0
     76 0
     77 0
     78 );
     79 
     80 my $ctx = { context => 3 };
     81 eq_or_diff( $shm->get_buffers($tu1), \@fib_good, 'fib count identical', $ctx );
     82 eq_or_diff( $shm->get_buffers($tu2), \@main_good, 'main count identical', $ctx );
     83 eq_or_diff( $shm->get_buffers($tu3), \@print_good, 'print count identical', $ctx );