| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "mojo/edk/system/options_validation.h" | 5 #include "mojo/edk/system/options_validation.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "mojo/public/c/system/macros.h" | 10 #include "mojo/public/c/system/macros.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 | 90 |
| 91 // These test invalid arguments that should cause death if we're being paranoid | 91 // These test invalid arguments that should cause death if we're being paranoid |
| 92 // about checking arguments (which we would want to do if, e.g., we were in a | 92 // about checking arguments (which we would want to do if, e.g., we were in a |
| 93 // true "kernel" situation, but we might not want to do otherwise for | 93 // true "kernel" situation, but we might not want to do otherwise for |
| 94 // performance reasons). Probably blatant errors like passing in null pointers | 94 // performance reasons). Probably blatant errors like passing in null pointers |
| 95 // (for required pointer arguments) will still cause death, but perhaps not | 95 // (for required pointer arguments) will still cause death, but perhaps not |
| 96 // predictably. | 96 // predictably. |
| 97 TEST(OptionsValidationTest, InvalidDeath) { | 97 TEST(OptionsValidationTest, InvalidDeath) { |
| 98 #if defined(OFFICIAL_BUILD) |
| 99 const char kMemoryCheckFailedRegex[] = ""; |
| 100 #else |
| 98 const char kMemoryCheckFailedRegex[] = "Check failed"; | 101 const char kMemoryCheckFailedRegex[] = "Check failed"; |
| 102 #endif |
| 99 | 103 |
| 100 // Null: | 104 // Null: |
| 101 EXPECT_DEATH_IF_SUPPORTED( | 105 EXPECT_DEATH_IF_SUPPORTED( |
| 102 { UserOptionsReader<TestOptions> reader((nullptr)); }, | 106 { UserOptionsReader<TestOptions> reader((nullptr)); }, |
| 103 kMemoryCheckFailedRegex); | 107 kMemoryCheckFailedRegex); |
| 104 | 108 |
| 105 // Unaligned: | 109 // Unaligned: |
| 106 EXPECT_DEATH_IF_SUPPORTED( | 110 EXPECT_DEATH_IF_SUPPORTED( |
| 107 { | 111 { |
| 108 UserOptionsReader<TestOptions> reader( | 112 UserOptionsReader<TestOptions> reader( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 121 : reinterpret_cast<TestOptions*>(&buffer[0]); | 125 : reinterpret_cast<TestOptions*>(&buffer[0]); |
| 122 options->struct_size = static_cast<uint32_t>(sizeof(TestOptions)); | 126 options->struct_size = static_cast<uint32_t>(sizeof(TestOptions)); |
| 123 UserOptionsReader<TestOptions> reader(options); | 127 UserOptionsReader<TestOptions> reader(options); |
| 124 }, | 128 }, |
| 125 kMemoryCheckFailedRegex); | 129 kMemoryCheckFailedRegex); |
| 126 } | 130 } |
| 127 | 131 |
| 128 } // namespace | 132 } // namespace |
| 129 } // namespace edk | 133 } // namespace edk |
| 130 } // namespace mojo | 134 } // namespace mojo |
| OLD | NEW |