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