commit add3ddd4f66af25ff4b81033941af2633314df76
parent 05a42b1d2275ed0f106a1f2b36924cca117349e0
Author: Kyle Milz <kyle@windows.krwm.net>
Date: Wed, 4 Jan 2017 18:29:35 -0800
t: convert wrap_jam.sh to perl
Diffstat:
D | t/wrap_jam.sh | | | 36 | ------------------------------------ |
A | t/wrap_jam.t | | | 68 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 files changed, 68 insertions(+), 36 deletions(-)
diff --git a/t/wrap_jam.sh b/t/wrap_jam.sh
@@ -1,36 +0,0 @@
-#!/bin/sh -u
-#
-# Test that wrapping the 'jam' build system produces instrumented binaries.
-#
-. t/utils.subr
-type jam || skip_all "jam not found"
-plan 6
-
-empty_main
-
-cat <<EOF > Jamfile
-Main program : main.c ;
-EOF
-
-ok "is instrumented jam successful" jam
-ok "is citrun_check successful" citrun_check -o check.out
-
-cat <<EOF > check.good
-Summary:
- 1 Source files used as input
- 1 Application link commands
- 1 Rewrite successes
- 1 Rewritten source compile successes
-
-Totals:
- 6 Lines of source code
- 1 Function definitions
- 1 Return statement values
- 3 Total statements
-EOF
-
-strip_millis check.out
-ok "is citrun_check output identical" diff -u check.good check.out
-
-ok "does compiled program run" ./program
-ok "is runtime shared memory file created" test -f procdir/program_*
diff --git a/t/wrap_jam.t b/t/wrap_jam.t
@@ -0,0 +1,68 @@
+#
+# Test that wrapping the 'jam' build system produces instrumented binaries.
+#
+use strict;
+use warnings;
+use File::Which;
+use t::utils;
+
+unless (which 'jam') {
+ plan skip_all => 'jam not found';
+}
+plan tests => 6;
+
+
+my $wrap = Test::Cmd->new( prog => 'citrun_wrap', workdir => '' );
+
+$wrap->write( 'main.c', 'int main(void) { return 0; }' );
+$wrap->write( 'Jamfile', <<EOF );
+Main program : main.c ;
+EOF
+
+$wrap->run( args => 'jam', chdir => $wrap->curdir );
+is( $wrap->stderr, '', 'is citrun_wrap jam stderr silent' );
+is( $? >> 8, 0, 'is citrun_wrap jam exit code 0' );
+
+my $citrun_log;
+my $log_good = <<EOF;
+>> citrun_inst
+CITRUN_COMPILERS = ''
+PATH=''
+Found source file ''
+Modified command line is ''
+Added clangtool argument ''
+Instrumentation of '' finished:
+ 1 Lines of source code
+ 1 Function definitions
+ 1 Return statement values
+ 3 Total statements
+Modified source written successfully.
+Rewriting successful.
+Forked compiler ''
+Rewritten source compile successful
+Restored ''
+>> citrun_inst
+CITRUN_COMPILERS = ''
+PATH=''
+Link detected, adding '' to command line.
+Modified command line is ''
+No source files found on command line.
+Forked compiler ''
+EOF
+
+$wrap->read( \$citrun_log, 'citrun.log' );
+$citrun_log = clean_citrun_log( $citrun_log );
+
+eq_or_diff( $citrun_log, $log_good, 'is citrun_wrap log file identical', { context => 3 } );
+
+$wrap->run( prog => $wrap->workdir . '/program', chdir => $wrap->curdir );
+
+SKIP: {
+ skip 'win32 broken', 3 if $^O eq "MSWin32";
+
+ is( $wrap->stdout, '', 'is instrumented program stdout silent' );
+ is( $wrap->stderr, '', 'is instrumented program stderr silent' );
+ is( $? >> 8, 0, 'is instrumented program exit code 0' );
+}
+
+#ok "is runtime shared memory file created" test -f procdir/program_*