Skip to content

Commit aecda74

Browse files
committed
Extend the integration test with posix_memalign and mmap
1 parent c815dce commit aecda74

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

integration-tests/src/tests.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,22 +173,28 @@ fn test_basic() {
173173
let a2 = iter.next().unwrap(); // malloc, freed through realloc
174174
let a3 = iter.next().unwrap(); // realloc
175175
let a4 = iter.next().unwrap(); // calloc, freed
176+
let a5 = iter.next().unwrap(); // posix_memalign, leaked
176177

177178
assert!( a0.deallocation.is_none() );
178179
assert!( a1.deallocation.is_some() );
179180
assert!( a2.deallocation.is_some() );
180181
assert!( a3.deallocation.is_none() );
181182
assert!( a4.deallocation.is_none() );
183+
assert!( a5.deallocation.is_none() );
184+
185+
assert_eq!( a5.address % 65536, 0 );
182186

183187
assert!( a0.size < a1.size );
184188
assert!( a1.size < a2.size );
185189
assert!( a2.size < a3.size );
186190
assert!( a3.size < a4.size );
191+
assert!( a4.size < a5.size );
187192

188193
assert_eq!( a0.thread, a1.thread );
189194
assert_eq!( a1.thread, a2.thread );
190195
assert_eq!( a2.thread, a3.thread );
191196
assert_eq!( a3.thread, a4.thread );
197+
assert_eq!( a4.thread, a5.thread );
192198

193199
assert_eq!( a0.backtrace.last().unwrap().line.unwrap() + 1, a1.backtrace.last().unwrap().line.unwrap() );
194200

integration-tests/test-programs/basic.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
#include <stdlib.h>
2+
#include <sys/mman.h>
23

34
void __attribute__ ((noinline)) foobar() {
45
void * a0 = malloc( 10 );
56
void * a1 = malloc( 100 );
67
void * a2 = malloc( 1000 );
78
void * a3 = realloc( a2, 10000 );
89
void * a4 = calloc( 100, 1000 );
10+
void * a5 = NULL;
11+
posix_memalign( &a5, 65536, 1000000 );
12+
void * a6 = mmap( NULL, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0 );
913

1014
free( a1 );
15+
munmap( a6, 4096 );
1116
}
1217

1318
int main() {

0 commit comments

Comments
 (0)