citrun

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

inst_two_src.t (1453B)


      1 #
      2 # Check that two source files given on the same command line both get
      3 # instrumented fully.
      4 #
      5 use Modern::Perl;
      6 use Test::Cmd;
      7 use Test::Differences;
      8 use Test::More tests => 3;
      9 
     10 use lib 't';
     11 require utils;
     12 
     13 
     14 my $wrap = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' );
     15 
     16 $wrap->write( 'main.c', 'int main(void) { return 0; }' );
     17 $wrap->write( 'other.c', <<EOF );
     18 int other(void) {
     19 	return 0;
     20 }
     21 EOF
     22 
     23 $wrap->run( args => utils::os_compiler() . 'main main.c other.c',
     24 	chdir => $wrap->curdir );
     25 
     26 my $log_good = <<EOF;
     27 >> citrun_inst
     28 Compilers path = ''
     29 PATH = ''
     30 Found source file ''
     31 Found source file ''
     32 Link detected, adding '' to command line.
     33 Command line is ''
     34 Added clangtool argument ''
     35 Instrumentation of '' finished:
     36     1 Lines of source code
     37     1 Function definitions
     38     1 Return statement values
     39     3 Total statements
     40 Modified source written successfully.
     41 Instrumentation of '' finished:
     42     4 Lines of source code
     43     1 Function definitions
     44     1 Return statement values
     45     3 Total statements
     46 Modified source written successfully.
     47 Forked compiler ''
     48 Rewritten source compile successful
     49 Restored ''
     50 Restored ''
     51 EOF
     52 
     53 my $citrun_log;
     54 $wrap->read( \$citrun_log, 'citrun.log' );
     55 $citrun_log = utils::clean_citrun_log($citrun_log);
     56 
     57 eq_or_diff( $citrun_log, $log_good, 'citrun.log identical', { context => 3 } );
     58 print $wrap->stdout;
     59 is( $wrap->stderr,	'',	'citrun_wrap stderr silent' );
     60 is( $? >> 8,		0,	'citrun_wrap exit code 0' );