Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
mehrdadh committed Jul 21, 2021
1 parent 1e6bca2 commit e8edb0b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tests/crt/aot_memory_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,19 @@ TEST(AOTMemory, InitialMemoryMisAlignment) {
tvm_workspace_t tvm_runtime_workspace;
uint8_t* model_memory_ptr = model_memory;

// Add misaslignment to memory pointer
uint32_t offset = misalign_pointer(&model_memory_ptr);

// Calculate expected offset
uint8_t* misaligned_ptr = model_memory_ptr;
uint32_t alignment_offset = align_pointer(&misaligned_ptr);

ASSERT_EQ(StackMemoryManager_Init(&tvm_runtime_workspace, model_memory_ptr,
sizeof(model_memory) - offset),
kTvmErrorNoError);
ASSERT_EQ(tvm_runtime_workspace.next_alloc,
&model_memory_ptr[TVM_RUNTIME_ALLOC_ALIGNMENT_BYTES - NUM_MEMORY_MISALIGNMENT_BYTES]);
ASSERT_EQ(tvm_runtime_workspace.workspace_size,
sizeof(model_memory) - offset -
(TVM_RUNTIME_ALLOC_ALIGNMENT_BYTES - NUM_MEMORY_MISALIGNMENT_BYTES));

ASSERT_EQ(tvm_runtime_workspace.next_alloc, &model_memory_ptr[alignment_offset]);
ASSERT_EQ(tvm_runtime_workspace.workspace_size, sizeof(model_memory) - offset - alignment_offset);
}

int main(int argc, char** argv) {
Expand Down

0 comments on commit e8edb0b

Please sign in to comment.