#include #include #include #include #include #include #include "m68k.h" #include "run.h" #include "sym.h" #include "tests.h" static void test_c9auth_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_Tauth); // type assert_int_equal(ru16le(b+5), 0); // tag assert_int_equal(ru32le(b+7), 0xf2345678); // afid assert_int_equal(ru16le(b+11), 4); // uname len assert_memory_equal(b+13, "abcd", 4); // uname assert_int_equal(ru16le(b+17), 4); // aname len assert_memory_equal(b+19, "efgh", 4); // aname assert_int_equal(b[23], fill); executed |= End; } void test_c9auth(void **state) { uint8_t *ctx; uint16_t sr; (void)state; ctx = mem+Ctx; initctx(ctx, Msize); c9begin = generic_begin; c9end = test_c9auth_end; executed = 0; m68k_set_reg(M68K_REG_A0, Ctx); m68k_set_reg(M68K_REG_A1, Tmp); strcpy((char*)mem+Tmp, "abcd"); m68k_set_reg(M68K_REG_A2, Tmp+5); strcpy((char*)mem+Tmp+5, "efgh"); m68k_set_reg(M68K_REG_D0, 0xf2345678); jsr(Progstart+SYM_c9auth); 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); }