citrun

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

commit e88370bcd99062f3740339a980205c08374e3251
parent 47ca399b60253090955331ae6f29d31693e26efe
Author: Kyle Milz <kyle@0x30.net>
Date:   Mon, 26 Dec 2016 14:10:56 -0700

t: add empty_main function and remove uses of citrun_wrap

Diffstat:
Msrc/inst_frontend.cc | 3++-
Mt/e2e_ansi.sh | 12+++---------
Mt/e2e_basic.sh | 2+-
Mt/e2e_stdout.sh | 2+-
Mt/inst_basic_link.sh | 9+++------
Mt/inst_fail.sh | 4++--
Mt/inst_link_multiple.sh | 4++--
Mt/inst_log.sh | 4++--
Mt/inst_preprocess.sh | 8++++----
Mt/inst_src_ext.sh | 42++++++++++++++++++++++++++----------------
Mt/inst_two_src.sh | 11+++--------
Mt/utils.subr | 13++++++++++++-
Mt/wrap_badsrc.sh | 2+-
Mt/wrap_cmake.sh | 13+++----------
Mt/wrap_jam.sh | 11++---------
Mt/wrap_make.sh | 11++---------
Mt/wrap_ninja.sh | 10++--------
Mt/wrap_parallel.sh | 22++++++++--------------
18 files changed, 79 insertions(+), 104 deletions(-)

