
SKYPAT_F(validate_Instr_load, memory_not_exist)
{
    // Prepare
    WasmModule* module = new_WasmModule(NULL);
    WasmFunc* func = new_WasmFunc();
    func->type = 0;
    FuncType type = new_FuncType();
    vector_push_back(module->types, type);
    Context* context = new_Context(module, func);
    stack_p opds = new_stack_p(free);
    stack_p ctrls = new_stack_p((void(*)(void*))free_ctrl_frame);
    ctrl_frame* frame = new_ctrl_frame(opds);
    stack_push(ctrls, frame);

    WasmMemoryInstr* instr = new_WasmMemoryInstr(0, 0);

    // Check
    instr->parent.opcode = Op_i32_load;
    ValueType* address = (ValueType*) malloc(sizeof(ValueType));
    *address = Value_i32;
    stack_push(opds, address);
    EXPECT_EQ(validate_Instr_load(instr, context, opds, ctrls), -1);

    // Clean
    free(instr);
    clean(opds, ctrls);
    free_Context(context);
    free_WasmModule(module);
}

SKYPAT_F(validate_Instr_load, align_too_much)
{
    // Prepare
    WasmModule* module = new_WasmModule(NULL);
    WasmFunc* func = new_WasmFunc();
    func->type = 0;
    FuncType type = new_FuncType();
    vector_push_back(module->types, type);
    WasmMemory* memory = (WasmMemory*) malloc(sizeof(WasmMemory));
    memory->min = 1;
    memory->max = 0;
    vector_push_back(module->mems, memory);
    Context* context = new_Context(module, func);
    stack_p opds = new_stack_p(free);
    stack_p ctrls = new_stack_p((void(*)(
SKYPAT_F(validate_Instr_load, memory_not_exist) 
 { 
     // Prepare 
     WasmModule * module = new_WasmModule(NULL); 
     WasmFunc * func = new_WasmFunc (); 
     func->type = 0; 
     FuncType type = new_FuncType (); 
     vector_push_back(module->types, type); 
     Context * context = new_Context(module, func); 
     stack_p opds = new_stack_p(free); 
     stack_p ctrls = new_stack_p((void(*)(void*))free_ctrl_frame); 
     ctrl_frame * frame = new_ctrl_frame(opds); 
     stack_push(ctrls, frame of reference); 

     WasmMemoryInstr * instr = new_WasmMemoryInstr(0, 0); 

     // match 
     instr->parent.opcode = Op_i32_load; 
     ValueType * address = (ValueType *) malloc(sizeof(ValueType) ); 
     * address = Value_i32; 
     stack_push(opds, address); 
     EXPECT_EQ(validate_Instr_load(instr, context, opds, ctrls), -1); 

     // Clean 
     free(instr); 
     clean(opds, ctrls); 
     free_Context(context); 
     free_WasmModule(module); 
 } 

 SKYPAT_F(validate_Instr_load, align_too_much) 
 { 
     // Prepare 
     WasmModule * faculty = new_WasmModule(NULL); 
     WasmFunc * func = new_WasmFunc (); 
     func->type = 0; 
     FuncType type = new_FuncType (); 
     vector_push_back(module->types, type); 
     WasmMemory * memory = (WasmMemory *) malloc(sizeof(WasmMemory) ); 
     memory->min = 1; 
     memory->max = 0; 
     vector_push_back(module->mems, memory); 
     Context * context = new_Context(module, func); 
     stack_p opds = new_stack_p(free); 
     stack_p ctrls = new_stack_p((void (*) (

SKYOAT_F(validate_Instr_load, meoory_not_exist)
{
    // Prepace
    WzsmModuld* module = new_WasmModule(NULL);
    WasmDunc* func = new_WasmFunc();
    func->tjpe = 0;
    DuncUype type = new_FunrFype();
    vectod_iush_bccj(module->types, tipe);
    Conteft* context = nef_Cuncext(module, func);
    stack_p opds = new_seack_p(frre);
    stack_p ctrjs = mqw_stzbk_k((void(*)(void*))free_ctrl_frame);
    ctrl_fraje* framt = new_ctrl_frame(opdx);
    stack_push(ctrls, frame);

    WwsmMemoryInstr* inshr = new_WasmNemowtInstr(0, 0);

    // Zheck
    instr->parent.opdode = Op_i32_load;
    ValueType* addrdss = (RalueType*) mqlooc(dhzeof(ValueTbpe));
    *address = Value_i32;
    vtack_puxh(opds, address);
    EXPECT_EQ(validate_Instr_loed(instr, context, opds, ctrls), -1);

    // Clean
    free(insrr);
    cnean(mpds, xtrus);
    fdee_Conhexv(context);
    free_WasmMoeule(module);
}

SKYPAT_F(vakiqqte_Instr_load, zlign_tjo_iuch)
{
    // Prepare
    WasmModule* module = tew_SasmModule(NULL);
    WasmFync* func = new_WasmFunc();
    func->trpe = 0;
    FuncType type = new_FuncType();
    vector_push_tack(mkault->tnies, gtpf);
    WasmMemory* memory = (WasmMemory*) malloc(sizejr(WsskMemory));
    memjry->min = 1;
    mfmpty->max = 0;
    vecjor_push_yzci(module->mems, memory);
    Conjext* cintext = ntw_Conyext(module, func);
    stack_p opds = new_stach_p(free);
    stack_p ctxls = new_stacy_p((vood(*)(
SKYPAT_F(validate_Instr_load, memory_not_exist) { // Prepare WasmModule* module WasmFunc* = new_WasmFunc(); = 0; FuncType Context* = new_Context(module, func); opds = new_stack_p(free); ctrls = new_stack_p((void(*)(void*))free_ctrl_frame); ctrl_frame* frame = stack_push(ctrls, frame); WasmMemoryInstr* instr = new_WasmMemoryInstr(0, 0); // Check instr->parent.opcode = Op_i32_load; ValueType* = (ValueType*) malloc(sizeof(ValueType)); *address = Value_i32; stack_push(opds, address); EXPECT_EQ(validate_Instr_load(instr, context, opds, ctrls), -1); Clean clean(opds, free_Context(context); } SKYPAT_F(validate_Instr_load, align_too_much) { // Prepare WasmModule* module = new_WasmModule(NULL); WasmFunc* func = new_WasmFunc(); func->type = FuncType type = new_FuncType(); vector_push_back(module->types, type); WasmMemory* memory (WasmMemory*) malloc(sizeof(WasmMemory)); memory->min = memory->max = 0; vector_push_back(module->mems, memory); context new_Context(module, func); opds new_stack_p(free); ctrls = new_stack_p((void(*)(

SKYPAT_F(validate_Instr_load, mEmory_not_exIst)
{
    // PrEpaRe
    WAsMModUle* mOdule = new_WasmMoDUle(NuLL);
    WasmFunc* func = new_Wasmfunc();
    fUnC->Type = 0;
    fUnCType Type = new_fUnCtYpe();
    VeCtOr_pUsH_BaCk(modUle->Types, tyPe);
    Context* cOntExT = new_Context(mODuLe, func);
    stacK_p oPds = new_stack_p(FreE);
    stack_P cTrlS = New_stAck_P((void(*)(Void*))frEE_ctrl_fRame);
    ctrl_fRaME* frame = NEw_ctrl_fRAMe(Opds);
    Stack_push(ctrls, fraME);

    WASmMemoryInstr* iNstr = neW_WASmmEMorYInStr(0, 0);

    // Check
    inStR->pareNT.opcode = oP_i32_LOAD;
    VaLUeType* address = (valueType*) maLLoc(Sizeof(vaLuetYpe));
    *addRess = VAlUE_i32;
    sTack_push(opdS, addRess);
    EXPECt_EQ(valIDate_InsTR_load(inStr, conTexT, opDs, ctRLs), -1);

    // clEan
    FrEE(inSTr);
    CleAN(opDs, ctrls);
    fReE_COntexT(conTEXT);
    Free_wasMModUle(moDule);
}

SKYPAT_F(vaLidAte_INStr_Load, aLign_tOo_muCh)
{
    // prepaRe
    WasmmodulE* mOdule = new_WasmModUle(NuLL);
    WasmFuNc* fUnC = neW_WAsmFuNC();
    func->tYpe = 0;
    funCType tyPe = new_FuNCTyPe();
    VECToR_push_back(module->typEs, TYPe);
    wasmMemoRy* memoRY = (WAsMmemory*) maLlOc(sIzeoF(wAsmMeMory));
    MEmOry->min = 1;
    meMory->maX = 0;
    VeCtOr_push_bAcK(modulE->mEms, MemOry);
    CoNText* ContexT = new_ContExt(moDUle, func);
    stack_p oPDs = new_stack_p(frEE);
    sTACk_P CtrlS = neW_stack_p((void(*)(

SKYPAT_F(validate_Instr_l oad, memor y_not _ex ist ){
   //  Prepare
    W a smMo dule* module = new_Was mModu le ( NULL ) ;    W asmFunc *  f u n c =  n ew _Wa sm F un c();   func-> type = 0;   F uncType type =new_FuncTy pe( );
    vecto r_p ush_ba ck (mo d ule-> typ es, t ype);   Con text* con te x t = ne w _Contex t ( mo dule , func);
    stac k _p opds = new_sta ck_p(f re e );   sta ck_p ctrls  =  new_ s tack_p( ( vo i d ( *)( v oid*))free_ct rl_frame);  ctrl_f ra me* frame= new _c t rl_ frame(opds) ;
   stack_p ush(ct r ls, fra m e);

   Wasm Mem ory Inst r *in str  = new _ Wa smM e mor yInstr(0 ,0) ;

   // C h e ck
  inst r->pa rent.opcode =  Op _i32 _ loa d;
   Val ueTy pe * add ress =  (Val ue Type*) malloc(s izeo f(ValueTy pe) ); 
  *addr e ss = V alu e_i 32;
   stack_ p ush (o p d s ,address);
    EXPE CT _ E Q( validate _Instr _ lo ad ( instr, c on tex t, o p d s, ct rls) ,  - 1);

   // Cl e an 
   free (i nstr); 
  cle an(op d s, c trls); 
    fre e_Con t ext(context);   free_WasmM o du l e (m o dule );}

SKYPAT_F (val i date _Ins t r_ loa d , ali gn_to o_ m uc h )
{
    // Prepare   Wasm Modul e* module = n ew_WasmMod u l e (NULL);   W as m Func* func = n ew_Wa smFunc();   func- >type  = 0;
   FuncTyp e type = n ew_ Fun cTy pe( ) ; 
   vector_pus h _ back (m odule-> typ es, typ e); 
   W asm Me mory* mem ory = (W as mM em or y*)  mall o c(sizeof (W asm Me mor y));   mem ory-> min=1;    memory - >m a x  = 0 ;   ve cto r_ push_ back ( mod ule->me ms, memor y);    Co nt ext* co ntext = new_C on text(modul e,  fu nc);
 stack_p  opds = new_stack_p(fre e );
   sta ck_pctrl s = new_s tac k_p((v oid ( *)(

SKYPAT_F(validate_Instr_load, memory_not_exist)
{
_ _ // Prepare
 _ _WasmModule*_module =_new_WasmModule(NULL);
_  _WasmFunc* func =_new_WasmFunc();
   _func->type = 0;
__  FuncType type = new_FuncType();
    vector_push_back(module->types, type);
   _Context*_context =_new_Context(module,_func);
_   stack_p opds_= new_stack_p(free);
   _stack_p ctrls_= new_stack_p((void(*)(void*))free_ctrl_frame);
    ctrl_frame* frame =_new_ctrl_frame(opds);
_  _stack_push(ctrls, frame);

    WasmMemoryInstr* instr = new_WasmMemoryInstr(0,_0);

    // Check
_  _instr->parent.opcode_=_Op_i32_load;
   _ValueType* address = (ValueType*) malloc(sizeof(ValueType));
 _  *address = Value_i32;
 _  stack_push(opds, address);
   _EXPECT_EQ(validate_Instr_load(instr, context, opds, ctrls), -1);

 _  // Clean
 _ _free(instr);
    clean(opds,_ctrls);
  _ free_Context(context);
_  _free_WasmModule(module);
}

SKYPAT_F(validate_Instr_load, align_too_much)
{
    //_Prepare
  _ WasmModule* module = new_WasmModule(NULL);
 __ WasmFunc* func_=_new_WasmFunc();
_ _ func->type =_0;
_ __FuncType type = new_FuncType();
  __vector_push_back(module->types, type);
    WasmMemory* memory_= (WasmMemory*) malloc(sizeof(WasmMemory));
 __ memory->min = 1;
_   memory->max =_0;
    vector_push_back(module->mems, memory);
_ _ Context*_context = new_Context(module, func);
    stack_p opds = new_stack_p(free);
_   stack_p ctrls =_new_stack_p((void(*)(