commit f08afc9700070d7a58798c4d03eba793c63e882b
parent 27b7fb322291afd19db40d0641c9c6efc061a00d
Author: Kyle Milz <kyle@windows.krwm.net>
Date: Tue, 3 Jan 2017 20:15:36 -0800
t: convert inst_link_multiple.sh to perl
Diffstat:
2 files changed, 88 insertions(+), 52 deletions(-)
diff --git a/t/inst_link_multiple.sh b/t/inst_link_multiple.sh
@@ -1,52 +0,0 @@
-#!/bin/sh -u
-#
-# Check that linking more than one instrumented object file together works.
-#
-. t/utils.subr
-plan 4
-
-
-cat <<EOF > one.c
-void second_func();
-
-int main(void) {
- second_func();
- return 0;
-}
-EOF
-
-cat <<EOF > two.c
-void third_func();
-
-void second_func(void) {
- third_func();
- return;
-}
-EOF
-
-cat <<EOF > three.c
-void third_func(void) {
- return;
-}
-EOF
-
-ok "is instrumented compile successful" cc -o main one.c two.c three.c
-ok "is citrun_check successful" citrun_check -o check.out
-
-cat <<EOF > check.good
-Summary:
- 3 Source files used as input
- 1 Application link commands
- 1 Rewrite successes
- 1 Rewritten source compile successes
-
-Totals:
- 18 Lines of source code
- 3 Function definitions
- 1 Return statement values
- 2 Call expressions
- 13 Total statements
-EOF
-
-strip_millis check.out
-ok "citrun_check diff" diff -u check.good check.out
diff --git a/t/wrap_link_multiple.t b/t/wrap_link_multiple.t
@@ -0,0 +1,88 @@
+#
+# Check that linking more than one instrumented object file together works.
+#
+use strict;
+use warnings;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 3;
+use t::utils;
+unified_diff;
+
+
+my $wrap = Test::Cmd->new( prog => 'citrun_wrap', workdir => '' );
+
+$wrap->write( 'one.c', <<EOF );
+void second_func();
+
+int main(void) {
+ second_func();
+ return 0;
+}
+EOF
+
+$wrap->write( 'two.c', <<EOF );
+void third_func();
+
+void second_func(void) {
+ third_func();
+ return;
+}
+EOF
+
+$wrap->write( 'three.c', <<EOF );
+void third_func(void) {
+ return;
+}
+EOF
+
+if ($^O eq "MSWin32") {
+ $wrap->run( args => 'cl /nologo one.c two.c three.c', chdir => $wrap->curdir );
+} else {
+ $wrap->run( args => 'cc -o main one.c two.c three.c', chdir => $wrap->curdir );
+}
+
+my $log_good = <<EOF;
+>> citrun_inst
+CITRUN_COMPILERS = ''
+PATH=''
+Found source file ''
+Found source file ''
+Found source file ''
+Link detected, adding '' to command line.
+Modified command line is ''
+Added clangtool argument ''
+Instrumentation of '' finished:
+ 7 Lines of source code
+ 1 Function definitions
+ 1 Return statement values
+ 1 Call expressions
+ 6 Total statements
+Modified source written successfully.
+Instrumentation of '' finished:
+ 7 Lines of source code
+ 1 Function definitions
+ 1 Call expressions
+ 5 Total statements
+Modified source written successfully.
+Instrumentation of '' finished:
+ 4 Lines of source code
+ 1 Function definitions
+ 2 Total statements
+Modified source written successfully.
+Rewriting successful.
+Forked compiler ''
+Rewritten source compile successful
+Restored ''
+Restored ''
+Restored ''
+EOF
+
+my $citrun_log;
+$wrap->read( \$citrun_log, 'citrun.log' );
+$citrun_log = t::utils::clean_citrun_log($citrun_log);
+
+eq_or_diff( $citrun_log, $log_good, 'is citrun.log identical', { context => 3 } );
+print $wrap->stdout;
+is( $wrap->stderr, '', 'is citrun_wrap stderr silent' );
+is( $? >> 8, 0, 'is citrun_wrap exit code 0' );