mirror of
https://github.com/gperftools/gperftools
synced 2025-01-25 16:33:52 +00:00
added test on errno = ENOMEM on out of memory
This commit is contained in:
parent
eb725ff263
commit
73fb7c7eb3
@ -1047,6 +1047,23 @@ static void TestSetNewMode() {
|
||||
tc_set_new_mode(old_mode);
|
||||
}
|
||||
|
||||
static void TestErrno(void) {
|
||||
errno = 0;
|
||||
void* ret = memalign(128, kTooBig);
|
||||
EXPECT_EQ(NULL, ret);
|
||||
EXPECT_EQ(ENOMEM, errno);
|
||||
|
||||
errno = 0;
|
||||
ret = malloc(kTooBig);
|
||||
EXPECT_EQ(NULL, ret);
|
||||
EXPECT_EQ(ENOMEM, errno);
|
||||
|
||||
errno = 0;
|
||||
ret = tc_malloc_skip_new_handler(kTooBig);
|
||||
EXPECT_EQ(NULL, ret);
|
||||
EXPECT_EQ(ENOMEM, errno);
|
||||
}
|
||||
|
||||
static int RunAllTests(int argc, char** argv) {
|
||||
// Optional argv[1] is the seed
|
||||
AllocatorState rnd(argc > 1 ? atoi(argv[1]) : 100);
|
||||
@ -1379,6 +1396,7 @@ static int RunAllTests(int argc, char** argv) {
|
||||
TestReleaseToSystem();
|
||||
TestAggressiveDecommit();
|
||||
TestSetNewMode();
|
||||
TestErrno();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user