summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal/pol/tests/graph_test.c
diff options
context:
space:
mode:
authorSander Vrijders <[email protected]>2017-09-25 17:36:18 +0200
committerSander Vrijders <[email protected]>2017-09-26 15:27:19 +0200
commit5d01c511fc1c31fdeee6bb515be0ca300854ba21 (patch)
treee2962df2d53d0a31bf935eec5088654bbfe204d0 /src/ipcpd/normal/pol/tests/graph_test.c
parent0847da715c82d49b01758d88ecca496eba2c8d34 (diff)
downloadouroboros-5d01c511fc1c31fdeee6bb515be0ca300854ba21.tar.gz
ouroboros-5d01c511fc1c31fdeee6bb515be0ca300854ba21.zip
ipcpd: normal: Add refcount to graph edges
This adds a refcount to the graph edges so that it is only included in the calculation if both sides announced it.
Diffstat (limited to 'src/ipcpd/normal/pol/tests/graph_test.c')
-rw-r--r--src/ipcpd/normal/pol/tests/graph_test.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/ipcpd/normal/pol/tests/graph_test.c b/src/ipcpd/normal/pol/tests/graph_test.c
index 0baba6fc..42cf3f06 100644
--- a/src/ipcpd/normal/pol/tests/graph_test.c
+++ b/src/ipcpd/normal/pol/tests/graph_test.c
@@ -44,9 +44,8 @@ int graph_test_entries(int entries)
return -1;
}
- list_for_each(p, &table) {
+ list_for_each(p, &table)
i++;
- }
if (i != entries) {
printf("Wrong number of entries.\n");
@@ -69,9 +68,8 @@ int graph_test_double_link(void)
return -1;
}
- list_for_each(p, &table) {
+ list_for_each(p, &table)
i++;
- }
if (i != 2) {
printf("Wrong number of entries.\n");
@@ -108,9 +106,8 @@ int graph_test_single_link(void)
return -1;
}
- list_for_each(p, &table) {
+ list_for_each(p, &table)
i++;
- }
if (i != 1) {
printf("Wrong number of entries.\n");
@@ -168,6 +165,12 @@ int graph_test(int argc,
return -1;
}
+ if (graph_update_edge(graph, 2, 1, qs)) {
+ printf("Failed to add edge.\n");
+ graph_destroy(graph);
+ return -1;
+ }
+
if (graph_test_single_link()) {
graph_destroy(graph);
return -1;
@@ -179,6 +182,13 @@ int graph_test(int argc,
return -1;
}
+ if (graph_update_edge(graph, 3, 2, qs)) {
+ printf("Failed to add edge.\n");
+ graph_destroy(graph);
+ return -1;
+ }
+
+
if (graph_test_double_link()) {
graph_destroy(graph);
return -1;
@@ -190,13 +200,21 @@ int graph_test(int argc,
return -1;
}
+ if (graph_del_edge(graph, 3, 2)) {
+ printf("Failed to delete edge.\n");
+ graph_destroy(graph);
+ return -1;
+ }
+
if (graph_test_single_link()) {
graph_destroy(graph);
return -1;
}
graph_update_edge(graph, 2, 3, qs);
+ graph_update_edge(graph, 3, 2, qs);
graph_update_edge(graph, 1, 3, qs);
+ graph_update_edge(graph, 3, 1, qs);
if (graph_test_entries(2)) {
graph_destroy(graph);
@@ -204,7 +222,9 @@ int graph_test(int argc,
}
graph_update_edge(graph, 3, 4, qs);
+ graph_update_edge(graph, 4, 3, qs);
graph_update_edge(graph, 4, 5, qs);
+ graph_update_edge(graph, 5, 4, qs);
if (graph_test_entries(4)) {
graph_destroy(graph);
@@ -212,8 +232,11 @@ int graph_test(int argc,
}
graph_update_edge(graph, 2, 6, qs);
+ graph_update_edge(graph, 6, 2, qs);
graph_update_edge(graph, 6, 7, qs);
+ graph_update_edge(graph, 7, 6, qs);
graph_update_edge(graph, 3, 7, qs);
+ graph_update_edge(graph, 7, 3, qs);
if (graph_test_entries(6)) {
graph_destroy(graph);