9 void test_application_case(struct isl_ctx *ctx, const char *name)
11 char filename[PATH_MAX];
14 struct isl_basic_set *bset1, *bset2;
15 struct isl_basic_map *bmap;
17 n = snprintf(filename, sizeof(filename),
18 "%s/test_inputs/%s.omega", srcdir, name);
19 assert(n < sizeof(filename));
20 input = fopen(filename, "r");
23 bset1 = isl_basic_set_read_from_file(ctx, input, ISL_FORMAT_OMEGA);
24 bmap = isl_basic_map_read_from_file(ctx, input, ISL_FORMAT_OMEGA);
26 bset1 = isl_basic_set_apply(ctx, bset1, bmap);
28 bset2 = isl_basic_set_read_from_file(ctx, input, ISL_FORMAT_OMEGA);
30 assert(isl_basic_set_is_equal(ctx, bset1, bset2) == 1);
32 isl_basic_set_free(ctx, bset1);
33 isl_basic_set_free(ctx, bset2);
38 void test_application(struct isl_ctx *ctx)
40 test_application_case(ctx, "application");
41 test_application_case(ctx, "application2");
44 void test_affine_hull_case(struct isl_ctx *ctx, const char *name)
46 char filename[PATH_MAX];
49 struct isl_basic_set *bset1, *bset2;
51 n = snprintf(filename, sizeof(filename),
52 "%s/test_inputs/%s.polylib", srcdir, name);
53 assert(n < sizeof(filename));
54 input = fopen(filename, "r");
57 bset1 = isl_basic_set_read_from_file(ctx, input, ISL_FORMAT_POLYLIB);
58 bset2 = isl_basic_set_read_from_file(ctx, input, ISL_FORMAT_POLYLIB);
60 bset1 = isl_basic_set_affine_hull(ctx, bset1);
62 assert(isl_basic_set_is_equal(ctx, bset1, bset2) == 1);
64 isl_basic_set_free(ctx, bset1);
65 isl_basic_set_free(ctx, bset2);
70 void test_affine_hull(struct isl_ctx *ctx)
72 test_affine_hull_case(ctx, "affine2");
73 test_affine_hull_case(ctx, "affine");
76 void test_convex_hull_case(struct isl_ctx *ctx, const char *name)
78 char filename[PATH_MAX];
81 struct isl_basic_set *bset1, *bset2;
84 n = snprintf(filename, sizeof(filename),
85 "%s/test_inputs/%s.polylib", srcdir, name);
86 assert(n < sizeof(filename));
87 input = fopen(filename, "r");
90 bset1 = isl_basic_set_read_from_file(ctx, input, ISL_FORMAT_POLYLIB);
91 bset2 = isl_basic_set_read_from_file(ctx, input, ISL_FORMAT_POLYLIB);
93 set = isl_basic_set_union(ctx, bset1, bset2);
94 bset1 = isl_set_convex_hull(ctx, set);
96 bset2 = isl_basic_set_read_from_file(ctx, input, ISL_FORMAT_POLYLIB);
98 assert(isl_basic_set_is_equal(ctx, bset1, bset2) == 1);
100 isl_basic_set_free(ctx, bset1);
101 isl_basic_set_free(ctx, bset2);
106 void test_convex_hull(struct isl_ctx *ctx)
108 test_convex_hull_case(ctx, "convex0");
109 test_convex_hull_case(ctx, "convex1");
110 test_convex_hull_case(ctx, "convex2");
111 test_convex_hull_case(ctx, "convex3");
112 test_convex_hull_case(ctx, "convex4");
113 test_convex_hull_case(ctx, "convex5");
114 test_convex_hull_case(ctx, "convex6");
115 test_convex_hull_case(ctx, "convex7");
122 srcdir = getenv("srcdir");
124 ctx = isl_ctx_alloc();
125 test_application(ctx);
126 test_affine_hull(ctx);
127 test_convex_hull(ctx);