commit 8a4f4e629259b0af342a5960a754cbf633600fd4
parent 9cdc1440b6e16e81dbcb60fde352a0817a8ff393
Author: Kyle Milz <kyle@0x30.net>
Date: Sun, 7 Aug 2016 20:44:01 -0600
t: switch inst_switch from Perl to shell
Diffstat:
2 files changed, 53 insertions(+), 12 deletions(-)
diff --git a/t/inst_switch.t b/t/inst_switch.t
@@ -1,12 +1,10 @@
-use strict;
-use Test::More tests => 1;
-use Test::Project;
-use Test::Viewer;
+#!/bin/sh -e
+echo 1..3
-my $project = Test::Project->new();
-my $viewer = Test::Viewer->new();
+. test/utils.sh
+setup
-$project->add_src(<<EOF);
+cat <<EOF > switch.c
int
main(void)
{
@@ -23,8 +21,51 @@ main(void)
}
EOF
-$project->compile();
-$project->run();
+cat <<EOF > switch.c.inst_good
+int
+main(void)
+{citrun_start();++_citrun_lines[1];++_citrun_lines[2];++_citrun_lines[3];
+ int i;
+
+ switch ((++_citrun_lines[6], i)) {
+ case 0:
+ break;
+ case 1:
+ break;
+ }
+
+ return (++_citrun_lines[13], 0);
+}
+EOF
+
+cat <<EOF > citrun.log.good
+
+citrun-inst v0.0 () called as ''.
+Command line is ''.
+Found source file ''.
+Object arg = 0, compile arg = 0
+Link detected, adding '' to command line.
+Added clangtool argument ''.
+Instrumentation of '' finished:
+ 15 Lines of source code
+ 30 Lines of instrumentation header
+ 1 Functions called ''
+ 1 Function declarations
+ 0 If statements
+ 0 For statements
+ 0 While statements
+ 1 Switch statements
+ 1 Return statement values
+ 0 Call expressions
+ 14 Total statements in source
+Writing modified source to ''.
+Modified source written successfully.
+Instrumentation successful.
+EOF
+
+citrun-inst switch.c
+
+diff -u switch.c.inst_good switch.c.citrun && echo "ok 2 - instrumented source diff"
-my ($ret) = $project->wait();
-is($ret, 0, "instrumented program check");
+process_citrun_log
+diff -u citrun.log.good citrun.log.proc && echo "ok 3 - citrun.log diff"
diff --git a/test/utils.sh b/test/utils.sh
@@ -1,8 +1,8 @@
-
function setup
{
tmpdir=`mktemp -d /tmp/citrun.XXXXXXXXXX`
trap "rm -rf $tmpdir" EXIT
+ echo "ok 1 - tmp dir created"
export PATH="`pwd`/src:${PATH}"
cd $tmpdir