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" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 fprintf(stdout, "%s\n", this->name()); | 48 fprintf(stdout, "%s\n", this->name()); |
49 run_matches++; | 49 run_matches++; |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 | 53 |
54 void Benchmark::RunBenchmark() { | 54 void Benchmark::RunBenchmark() { |
55 if ((run_filter == kAllBenchmarks) || | 55 if ((run_filter == kAllBenchmarks) || |
56 (strcmp(run_filter, this->name()) == 0)) { | 56 (strcmp(run_filter, this->name()) == 0)) { |
57 this->Run(); | 57 this->Run(); |
58 OS::Print("%s(%s): %" Pd64 "\n", | 58 OS::Print("%s(%s): %" Pd64 "\n", this->name(), this->score_kind(), |
59 this->name(), this->score_kind(), this->score()); | 59 this->score()); |
60 run_matches++; | 60 run_matches++; |
61 } else if (run_filter == kList) { | 61 } else if (run_filter == kList) { |
62 fprintf(stdout, "%s\n", this->name()); | 62 fprintf(stdout, "%s\n", this->name()); |
63 run_matches++; | 63 run_matches++; |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 | 67 |
68 static void PrintUsage() { | 68 static void PrintUsage() { |
69 fprintf(stderr, "run_vm_tests [--list | --benchmarks | " | 69 fprintf(stderr, |
70 "<test name> | <benchmark name>]\n"); | 70 "run_vm_tests [--list | --benchmarks | " |
| 71 "<test name> | <benchmark name>]\n"); |
71 fprintf(stderr, "run_vm_tests [vm-flags ...] <test name>\n"); | 72 fprintf(stderr, "run_vm_tests [vm-flags ...] <test name>\n"); |
72 fprintf(stderr, "run_vm_tests [vm-flags ...] <benchmark name>\n"); | 73 fprintf(stderr, "run_vm_tests [vm-flags ...] <benchmark name>\n"); |
73 } | 74 } |
74 | 75 |
75 | 76 |
76 static int Main(int argc, const char** argv) { | 77 static int Main(int argc, const char** argv) { |
77 // Flags being passed to the Dart VM. | 78 // Flags being passed to the Dart VM. |
78 int dart_argc = 0; | 79 int dart_argc = 0; |
79 const char** dart_argv = NULL; | 80 const char** dart_argv = NULL; |
80 | 81 |
(...skipping 15 matching lines...) Expand all Loading... |
96 run_filter = argv[1]; | 97 run_filter = argv[1]; |
97 } | 98 } |
98 } else { | 99 } else { |
99 // Last argument is the test name, the rest are vm flags. | 100 // Last argument is the test name, the rest are vm flags. |
100 run_filter = argv[argc - 1]; | 101 run_filter = argv[argc - 1]; |
101 // Remove the first value (executable) from the arguments and | 102 // Remove the first value (executable) from the arguments and |
102 // exclude the last argument which is the test name. | 103 // exclude the last argument which is the test name. |
103 dart_argc = argc - 2; | 104 dart_argc = argc - 2; |
104 dart_argv = &argv[1]; | 105 dart_argv = &argv[1]; |
105 } | 106 } |
106 bool set_vm_flags_success = Flags::ProcessCommandLineFlags(dart_argc, | 107 bool set_vm_flags_success = |
107 dart_argv); | 108 Flags::ProcessCommandLineFlags(dart_argc, dart_argv); |
108 ASSERT(set_vm_flags_success); | 109 ASSERT(set_vm_flags_success); |
109 const char* err_msg = Dart::InitOnce(dart::bin::vm_isolate_snapshot_buffer, | 110 const char* err_msg = Dart::InitOnce( |
110 NULL, NULL, | 111 dart::bin::vm_isolate_snapshot_buffer, NULL, NULL, NULL, NULL, NULL, |
111 NULL, NULL, | 112 dart::bin::DartUtils::OpenFile, dart::bin::DartUtils::ReadFile, |
112 NULL, | 113 dart::bin::DartUtils::WriteFile, dart::bin::DartUtils::CloseFile, NULL, |
113 dart::bin::DartUtils::OpenFile, | 114 NULL); |
114 dart::bin::DartUtils::ReadFile, | |
115 dart::bin::DartUtils::WriteFile, | |
116 dart::bin::DartUtils::CloseFile, | |
117 NULL, | |
118 NULL); | |
119 ASSERT(err_msg == NULL); | 115 ASSERT(err_msg == NULL); |
120 // Apply the filter to all registered tests. | 116 // Apply the filter to all registered tests. |
121 TestCaseBase::RunAll(); | 117 TestCaseBase::RunAll(); |
122 // Apply the filter to all registered benchmarks. | 118 // Apply the filter to all registered benchmarks. |
123 Benchmark::RunAll(argv[0]); | 119 Benchmark::RunAll(argv[0]); |
124 | 120 |
125 err_msg = Dart::Cleanup(); | 121 err_msg = Dart::Cleanup(); |
126 ASSERT(err_msg == NULL); | 122 ASSERT(err_msg == NULL); |
127 | 123 |
128 // Print a warning message if no tests or benchmarks were matched. | 124 // Print a warning message if no tests or benchmarks were matched. |
129 if (run_matches == 0) { | 125 if (run_matches == 0) { |
130 fprintf(stderr, "No tests matched: %s\n", run_filter); | 126 fprintf(stderr, "No tests matched: %s\n", run_filter); |
131 return 1; | 127 return 1; |
132 } | 128 } |
133 if (DynamicAssertionHelper::failed()) { | 129 if (DynamicAssertionHelper::failed()) { |
134 return 255; | 130 return 255; |
135 } | 131 } |
136 return 0; | 132 return 0; |
137 } | 133 } |
138 | 134 |
139 } // namespace dart | 135 } // namespace dart |
140 | 136 |
141 | 137 |
142 int main(int argc, const char** argv) { | 138 int main(int argc, const char** argv) { |
143 dart::bin::Platform::Exit(dart::Main(argc, argv)); | 139 dart::bin::Platform::Exit(dart::Main(argc, argv)); |
144 } | 140 } |
OLD | NEW |