From fbbd44f63fc2718c8d48b12b8934c731fb765c2e Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sun, 26 Nov 2023 22:18:06 +0100 Subject: [PATCH] Added built tests for t0 --- makefile | 5 +++++ src/test.c | 12 ++++++++---- tests/t0.bin | Bin 0 -> 80 bytes tests/t0.s | 6 +++++- 4 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 tests/t0.bin diff --git a/makefile b/makefile index 2e21406..c5fa268 100644 --- a/makefile +++ b/makefile @@ -72,3 +72,8 @@ lint: .PHONY: runtest runtest: ./$(BDIR)/$(TEST_BNAME) + +.PHONY: buildtests +buildtests: + ./$(BDIR)/$(BNAME) tests/t0.s -l - -o tests/t0.bin + diff --git a/src/test.c b/src/test.c index 27acf57..f551650 100644 --- a/src/test.c +++ b/src/test.c @@ -303,19 +303,23 @@ void test_asminstr(void) { #define ULAS_FULLEN 0xFFFF -#define ASSERT_FULL(expect_len, expect_rc, in_path, ...) \ +#define ASSERT_FULL(expect_rc, in_path, expect_path) \ { \ + printf("[source: %s; expect: %s]\n", in_path, expect_path); \ ulaslstout = stdout; \ struct ulas_config cfg = ulas_cfg_from_env(); \ char dstbuf[ULAS_FULLEN]; \ - char expect[] = {__VA_ARGS__}; \ + char expect[ULAS_FULLEN]; \ + FILE *expectf = fopen(expect_path, "re"); \ + int expect_len = fread(expect, 1, ULAS_FULLEN, expectf); \ + fclose(expectf); \ memset(dstbuf, 0, ULAS_FULLEN); \ ulasout = fmemopen(dstbuf, ULAS_FULLEN, "we"); \ ulasin = fopen(in_path, "re"); \ assert(ulas_main(cfg) == expect_rc); \ fclose(ulasout); \ for (int i = 0; i < expect_len; i++) { \ - assert(dstbuf[i] == expect[i]); \ + assert(expect[i] == dstbuf[i]); \ } \ for (int i = expect_len; i < ULAS_FULLEN; i++) { \ assert(dstbuf[i] == 0); \ @@ -328,7 +332,7 @@ void test_asminstr(void) { void test_full(void) { TESTBEGIN("testfull"); - ASSERT_FULL(2, 0, "tests/t0.s", 0, 0x76); + ASSERT_FULL(0, "tests/t0.s", "tests/t0.bin"); TESTEND("testfull"); } diff --git a/tests/t0.bin b/tests/t0.bin new file mode 100644 index 0000000000000000000000000000000000000000..1cc8c84c6ddfe8c65a6145558e67d10ebf7de588 GIT binary patch literal 80 zcmV-W0I&Z5b`Svc`%gxR1_&SoF&YCRBQ!Pv2m=5Z{s{^y3q1}4z~BM!0^;)O0RZ{} m0Kvin0K)?S)B*tY#skOb1o#5U*~$U{%>@9<0m}x