diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2014-08-04 20:25:56 -0400 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2014-08-04 20:25:56 -0400 |
commit | 878bacd0f710547c1939ac38d9861b43cf137ab3 (patch) | |
tree | 0290b338368d93bb04adca4786c14950526aa506 | |
parent | a893f095721f40a5d77c5248c86cdf415d4268ea (diff) |
dottest: Add test tool for dot printing.
This patch adds a simple test tool for testing
PGM's printing of graphs in the dot format.
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | tools/dottest.cpp | 93 |
3 files changed, 98 insertions, 1 deletions
@@ -23,3 +23,4 @@ ringtest | |||
23 | sockstreamtest | 23 | sockstreamtest |
24 | backedgetest | 24 | backedgetest |
25 | ancestortest | 25 | ancestortest |
26 | dottest | ||
@@ -86,7 +86,7 @@ AR := ${CROSS_COMPILE}${AR} | |||
86 | # Targets | 86 | # Targets |
87 | 87 | ||
88 | all = lib ${tools} | 88 | all = lib ${tools} |
89 | tools = cvtest ringtest basictest datapassingtest sockstreamtest pingpong depthtest pgmrt backedgetest ancestortest | 89 | tools = cvtest ringtest basictest datapassingtest sockstreamtest pingpong depthtest pgmrt backedgetest ancestortest dottest |
90 | 90 | ||
91 | .PHONY: all lib clean dump-config TAGS tags cscope help | 91 | .PHONY: all lib clean dump-config TAGS tags cscope help |
92 | 92 | ||
@@ -166,6 +166,9 @@ lib-backedgetest = -lpthread -lm -lrt -lboost_graph -lboost_filesystem -lboost_s | |||
166 | obj-ancestortest = ancestortest.o | 166 | obj-ancestortest = ancestortest.o |
167 | lib-ancestortest = -lpthread -lm -lrt -lboost_graph -lboost_filesystem -lboost_system ${liblitmus-flags} | 167 | lib-ancestortest = -lpthread -lm -lrt -lboost_graph -lboost_filesystem -lboost_system ${liblitmus-flags} |
168 | 168 | ||
169 | obj-dottest = dottest.o | ||
170 | lib-dottest = -lpthread -lm -lrt -lboost_graph -lboost_filesystem -lboost_system ${liblitmus-flags} | ||
171 | |||
169 | # ############################################################################## | 172 | # ############################################################################## |
170 | # Build everything that depends on liblitmus. | 173 | # Build everything that depends on liblitmus. |
171 | 174 | ||
diff --git a/tools/dottest.cpp b/tools/dottest.cpp new file mode 100644 index 0000000..76c3473 --- /dev/null +++ b/tools/dottest.cpp | |||
@@ -0,0 +1,93 @@ | |||
1 | // Copyright (c) 2014, Glenn Elliott | ||
2 | // All rights reserved. | ||
3 | |||
4 | /* Program for testing all edge types (except for sock_stream). */ | ||
5 | |||
6 | #include <iostream> | ||
7 | #include <unistd.h> | ||
8 | #include <errno.h> | ||
9 | #include <pthread.h> | ||
10 | #include <string.h> | ||
11 | |||
12 | #include "pgm.h" | ||
13 | |||
14 | int errors = 0; | ||
15 | pthread_barrier_t init_barrier; | ||
16 | |||
17 | __thread char __errstr[80] = {0}; | ||
18 | |||
19 | #define CheckError(e) \ | ||
20 | do { int __ret = (e); \ | ||
21 | if(__ret < 0) { \ | ||
22 | errors++; \ | ||
23 | char* errstr = strerror_r(errno, __errstr, sizeof(errstr)); \ | ||
24 | fprintf(stderr, "%lu: Error %d (%s (%d)) @ %s:%s:%d\n", \ | ||
25 | pthread_self(), __ret, errstr, errno, __FILE__, __FUNCTION__, __LINE__); \ | ||
26 | }}while(0) | ||
27 | |||
28 | int main(void) | ||
29 | { | ||
30 | graph_t g; | ||
31 | node_t n0, n1, n2, n3, n4, n5, n6; | ||
32 | edge_t e0_1, e0_2, e0_3, e0_4, e0_5; | ||
33 | edge_t e1_6, e2_6, e3_6, e4_6, e5_6; | ||
34 | edge_t be6_0; | ||
35 | |||
36 | edge_attr_t cv_attr; | ||
37 | edge_attr_t fast_fifo_attr, fast_mq_attr; | ||
38 | edge_attr_t fifo_attr, mq_attr; | ||
39 | edge_attr_t be_cv_attr; | ||
40 | |||
41 | memset(&cv_attr, 0, sizeof(cv_attr)); | ||
42 | |||
43 | cv_attr.nr_produce = 1; | ||
44 | cv_attr.nr_consume = 1; | ||
45 | cv_attr.nr_threshold = 1; | ||
46 | |||
47 | be_cv_attr = fast_fifo_attr = fast_mq_attr = fifo_attr = mq_attr = cv_attr; | ||
48 | |||
49 | cv_attr.type = be_cv_attr.type = pgm_cv_edge; | ||
50 | fast_fifo_attr.type = pgm_fast_fifo_edge; | ||
51 | fast_mq_attr.type = pgm_fast_mq_edge; | ||
52 | fifo_attr.type = pgm_fifo_edge; | ||
53 | mq_attr.type = pgm_mq_edge; | ||
54 | |||
55 | fast_mq_attr.mq_maxmsg = 10; /* root required for higher values */ | ||
56 | mq_attr.mq_maxmsg = 10; | ||
57 | |||
58 | cv_attr.nr_consume = 5; | ||
59 | cv_attr.nr_threshold = 6; | ||
60 | |||
61 | CheckError(pgm_init("/tmp/graphs", 1)); | ||
62 | CheckError(pgm_init_graph(&g, "dotDemo")); | ||
63 | |||
64 | CheckError(pgm_init_node(&n0, g, "n0")); | ||
65 | CheckError(pgm_init_node(&n1, g, "n1")); | ||
66 | CheckError(pgm_init_node(&n2, g, "n2")); | ||
67 | CheckError(pgm_init_node(&n3, g, "n3")); | ||
68 | CheckError(pgm_init_node(&n4, g, "n4")); | ||
69 | CheckError(pgm_init_node(&n5, g, "n5")); | ||
70 | CheckError(pgm_init_node(&n6, g, "n6")); | ||
71 | |||
72 | CheckError(pgm_init_edge(&e0_1, n0, n1, "e0_1", &cv_attr)); | ||
73 | CheckError(pgm_init_edge(&e0_2, n0, n2, "e0_2", &fifo_attr)); | ||
74 | CheckError(pgm_init_edge(&e0_3, n0, n3, "e0_3", &fast_mq_attr)); | ||
75 | CheckError(pgm_init_edge(&e0_4, n0, n4, "e0_4", &mq_attr)); | ||
76 | CheckError(pgm_init_edge(&e0_5, n0, n5, "e0_5", &fast_fifo_attr)); | ||
77 | |||
78 | CheckError(pgm_init_edge(&e1_6, n1, n6, "e1_6", &fast_mq_attr)); | ||
79 | CheckError(pgm_init_edge(&e2_6, n2, n6, "e2_6", &fifo_attr)); | ||
80 | CheckError(pgm_init_edge(&e3_6, n3, n6, "e3_6", &cv_attr)); | ||
81 | CheckError(pgm_init_edge(&e4_6, n4, n6, "e4_6", &mq_attr)); | ||
82 | CheckError(pgm_init_edge(&e5_6, n5, n6, "e5_6", &fast_fifo_attr)); | ||
83 | |||
84 | CheckError(pgm_init_backedge(&be6_0, 1, n6, n0, "be6_0", &be_cv_attr)); | ||
85 | |||
86 | CheckError(pgm_print_graph(g, stdout)); | ||
87 | |||
88 | CheckError(pgm_destroy_graph(g)); | ||
89 | |||
90 | CheckError(pgm_destroy()); | ||
91 | |||
92 | return 0; | ||
93 | } | ||