47 lines · c
1/*2 * Copyright 2021 Cerebras Systems3 *4 * Use of this software is governed by the MIT license5 *6 * Written by Sven Verdoolaege,7 * Cerebras Systems, 1237 E Arques Ave, Sunnyvale, CA, USA8 */9 10#define xCAT(A,B) A ## B11#define CAT(A,B) xCAT(A,B)12#undef TYPE13#define TYPE CAT(isl_,BASE)14#define xFN(TYPE,NAME) TYPE ## _ ## NAME15#define FN(TYPE,NAME) xFN(TYPE,NAME)16 17#undef TESTS18#define TESTS CAT(parse_,CAT(BASE,_fail_tests))19 20/* Test parsing of objects of type TYPE21 * that are expected to fail.22 */23static isl_stat FN(check,TESTS)(isl_ctx *ctx)24{25 int i, n;26 int on_error;27 28 on_error = isl_options_get_on_error(ctx);29 isl_options_set_on_error(ctx, ISL_ON_ERROR_CONTINUE);30 n = ARRAY_SIZE(TESTS);31 for (i = 0; i < n; ++i) {32 TYPE *obj;33 34 obj = FN(TYPE,read_from_str)(ctx, TESTS[i]);35 FN(TYPE,free)(obj);36 if (obj)37 break;38 }39 isl_options_set_on_error(ctx, on_error);40 if (i < n)41 isl_die(ctx, isl_error_unknown,42 "parsing not expected to succeed",43 return isl_stat_error);44 45 return isl_stat_ok;46}47