Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #include "gtest/gtest.h" | 7 #include "gtest/gtest.h" |
| 8 | 8 |
| 9 #include "native_client/src/include/nacl_compiler_annotations.h" | 9 #include "native_client/src/include/nacl_compiler_annotations.h" |
| 10 #include "native_client/src/shared/platform/nacl_log.h" | 10 #include "native_client/src/shared/platform/nacl_log.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 bundle_size = 32; | 127 bundle_size = 32; |
| 128 | 128 |
| 129 memset(code_buffer, 0x90, sizeof(code_buffer)); | 129 memset(code_buffer, 0x90, sizeof(code_buffer)); |
| 130 } | 130 } |
| 131 | 131 |
| 132 NaClValidationStatus Validate() { | 132 NaClValidationStatus Validate() { |
| 133 return NACL_SUBARCH_NAME(ApplyValidator, | 133 return NACL_SUBARCH_NAME(ApplyValidator, |
| 134 NACL_TARGET_ARCH, | 134 NACL_TARGET_ARCH, |
| 135 NACL_TARGET_SUBARCH)( | 135 NACL_TARGET_SUBARCH)( |
| 136 NACL_SB_DEFAULT, | 136 NACL_SB_DEFAULT, |
| 137 NaClApplyCodeValidation, | |
| 138 0, code_buffer, 32, | 137 0, code_buffer, 32, |
| 139 bundle_size, FALSE, &cpu_features, | 138 bundle_size, FALSE, FALSE, &cpu_features, |
|
Mark Seaborn
2012/04/10 00:57:38
Could you add comments for the args here too, perh
Nick Bray (chromium)
2012/04/10 18:49:20
Done.
| |
| 140 &cache); | 139 &cache); |
| 141 } | 140 } |
| 142 }; | 141 }; |
| 143 | 142 |
| 144 TEST_F(ValidationCachingInterfaceTests, Sanity) { | 143 TEST_F(ValidationCachingInterfaceTests, Sanity) { |
| 145 void *query = cache.CreateQuery(cache.handle); | 144 void *query = cache.CreateQuery(cache.handle); |
| 146 cache.AddData(query, NULL, 6); | 145 cache.AddData(query, NULL, 6); |
| 147 cache.AddData(query, NULL, 128); | 146 cache.AddData(query, NULL, 128); |
| 148 EXPECT_EQ(1, cache.QueryKnownToValidate(query)); | 147 EXPECT_EQ(1, cache.QueryKnownToValidate(query)); |
| 149 cache.DestroyQuery(query); | 148 cache.DestroyQuery(query); |
| 150 EXPECT_EQ(true, context.query_destroyed); | 149 EXPECT_EQ(true, context.query_destroyed); |
| 151 } | 150 } |
| 152 | 151 |
| 153 TEST_F(ValidationCachingInterfaceTests, NoCache) { | 152 TEST_F(ValidationCachingInterfaceTests, NoCache) { |
| 154 NaClValidationStatus status = | 153 NaClValidationStatus status = |
| 155 NACL_SUBARCH_NAME(ApplyValidator, | 154 NACL_SUBARCH_NAME(ApplyValidator, |
| 156 NACL_TARGET_ARCH, | 155 NACL_TARGET_ARCH, |
| 157 NACL_TARGET_SUBARCH)( | 156 NACL_TARGET_SUBARCH)( |
| 158 NACL_SB_DEFAULT, | 157 NACL_SB_DEFAULT, |
| 159 NaClApplyCodeValidation, | |
| 160 0, code_buffer, CODE_SIZE, | 158 0, code_buffer, CODE_SIZE, |
| 161 bundle_size, FALSE, &cpu_features, | 159 bundle_size, FALSE, FALSE, &cpu_features, |
| 162 NULL); | 160 NULL); |
| 163 EXPECT_EQ(NaClValidationSucceeded, status); | 161 EXPECT_EQ(NaClValidationSucceeded, status); |
| 164 } | 162 } |
| 165 | 163 |
| 166 TEST_F(ValidationCachingInterfaceTests, CacheHit) { | 164 TEST_F(ValidationCachingInterfaceTests, CacheHit) { |
| 167 NaClValidationStatus status = Validate(); | 165 NaClValidationStatus status = Validate(); |
| 168 EXPECT_EQ(NaClValidationSucceeded, status); | 166 EXPECT_EQ(NaClValidationSucceeded, status); |
| 169 EXPECT_EQ(true, context.query_destroyed); | 167 EXPECT_EQ(true, context.query_destroyed); |
| 170 } | 168 } |
| 171 | 169 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 214 // Test driver function. | 212 // Test driver function. |
| 215 int main(int argc, char *argv[]) { | 213 int main(int argc, char *argv[]) { |
| 216 // The IllegalInst test touches the log mutex deep inside the validator. | 214 // The IllegalInst test touches the log mutex deep inside the validator. |
| 217 // This causes an SEH exception to be thrown on Windows if the mutex is not | 215 // This causes an SEH exception to be thrown on Windows if the mutex is not |
| 218 // initialized. | 216 // initialized. |
| 219 // http://code.google.com/p/nativeclient/issues/detail?id=1696 | 217 // http://code.google.com/p/nativeclient/issues/detail?id=1696 |
| 220 NaClLogModuleInit(); | 218 NaClLogModuleInit(); |
| 221 testing::InitGoogleTest(&argc, argv); | 219 testing::InitGoogleTest(&argc, argv); |
| 222 return RUN_ALL_TESTS(); | 220 return RUN_ALL_TESTS(); |
| 223 } | 221 } |
| OLD | NEW |