scop.c: *_collect_params: fix error handling
[pet.git] / pet_scop_cmp.c
blobd743a810872741106af8b896266200549148f888
1 /*
2 * Copyright 2011 Leiden University. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following
13 * disclaimer in the documentation and/or other materials provided
14 * with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY LEIDEN UNIVERSITY ''AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LEIDEN UNIVERSITY OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * The views and conclusions contained in the software and documentation
29 * are those of the authors and should not be interpreted as
30 * representing official policies, either expressed or implied, of
31 * Leiden University.
32 */
34 #include <assert.h>
35 #include <stdio.h>
36 #include <isl/arg.h>
38 #include "scop.h"
39 #include "scop_yaml.h"
41 struct options {
42 char *scop1;
43 char *scop2;
46 ISL_ARGS_START(struct options, options_args)
47 ISL_ARG_ARG(struct options, scop1, "scop1", NULL)
48 ISL_ARG_ARG(struct options, scop2, "scop2", NULL)
49 ISL_ARGS_END
51 ISL_ARG_DEF(options, struct options, options_args)
53 /* Given two YAML descriptions of pet_scops, check whether they
54 * represent equivalent scops.
55 * If so, return 0. Otherwise, return 1.
57 int main(int argc, char **argv)
59 isl_ctx *ctx;
60 struct options *options;
61 struct pet_scop *scop1, *scop2;
62 FILE *file1, *file2;
63 int equal;
65 options = options_new_with_defaults();
66 assert(options);
67 argc = options_parse(options, argc, argv, ISL_ARG_ALL);
68 ctx = isl_ctx_alloc_with_options(&options_args, options);
70 file1 = fopen(options->scop1, "r");
71 assert(file1);
72 file2 = fopen(options->scop2, "r");
73 assert(file2);
75 scop1 = pet_scop_parse(ctx, file1);
76 scop2 = pet_scop_parse(ctx, file2);
78 equal = pet_scop_is_equal(scop1, scop2);
80 pet_scop_free(scop2);
81 pet_scop_free(scop1);
83 fclose(file2);
84 fclose(file1);
85 isl_ctx_free(ctx);
87 return equal ? 0 : 1;