14 #define WEXITSTATUS(status) status
15 #define WIFEXITED(status) 1
20 static char *tmp_dir
= NULL
;
23 static char *create_temp_dir()
25 static char temp_name
[MAX_PATH
];
27 GetTempFileName(".", "isa_test_", 0, temp_name
);
28 DeleteFile(temp_name
);
29 CreateDirectory(temp_name
, NULL
);
30 return strdup(temp_name
);
33 static char *create_temp_dir()
35 return mkdtemp(strdup("isa_test_XXXXXX"));
39 void remove_tmp_dir(void)
41 char command
[2*PATH_MAX
+100];
44 n
= snprintf(command
, sizeof(command
), "rm -r %s", tmp_dir
);
45 assert(n
< sizeof(command
));
46 ret
= system(command
);
47 assert(WEXITSTATUS(ret
) == 0);
52 void construct_pdg(const char *base
, const char *options
, const char *dir
)
54 char command
[2*PATH_MAX
+100];
58 srcdir
= getenv("srcdir");
62 tmp_dir
= create_temp_dir();
64 atexit(remove_tmp_dir
);
67 n
= snprintf(command
, sizeof(command
), "cp %s/inputs/%s/%s.c %s",
68 srcdir
, dir
? dir
: "", base
, tmp_dir
);
69 assert(n
< sizeof(command
));
70 ret
= system(command
);
71 assert(WEXITSTATUS(ret
) == 0);
73 n
= snprintf(command
, sizeof(command
), "../c2pdg %s %s/%s.c",
74 options
? options
: "", tmp_dir
, base
);
75 assert(n
< sizeof(command
));
76 ret
= system(command
);
77 assert(WEXITSTATUS(ret
) == 0);
80 pdg::PDG
*get_pdg(isl_ctx
*ctx
, const char *base
, const char *options
)
82 char command
[2*PATH_MAX
+100];
84 construct_pdg(base
, options
);
87 n
= snprintf(command
, sizeof(command
), "%s/%s.yaml", tmp_dir
, base
);
88 assert(n
< sizeof(command
));
89 in
= fopen(command
, "r");
93 pdg
= PDG::Load(in
, ctx
);
100 void construct_pn(const char *base
, const char *options
)
102 char command
[2*PATH_MAX
+100];
105 n
= snprintf(command
, sizeof(command
), "../pn %s --input %s/%s.yaml",
106 options
? options
: "",
108 assert(n
< sizeof(command
));
109 ret
= system(command
);
110 assert(WEXITSTATUS(ret
) == 0);
113 pdg::PDG
*get_pn(isl_ctx
*ctx
, const char *base
, const char *options
)
115 char command
[2*PATH_MAX
+100];
118 construct_pn(base
, options
);
120 n
= snprintf(command
, sizeof(command
), "%s/%s_pn.yaml", tmp_dir
, base
);
121 assert(n
< sizeof(command
));
122 in
= fopen(command
, "r");
126 pdg
= PDG::Load(in
, ctx
);
133 void construct_da(const char *base
, const char *options
)
135 char command
[2*PATH_MAX
+100];
138 n
= snprintf(command
, sizeof(command
), "../da %s --input %s/%s.yaml",
139 options
? options
: "",
141 assert(n
< sizeof(command
));
142 ret
= system(command
);
143 assert(WEXITSTATUS(ret
) == 0);
146 pdg::PDG
*get_da(isl_ctx
*ctx
, const char *base
, const char *options
)
148 char command
[2*PATH_MAX
+100];
151 construct_da(base
, options
);
153 n
= snprintf(command
, sizeof(command
), "%s/%s_da.yaml", tmp_dir
, base
);
154 assert(n
< sizeof(command
));
155 in
= fopen(command
, "r");
159 pdg
= PDG::Load(in
, ctx
);
166 void check_eqv(const char *test
, const char *options
, const char *output
)
168 char command
[2*PATH_MAX
+100];
173 srcdir
= getenv("srcdir");
176 n
= snprintf(dir
, sizeof(dir
), "eqv/%s", test
);
177 assert(n
< sizeof(dir
));
179 construct_pdg("1", NULL
, dir
);
180 construct_da("1", "-t flow,output -A");
182 construct_pdg("2", NULL
, dir
);
183 construct_da("2", "-t flow,output -A");
185 n
= snprintf(command
, sizeof(command
),
186 "../eqv %s %s/1_da.yaml %s/2_da.yaml > %s/output",
187 options
, tmp_dir
, tmp_dir
, tmp_dir
);
188 assert(n
< sizeof(command
));
189 ret
= system(command
);
190 assert(WEXITSTATUS(ret
) == 0);
192 n
= snprintf(command
, sizeof(command
),
193 "../eqv_cmp %s/inputs/%s/%s %s/output",
194 srcdir
, dir
, output
, tmp_dir
);
195 assert(n
< sizeof(command
));
196 ret
= system(command
);
197 assert(WEXITSTATUS(ret
) == 0);
200 void construct_adg(const char *base
, const char *options
)
202 char command
[2 * PATH_MAX
+ 100];
205 n
= snprintf(command
, sizeof(command
), "../pn2adg %s -i %s/%s_pn.yaml",
206 options
? options
: "",
208 assert(n
< sizeof(command
));
209 ret
= system(command
);
210 assert(WEXITSTATUS(ret
) == 0);
213 adg
*get_adg(isl_ctx
*ctx
, const char *base
)
221 n
= snprintf(path
, sizeof(path
), "%s/%s_pn_adg.yaml", tmp_dir
, base
);
222 assert(n
< sizeof(path
));
223 in
= fopen(path
, "r");
226 adg
= adg_parse(ctx
, in
);