diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2023-08-04 21:16:34 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2023-08-04 21:16:34 +0300 |
| commit | 09f8df9f7e1166be48cdd6b1caba0f6771dd753e (patch) | |
| tree | 1cad6a2b118825e19432e2acf4e65c45e975ab60 /tests/check.c | |
| parent | c671d6612be0fb28eea498246c39bb5032afa872 (diff) | |
| download | copyjit-09f8df9f7e1166be48cdd6b1caba0f6771dd753e.tar.gz copyjit-09f8df9f7e1166be48cdd6b1caba0f6771dd753e.zip | |
add simple patching mechanism
Diffstat (limited to 'tests/check.c')
| -rw-r--r-- | tests/check.c | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/tests/check.c b/tests/check.c index 8f4c6de..f6e775c 100644 --- a/tests/check.c +++ b/tests/check.c @@ -138,8 +138,45 @@ static void check_add() static void check_branch() { - /* oh yeah, I don't support forward references (yet), so this is a bit - * tricky */ + for (size_t i = 0; i < 2; ++i) { + ctx_t ctx; + compile_start(&ctx); + + compile_fast_lia(&ctx, i); + reloc_t r = compile_placeholder(&ctx, compile_lio); + compile_ban(&ctx); + + compile_lix(&ctx, 0); + compile_end(&ctx); + + void *skip = compile_lix(&ctx, 1); + compile_end(&ctx); + compile_patch(r, skip); + + compile_finish(&ctx); + + assert(run(&ctx) == (i != 0)); + } + + for (size_t i = 0; i < 2; ++i) { + ctx_t ctx; + compile_start(&ctx); + + compile_fast_lia(&ctx, i); + reloc_t r = compile_placeholder(&ctx, compile_lio); + compile_baz(&ctx); + + compile_lix(&ctx, 0); + compile_end(&ctx); + + void *skip = compile_lix(&ctx, 1); + compile_end(&ctx); + compile_patch(r, skip); + + compile_finish(&ctx); + + assert(run(&ctx) == (i == 0)); + } } int main() |
