Skip to content

Commit d5b99d2

Browse files
committed
Debug output for unit tests
1 parent d03953c commit d5b99d2

File tree

1 file changed

+49
-48
lines changed

1 file changed

+49
-48
lines changed

unit/memory-analyzer/gdb_api.cpp

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ Author: Malte Mues <[email protected]>
2323

2424
void compile_test_file()
2525
{
26-
std::string test_file("memory-analyzer/test.c");
26+
std::string test_file("memory-analyzer/test.c"); std::cout << "Here 0" << std::endl;
2727

28-
std::string cmd("gcc -g -o test ");
29-
cmd += test_file;
28+
std::string cmd("gcc -g -o test "); std::cout << "Here 1" << std::endl;
29+
cmd += test_file; std::cout << "Here 2" << std::endl;
3030

31-
const int r = system(cmd.c_str());
32-
REQUIRE(!r);
31+
const int r = system(cmd.c_str()); std::cout << "Here 3" << std::endl;
32+
REQUIRE(!r); std::cout << "Here 4" << std::endl;
3333
}
3434

3535
class gdb_api_testt : public gdb_apit
@@ -43,110 +43,111 @@ class gdb_api_testt : public gdb_apit
4343

4444
void gdb_api_internals_test()
4545
{
46-
compile_test_file();
46+
compile_test_file(); std::cout << "Here 7" << std::endl;
4747

4848
SECTION("parse gdb output record")
4949
{
50-
gdb_api_testt gdb_api("test");
50+
gdb_api_testt gdb_api("test"); std::cout << "Here 8" << std::endl;
5151

52-
gdb_api_testt::gdb_output_recordt gor;
52+
gdb_api_testt::gdb_output_recordt gor; std::cout << "Here 9" << std::endl;
5353

5454
gor = gdb_api.parse_gdb_output_record(
55-
"a = \"1\", b = \"2\", c = {1, 2}, d = [3, 4], e=\"0x0\"");
55+
"a = \"1\", b = \"2\", c = {1, 2}, d = [3, 4], e=\"0x0\""); std::cout << "Here 10" << std::endl;
5656

57-
REQUIRE(gor["a"] == "1");
58-
REQUIRE(gor["b"] == "2");
59-
REQUIRE(gor["c"] == "{1, 2}");
60-
REQUIRE(gor["d"] == "[3, 4]");
61-
REQUIRE(gor["e"] == "0x0");
57+
REQUIRE(gor["a"] == "1"); std::cout << "Here 11" << std::endl;
58+
REQUIRE(gor["b"] == "2"); std::cout << "Here 12" << std::endl;
59+
REQUIRE(gor["c"] == "{1, 2}"); std::cout << "Here 13" << std::endl;
60+
REQUIRE(gor["d"] == "[3, 4]"); std::cout << "Here 14" << std::endl;
61+
REQUIRE(gor["e"] == "0x0"); std::cout << "Here 15" << std::endl;
6262
}
6363

6464
SECTION("read a line from an input stream")
6565
{
66-
gdb_api_testt gdb_api("test");
66+
gdb_api_testt gdb_api("test"); std::cout << "Here 16" << std::endl;
6767

68-
FILE *f = fopen("memory-analyzer/input.txt", "r");
69-
gdb_api.input_stream = f;
68+
FILE *f = fopen("memory-analyzer/input.txt", "r"); std::cout << "Here 17" << std::endl;
69+
gdb_api.input_stream = f; std::cout << "Here 18" << std::endl;
7070

71-
std::string line;
71+
std::string line; std::cout << "Here 19" << std::endl;
7272

73-
line = gdb_api.read_next_line();
74-
REQUIRE(line == "abc\n");
73+
line = gdb_api.read_next_line(); std::cout << "Here 20" << std::endl;
74+
REQUIRE(line == "abc\n"); std::cout << "Here 21" << std::endl;
7575

76-
line = gdb_api.read_next_line();
77-
REQUIRE(line == std::string(1120, 'a') + "\n");
76+
line = gdb_api.read_next_line(); std::cout << "Here 22" << std::endl;
77+
REQUIRE(line == std::string(1120, 'a') + "\n"); std::cout << "Here 23" << std::endl;
7878

79-
line = gdb_api.read_next_line();
80-
REQUIRE(line == "xyz");
79+
line = gdb_api.read_next_line(); std::cout << "Here 24" << std::endl;
80+
REQUIRE(line == "xyz"); std::cout << "Here 25" << std::endl;
8181
}
8282