diff --git a/src/inst_frontend.cc b/src/inst_frontend.cc @@ -229,7 +229,8 @@ InstFrontend::process_cmdline() for (auto &arg : m_args) { if (std::strcmp(arg, "-E") == 0 || std::strcmp(arg, "-MM") == 0) { // I don't know the repercussions of doing otherwise. - m_log << "Preprocessor argument found" << std::endl; + m_log << "Preprocessor argument " << arg << " found" + << std::endl; exec_compiler(); } else if (std::strcmp(arg, "-o") == 0) diff --git a/t/e2e_ansi.sh b/t/e2e_ansi.sh @@ -6,13 +6,7 @@ . t/utils.subr plan 4 - -cat <<EOF > main.c -int -main(void) { - return 0; -} -EOF +empty_main cat <<EOF > check.good Summary: @@ -22,13 +16,13 @@ Summary: 1 Rewritten source compile successes Totals: - 5 Lines of source code + 6 Lines of source code 1 Function definitions 1 Return statement values 3 Total statements EOF -ok "is compile successful" citrun_wrap cc -ansi -o main main.c +ok "is instrumented compile successful" cc -ansi -o main main.c ok "is citrun_check exit 0" citrun_check -o check.out strip_millis check.out diff --git a/t/e2e_basic.sh b/t/e2e_basic.sh @@ -49,7 +49,7 @@ Totals: 7 Binary operators EOF -ok "wrapped source compile" citrun_wrap cc -o fib fib.c +ok "is instrumented compile successful" cc -o fib fib.c ok "running citrun_check" citrun_check -o check.out strip_millis check.out diff --git a/t/e2e_stdout.sh b/t/e2e_stdout.sh @@ -30,7 +30,7 @@ Totals: 9 Total statements EOF -ok "wrapped compile" citrun_wrap cc -o hello hello.c +ok "is instrumented compile successful" cc -o hello hello.c ok "citrun_check" citrun_check -o check.out strip_millis check.out diff --git a/t/inst_basic_link.sh b/t/inst_basic_link.sh @@ -5,12 +5,9 @@ . t/utils.subr plan 4 +empty_main -cat <<EOF > main.c -int main(void) { return 0; } -EOF - -ok "wrapping simple build command" citrun_wrap cc main.c +ok "is instrumented compile successful" cc main.c cat <<EOF > check.good Summary: @@ -20,7 +17,7 @@ Summary: 1 Rewritten source compile successes Totals: - 2 Lines of source code + 6 Lines of source code 1 Function definitions 1 Return statement values 3 Total statements diff --git a/t/inst_fail.sh b/t/inst_fail.sh @@ -8,8 +8,8 @@ plan 4 echo "int main(void) { return 0; " > bad.c -citrun_wrap cc -c bad.c 2> /dev/null -ok "is citrun_wrap exit code 1" test $? -eq 1 +cc -c bad.c 2> /dev/null +ok "is instrumented compile exit code 1" test $? -eq 1 cat <<EOF > check.good Summary: diff --git a/t/inst_link_multiple.sh b/t/inst_link_multiple.sh @@ -30,8 +30,8 @@ void third_func(void) { } EOF -ok "is compile ok" citrun_wrap cc -o main one.c two.c three.c -ok "running citrun_check" citrun_check -o check.out +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: diff --git a/t/inst_log.sh b/t/inst_log.sh @@ -31,8 +31,8 @@ main(int argc, char *argv[]) } EOF -ok "is compile ok" citrun_wrap cc -c main.c -ok "is link ok" citrun_wrap cc -o main main.o +ok "is instrumented compile ok" cc -c main.c +ok "is instrumented link ok" cc -o main main.o strip_log citrun.log diff --git a/t/inst_preprocess.sh b/t/inst_preprocess.sh @@ -8,18 +8,18 @@ plan 3 echo "int main(void) { return 0; }" > prepro.c -ok "wrapping compile w/ preprocessor arg -E" citrun_wrap cc -E prepro.c -ok "wrapping compile w/ preprocessor arg -MM" citrun_wrap cc -E prepro.c +ok "is instrumented compile argument -E handled" cc -E prepro.c +ok "is instrumented compile argument -MM handled" cc -MM prepro.c cat <<EOF > citrun.log.good >> citrun_inst v0.0 () CITRUN_SHARE = '' PATH='' -Preprocessor argument found +Preprocessor argument -E found >> citrun_inst v0.0 () CITRUN_SHARE = '' PATH='' -Preprocessor argument found +Preprocessor argument -MM found EOF strip_log citrun.log diff --git a/t/inst_src_ext.sh b/t/inst_src_ext.sh @@ -3,26 +3,36 @@ # Check that the advertised source file extensions work. # . t/utils.subr -plan 8 - - -touch main.{c,cc,cxx,cpp,C} -ok "extension .c" citrun_wrap cc -c main.c -ok "extension .cc" citrun_wrap c++ -c main.cc -ok "extension .cxx" citrun_wrap c++ -c main.cxx -ok "extension .cpp" citrun_wrap c++ -c main.cpp -ok "extension .C (not supported)" citrun_wrap c++ -c main.C +plan 18 cat <<EOF > check.good Summary: - 4 Source files used as input - 4 Rewrite successes - 4 Rewritten source compile successes + 1 Source files used as input + 1 Rewrite successes + 1 Rewritten source compile successes Totals: - 4 Lines of source code + 1 Lines of source code EOF -ok "citrun_check" citrun_check -o check.out -strip_millis check.out -ok "citrun_check diff" diff -u check.good check.out +# Check supported extensions. +for ext in c cc cxx cpp; do + touch main.$ext + ok "is extension .$ext compiled successfully" cc -c main.$ext + + ok "is citrun_check successful" citrun_check -o check.out + strip_millis check.out + ok "citrun_check diff" diff -u check.good check.out + + rm main.$ext citrun.log check.out main.o +done + +# Check unsupported extensions. +for ext in C; do + touch main.$ext + + ok "is extension .$ext compiled successfully" cc -c main.$ext + ok_program "is citrun_check exit code 1" 123 "" citrun_check -o check.out + + rm main.$ext main.o +done diff --git a/t/inst_two_src.sh b/t/inst_two_src.sh @@ -6,12 +6,7 @@ . t/utils.subr plan 4 - -cat <<EOF > main.c -int main(void) { - return 0; -} -EOF +empty_main cat <<EOF > other.c int other(void) { @@ -27,13 +22,13 @@ Summary: 1 Rewritten source compile successes Totals: - 8 Lines of source code + 10 Lines of source code 2 Function definitions 2 Return statement values 6 Total statements EOF -ok "citrun_wrap compile" citrun_wrap cc -o main main.c other.c +ok "is instrumented compile successful" cc -o main main.c other.c ok "citrun_check" citrun_check -o check.out strip_millis check.out diff --git a/t/utils.subr b/t/utils.subr @@ -25,5 +25,16 @@ strip_log() strip_millis() { - ok "are milliseconds sanitized" sed -i -e "/Milliseconds spent/d" $1 + ok "is 'Milliseconds' sanitized" sed -i -e "/Milliseconds spent/d" $1 +} + +empty_main() +{ + cat <<EOF > main.c || exit 1 +int +main(void) +{ + return 0; +} +EOF } diff --git a/t/wrap_badsrc.sh b/t/wrap_badsrc.sh @@ -7,7 +7,7 @@ plan 4 output_good="citrun_inst: stat: No such file or directory" -ok_program "is citrun_wrap failing" 1 "$output_good" citrun_wrap cc -o main main.c +ok_program "is instrumented compile failure" 1 "$output_good" cc -o main main.c ok "is citrun_check successful" citrun_check -o check.out cat <<EOF > check.good diff --git a/t/wrap_cmake.sh b/t/wrap_cmake.sh @@ -6,14 +6,7 @@ type cmake || skip_all "ninja not found" plan 7 - -cat <<EOF > main.c -int -main(void) -{ - return 0; -} -EOF +empty_main cat <<EOF > CMakeLists.txt cmake_minimum_required (VERSION 2.6) @@ -21,10 +14,10 @@ project (program) add_executable(program main.c) EOF -ok "is cmake successful" citrun_wrap cmake . +ok "is instrumented cmake successful" cmake . find . -name citrun.log -print0 | xargs -0 rm -ok "is make (from cmake) successful" citrun_wrap make +ok "is instrumented make (from cmake) successful" make ok "is citrun_check successful" citrun_check -o check.out cat <<EOF > check.good diff --git a/t/wrap_jam.sh b/t/wrap_jam.sh @@ -6,20 +6,13 @@ type jam || skip_all "jam not found" plan 6 - -cat <<EOF > main.c -int -main(void) -{ - return 0; -} -EOF +empty_main cat <<EOF > Jamfile Main program : main.c ; EOF -ok "is jam successful" citrun_wrap jam +ok "is instrumented jam successful" jam ok "is citrun_check successful" citrun_check -o check.out cat <<EOF > check.good diff --git a/t/wrap_make.sh b/t/wrap_make.sh @@ -6,21 +6,14 @@ type make || skip_all "make not found" plan 6 - -cat <<EOF > main.c -int -main(void) -{ - return 0; -} -EOF +empty_main cat <<EOF > Makefile program: main.o cc -o program main.o EOF -ok "is make successful" citrun_wrap make +ok "is instrumented make successful" make ok "is citrun_check successful" citrun_check -o check.out cat <<EOF > check.good diff --git a/t/wrap_ninja.sh b/t/wrap_ninja.sh @@ -6,13 +6,7 @@ type ninja || skip_all "ninja not found" plan 6 -cat <<EOF > main.c -int -main(void) -{ - return 0; -} -EOF +empty_main # Quote the here-doc so that '$' does not get substituted. cat <<'EOF' > build.ninja @@ -26,7 +20,7 @@ build main.o: cc main.c build program: link main.o EOF -ok "is ninja successful" citrun_wrap ninja +ok "is instrumented ninja successful" ninja ok "is citrun_check successful" citrun_check -o check.out cat <<EOF > check.good diff --git a/t/wrap_parallel.sh b/t/wrap_parallel.sh @@ -5,17 +5,11 @@ . t/utils.subr plan 12 - -cat <<EOF > main1.c -int -main(void) -{ - return 0; -} -EOF -cp main1.c main2.c -cp main1.c main3.c -cp main1.c main4.c +empty_main +cp main.c main1.c +cp main.c main2.c +cp main.c main3.c +cp main.c main4.c cat <<EOF > Makefile all: program1 program2 program3 program4 @@ -30,7 +24,7 @@ program4: main4.o cc -o program4 main4.o EOF -ok "is make successful" citrun_wrap make -j4 +ok "is instrumented make -j4 successful" make -j4 ok "is citrun_check successful" citrun_check -o check.out cat <<EOF > check.good @@ -51,6 +45,6 @@ strip_millis check.out ok "is citrun_check output identical" diff -u check.good check.out for i in 1 2 3 4; do - ok "does compiled program$i run" ./program$i - ok "is runtime shared memory file created" test -f procdir/program${i}_* + ok "is program$i execution successful" ./program$i + ok "is program$i runtime memory file created" test -f procdir/program${i}_* done