diff --git a/src/tests/system/libroot/posix/Jamfile b/src/tests/system/libroot/posix/Jamfile index 3736add4df..ee5e4f60f9 100644 --- a/src/tests/system/libroot/posix/Jamfile +++ b/src/tests/system/libroot/posix/Jamfile @@ -10,6 +10,7 @@ TARGET_WARNING_C++FLAGS_$(TARGET_PACKAGING_ARCH) SimpleTest abort_test : abort_test.cpp ; SimpleTest SyslogTest : SyslogTest.cpp ; SimpleTest brk_test : brk_test.c ; +SimpleTest calloc_test : calloc_test.c ; SimpleTest clearenv : clearenv.cpp ; SimpleTest dirent_test : dirent_test.cpp ; SimpleTest flock_test : flock_test.cpp ; diff --git a/src/tests/system/libroot/posix/calloc_test.c b/src/tests/system/libroot/posix/calloc_test.c new file mode 100644 index 0000000000..a2353ce558 --- /dev/null +++ b/src/tests/system/libroot/posix/calloc_test.c @@ -0,0 +1,35 @@ +/* + * Copyright 2017, ohnx, me@masonx.ca. + * Distributed under the terms of the CC0 License. + */ + +#include +#include +#include + +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; +}