tests: make no-optimize attribute Clang compatible
This commit is contained in:
test
large_array_growth.cmallinfo.cmalloc_info.c
simple-memory-corruption
delete_type_size_mismatch.ccdouble_free_large.cdouble_free_large_delayed.cdouble_free_small.cdouble_free_small_delayed.ceight_byte_overflow_large.ceight_byte_overflow_small.cinvalid_free_protected.cinvalid_free_small_region.cinvalid_free_small_region_far.cinvalid_free_unprotected.cinvalid_malloc_usable_size_small.cinvalid_malloc_usable_size_small_quarantine.cmalloc_object_size.cmalloc_object_size_offset.cread_after_free_large.cread_after_free_small.cread_zero_size.cstring_overflow.cunaligned_free_large.cunaligned_free_small.cunaligned_malloc_usable_size_small.cuninitialized_free.cuninitialized_malloc_usable_size.cuninitialized_realloc.cwrite_after_free_large.cwrite_after_free_large_reuse.cwrite_after_free_small.cwrite_after_free_small_reuse.cwrite_zero_size.c
test_util.h@@ -1,8 +1,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
void *p = NULL;
|
void *p = NULL;
|
||||||
size_t size = 256 * 1024;
|
size_t size = 256 * 1024;
|
||||||
|
|
||||||
|
@@ -1,7 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
malloc(1024 * 1024 * 1024);
|
malloc(1024 * 1024 * 1024);
|
||||||
malloc(16);
|
malloc(16);
|
||||||
malloc(32);
|
malloc(32);
|
||||||
|
@@ -1,16 +1,18 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "test_util.h"
|
||||||
void leak_memory(void) {
|
|
||||||
|
OPTNONE static void leak_memory(void) {
|
||||||
(void)malloc(1024 * 1024 * 1024);
|
(void)malloc(1024 * 1024 * 1024);
|
||||||
(void)malloc(16);
|
(void)malloc(16);
|
||||||
(void)malloc(32);
|
(void)malloc(32);
|
||||||
(void)malloc(4096);
|
(void)malloc(4096);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *do_work(void *p) {
|
static void *do_work(void *p) {
|
||||||
leak_memory();
|
leak_memory();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "../test_util.h"
|
||||||
|
|
||||||
struct foo {
|
struct foo {
|
||||||
uint64_t a, b, c, d;
|
uint64_t a, b, c, d;
|
||||||
};
|
};
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
OPTNONE int main(void) {
|
||||||
int main(void) {
|
|
||||||
void *p = new char;
|
void *p = new char;
|
||||||
struct foo *c = (struct foo *)p;
|
struct foo *c = (struct foo *)p;
|
||||||
delete c;
|
delete c;
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
void *p = malloc(128 * 1024);
|
void *p = malloc(128 * 1024);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
void *p = malloc(128 * 1024);
|
void *p = malloc(128 * 1024);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
void *p = malloc(16);
|
void *p = malloc(16);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
void *p = malloc(16);
|
void *p = malloc(16);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
char *p = malloc(256 * 1024);
|
char *p = malloc(256 * 1024);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
char *p = malloc(8);
|
char *p = malloc(8);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
free(malloc(16));
|
free(malloc(16));
|
||||||
char *p = mmap(NULL, 4096 * 16, PROT_NONE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
|
char *p = mmap(NULL, 4096 * 16, PROT_NONE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
|
||||||
if (p == MAP_FAILED) {
|
if (p == MAP_FAILED) {
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
char *p = malloc(16);
|
char *p = malloc(16);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
char *p = malloc(16);
|
char *p = malloc(16);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
free(malloc(16));
|
free(malloc(16));
|
||||||
char *p = mmap(NULL, 4096 * 16, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
|
char *p = mmap(NULL, 4096 * 16, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
|
||||||
if (p == MAP_FAILED) {
|
if (p == MAP_FAILED) {
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
char *p = malloc(16);
|
char *p = malloc(16);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
void *p = malloc(16);
|
void *p = malloc(16);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -1,10 +1,11 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|
||||||
|
#include "../test_util.h"
|
||||||
|
|
||||||
size_t malloc_object_size(void *ptr);
|
size_t malloc_object_size(void *ptr);
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
OPTNONE int main(void) {
|
||||||
int main(void) {
|
|
||||||
char *p = malloc(16);
|
char *p = malloc(16);
|
||||||
size_t size = malloc_object_size(p);
|
size_t size = malloc_object_size(p);
|
||||||
return size != (SLAB_CANARY ? 24 : 32);
|
return size != (SLAB_CANARY ? 24 : 32);
|
||||||
|
@@ -1,10 +1,11 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|
||||||
|
#include "../test_util.h"
|
||||||
|
|
||||||
size_t malloc_object_size(void *ptr);
|
size_t malloc_object_size(void *ptr);
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
OPTNONE int main(void) {
|
||||||
int main(void) {
|
|
||||||
char *p = malloc(16);
|
char *p = malloc(16);
|
||||||
size_t size = malloc_object_size(p + 5);
|
size_t size = malloc_object_size(p + 5);
|
||||||
return size != (SLAB_CANARY ? 19 : 27);
|
return size != (SLAB_CANARY ? 19 : 27);
|
||||||
|
@@ -2,8 +2,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
char *p = malloc(128 * 1024);
|
char *p = malloc(128 * 1024);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -2,8 +2,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
char *p = malloc(16);
|
char *p = malloc(16);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
char *p = malloc(0);
|
char *p = malloc(0);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -4,8 +4,9 @@
|
|||||||
|
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
char *p = malloc(16);
|
char *p = malloc(16);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
char *p = malloc(128 * 1024);
|
char *p = malloc(128 * 1024);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
char *p = malloc(16);
|
char *p = malloc(16);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
char *p = malloc(16);
|
char *p = malloc(16);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
free((void *)1);
|
free((void *)1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
malloc_usable_size((void *)1);
|
malloc_usable_size((void *)1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
void *p = realloc((void *)1, 16);
|
void *p = realloc((void *)1, 16);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
char *p = malloc(128 * 1024);
|
char *p = malloc(128 * 1024);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
char *p = malloc(128 * 1024);
|
char *p = malloc(128 * 1024);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
char *p = malloc(128);
|
char *p = malloc(128);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
char *p = malloc(128);
|
char *p = malloc(128);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
__attribute__((optimize(0)))
|
#include "../test_util.h"
|
||||||
int main(void) {
|
|
||||||
|
OPTNONE int main(void) {
|
||||||
char *p = malloc(0);
|
char *p = malloc(0);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
|
10
test/test_util.h
Normal file
10
test/test_util.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#ifndef TEST_UTIL_H
|
||||||
|
#define TEST_UTIL_H
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
#define OPTNONE __attribute__((optnone))
|
||||||
|
#else
|
||||||
|
#define OPTNONE __attribute__((optimize(0)))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user