citrun

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

lib_badver.t (1179B)


      1 #
      2 # Check that linking object files of one citrun version with libcitrun of
      3 # another errors.
      4 #
      5 use Modern::Perl;
      6 use Test::Cmd;
      7 use Test::More tests => 5;
      8 
      9 use lib 't';
     10 require utils;
     11 
     12 
     13 my $wrap = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' );
     14 $wrap->write( 'main.c', <<EOF );
     15 #include <stddef.h>
     16 
     17 struct citrun_node;
     18 void citrun_node_add(unsigned int, unsigned int, struct citrun_node *);
     19 
     20 int
     21 main(int argc, char *argv[])
     22 {
     23 	citrun_node_add(/* major */ 0, /* minor */ 255, NULL);
     24 }
     25 EOF
     26 
     27 $wrap->run( args => utils::os_compiler() . 'main main.c',
     28 	chdir => $wrap->curdir );
     29 # is( $wrap->stdout,	'',	'compiler stdout silent' );
     30 is( $wrap->stderr,	'',	'citrun_wrap stderr silent' );
     31 is( $? >> 8,		0,	'citrun_wrap exit code 0' );
     32 
     33 my $err_good = 'libcitrun 0.0: incompatible version 0.255.
     34 Try cleaning and rebuilding your project.';
     35 
     36 my $abs_prog_path = File::Spec->catfile( $wrap->workdir, "main" );
     37 
     38 $wrap->run( prog => $abs_prog_path, chdir => $wrap->curdir );
     39 is(	$wrap->stdout,	'',		'node program stdout silent' );
     40 like(	$wrap->stderr,	qr/$err_good/,	'node program stderr good' );
     41 isnt(	$? >> 8,	0,		'node program exit code nonzero' );
     42 unlink "/tmp/citrun.out";