| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stdint.h> |
| 6 |
| 5 #include "components/nacl/loader/nacl_validation_db.h" | 7 #include "components/nacl/loader/nacl_validation_db.h" |
| 6 #include "components/nacl/loader/nacl_validation_query.h" | 8 #include "components/nacl/loader/nacl_validation_query.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 10 |
| 9 // This test makes sure that validation signature generation is performed | 11 // This test makes sure that validation signature generation is performed |
| 10 // correctly. In effect, this means that we are checking all of the data | 12 // correctly. In effect, this means that we are checking all of the data |
| 11 // (and no other data) we are passing the signature generator affects the final | 13 // (and no other data) we are passing the signature generator affects the final |
| 12 // signature. To avoid tying the tests to a particular implementation, each | 14 // signature. To avoid tying the tests to a particular implementation, each |
| 13 // test generates two signatures and compares them rather than trying to compare | 15 // test generates two signatures and compares them rather than trying to compare |
| 14 // against a specified signature. | 16 // against a specified signature. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 NaClValidationQuery::kDigestLength); | 66 NaClValidationQuery::kDigestLength); |
| 65 // Signatures should be the same. | 67 // Signatures should be the same. |
| 66 EXPECT_EQ(0, memcmp(query_signature_, set_signature_, | 68 EXPECT_EQ(0, memcmp(query_signature_, set_signature_, |
| 67 NaClValidationQuery::kDigestLength)); | 69 NaClValidationQuery::kDigestLength)); |
| 68 } | 70 } |
| 69 | 71 |
| 70 bool did_query_; | 72 bool did_query_; |
| 71 bool did_set_; | 73 bool did_set_; |
| 72 bool status_; | 74 bool status_; |
| 73 | 75 |
| 74 uint8 query_signature_[NaClValidationQuery::kDigestLength]; | 76 uint8_t query_signature_[NaClValidationQuery::kDigestLength]; |
| 75 uint8 set_signature_[NaClValidationQuery::kDigestLength]; | 77 uint8_t set_signature_[NaClValidationQuery::kDigestLength]; |
| 76 }; | 78 }; |
| 77 | 79 |
| 78 class TestQuery { | 80 class TestQuery { |
| 79 public: | 81 public: |
| 80 TestQuery(const char* key, const char* version) { | 82 TestQuery(const char* key, const char* version) { |
| 81 db.reset(new MockValidationDB()); | 83 db.reset(new MockValidationDB()); |
| 82 context.reset(new NaClValidationQueryContext(db.get(), key, version)); | 84 context.reset(new NaClValidationQueryContext(db.get(), key, version)); |
| 83 query.reset(context->CreateQuery()); | 85 query.reset(context->CreateQuery()); |
| 84 } | 86 } |
| 85 | 87 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 query1->query->AddData(kShortData, sizeof(kShortData)); | 269 query1->query->AddData(kShortData, sizeof(kShortData)); |
| 268 query1->query->QueryKnownToValidate(); | 270 query1->query->QueryKnownToValidate(); |
| 269 | 271 |
| 270 query2->query->AddData(kShortData, sizeof(kShortData)); | 272 query2->query->AddData(kShortData, sizeof(kShortData)); |
| 271 query2->query->QueryKnownToValidate(); | 273 query2->query->QueryKnownToValidate(); |
| 272 | 274 |
| 273 AssertQueryDifferent(); | 275 AssertQueryDifferent(); |
| 274 } | 276 } |
| 275 | 277 |
| 276 } | 278 } |
| OLD | NEW |