wrap_jam.t (1788B)
1 # 2 # Test that wrapping the 'jam' build system produces instrumented binaries. 3 # 4 use File::Which; 5 use Modern::Perl; 6 use Test::Cmd; 7 use Test::Differences; 8 use Test::More; 9 10 plan skip_all => 'jam not found' unless (which 'jam'); 11 plan tests => 6; 12 13 use lib 't'; 14 require utils; 15 16 17 my $wrap = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' ); 18 19 $wrap->write( 'main.c', 'int main(void) { return 0; }' ); 20 $wrap->write( 'Jamfile', <<EOF ); 21 Main program : main.c ; 22 EOF 23 24 $wrap->run( args => 'jam', chdir => $wrap->curdir ); 25 print $wrap->stdout; 26 is( $wrap->stderr, '', 'citrun_wrap jam stderr silent' ); 27 is( $? >> 8, 0, 'citrun_wrap jam exit code 0' ); 28 29 my $citrun_log; 30 my $log_good = <<EOF; 31 >> citrun_inst 32 Compilers path = '' 33 PATH = '' 34 Found source file '' 35 Command line is '' 36 Added clangtool argument '' 37 Instrumentation of '' finished: 38 1 Lines of source code 39 1 Function definitions 40 1 Return statement values 41 3 Total statements 42 Modified source written successfully. 43 Forked compiler '' 44 Rewritten source compile successful 45 Restored '' 46 >> citrun_inst 47 Compilers path = '' 48 PATH = '' 49 Link detected, adding '' to command line. 50 Command line is '' 51 No source files found on command line. 52 EOF 53 54 if ($^O eq 'MSWin32') { 55 # Windows gets an extra message because exec() is emulated by fork(). 56 $log_good .= <<EOF ; 57 Forked compiler '' 58 EOF 59 } 60 61 62 $wrap->read( \$citrun_log, 'citrun.log' ); 63 $citrun_log = utils::clean_citrun_log( $citrun_log ); 64 65 eq_or_diff( $citrun_log, $log_good, 'citrun_wrap log file identical', 66 { context => 3 } ); 67 68 $wrap->run( prog => $wrap->workdir . '/program', chdir => $wrap->curdir ); 69 is( $wrap->stdout, '', 'inst program stdout silent' ); 70 isnt( $wrap->stderr, '', 'inst program stderr silent' ); 71 is( $? >> 8, 0, 'inst program exit code 0' ); 72 unlink "/tmp/citrun.out";