commit ccf8cc6657025f326914260707a2644b26a3f4dc
parent 4937ab2cf5731ddab0a0b8e47322e7461aeb274b
Author: Kyle Milz <kyle@0x30.net>
Date: Thu, 18 Aug 2016 19:12:57 -0600
t: update tests in light of recent changes
Diffstat:
20 files changed, 41 insertions(+), 60 deletions(-)
diff --git a/src/inst_action.cc b/src/inst_action.cc
@@ -79,14 +79,14 @@ InstrumentAction::EndSourceFileAction()
<< "extern \"C\" {\n"
<< "#endif\n";
preamble << runtime_h << "\n";
- preamble << "static struct citrun_node _citrun_node = {\n"
+ preamble << "static struct citrun_node _citrun = {\n"
<< " " << num_lines << ",\n"
<< " \"" << m_compiler_file_name << "\",\n"
<< " \"" << getCurrentFile().str() << "\",\n";
preamble << "};\n";
preamble << "__attribute__((constructor))\n"
<< "static void citrun_constructor() {\n"
- << " citrun_node_add(citrun_major, citrun_minor, &_citrun_node);\n"
+ << " citrun_node_add(citrun_major, citrun_minor, &_citrun);\n"
<< "}\n";
preamble << "#ifdef __cplusplus\n"
<< "}\n"
diff --git a/src/inst_visitor.cc b/src/inst_visitor.cc
@@ -142,7 +142,7 @@ RewriteASTVisitor::modify_stmt(clang::Stmt *s, int &counter)
// If x = y is the original statement on line 19 then we try rewriting
// as (++_citrun[19], x = y).
std::stringstream ss;
- ss << "(++_citrun_node.data["
+ ss << "(++_citrun.data["
<< m_SM.getPresumedLineNumber(s->getLocStart()) - 1
<< "], ";
@@ -173,7 +173,7 @@ RewriteASTVisitor::VisitFunctionDecl(clang::FunctionDecl *f)
int decl_start = m_SM.getPresumedLineNumber(f->getLocStart());
int decl_end = m_SM.getPresumedLineNumber(curly_brace);
for (int i = decl_start; i <= decl_end; ++i)
- rewrite_text << "++_citrun_node.data[" << i - 1 << "];";
+ rewrite_text << "++_citrun.data[" << i - 1 << "];";
// Rewrite the function source right after the beginning curly brace.
m_TheRewriter.InsertTextBefore(curly_brace, rewrite_text.str());
diff --git a/t/inst_binop.t b/t/inst_binop.t
@@ -39,9 +39,9 @@ static const struct {
unsigned char data[0 + 64 * 6];
} blah;
-int main(void) {citrun_start();++_citrun[13];
- if ((++_citrun[14], (++_citrun[14], 4 + 3)))
- return (++_citrun[15], 0);
+int main(void) {++_citrun.data[13];
+ if ((++_citrun.data[14], (++_citrun.data[14], 4 + 3)))
+ return (++_citrun.data[15], 0);
}
EOF
@@ -53,7 +53,6 @@ Summary:
Totals:
18 Lines of source code
- 1 Functions called 'main'
1 Function definitions
1 If statements
1 Return statement values
diff --git a/t/inst_correct.t b/t/inst_correct.t
@@ -38,7 +38,6 @@ Summary:
Totals:
21 Lines of source code
- 1 Functions called 'main'
2 Function definitions
3 If statements
5 Return statement values
diff --git a/t/inst_dowhile.t b/t/inst_dowhile.t
@@ -15,11 +15,11 @@ int main(int argc, char *argv[]) {
EOF
cat <<EOF > while.c.inst_good
-int main(int argc, char *argv[]) {citrun_start();++_citrun[0];
+int main(int argc, char *argv[]) {++_citrun.data[0];
do {
argc++;
- } while ((++_citrun[3], (++_citrun[3], argc != 10)));
- return (++_citrun[4], 0);
+ } while ((++_citrun.data[3], (++_citrun.data[3], argc != 10)));
+ return (++_citrun.data[4], 0);
}
EOF
@@ -31,7 +31,6 @@ Summary:
Totals:
7 Lines of source code
- 1 Functions called 'main'
1 Function definitions
1 Do while loops
1 Return statement values
diff --git a/t/inst_for.t b/t/inst_for.t
@@ -15,10 +15,10 @@ int main(int argc, char *argv[]) {
EOF
cat <<EOF > for.c.inst_good
-int main(int argc, char *argv[]) {citrun_start();++_citrun[0];
+int main(int argc, char *argv[]) {++_citrun.data[0];
for (;;);
- for ((++_citrun[3], argc = 0); (++_citrun[3], (++_citrun[3], argc < 10)); argc++)
+ for ((++_citrun.data[3], argc = 0); (++_citrun.data[3], (++_citrun.data[3], argc < 10)); argc++)
argv++;
}
EOF
@@ -31,7 +31,6 @@ Summary:
Totals:
7 Lines of source code
- 1 Functions called 'main'
1 Function definitions
1 For loops
15 Total statements
diff --git a/t/inst_funcdef.t b/t/inst_funcdef.t
@@ -23,7 +23,7 @@ other(int a,
int b)
-{++_citrun[0];++_citrun[1];++_citrun[2];++_citrun[3];++_citrun[4];++_citrun[5];++_citrun[6];
+{++_citrun.data[0];++_citrun.data[1];++_citrun.data[2];++_citrun.data[3];++_citrun.data[4];++_citrun.data[5];++_citrun.data[6];
}
EOF
diff --git a/t/inst_if.t b/t/inst_if.t
@@ -20,16 +20,16 @@ int main(int argc, char *argv[]) {
EOF
cat <<EOF > if.c.inst_good
-int main(int argc, char *argv[]) {citrun_start();++_citrun[0];
- if ((++_citrun[1], (++_citrun[1], argc == 1)))
- return (++_citrun[2], 1);
+int main(int argc, char *argv[]) {++_citrun.data[0];
+ if ((++_citrun.data[1], (++_citrun.data[1], argc == 1)))
+ return (++_citrun.data[2], 1);
else
- return(++_citrun[4], (14));
+ return(++_citrun.data[4], (14));
- if ((++_citrun[6], ((++_citrun[6], argc = 2))))
- return (++_citrun[7], 5);
+ if ((++_citrun.data[6], ((++_citrun.data[6], argc = 2))))
+ return (++_citrun.data[7], 5);
else
- return(++_citrun[9], (0));
+ return(++_citrun.data[9], (0));
}
EOF
@@ -41,7 +41,6 @@ Summary:
Totals:
12 Lines of source code
- 1 Functions called 'main'
1 Function definitions
2 If statements
4 Return statement values
diff --git a/t/inst_link_multiple.t b/t/inst_link_multiple.t
@@ -46,7 +46,6 @@ Summary:
Totals:
18 Lines of source code
- 1 Functions called 'main'
3 Function definitions
1 Return statement values
2 Call expressions
diff --git a/t/inst_log.t b/t/inst_log.t
@@ -55,7 +55,6 @@ Command line is ''.
Added clangtool argument ''.
Instrumentation of '' finished:
22 Lines of source code
- 1 Functions called ''
2 Function definitions
2 If statements
4 Return statement values
diff --git a/t/inst_macro.t b/t/inst_macro.t
@@ -18,9 +18,9 @@ EOF
cat <<EOF > macro.c.inst_good
#define MAYBE 1023;
-int main(int argc, char *argv[]) {citrun_start();++_citrun[2];
+int main(int argc, char *argv[]) {++_citrun.data[2];
int abd = 1023 + MAYBE;
- return (++_citrun[4], 0);
+ return (++_citrun.data[4], 0);
}
EOF
@@ -32,7 +32,6 @@ Summary:
Totals:
7 Lines of source code
- 1 Functions called 'main'
1 Function definitions
1 Return statement values
7 Total statements
diff --git a/t/inst_preamble.t b/t/inst_preamble.t
@@ -17,27 +17,21 @@ extern "" {
static const uint8_t citrun_major = 0;
static const uint8_t citrun_minor = 0;
struct citrun_node {
- uint64_t *data;
uint32_t size;
const char *comp_file_path;
const char *abs_file_path;
- struct citrun_node *next;
- uint64_t *data_old;
- uint32_t *data_diff;
+ uint64_t *data;
};
void citrun_node_add(uint8_t, uint8_t, struct citrun_node *);
-void citrun_start();
-static uint64_t _citrun[1];
-static struct citrun_node _citrun_node = {
- _citrun,
+static struct citrun_node _citrun = {
1,
"",
"",
};
__attribute__((constructor))
static void citrun_constructor() {
- citrun_node_add(citrun_major, citrun_minor, &_citrun_node);
+ citrun_node_add(citrun_major, citrun_minor, &_citrun);
}
#ifdef __cplusplus
}
diff --git a/t/inst_return.t b/t/inst_return.t
@@ -20,16 +20,16 @@ int main(void) {
EOF
cat <<EOF > return.c.inst_good
-int foo() {++_citrun[0];
- return (++_citrun[1], 0);
+int foo() {++_citrun.data[0];
+ return (++_citrun.data[1], 0);
}
-int main(void) {citrun_start();++_citrun[4];
- return (++_citrun[5], 10);
+int main(void) {++_citrun.data[4];
+ return (++_citrun.data[5], 10);
- return (++_citrun[7], (++_citrun[7], 10 + 10));
+ return (++_citrun.data[7], (++_citrun.data[7], 10 + 10));
- return (++_citrun[9], (++_citrun[9], foo()));
+ return (++_citrun.data[9], (++_citrun.data[9], foo()));
}
EOF
@@ -41,7 +41,6 @@ Summary:
Totals:
12 Lines of source code
- 1 Functions called 'main'
2 Function definitions
4 Return statement values
1 Call expressions
diff --git a/t/inst_stdout.t b/t/inst_stdout.t
@@ -24,7 +24,6 @@ Summary:
Totals:
7 Lines of source code
- 1 Functions called 'main'
1 Function definitions
1 Return statement values
1 Call expressions
diff --git a/t/inst_switch.t b/t/inst_switch.t
@@ -21,17 +21,17 @@ int main(void) {
EOF
cat <<EOF > switch.c.inst_good
-int main(void) {citrun_start();++_citrun[0];
+int main(void) {++_citrun.data[0];
int i;
- switch ((++_citrun[3], i)) {
+ switch ((++_citrun.data[3], i)) {
case 0:
break;
case 1:
break;
}
- return (++_citrun[10], 0);
+ return (++_citrun.data[10], 0);
}
EOF
@@ -43,7 +43,6 @@ Summary:
Totals:
13 Lines of source code
- 1 Functions called 'main'
1 Function definitions
1 Switch statements
1 Return statement values
diff --git a/t/inst_two_src.t b/t/inst_two_src.t
@@ -28,7 +28,6 @@ Summary:
Totals:
8 Lines of source code
- 1 Functions called 'main'
2 Function definitions
2 Return statement values
6 Total statements
diff --git a/t/inst_while.t b/t/inst_while.t
@@ -16,12 +16,12 @@ int main(int argc, char *argv[]) {
EOF
cat <<EOF > while.c.inst_good
-int main(int argc, char *argv[]) {citrun_start();++_citrun[0];
- while ((++_citrun[1], (++_citrun[1], argc < 17)))
+int main(int argc, char *argv[]) {++_citrun.data[0];
+ while ((++_citrun.data[1], (++_citrun.data[1], argc < 17)))
argc++;
- while ((++_citrun[4], ((++_citrun[4], argc && argv))));
- return (++_citrun[5], 0);
+ while ((++_citrun.data[4], ((++_citrun.data[4], argc && argv))));
+ return (++_citrun.data[5], 0);
}
EOF
@@ -33,7 +33,6 @@ Summary:
Totals:
8 Lines of source code
- 1 Functions called 'main'
1 Function definitions
2 While loops
1 Return statement values
diff --git a/t/rt_ver.t b/t/rt_ver.t
@@ -17,7 +17,7 @@ main(int argc, char *argv[])
EOF
/usr/bin/cc -c main.c
-/usr/bin/cc -o main main.o -pthread $TEST_TOOLS/libcitrun.a
+/usr/bin/cc -o main main.o $TEST_TOOLS/libcitrun.a
export CITRUN_SOCKET=
main 2> out
diff --git a/t/term_basic.t b/t/term_basic.t
@@ -1,6 +1,6 @@
use strict;
use Expect;
-use Test::More tests => 1;
+use Test::More skip_all => "Uses perl expect";
use test::project;
my $project = test::project->new();
diff --git a/test/utils.sh b/test/utils.sh
@@ -24,7 +24,7 @@ function inst_diff
test_num="${2}"
test_desc="instrumented source diff"
- tail -n +33 $file.citrun > $file.inst_proc
+ tail -n +27 $file.citrun > $file.inst_proc
test_diff $test_num "$test_desc" $file.inst_good $file.inst_proc
}