Skip to content

Commit

Permalink
Unquarantine expression error checking tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMertens committed Dec 6, 2024
1 parent a293e7c commit 875c693
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
12 changes: 8 additions & 4 deletions distr/flecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -29577,6 +29577,8 @@ void* flecs_bcalloc_w_dbg_info(
ecs_block_allocator_t *ba,
const char *type_name)
{
(void)type_name;

#ifdef FLECS_USE_OS_ALLOC
ecs_assert(ba != NULL, ECS_INTERNAL_ERROR, NULL);
return ecs_os_calloc(ba->data_size);
Expand Down Expand Up @@ -29618,16 +29620,16 @@ void flecs_bfree_w_dbg_info(

#ifdef FLECS_SANITIZE
memory = ECS_OFFSET(memory, -ECS_SIZEOF(int64_t));
ecs_block_allocator_t *actual_ba = *(ecs_block_allocator_t**)memory;
if (actual_ba != ba) {
ecs_block_allocator_t *actual = *(ecs_block_allocator_t**)memory;
if (actual != ba) {
if (type_name) {
ecs_err("chunk %p returned to wrong allocator "
"(chunk = %ub, allocator = %ub, type = %s)",
memory, actual_ba->data_size, ba->data_size, type_name);
memory, actual->data_size, ba->data_size, type_name);
} else {
ecs_err("chunk %p returned to wrong allocator "
"(chunk = %ub, allocator = %ub)",
memory, actual_ba->data_size, ba->chunk_size);
memory, actual->data_size, ba->chunk_size);
}
ecs_abort(ECS_INTERNAL_ERROR, NULL);
}
Expand Down Expand Up @@ -29661,6 +29663,8 @@ void* flecs_brealloc_w_dbg_info(
void *memory,
const char *type_name)
{
(void)type_name;

void *result;
#ifdef FLECS_USE_OS_ALLOC
(void)src;
Expand Down
12 changes: 8 additions & 4 deletions src/datastructures/block_allocator.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ void* flecs_bcalloc_w_dbg_info(
ecs_block_allocator_t *ba,
const char *type_name)
{
(void)type_name;

#ifdef FLECS_USE_OS_ALLOC
ecs_assert(ba != NULL, ECS_INTERNAL_ERROR, NULL);
return ecs_os_calloc(ba->data_size);
Expand Down Expand Up @@ -232,16 +234,16 @@ void flecs_bfree_w_dbg_info(

#ifdef FLECS_SANITIZE
memory = ECS_OFFSET(memory, -ECS_SIZEOF(int64_t));
ecs_block_allocator_t *actual_ba = *(ecs_block_allocator_t**)memory;
if (actual_ba != ba) {
ecs_block_allocator_t *actual = *(ecs_block_allocator_t**)memory;
if (actual != ba) {
if (type_name) {
ecs_err("chunk %p returned to wrong allocator "
"(chunk = %ub, allocator = %ub, type = %s)",
memory, actual_ba->data_size, ba->data_size, type_name);
memory, actual->data_size, ba->data_size, type_name);
} else {
ecs_err("chunk %p returned to wrong allocator "
"(chunk = %ub, allocator = %ub)",
memory, actual_ba->data_size, ba->chunk_size);
memory, actual->data_size, ba->chunk_size);
}
ecs_abort(ECS_INTERNAL_ERROR, NULL);
}
Expand Down Expand Up @@ -275,6 +277,8 @@ void* flecs_brealloc_w_dbg_info(
void *memory,
const char *type_name)
{
(void)type_name;

void *result;
#ifdef FLECS_USE_OS_ALLOC
(void)src;
Expand Down
15 changes: 5 additions & 10 deletions test/script/src/Error.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,8 +660,6 @@ void Error_entity_w_anonymous_tag(void) {
}

void Error_member_expr_without_value_end_of_scope(void) {
test_quarantine("Mon Aug 5"); // address when porting expressions over to new parser

ecs_world_t *world = ecs_init();

ECS_COMPONENT(world, Position);
Expand All @@ -674,14 +672,13 @@ void Error_member_expr_without_value_end_of_scope(void) {
}
});

ecs_log_set_level(-4);
test_assert(ecs_script_run(world, NULL, "Position(x:)") != 0);

ecs_fini(world);
}

void Error_member_expr_without_value_comma(void) {
test_quarantine("Mon Aug 5"); // address when porting expressions over to new parser

ecs_world_t *world = ecs_init();

ECS_COMPONENT(world, Position);
Expand All @@ -694,14 +691,13 @@ void Error_member_expr_without_value_comma(void) {
}
});

ecs_log_set_level(-4);
test_assert(ecs_script_run(world, NULL, "Position(x:,0)") != 0);

ecs_fini(world);
}

void Error_member_expr_without_value_newline(void) {
test_quarantine("Mon Aug 5"); // address when porting expressions over to new parser

ecs_world_t *world = ecs_init();

ECS_COMPONENT(world, Position);
Expand All @@ -714,14 +710,13 @@ void Error_member_expr_without_value_newline(void) {
}
});

ecs_log_set_level(-4);
test_assert(ecs_script_run(world, NULL, "Position(x:\n)") != 0);

ecs_fini(world);
}

void Error_2_member_expr_without_value(void) {
test_quarantine("Mon Aug 5"); // address when porting expressions over to new parser

ecs_world_t *world = ecs_init();

ECS_COMPONENT(world, Position);
Expand All @@ -734,6 +729,7 @@ void Error_2_member_expr_without_value(void) {
}
});

ecs_log_set_level(-4);
test_assert(ecs_script_run(world, NULL, "Position(x:y:)") != 0);

ecs_fini(world);
Expand Down Expand Up @@ -778,8 +774,6 @@ void Error_expr_junk_after_unary_minus(void) {
}

void Error_expr_comma_after_nothing(void) {
test_quarantine("Mon Aug 5"); // address when porting expressions over to new parser

ecs_world_t *world = ecs_init();

ECS_COMPONENT(world, Position);
Expand All @@ -792,6 +786,7 @@ void Error_expr_comma_after_nothing(void) {
}
});

ecs_log_set_level(-4);
test_assert(ecs_script_run(world, NULL, "Position(,)") != 0);

ecs_fini(world);
Expand Down

0 comments on commit 875c693

Please sign in to comment.