OLD | NEW |
1 // Copyright 2014 Google Inc. All Rights Reserved. | 1 // Copyright 2014 Google Inc. All Rights Reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 171 |
172 EXPECT_TRUE(BlockPlanLayout(8, 8, 61, 0, 0, &layout)); | 172 EXPECT_TRUE(BlockPlanLayout(8, 8, 61, 0, 0, &layout)); |
173 EXPECT_EQ(BuildBlockLayout(8, 104, 16, 0, 61, 7, 20), layout); | 173 EXPECT_EQ(BuildBlockLayout(8, 104, 16, 0, 61, 7, 20), layout); |
174 | 174 |
175 // Plan a layout that would use guard pages. | 175 // Plan a layout that would use guard pages. |
176 EXPECT_TRUE(BlockPlanLayout(4096, 8, 100, 4096, 4096, &layout)); | 176 EXPECT_TRUE(BlockPlanLayout(4096, 8, 100, 4096, 4096, &layout)); |
177 EXPECT_EQ(BuildBlockLayout(4096, 3 * 4096, 16, 8072, 100, 4080, 20), layout); | 177 EXPECT_EQ(BuildBlockLayout(4096, 3 * 4096, 16, 8072, 100, 4080, 20), layout); |
178 #else | 178 #else |
179 // Zero sized allocations should work fine. | 179 // Zero sized allocations should work fine. |
180 EXPECT_TRUE(BlockPlanLayout(8, 8, 0, 0, 0, &layout)); | 180 EXPECT_TRUE(BlockPlanLayout(8, 8, 0, 0, 0, &layout)); |
181 EXPECT_EQ(BuildBlockLayout(8, 48, 24, 0, 0, 4, 20), layout); | 181 EXPECT_EQ(BuildBlockLayout(8, 56, 24, 0, 0, 4, 28), layout); |
182 | 182 |
183 EXPECT_TRUE(BlockPlanLayout(8, 8, 60, 32, 32, &layout)); | 183 EXPECT_TRUE(BlockPlanLayout(8, 8, 60, 32, 32, &layout)); |
184 EXPECT_EQ(BuildBlockLayout(8, 128, 24, 8, 60, 16, 20), layout); | 184 EXPECT_EQ(BuildBlockLayout(8, 128, 24, 8, 60, 8, 28), layout); |
185 | 185 |
186 EXPECT_TRUE(BlockPlanLayout(8, 8, 60, 0, 0, &layout)); | 186 EXPECT_TRUE(BlockPlanLayout(8, 8, 60, 0, 0, &layout)); |
187 EXPECT_EQ(BuildBlockLayout(8, 104, 24, 0, 60, 0, 20), layout); | 187 EXPECT_EQ(BuildBlockLayout(8, 112, 24, 0, 60, 0, 28), layout); |
188 | 188 |
189 EXPECT_TRUE(BlockPlanLayout(8, 8, 64, 0, 0, &layout)); | 189 EXPECT_TRUE(BlockPlanLayout(8, 8, 64, 0, 0, &layout)); |
190 EXPECT_EQ(BuildBlockLayout(8, 112, 24, 0, 64, 4, 20), layout); | 190 EXPECT_EQ(BuildBlockLayout(8, 120, 24, 0, 64, 4, 28), layout); |
191 | 191 |
192 EXPECT_TRUE(BlockPlanLayout(8, 8, 61, 0, 0, &layout)); | 192 EXPECT_TRUE(BlockPlanLayout(8, 8, 61, 0, 0, &layout)); |
193 EXPECT_EQ(BuildBlockLayout(8, 112, 24, 0, 61, 7, 20), layout); | 193 EXPECT_EQ(BuildBlockLayout(8, 120, 24, 0, 61, 7, 28), layout); |
194 | 194 |
195 // Plan a layout that would use guard pages. | 195 // Plan a layout that would use guard pages. |
196 EXPECT_TRUE(BlockPlanLayout(4096, 8, 100, 4096, 4096, &layout)); | 196 EXPECT_TRUE(BlockPlanLayout(4096, 8, 100, 4096, 4096, &layout)); |
197 EXPECT_EQ(BuildBlockLayout(4096, 3 * 4096, 24, 8064, 100, 4080, 20), layout); | 197 EXPECT_EQ(BuildBlockLayout(4096, 3 * 4096, 24, 8064, 100, 4072, 28), layout); |
198 #endif | 198 #endif |
199 | 199 |
200 // Plan a layout with an invalid size, this should fail. | 200 // Plan a layout with an invalid size, this should fail. |
201 EXPECT_FALSE(BlockPlanLayout(8, 8, 0xffffffff, 0, 0, &layout)); | 201 EXPECT_FALSE(BlockPlanLayout(8, 8, 0xffffffff, 0, 0, &layout)); |
202 } | 202 } |
203 | 203 |
204 TEST_F(BlockTest, EndToEnd) { | 204 TEST_F(BlockTest, EndToEnd) { |
205 BlockLayout layout = {}; | 205 BlockLayout layout = {}; |
206 BlockInfo block_info = {}; | 206 BlockInfo block_info = {}; |
207 | 207 |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 BlockBitFlipsFixChecksum(QUARANTINED_BLOCK, block1.block_info, 0)); | 823 BlockBitFlipsFixChecksum(QUARANTINED_BLOCK, block1.block_info, 0)); |
824 EXPECT_TRUE( | 824 EXPECT_TRUE( |
825 BlockBitFlipsFixChecksum(QUARANTINED_BLOCK, block1.block_info, 3)); | 825 BlockBitFlipsFixChecksum(QUARANTINED_BLOCK, block1.block_info, 3)); |
826 flips = BlockBitFlipsRequired(QUARANTINED_BLOCK, block1.block_info, 3); | 826 flips = BlockBitFlipsRequired(QUARANTINED_BLOCK, block1.block_info, 3); |
827 EXPECT_LT(0u, flips); | 827 EXPECT_LT(0u, flips); |
828 EXPECT_GE(3u, flips); | 828 EXPECT_GE(3u, flips); |
829 } | 829 } |
830 | 830 |
831 } // namespace asan | 831 } // namespace asan |
832 } // namespace agent | 832 } // namespace agent |
OLD | NEW |