8383
SECTION("start and exit gdb")
8484
{
85-
gdb_api_testt gdb_api("test");
85+
gdb_api_testt gdb_api("test"); std::cout << "Here 26" << std::endl;
8686

87-
gdb_api.create_gdb_process();
87+
gdb_api.create_gdb_process(); std::cout << "Here 27" << std::endl;
8888

8989
// check input and output streams
90-
REQUIRE(!ferror(gdb_api.input_stream));
91-
REQUIRE(!ferror(gdb_api.output_stream));
90+
REQUIRE(!ferror(gdb_api.input_stream)); std::cout << "Here 28" << std::endl;
91+
REQUIRE(!ferror(gdb_api.output_stream)); std::cout << "Here 29" << std::endl;
9292

93-
gdb_api.terminate_gdb_process();
93+
gdb_api.terminate_gdb_process(); std::cout << "Here 30" << std::endl;
9494
}
9595
}
9696

9797
TEST_CASE("gdb api internals test", "[core][memory-analyzer]")
9898
{
99-
gdb_api_internals_test();
99+
gdb_api_internals_test(); std::cout << "Here 31" << std::endl;
100100
}
101101

102102
TEST_CASE("gdb api test", "[core][memory-analyzer]")
103103
{
104-
compile_test_file();
104+
compile_test_file(); std::cout << "Here 32" << std::endl;
105105

106-
gdb_apit gdb_api("test");
106+
gdb_apit gdb_api("test"); std::cout << "Here 33" << std::endl;
107107

108-
gdb_api.create_gdb_process();
108+
gdb_api.create_gdb_process(); std::cout << "Here 34" << std::endl;
109109

110110
SECTION("breakpoint is hit")
111111
{
112-
const bool r = gdb_api.run_gdb_to_breakpoint("checkpoint");
113-
REQUIRE(r);
112+
const bool r = gdb_api.run_gdb_to_breakpoint("checkpoint"); std::cout << "Here 35" << std::endl;
113+
REQUIRE(r); std::cout << "Here 36" << std::endl;
114114
}
115115

116116
SECTION("breakpoint is not hit")
117117
{
118-
const bool r = gdb_api.run_gdb_to_breakpoint("checkpoint2");
119-
REQUIRE(!r);
118+
const bool r = gdb_api.run_gdb_to_breakpoint("checkpoint2"); std::cout << "Here 37" << std::endl;
119+
REQUIRE(!r); std::cout << "Here 38" << std::endl;
120120
}
121121

122122
SECTION("breakpoint does not exist")
123123
{
124124
REQUIRE_THROWS_AS(
125-
gdb_api.run_gdb_to_breakpoint("checkpoint3"), gdb_interaction_exceptiont);
125+
gdb_api.run_gdb_to_breakpoint("checkpoint3"), gdb_interaction_exceptiont); std::cout << "Here 39" << std::endl;
126126
}
127127

128128
SECTION("query memory")
129129
{
130-
const bool r = gdb_api.run_gdb_to_breakpoint("checkpoint");
131-
REQUIRE(r);
130+
const bool r = gdb_api.run_gdb_to_breakpoint("checkpoint"); std::cout << "Here 40" << std::endl;
131+
REQUIRE(r); std::cout << "Here 41" << std::endl;
132132

133-
REQUIRE(gdb_api.get_value("x") == "8");
134-
REQUIRE(gdb_api.get_value("s") == "abc");
133+
REQUIRE(gdb_api.get_value("x") == "8"); std::cout << "Here 42" << std::endl;
134+
REQUIRE(gdb_api.get_value("s") == "abc"); std::cout << "Here 43" << std::endl;
135135

136-
const std::regex regex(R"(0x[1-9a-f][0-9a-f]*)");
136+
const std::regex regex(R"(0x[1-9a-f][0-9a-f]*)"); std::cout << "Here 44" << std::endl;
137137

138138
{
139-
std::string address = gdb_api.get_memory("p");
140-
REQUIRE(std::regex_match(address, regex));
139+
std::string address = gdb_api.get_memory("p"); std::cout << "Here 45" << std::endl;
140+
REQUIRE(std::regex_match(address, regex)); std::cout << "Here 46" << std::endl;
141141
}
142142

143143
{
144-
std::string address = gdb_api.get_memory("vp");
145-
REQUIRE(std::regex_match(address, regex));
144+
std::string address = gdb_api.get_memory("vp"); std::cout << "Here 47" << std::endl;
145+
REQUIRE(std::regex_match(address, regex)); std::cout << "Here 48" << std::endl;
146146
}
147147
}
148148

149-
gdb_api.terminate_gdb_process();
149+
gdb_api.terminate_gdb_process(); std::cout << "Here 49" << std::endl;
150150
}
151151

152152
#endif
153+

0 commit comments

Comments
 (0)