| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Fuzz testing for EncodedProgram serialized format and assembly. | 5 // Fuzz testing for EncodedProgram serialized format and assembly. |
| 6 // | 6 // |
| 7 // We would like some assurance that if an EncodedProgram is malformed we will | 7 // We would like some assurance that if an EncodedProgram is malformed we will |
| 8 // not crash. The EncodedProgram could be malformed either due to malicious | 8 // not crash. The EncodedProgram could be malformed either due to malicious |
| 9 // attack to due to an error in patch generation. | 9 // attack to due to an error in patch generation. |
| 10 // | 10 // |
| 11 // We try a lot of arbitrary modifications to the serialized form and make sure | 11 // We try a lot of arbitrary modifications to the serialized form and make sure |
| 12 // that the outcome is not a crash. | 12 // that the outcome is not a crash. |
| 13 | 13 |
| 14 #include "base/test/test_suite.h" | 14 #include "base/test/test_suite.h" |
| 15 | 15 |
| 16 #include <stddef.h> |
| 17 |
| 16 #include "courgette/base_test_unittest.h" | 18 #include "courgette/base_test_unittest.h" |
| 17 #include "courgette/courgette.h" | 19 #include "courgette/courgette.h" |
| 18 #include "courgette/streams.h" | 20 #include "courgette/streams.h" |
| 19 | 21 |
| 20 class DecodeFuzzTest : public BaseTest { | 22 class DecodeFuzzTest : public BaseTest { |
| 21 public: | 23 public: |
| 22 void FuzzExe(const char *) const; | 24 void FuzzExe(const char *) const; |
| 23 | 25 |
| 24 private: | 26 private: |
| 25 void FuzzByte(const std::string& buffer, const std::string& output, | 27 void FuzzByte(const std::string& buffer, const std::string& output, |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 } | 200 } |
| 199 | 201 |
| 200 TEST_F(DecodeFuzzTest, All) { | 202 TEST_F(DecodeFuzzTest, All) { |
| 201 FuzzExe("setup1.exe"); | 203 FuzzExe("setup1.exe"); |
| 202 FuzzExe("elf-32-1.exe"); | 204 FuzzExe("elf-32-1.exe"); |
| 203 } | 205 } |
| 204 | 206 |
| 205 int main(int argc, char** argv) { | 207 int main(int argc, char** argv) { |
| 206 return base::TestSuite(argc, argv).Run(); | 208 return base::TestSuite(argc, argv).Run(); |
| 207 } | 209 } |
| OLD | NEW |