#include #include #include #include #include #include #include "m68k.h" #include "run.h" #include "sym.h" #include "tests.h" static void test_c9attach_end(void) { uint8_t *ctx, *b; ctx = mem+m68k_get_reg(NULL, M68K_REG_A0); assert_ptr_equal(ctx, mem+Ctx); b = mem+Begindst; assert_int_equal(ru32le(b), bufsz); // size assert_int_equal(b[4], EXPR_Tattach); // type assert_int_equal(ru16le(b+5), 0); // tag assert_int_equal(ru32le(b+7), 0xf2345678); // fid assert_int_equal(ru32le(b+11), 0x98765432); // afid assert_int_equal(ru16le(b+15), 4); // uname len assert_memory_equal(b+17, "efgh", 4); // uname assert_int_equal(ru16le(b+21), 4); // aname len assert_memory_equal(b+23, "abcd", 4); // aname assert_int_equal(b[27], fill); executed |= End; } void test_c9attach(void **state) { uint8_t *ctx; uint16_t sr; (void)state; ctx = mem+Ctx; initctx(ctx, Msize); c9begin = generic_begin; c9end = test_c9attach_end; executed = 0; m68k_set_reg(M68K_REG_A0, Ctx); m68k_set_reg(M68K_REG_A1, Tmp+1); strcpy((char*)mem+Tmp+1, "efgh"); m68k_set_reg(M68K_REG_A2, Tmp+6); strcpy((char*)mem+Tmp+6, "abcd"); m68k_set_reg(M68K_REG_D0, 0xf2345678); m68k_set_reg(M68K_REG_D1, 0x98765432); jsr(Progstart+SYM_c9attach); sr = m68k_get_reg(NULL, M68K_REG_SR); assert_false(sr & SR_C); // check if the data buffer was used assert_int_equal(executed, Begin|End); }