Skip to content

Commit

Permalink
Add test for malloc
Browse files Browse the repository at this point in the history
  • Loading branch information
krtab committed Jan 22, 2024
1 parent a79e374 commit db7c557
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/owic/stdlib/malloc_aligned.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <owi.h>
#include <stdlib.h>

void arbitrary_pre_align() {
int s = owi_i32();
int m = (s < 8) ? s : 7;
for (int i = 0; i < m; i++) {
malloc(1);
}
}

int main() {
malloc(1024);
arbitrary_pre_align();
for (int p = 0; p < 10; p++) {
int low_pow = (1 << p);
for (int i = low_pow; i < 2*low_pow; i++) {
void * ptr = malloc(i);
if (low_pow < 16) {
owi_assert((int) ptr % low_pow == 0);
} else {
owi_assert((int) ptr % 16 == 0);
}
}
}
}

0 comments on commit db7c557

Please sign in to comment.