Skip to content

Commit 66d0f52

Browse files
author
Owen Jones
committed
Update unit test for direct callgraph
Add a node with no edges to the test and check that it does the right thing
1 parent a149a34 commit 66d0f52

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

unit/analyses/call_graph.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ SCENARIO("call_graph",
6464
// }
6565
// void C() { }
6666
// void D() { }
67+
// void E() { }
6768

6869
goto_modelt goto_model;
6970
code_typet void_function_type;
@@ -101,6 +102,8 @@ SCENARIO("call_graph",
101102
create_void_function_symbol("C", code_skipt()));
102103
goto_model.symbol_table.add(
103104
create_void_function_symbol("D", code_skipt()));
105+
goto_model.symbol_table.add(
106+
create_void_function_symbol("E", code_skipt()));
104107

105108
stream_message_handlert msg(std::cout);
106109
goto_convert(goto_model, msg);
@@ -183,6 +186,11 @@ SCENARIO("call_graph",
183186
for(node_indext i=0; i<exported.size(); ++i)
184187
nodes_by_name[exported[i].function]=i;
185188

189+
THEN("We expect 5 nodes")
190+
{
191+
REQUIRE(exported.size() == 5);
192+
}
193+
186194
THEN("We expect edges A -> { A, B }, B -> { C, D }")
187195
{
188196
// Note that means the extra A -> B edge has gone away (the grapht
@@ -228,6 +236,14 @@ SCENARIO("call_graph",
228236
REQUIRE(predecessors.count("B"));
229237
REQUIRE(predecessors.count("D"));
230238
}
239+
240+
THEN("We expect {E} to be able to reach E")
241+
{
242+
std::set<irep_idt> predecessors =
243+
get_reaching_functions(exported, "E");
244+
REQUIRE(predecessors.size() == 1);
245+
REQUIRE(predecessors.count("E"));
246+
}
231247
}
232248

233249
WHEN("The call graph, with call sites, is exported as a grapht")
@@ -241,6 +257,11 @@ SCENARIO("call_graph",
241257
for(node_indext i=0; i<exported.size(); ++i)
242258
nodes_by_name[exported[i].function]=i;
243259

260+
THEN("We expect 5 nodes")
261+
{
262+
REQUIRE(exported.size() == 5);
263+
}
264+
244265
THEN("We expect edges A -> { A, B }, B -> { C, D }")
245266
{
246267
// Note that means the extra A -> B edge has gone away (the grapht

0 commit comments

Comments
 (0)