Add tests for calloc()
Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
This commit is contained in:
parent
8a4744fbe4
commit
3934b3e6cc
@ -10,6 +10,7 @@ TARGET_WARNING_C++FLAGS_$(TARGET_PACKAGING_ARCH)
|
|||||||
SimpleTest abort_test : abort_test.cpp ;
|
SimpleTest abort_test : abort_test.cpp ;
|
||||||
SimpleTest SyslogTest : SyslogTest.cpp ;
|
SimpleTest SyslogTest : SyslogTest.cpp ;
|
||||||
SimpleTest brk_test : brk_test.c ;
|
SimpleTest brk_test : brk_test.c ;
|
||||||
|
SimpleTest calloc_test : calloc_test.c ;
|
||||||
SimpleTest clearenv : clearenv.cpp ;
|
SimpleTest clearenv : clearenv.cpp ;
|
||||||
SimpleTest dirent_test : dirent_test.cpp ;
|
SimpleTest dirent_test : dirent_test.cpp ;
|
||||||
SimpleTest flock_test : flock_test.cpp ;
|
SimpleTest flock_test : flock_test.cpp ;
|
||||||
|
35
src/tests/system/libroot/posix/calloc_test.c
Normal file
35
src/tests/system/libroot/posix/calloc_test.c
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017, ohnx, me@masonx.ca.
|
||||||
|
* Distributed under the terms of the CC0 License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
void *ptr;
|
||||||
|
|
||||||
|
printf("Testing calloc(SIZE_MAX, SIZE_MAX)... ");
|
||||||
|
if (calloc(SIZE_MAX, SIZE_MAX) != NULL) {
|
||||||
|
printf("fail!\n");
|
||||||
|
}
|
||||||
|
printf("pass!\n");
|
||||||
|
|
||||||
|
printf("Testing calloc(0, 0)... ");
|
||||||
|
/* issues with calloc() here will throw a panic */
|
||||||
|
ptr = calloc(0, 0);
|
||||||
|
/* free the value, since calloc() should return a free() able pointer */
|
||||||
|
free(ptr);
|
||||||
|
printf("pass!\n");
|
||||||
|
|
||||||
|
printf("Testing calloc(-1, -1)... ");
|
||||||
|
if (calloc(-1, -1) != NULL) {
|
||||||
|
printf("")
|
||||||
|
}
|
||||||
|
printf("pass!\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user