commit 36effb2f66065edcc4a54fb11f76ee236e1a8e55
parent 8526d7cea27e9f2435874bb221f529ca66c7b184
Author: Kyle Milz <kyle@0x30.net>
Date: Sun, 8 Jan 2017 02:51:16 -0700
t: replace wrap_make.sh with perl
Diffstat:
D | t/wrap_make.sh | | | 37 | ------------------------------------- |
A | t/wrap_make.t | | | 62 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 files changed, 62 insertions(+), 37 deletions(-)
diff --git a/t/wrap_make.sh b/t/wrap_make.sh
@@ -1,37 +0,0 @@
-#!/bin/sh -u
-#
-# Test that wrapping the 'make' build system produces instrumented binaries.
-#
-. t/utils.subr
-type make || skip_all "make not found"
-plan 6
-
-empty_main
-
-cat <<EOF > Makefile
-program: main.o
- cc -o program main.o
-EOF
-
-ok "is instrumented make successful" make
-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_make.t b/t/wrap_make.t
@@ -0,0 +1,62 @@
+#
+# Test that wrapping the 'make' build system produces instrumented binaries.
+#
+use strict;
+use warnings;
+use File::Which;
+use t::utils;
+
+unless (which 'make') {
+ plan skip_all => 'make 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( 'Makefile', <<'EOF' );
+program: main.o
+ cc -o program main.o
+EOF
+
+$wrap->run( args => 'make', chdir => $wrap->curdir );
+print $wrap->stdout;
+is( $wrap->stderr, '', 'is citrun_wrap make stderr silent' );
+is( $? >> 8, 0, 'is citrun_wrap make 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.
+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 );
+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' );