added test on errno = ENOMEM on out of memory

This commit is contained in:
Aliaksey Kandratsenka 2015-08-02 01:47:55 -07:00
parent eb725ff263
commit 73fb7c7eb3

View File

@ -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;
}