OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include <stdio.h> | 5 #include <stdio.h> |
6 | 6 |
7 #include "bin/dartutils.h" | 7 #include "bin/dartutils.h" |
8 #include "bin/file.h" | 8 #include "bin/file.h" |
9 #include "bin/platform.h" | 9 #include "bin/platform.h" |
10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
11 #include "vm/benchmark_test.h" | 11 #include "vm/benchmark_test.h" |
12 #include "vm/dart.h" | 12 #include "vm/dart.h" |
13 #include "vm/unit_test.h" | 13 #include "vm/unit_test.h" |
14 | 14 |
15 | 15 |
16 // TODO(iposva, asiva): This is a placeholder for the real unittest framework. | 16 // TODO(iposva, asiva): This is a placeholder for the real unittest framework. |
17 namespace dart { | 17 namespace dart { |
18 | 18 |
19 // Defined in vm/os_thread_win.cc | 19 // Defined in vm/os_thread_win.cc |
20 extern bool private_flag_windows_run_tls_destructors; | 20 extern bool private_flag_windows_run_tls_destructors; |
21 | 21 |
22 // vm_isolate_snapshot_buffer points to a snapshot for the vm isolate if we | 22 // vm_snapshot_data_buffer points to a snapshot for the vm isolate if we |
23 // link in a snapshot otherwise it is initialized to NULL. | 23 // link in a snapshot otherwise it is initialized to NULL. |
24 extern const uint8_t* bin::vm_isolate_snapshot_buffer; | 24 extern const uint8_t* bin::vm_snapshot_data; |
| 25 extern const uint8_t* bin::vm_snapshot_instructions; |
25 | 26 |
26 // Only run tests that match the filter string. The default does not match any | 27 // Only run tests that match the filter string. The default does not match any |
27 // tests. | 28 // tests. |
28 static const char* const kNone = "No Test or Benchmarks"; | 29 static const char* const kNone = "No Test or Benchmarks"; |
29 static const char* const kList = "List all Tests and Benchmarks"; | 30 static const char* const kList = "List all Tests and Benchmarks"; |
30 static const char* const kAllBenchmarks = "All Benchmarks"; | 31 static const char* const kAllBenchmarks = "All Benchmarks"; |
31 static const char* run_filter = kNone; | 32 static const char* run_filter = kNone; |
32 | 33 |
33 static int run_matches = 0; | 34 static int run_matches = 0; |
34 | 35 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 run_filter = argv[argc - 1]; | 102 run_filter = argv[argc - 1]; |
102 // Remove the first value (executable) from the arguments and | 103 // Remove the first value (executable) from the arguments and |
103 // exclude the last argument which is the test name. | 104 // exclude the last argument which is the test name. |
104 dart_argc = argc - 2; | 105 dart_argc = argc - 2; |
105 dart_argv = &argv[1]; | 106 dart_argv = &argv[1]; |
106 } | 107 } |
107 bool set_vm_flags_success = | 108 bool set_vm_flags_success = |
108 Flags::ProcessCommandLineFlags(dart_argc, dart_argv); | 109 Flags::ProcessCommandLineFlags(dart_argc, dart_argv); |
109 ASSERT(set_vm_flags_success); | 110 ASSERT(set_vm_flags_success); |
110 const char* err_msg = Dart::InitOnce( | 111 const char* err_msg = Dart::InitOnce( |
111 dart::bin::vm_isolate_snapshot_buffer, NULL, NULL, NULL, NULL, NULL, | 112 dart::bin::vm_snapshot_data, dart::bin::vm_snapshot_instructions, NULL, |
112 dart::bin::DartUtils::OpenFile, dart::bin::DartUtils::ReadFile, | 113 NULL, NULL, dart::bin::DartUtils::OpenFile, |
113 dart::bin::DartUtils::WriteFile, dart::bin::DartUtils::CloseFile, NULL, | 114 dart::bin::DartUtils::ReadFile, dart::bin::DartUtils::WriteFile, |
114 NULL); | 115 dart::bin::DartUtils::CloseFile, NULL, NULL); |
115 ASSERT(err_msg == NULL); | 116 ASSERT(err_msg == NULL); |
116 // Apply the filter to all registered tests. | 117 // Apply the filter to all registered tests. |
117 TestCaseBase::RunAll(); | 118 TestCaseBase::RunAll(); |
118 // Apply the filter to all registered benchmarks. | 119 // Apply the filter to all registered benchmarks. |
119 Benchmark::RunAll(argv[0]); | 120 Benchmark::RunAll(argv[0]); |
120 | 121 |
121 err_msg = Dart::Cleanup(); | 122 err_msg = Dart::Cleanup(); |
122 ASSERT(err_msg == NULL); | 123 ASSERT(err_msg == NULL); |
123 | 124 |
124 // Print a warning message if no tests or benchmarks were matched. | 125 // Print a warning message if no tests or benchmarks were matched. |
125 if (run_matches == 0) { | 126 if (run_matches == 0) { |
126 fprintf(stderr, "No tests matched: %s\n", run_filter); | 127 fprintf(stderr, "No tests matched: %s\n", run_filter); |
127 return 1; | 128 return 1; |
128 } | 129 } |
129 if (DynamicAssertionHelper::failed()) { | 130 if (DynamicAssertionHelper::failed()) { |
130 return 255; | 131 return 255; |
131 } | 132 } |
132 return 0; | 133 return 0; |
133 } | 134 } |
134 | 135 |
135 } // namespace dart | 136 } // namespace dart |
136 | 137 |
137 | 138 |
138 int main(int argc, const char** argv) { | 139 int main(int argc, const char** argv) { |
139 dart::bin::Platform::Exit(dart::Main(argc, argv)); | 140 dart::bin::Platform::Exit(dart::Main(argc, argv)); |
140 } | 141 } |
OLD | NEW |