citrun

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

e2e_ansi.t (1231B)


      1 #
      2 # Check that instrumentation works when the -ansi flag is passed during
      3 # compilation.
      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 $cc = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' );
     15 $cc->write( 'main.c', 'int main(void) { return 0; }' );
     16 
     17 if ($^O eq 'MSWin32') {
     18 	$cc->run( args => 'cl /nologo /Za main.c', chdir => $cc->curdir );
     19 } else {
     20 	$cc->run( args => 'cc -ansi -o main main.c', chdir => $cc->curdir );
     21 }
     22 #is( $cc->stdout,	'',		'citrun_wrap cc stdout silent' );
     23 is( $cc->stderr,	'',		'citrun_wrap cc stderr silent' );
     24 is( $? >> 8,		0,		'citrun_wrap cc exit code 0' );
     25 
     26 my $log_good = <<EOF;
     27 >> citrun_inst
     28 Compilers path = ''
     29 PATH = ''
     30 Found source file ''
     31 Link detected, adding '' to command line.
     32 Command line is ''
     33 Added clangtool argument ''
     34 Instrumentation of '' finished:
     35     1 Lines of source code
     36     1 Function definitions
     37     1 Return statement values
     38     3 Total statements
     39 Modified source written successfully.
     40 Forked compiler ''
     41 Rewritten source compile successful
     42 Restored ''
     43 EOF
     44 
     45 my $log_out;
     46 $cc->read( \$log_out, 'citrun.log' );
     47 eq_or_diff( utils::clean_citrun_log($log_out),	$log_good, 'is citrun.log identical');