| 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/file.h" | 7 #include "bin/file.h" |
| 8 | 8 |
| 9 #include "vm/benchmark_test.h" | 9 #include "vm/benchmark_test.h" |
| 10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
| 11 #include "bin/dartutils.h" | 11 #include "bin/dartutils.h" |
| 12 #include "vm/unit_test.h" | 12 #include "vm/unit_test.h" |
| 13 | 13 |
| 14 | 14 |
| 15 // TODO(iposva, asiva): This is a placeholder for the real unittest framework. | 15 // TODO(iposva, asiva): This is a placeholder for the real unittest framework. |
| 16 namespace dart { | 16 namespace dart { |
| 17 | 17 |
| 18 // vm_isolate_snapshot_buffer points to a snapshot for the vm isolate if we |
| 19 // link in a snapshot otherwise it is initialized to NULL. |
| 20 extern const uint8_t* bin::vm_isolate_snapshot_buffer; |
| 21 |
| 18 // Only run tests that match the filter string. The default does not match any | 22 // Only run tests that match the filter string. The default does not match any |
| 19 // tests. | 23 // tests. |
| 20 static const char* const kNone = "No Test or Benchmarks"; | 24 static const char* const kNone = "No Test or Benchmarks"; |
| 21 static const char* const kList = "List all Tests and Benchmarks"; | 25 static const char* const kList = "List all Tests and Benchmarks"; |
| 22 static const char* const kAllBenchmarks = "All Benchmarks"; | 26 static const char* const kAllBenchmarks = "All Benchmarks"; |
| 23 static const char* run_filter = kNone; | 27 static const char* run_filter = kNone; |
| 24 | 28 |
| 25 static int run_matches = 0; | 29 static int run_matches = 0; |
| 26 | 30 |
| 27 | 31 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 // Last argument is the test name, the rest are vm flags. | 94 // Last argument is the test name, the rest are vm flags. |
| 91 run_filter = argv[argc - 1]; | 95 run_filter = argv[argc - 1]; |
| 92 // Remove the first value (executable) from the arguments and | 96 // Remove the first value (executable) from the arguments and |
| 93 // exclude the last argument which is the test name. | 97 // exclude the last argument which is the test name. |
| 94 dart_argc = argc - 2; | 98 dart_argc = argc - 2; |
| 95 dart_argv = &argv[1]; | 99 dart_argv = &argv[1]; |
| 96 } | 100 } |
| 97 bool set_vm_flags_success = Flags::ProcessCommandLineFlags(dart_argc, | 101 bool set_vm_flags_success = Flags::ProcessCommandLineFlags(dart_argc, |
| 98 dart_argv); | 102 dart_argv); |
| 99 ASSERT(set_vm_flags_success); | 103 ASSERT(set_vm_flags_success); |
| 100 const char* err_msg = Dart::InitOnce(NULL, | 104 const char* err_msg = Dart::InitOnce(dart::bin::vm_isolate_snapshot_buffer, |
| 101 NULL, NULL, NULL, NULL, | 105 NULL, NULL, NULL, NULL, |
| 102 dart::bin::DartUtils::OpenFile, | 106 dart::bin::DartUtils::OpenFile, |
| 103 dart::bin::DartUtils::ReadFile, | 107 dart::bin::DartUtils::ReadFile, |
| 104 dart::bin::DartUtils::WriteFile, | 108 dart::bin::DartUtils::WriteFile, |
| 105 dart::bin::DartUtils::CloseFile, | 109 dart::bin::DartUtils::CloseFile, |
| 106 NULL); | 110 NULL); |
| 107 ASSERT(err_msg == NULL); | 111 ASSERT(err_msg == NULL); |
| 108 // Apply the filter to all registered tests. | 112 // Apply the filter to all registered tests. |
| 109 TestCaseBase::RunAll(); | 113 TestCaseBase::RunAll(); |
| 110 // Apply the filter to all registered benchmarks. | 114 // Apply the filter to all registered benchmarks. |
| 111 Benchmark::RunAll(argv[0]); | 115 Benchmark::RunAll(argv[0]); |
| 112 // Print a warning message if no tests or benchmarks were matched. | 116 // Print a warning message if no tests or benchmarks were matched. |
| 113 if (run_matches == 0) { | 117 if (run_matches == 0) { |
| 114 fprintf(stderr, "No tests matched: %s\n", run_filter); | 118 fprintf(stderr, "No tests matched: %s\n", run_filter); |
| 115 return 1; | 119 return 1; |
| 116 } | 120 } |
| 117 return 0; | 121 return 0; |
| 118 } | 122 } |
| 119 | 123 |
| 120 } // namespace dart | 124 } // namespace dart |
| 121 | 125 |
| 122 | 126 |
| 123 int main(int argc, const char** argv) { | 127 int main(int argc, const char** argv) { |
| 124 return dart::Main(argc, argv); | 128 return dart::Main(argc, argv); |
| 125 } | 129 } |
| OLD | NEW |