FILE *dst = fmemopen(dstbuf, ULAS_LINEMAX, "we"); \
assert(ulas_preproc(dst, src) == (expect_ret)); \
fclose(src); \
- fclose(dst); \
+ fclose(dst); \
assert(strcmp(dstbuf, (expect_dst)) == 0); \
}
{ \
struct ulas_config cfg = ulas_cfg_from_env(); \
char *defs[] = {"ULAS_PREDEF"}; \
- cfg.defs = defs; cfg.defslen = 1; \
+ cfg.defs = defs; \
+ cfg.defslen = 1; \
ASSERT_FULL(expect_rc, in_path, expect_path) \
}
TESTEND("testfullasm");
}
+#define ASSERT_FULL_ASM_FAIL(expect_rc, in_path) \
+ { \
+ struct ulas_config cfg = ulas_cfg_from_env(); \
+ printf("[source: %s;]\n", in_path); \
+ ulaslstout = stdout; \
+ ulassymout = stdout; \
+ cfg.verbose = 1; \
+ char dstbuf[ULAS_FULLEN]; \
+ memset(dstbuf, 0, ULAS_FULLEN); \
+ ulasout = fmemopen(dstbuf, ULAS_FULLEN, "we"); \
+ ulasin = fopen(in_path, "re"); \
+ assert(ulas_main(cfg) == (expect_rc)); \
+ fclose(ulasout); \
+ ulasin = stdin; \
+ ulasout = stdout; \
+ }
+
+void test_full_asm_fail(void) {
+ TESTBEGIN("testfullasmfail");
+
+ ASSERT_FULL_ASM_FAIL(-1, "tests/fail_scope_nesting.s");
+ ASSERT_FULL_ASM_FAIL(-1, "tests/fail_endscope.s");
+
+ TESTEND("testfullasm");
+}
+
#define ASSERT_FULL_DASM(expect_rc, in_path, expect_path) \
{ \
struct ulas_config cfg = ulas_cfg_from_env(); \
// this will re-init everything on its own,
// so call after free
test_full_dasm();
+ test_full_asm_fail();
test_full_asm();
TESTEND("ulas test");
break;
case ULAS_ASMDIR_BEGIN_SCOPE:
if (ulas.prev_scope != 0) {
- ULASPANIC("nested .beginscope detected\n");
+ ULASERR("nested .beginscope detected\n");
+ rc = -1;
}
ulas.prev_scope = ulas.scope;
ulas.scope = -1 - ulas_icntr();
break;
case ULAS_ASMDIR_END_SCOPE:
if (ulas.prev_scope == 0) {
- ULASPANIC("calling .endscope without starting a scope\n");
+ ULASERR("calling .endscope without starting a scope\n");
+ rc = -1;
}
ulas.scope = ulas.prev_scope;
ulas.prev_scope = 0;