| 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" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } else if (strcmp(argv[1], "--tests") == 0) { | 112 } else if (strcmp(argv[1], "--tests") == 0) { |
| 113 run_filter = kAllTests; | 113 run_filter = kAllTests; |
| 114 } else if (strcmp(argv[1], "--benchmarks") == 0) { | 114 } else if (strcmp(argv[1], "--benchmarks") == 0) { |
| 115 run_filter = kAllBenchmarks; | 115 run_filter = kAllBenchmarks; |
| 116 } else { | 116 } else { |
| 117 run_filter = argv[1]; | 117 run_filter = argv[1]; |
| 118 } | 118 } |
| 119 } else { | 119 } else { |
| 120 // Last argument is the test name, the rest are vm flags. | 120 // Last argument is the test name, the rest are vm flags. |
| 121 run_filter = argv[argc - 1]; | 121 run_filter = argv[argc - 1]; |
| 122 const char* pprof_option = "--generate_pprof_symbols="; | 122 // Remove the first value (executable) from the arguments and |
| 123 int length = strlen(pprof_option); | 123 // exclude the last argument which is the test name. |
| 124 if (strncmp(pprof_option, argv[1], length) == 0) { | 124 dart_argc = argc - 2; |
| 125 pprof_filename = (argv[1] + length); | 125 dart_argv = &argv[1]; |
| 126 Dart_InitPprofSupport(); | |
| 127 // Remove the first two values (executable, pprof flag) from the | |
| 128 // arguments and exclude the last argument which is the test name. | |
| 129 dart_argc = argc - 3; | |
| 130 dart_argv = &argv[2]; | |
| 131 } else { | |
| 132 // Remove the first value (executable) from the arguments and | |
| 133 // exclude the last argument which is the test name. | |
| 134 dart_argc = argc - 2; | |
| 135 dart_argv = &argv[1]; | |
| 136 } | |
| 137 } | 126 } |
| 138 bool set_vm_flags_success = Flags::ProcessCommandLineFlags(dart_argc, | 127 bool set_vm_flags_success = Flags::ProcessCommandLineFlags(dart_argc, |
| 139 dart_argv); | 128 dart_argv); |
| 140 ASSERT(set_vm_flags_success); | 129 ASSERT(set_vm_flags_success); |
| 141 const char* err_msg = Dart::InitOnce(NULL, NULL, NULL, NULL, | 130 const char* err_msg = Dart::InitOnce(NULL, NULL, NULL, NULL, |
| 142 NULL, NULL, NULL); | 131 NULL, NULL, NULL); |
| 143 ASSERT(err_msg == NULL); | 132 ASSERT(err_msg == NULL); |
| 144 // Apply the filter to all registered tests. | 133 // Apply the filter to all registered tests. |
| 145 TestCaseBase::RunAll(); | 134 TestCaseBase::RunAll(); |
| 146 // Apply the filter to all registered benchmarks. | 135 // Apply the filter to all registered benchmarks. |
| 147 Benchmark::RunAll(argv[0]); | 136 Benchmark::RunAll(argv[0]); |
| 148 // Print a warning message if no tests or benchmarks were matched. | 137 // Print a warning message if no tests or benchmarks were matched. |
| 149 if (run_matches == 0) { | 138 if (run_matches == 0) { |
| 150 fprintf(stderr, "No tests matched: %s\n", run_filter); | 139 fprintf(stderr, "No tests matched: %s\n", run_filter); |
| 151 return 1; | 140 return 1; |
| 152 } | 141 } |
| 153 // Dump symbol information for the profiler. | 142 // Dump symbol information for the profiler. |
| 154 DumpPprofSymbolInfo(pprof_filename); | 143 DumpPprofSymbolInfo(pprof_filename); |
| 155 return 0; | 144 return 0; |
| 156 } | 145 } |
| 157 | 146 |
| 158 } // namespace dart | 147 } // namespace dart |
| 159 | 148 |
| 160 | 149 |
| 161 int main(int argc, const char** argv) { | 150 int main(int argc, const char** argv) { |
| 162 return dart::Main(argc, argv); | 151 return dart::Main(argc, argv); |
| 163 } | 152 } |
| OLD | NEW |