e2e_link_multiple.t (1796B)
1 # 2 # Check that linking more than one instrumented object file together works. 3 # 4 use Modern::Perl; 5 use Test::Cmd; 6 use Test::Differences; 7 use Test::More tests => 3; 8 9 use lib 't'; 10 require utils; 11 12 13 my $wrap = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' ); 14 15 $wrap->write( 'one.c', <<EOF ); 16 void second_func(); 17 18 int main(void) { 19 second_func(); 20 return 0; 21 } 22 EOF 23 24 $wrap->write( 'two.c', <<EOF ); 25 void third_func(); 26 27 void second_func(void) { 28 third_func(); 29 return; 30 } 31 EOF 32 33 $wrap->write( 'three.c', <<EOF ); 34 void third_func(void) { 35 return; 36 } 37 EOF 38 39 $wrap->run( args => utils::os_compiler() . 'main one.c two.c three.c', 40 chdir => $wrap->curdir ); 41 42 my $log_good = <<EOF; 43 >> citrun_inst 44 Compilers path = '' 45 PATH = '' 46 Found source file '' 47 Found source file '' 48 Found source file '' 49 Link detected, adding '' to command line. 50 Command line is '' 51 Added clangtool argument '' 52 Instrumentation of '' finished: 53 7 Lines of source code 54 1 Function definitions 55 1 Return statement values 56 1 Call expressions 57 6 Total statements 58 Modified source written successfully. 59 Instrumentation of '' finished: 60 7 Lines of source code 61 1 Function definitions 62 1 Call expressions 63 5 Total statements 64 Modified source written successfully. 65 Instrumentation of '' finished: 66 4 Lines of source code 67 1 Function definitions 68 2 Total statements 69 Modified source written successfully. 70 Forked compiler '' 71 Rewritten source compile successful 72 Restored '' 73 Restored '' 74 Restored '' 75 EOF 76 77 my $citrun_log; 78 $wrap->read( \$citrun_log, 'citrun.log' ); 79 $citrun_log = utils::clean_citrun_log($citrun_log); 80 81 eq_or_diff( $citrun_log, $log_good, 'citrun.log identical', { context => 3 } ); 82 print $wrap->stdout; 83 is( $wrap->stderr, '', 'citrun_wrap stderr silent' ); 84 is( $? >> 8, 0, 'citrun_wrap exit code 0' );