Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Side by Side Diff: Source/wtf/PartitionAllocTest.cpp

Issue 186863002: Build blink_platform_unittests and wtf_unittests on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/platform/blink_platform_tests.gyp ('k') | Source/wtf/wtf_tests.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 ptr = partitionAllocGeneric(genericAllocator.root(), size); 1057 ptr = partitionAllocGeneric(genericAllocator.root(), size);
1058 EXPECT_TRUE(ptr); 1058 EXPECT_TRUE(ptr);
1059 partitionFreeGeneric(genericAllocator.root(), ptr); 1059 partitionFreeGeneric(genericAllocator.root(), ptr);
1060 1060
1061 EXPECT_TRUE(bucket->activePagesHead); 1061 EXPECT_TRUE(bucket->activePagesHead);
1062 EXPECT_TRUE(bucket->freePagesHead); 1062 EXPECT_TRUE(bucket->freePagesHead);
1063 1063
1064 TestShutdown(); 1064 TestShutdown();
1065 } 1065 }
1066 1066
1067 #if !OS(ANDROID)
1068
1067 // Make sure that malloc(-1) dies. 1069 // Make sure that malloc(-1) dies.
1068 // In the past, we had an integer overflow that would alias malloc(-1) to 1070 // In the past, we had an integer overflow that would alias malloc(-1) to
1069 // malloc(0), which is not good. 1071 // malloc(0), which is not good.
1070 TEST(WTF_PartitionAllocDeathTest, LargeAllocs) 1072 TEST(WTF_PartitionAllocDeathTest, LargeAllocs)
1071 { 1073 {
1072 TestSetup(); 1074 TestSetup();
1073 // Largest alloc. 1075 // Largest alloc.
1074 EXPECT_DEATH(partitionAllocGeneric(genericAllocator.root(), static_cast<size _t>(-1)), ""); 1076 EXPECT_DEATH(partitionAllocGeneric(genericAllocator.root(), static_cast<size _t>(-1)), "");
1075 // And the smallest allocation we expect to die. 1077 // And the smallest allocation we expect to die.
1076 EXPECT_DEATH(partitionAllocGeneric(genericAllocator.root(), static_cast<size _t>(INT_MAX) + 1), ""); 1078 EXPECT_DEATH(partitionAllocGeneric(genericAllocator.root(), static_cast<size _t>(INT_MAX) + 1), "");
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 char* charPtr = reinterpret_cast<char*>(ptr) - kPointerOffset; 1126 char* charPtr = reinterpret_cast<char*>(ptr) - kPointerOffset;
1125 1127
1126 EXPECT_DEATH(*(charPtr - 1) = 'A', ""); 1128 EXPECT_DEATH(*(charPtr - 1) = 'A', "");
1127 EXPECT_DEATH(*(charPtr + size + kExtraAllocSize) = 'A', ""); 1129 EXPECT_DEATH(*(charPtr + size + kExtraAllocSize) = 'A', "");
1128 1130
1129 partitionFreeGeneric(genericAllocator.root(), ptr); 1131 partitionFreeGeneric(genericAllocator.root(), ptr);
1130 1132
1131 TestShutdown(); 1133 TestShutdown();
1132 } 1134 }
1133 1135
1136 #endif // !OS(ANDROID)
1137
1134 // Tests that the countLeadingZeros() functions work to our satisfaction. 1138 // Tests that the countLeadingZeros() functions work to our satisfaction.
1135 // It doesn't seem worth the overhead of a whole new file for these tests, so 1139 // It doesn't seem worth the overhead of a whole new file for these tests, so
1136 // we'll put them here since partitionAllocGeneric will depend heavily on these 1140 // we'll put them here since partitionAllocGeneric will depend heavily on these
1137 // functions working correctly. 1141 // functions working correctly.
1138 TEST(WTF_PartitionAlloc, CLZWorks) 1142 TEST(WTF_PartitionAlloc, CLZWorks)
1139 { 1143 {
1140 EXPECT_EQ(32u, WTF::countLeadingZeros32(0)); 1144 EXPECT_EQ(32u, WTF::countLeadingZeros32(0));
1141 EXPECT_EQ(31u, WTF::countLeadingZeros32(1)); 1145 EXPECT_EQ(31u, WTF::countLeadingZeros32(1));
1142 EXPECT_EQ(1u, WTF::countLeadingZeros32(1 << 30)); 1146 EXPECT_EQ(1u, WTF::countLeadingZeros32(1 << 30));
1143 EXPECT_EQ(0u, WTF::countLeadingZeros32(1 << 31)); 1147 EXPECT_EQ(0u, WTF::countLeadingZeros32(1 << 31));
1144 1148
1145 #if CPU(64BIT) 1149 #if CPU(64BIT)
1146 EXPECT_EQ(64u, WTF::countLeadingZerosSizet(0ull)); 1150 EXPECT_EQ(64u, WTF::countLeadingZerosSizet(0ull));
1147 EXPECT_EQ(63u, WTF::countLeadingZerosSizet(1ull)); 1151 EXPECT_EQ(63u, WTF::countLeadingZerosSizet(1ull));
1148 EXPECT_EQ(32u, WTF::countLeadingZerosSizet(1ull << 31)); 1152 EXPECT_EQ(32u, WTF::countLeadingZerosSizet(1ull << 31));
1149 EXPECT_EQ(1u, WTF::countLeadingZerosSizet(1ull << 62)); 1153 EXPECT_EQ(1u, WTF::countLeadingZerosSizet(1ull << 62));
1150 EXPECT_EQ(0u, WTF::countLeadingZerosSizet(1ull << 63)); 1154 EXPECT_EQ(0u, WTF::countLeadingZerosSizet(1ull << 63));
1151 #else 1155 #else
1152 EXPECT_EQ(32u, WTF::countLeadingZerosSizet(0)); 1156 EXPECT_EQ(32u, WTF::countLeadingZerosSizet(0));
1153 EXPECT_EQ(31u, WTF::countLeadingZerosSizet(1)); 1157 EXPECT_EQ(31u, WTF::countLeadingZerosSizet(1));
1154 EXPECT_EQ(1u, WTF::countLeadingZerosSizet(1 << 30)); 1158 EXPECT_EQ(1u, WTF::countLeadingZerosSizet(1 << 30));
1155 EXPECT_EQ(0u, WTF::countLeadingZerosSizet(1 << 31)); 1159 EXPECT_EQ(0u, WTF::countLeadingZerosSizet(1 << 31));
1156 #endif 1160 #endif
1157 } 1161 }
1158 1162
1159 } // namespace 1163 } // namespace
1160 1164
1161 #endif // !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) 1165 #endif // !defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
OLDNEW
« no previous file with comments | « Source/platform/blink_platform_tests.gyp ('k') | Source/wtf/wtf_tests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698