Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(633)

Side by Side Diff: runtime/bin/run_vm_tests.cc

Issue 11018014: Change run_vm_tests to take the VM arguments before the test name so (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/testing/dart/test_suite.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 delete pprof_file; // Closes the file. 78 delete pprof_file; // Closes the file.
79 Dart_ExitScope(); 79 Dart_ExitScope();
80 Dart_ShutdownIsolate(); 80 Dart_ShutdownIsolate();
81 } 81 }
82 } 82 }
83 83
84 84
85 static void PrintUsage() { 85 static void PrintUsage() {
86 fprintf(stderr, "run_vm_tests [--list | --benchmarks | " 86 fprintf(stderr, "run_vm_tests [--list | --benchmarks | "
87 "--tests | --all | <test name> | <benchmark name>]\n"); 87 "--tests | --all | <test name> | <benchmark name>]\n");
88 fprintf(stderr, "run_vm_tests <test name> [vm-flags ...]\n"); 88 fprintf(stderr, "run_vm_tests <test name> [vm-flags ...]\n");
ricow1 2012/10/01 13:50:28 we should update these to reflect the new structur
Mads Ager (google) 2012/10/01 14:03:38 Done.
89 fprintf(stderr, "run_vm_tests <benchmark name> [flags ...]\n"); 89 fprintf(stderr, "run_vm_tests <benchmark name> [flags ...]\n");
90 } 90 }
91 91
92 92
93 static int Main(int argc, const char** argv) { 93 static int Main(int argc, const char** argv) {
94 // Flags being passed to the Dart VM. 94 // Flags being passed to the Dart VM.
95 int dart_argc = 0; 95 int dart_argc = 0;
96 const char** dart_argv = NULL; 96 const char** dart_argv = NULL;
97 const char* pprof_filename = NULL; 97 const char* pprof_filename = NULL;
98 98
99 if (argc < 2) { 99 if (argc < 2) {
100 // Bad parameter count. 100 // Bad parameter count.
101 PrintUsage(); 101 PrintUsage();
102 return 1; 102 return 1;
103 } else if (argc == 2) { 103 } else if (argc == 2) {
ricow1 2012/10/01 13:50:28 I think we may need to update the functionality in
Mads Ager (google) 2012/10/01 14:03:38 This is the argc == 2 case where argv[0] is the ex
104 if (strcmp(argv[1], "--list") == 0) { 104 if (strcmp(argv[1], "--list") == 0) {
105 run_filter = kList; 105 run_filter = kList;
106 // List all tests and benchmarks and exit without initializing the VM. 106 // List all tests and benchmarks and exit without initializing the VM.
107 TestCaseBase::RunAll(); 107 TestCaseBase::RunAll();
108 Benchmark::RunAll(argv[0]); 108 Benchmark::RunAll(argv[0]);
109 return 0; 109 return 0;
110 } else if (strcmp(argv[1], "--all") == 0) { 110 } else if (strcmp(argv[1], "--all") == 0) {
111 run_filter = kAll; 111 run_filter = kAll;
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 // First 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[1]; 121 run_filter = argv[argc - 1];
122 const char* pprof_option = "--generate_pprof_symbols="; 122 const char* pprof_option = "--generate_pprof_symbols=";
123 int length = strlen(pprof_option); 123 int length = strlen(pprof_option);
124 if (strncmp(pprof_option, argv[2], length) == 0) { 124 if (strncmp(pprof_option, argv[1], length) == 0) {
125 pprof_filename = (argv[2] + length); 125 pprof_filename = (argv[1] + length);
126 Dart_InitPprofSupport(); 126 Dart_InitPprofSupport();
127 // Remove the first three values from the arguments. 127 // Remove the first two values (executable, pprof flag) from the
128 // arguments and exclude the last argument which is the test name.
128 dart_argc = argc - 3; 129 dart_argc = argc - 3;
129 dart_argv = &argv[3]; 130 dart_argv = &argv[2];
130 } else { 131 } else {
131 // Remove the first two values from the arguments. 132 // Remove the first value (executable) from the arguments and
133 // exclude the last argument which is the test name.
132 dart_argc = argc - 2; 134 dart_argc = argc - 2;
133 dart_argv = &argv[2]; 135 dart_argv = &argv[1];
134 } 136 }
135 } 137 }
136 bool set_vm_flags_success = Flags::ProcessCommandLineFlags(dart_argc, 138 bool set_vm_flags_success = Flags::ProcessCommandLineFlags(dart_argc,
137 dart_argv); 139 dart_argv);
138 ASSERT(set_vm_flags_success); 140 ASSERT(set_vm_flags_success);
139 bool init_success = Dart::InitOnce(NULL, NULL, NULL); 141 bool init_success = Dart::InitOnce(NULL, NULL, NULL);
140 ASSERT(init_success); 142 ASSERT(init_success);
141 // Apply the filter to all registered tests. 143 // Apply the filter to all registered tests.
142 TestCaseBase::RunAll(); 144 TestCaseBase::RunAll();
143 // Apply the filter to all registered benchmarks. 145 // Apply the filter to all registered benchmarks.
144 Benchmark::RunAll(argv[0]); 146 Benchmark::RunAll(argv[0]);
145 // Print a warning message if no tests or benchmarks were matched. 147 // Print a warning message if no tests or benchmarks were matched.
146 if (run_matches == 0) { 148 if (run_matches == 0) {
147 fprintf(stderr, "No tests matched: %s\n", run_filter); 149 fprintf(stderr, "No tests matched: %s\n", run_filter);
148 return 1; 150 return 1;
149 } 151 }
150 // Dump symbol information for the profiler. 152 // Dump symbol information for the profiler.
151 DumpPprofSymbolInfo(pprof_filename); 153 DumpPprofSymbolInfo(pprof_filename);
152 return 0; 154 return 0;
153 } 155 }
154 156
155 } // namespace dart 157 } // namespace dart
156 158
157 159
158 int main(int argc, const char** argv) { 160 int main(int argc, const char** argv) {
159 return dart::Main(argc, argv); 161 return dart::Main(argc, argv);
160 } 162 }
OLDNEW
« no previous file with comments | « no previous file | tools/testing/dart/test_suite.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698