| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <set> | 5 #include <set> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 .AppendASCII("validation"); | 33 .AppendASCII("validation"); |
| 34 | 34 |
| 35 return path.AsUTF8Unsafe(); | 35 return path.AsUTF8Unsafe(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 bool GenerateEntropy(uint8_t* buffer, intptr_t length) { | 38 bool GenerateEntropy(uint8_t* buffer, intptr_t length) { |
| 39 base::RandBytes(static_cast<void*>(buffer), length); | 39 base::RandBytes(static_cast<void*>(buffer), length); |
| 40 return true; | 40 return true; |
| 41 } | 41 } |
| 42 | 42 |
| 43 void ExceptionCallback(bool* exception, Dart_Handle error) { | 43 void ExceptionCallback(bool* exception, |
| 44 int64_t* closed_handles, |
| 45 Dart_Handle error, |
| 46 int64_t count) { |
| 44 *exception = true; | 47 *exception = true; |
| 48 *closed_handles = count; |
| 45 } | 49 } |
| 46 | 50 |
| 47 // Enumerates files inside |path| and collects all data needed to run | 51 // Enumerates files inside |path| and collects all data needed to run |
| 48 // conformance tests. | 52 // conformance tests. |
| 49 // For each test there are three entries in the returned vector. | 53 // For each test there are three entries in the returned vector. |
| 50 // [0] -> test name. | 54 // [0] -> test name. |
| 51 // [1] -> contents of test's .data file. | 55 // [1] -> contents of test's .data file. |
| 52 // [2] -> contents of test's .expected file. | 56 // [2] -> contents of test's .expected file. |
| 53 std::vector<std::string> CollectTests(base::FilePath path) { | 57 std::vector<std::string> CollectTests(base::FilePath path) { |
| 54 base::FileEnumerator enumerator(path, false, base::FileEnumerator::FILES); | 58 base::FileEnumerator enumerator(path, false, base::FileEnumerator::FILES); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 115 |
| 112 // Setup the package root. | 116 // Setup the package root. |
| 113 base::FilePath package_root; | 117 base::FilePath package_root; |
| 114 PathService::Get(base::DIR_EXE, &package_root); | 118 PathService::Get(base::DIR_EXE, &package_root); |
| 115 package_root = package_root.AppendASCII("gen") | 119 package_root = package_root.AppendASCII("gen") |
| 116 .AppendASCII("dart-pkg") | 120 .AppendASCII("dart-pkg") |
| 117 .AppendASCII("packages"); | 121 .AppendASCII("packages"); |
| 118 | 122 |
| 119 char* error = NULL; | 123 char* error = NULL; |
| 120 bool unhandled_exception = false; | 124 bool unhandled_exception = false; |
| 125 int64_t closed_handles = 0; |
| 121 DartControllerConfig config; | 126 DartControllerConfig config; |
| 122 // Run with strict compilation even in Release mode so that ASAN testing gets | 127 // Run with strict compilation even in Release mode so that ASAN testing gets |
| 123 // coverage of Dart asserts, type-checking, etc. | 128 // coverage of Dart asserts, type-checking, etc. |
| 124 config.strict_compilation = true; | 129 config.strict_compilation = true; |
| 125 config.script_uri = path.value(); | 130 config.script_uri = path.value(); |
| 126 config.package_root = package_root.AsUTF8Unsafe(); | 131 config.package_root = package_root.AsUTF8Unsafe(); |
| 127 config.callbacks.exception = | 132 config.callbacks.exception = |
| 128 base::Bind(&ExceptionCallback, &unhandled_exception); | 133 base::Bind(&ExceptionCallback, &unhandled_exception, &closed_handles); |
| 129 config.entropy = GenerateEntropy; | 134 config.entropy = GenerateEntropy; |
| 130 config.SetVmFlags(nullptr, 0); | 135 config.SetVmFlags(nullptr, 0); |
| 131 config.error = &error; | 136 config.error = &error; |
| 132 config.SetScriptFlags(arguments_c_str.data(), arguments_c_str.size()); | 137 config.SetScriptFlags(arguments_c_str.data(), arguments_c_str.size()); |
| 133 | 138 |
| 134 bool success = DartController::RunSingleDartScript(config); | 139 bool success = DartController::RunSingleDartScript(config); |
| 135 EXPECT_TRUE(success) << error; | 140 EXPECT_TRUE(success) << error; |
| 136 EXPECT_FALSE(unhandled_exception); | 141 EXPECT_FALSE(unhandled_exception); |
| 142 EXPECT_EQ(closed_handles, 0); |
| 137 } | 143 } |
| 138 | 144 |
| 139 TEST(DartTest, validation) { | 145 TEST(DartTest, validation) { |
| 140 RunTest(GetPath()); | 146 RunTest(GetPath()); |
| 141 } | 147 } |
| 142 | 148 |
| 143 } // namespace | 149 } // namespace |
| 144 } // namespace dart | 150 } // namespace dart |
| 145 } // namespace mojo | 151 } // namespace mojo |
| OLD | NEW |