| 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/dfe.h" | 8 #include "bin/dfe.h" |
| 9 #include "bin/file.h" | 9 #include "bin/file.h" |
| 10 #include "bin/loader.h" | 10 #include "bin/loader.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // Only run tests that match the filter string. The default does not match any | 46 // Only run tests that match the filter string. The default does not match any |
| 47 // tests. | 47 // tests. |
| 48 static const char* const kNone = "No Test or Benchmarks"; | 48 static const char* const kNone = "No Test or Benchmarks"; |
| 49 static const char* const kList = "List all Tests and Benchmarks"; | 49 static const char* const kList = "List all Tests and Benchmarks"; |
| 50 static const char* const kAllBenchmarks = "All Benchmarks"; | 50 static const char* const kAllBenchmarks = "All Benchmarks"; |
| 51 static const char* run_filter = kNone; | 51 static const char* run_filter = kNone; |
| 52 static const char* kernel_snapshot = NULL; | 52 static const char* kernel_snapshot = NULL; |
| 53 | 53 |
| 54 static int run_matches = 0; | 54 static int run_matches = 0; |
| 55 | 55 |
| 56 | |
| 57 void TestCase::Run() { | 56 void TestCase::Run() { |
| 58 OS::Print("Running test: %s\n", name()); | 57 OS::Print("Running test: %s\n", name()); |
| 59 (*run_)(); | 58 (*run_)(); |
| 60 OS::Print("Done: %s\n", name()); | 59 OS::Print("Done: %s\n", name()); |
| 61 } | 60 } |
| 62 | 61 |
| 63 | |
| 64 void RawTestCase::Run() { | 62 void RawTestCase::Run() { |
| 65 OS::Print("Running test: %s\n", name()); | 63 OS::Print("Running test: %s\n", name()); |
| 66 (*run_)(); | 64 (*run_)(); |
| 67 OS::Print("Done: %s\n", name()); | 65 OS::Print("Done: %s\n", name()); |
| 68 } | 66 } |
| 69 | 67 |
| 70 | |
| 71 void TestCaseBase::RunTest() { | 68 void TestCaseBase::RunTest() { |
| 72 if (strcmp(run_filter, this->name()) == 0) { | 69 if (strcmp(run_filter, this->name()) == 0) { |
| 73 this->Run(); | 70 this->Run(); |
| 74 run_matches++; | 71 run_matches++; |
| 75 } else if (run_filter == kList) { | 72 } else if (run_filter == kList) { |
| 76 OS::Print("%s\n", this->name()); | 73 OS::Print("%s\n", this->name()); |
| 77 run_matches++; | 74 run_matches++; |
| 78 } | 75 } |
| 79 } | 76 } |
| 80 | 77 |
| 81 | |
| 82 void Benchmark::RunBenchmark() { | 78 void Benchmark::RunBenchmark() { |
| 83 if ((run_filter == kAllBenchmarks) || | 79 if ((run_filter == kAllBenchmarks) || |
| 84 (strcmp(run_filter, this->name()) == 0)) { | 80 (strcmp(run_filter, this->name()) == 0)) { |
| 85 this->Run(); | 81 this->Run(); |
| 86 OS::Print("%s(%s): %" Pd64 "\n", this->name(), this->score_kind(), | 82 OS::Print("%s(%s): %" Pd64 "\n", this->name(), this->score_kind(), |
| 87 this->score()); | 83 this->score()); |
| 88 run_matches++; | 84 run_matches++; |
| 89 } else if (run_filter == kList) { | 85 } else if (run_filter == kList) { |
| 90 OS::Print("%s\n", this->name()); | 86 OS::Print("%s\n", this->name()); |
| 91 run_matches++; | 87 run_matches++; |
| 92 } | 88 } |
| 93 } | 89 } |
| 94 | 90 |
| 95 | |
| 96 static void PrintUsage() { | 91 static void PrintUsage() { |
| 97 OS::PrintErr( | 92 OS::PrintErr( |
| 98 "Usage: one of the following\n" | 93 "Usage: one of the following\n" |
| 99 " run_vm_tests --list\n" | 94 " run_vm_tests --list\n" |
| 100 " run_vm_tests [--dfe=<snapshot file name>] --benchmarks\n" | 95 " run_vm_tests [--dfe=<snapshot file name>] --benchmarks\n" |
| 101 " run_vm_tests [--dfe=<snapshot file name>] [vm-flags ...] <test name>\n" | 96 " run_vm_tests [--dfe=<snapshot file name>] [vm-flags ...] <test name>\n" |
| 102 " run_vm_tests [--dfe=<snapshot file name>] [vm-flags ...] <benchmark " | 97 " run_vm_tests [--dfe=<snapshot file name>] [vm-flags ...] <benchmark " |
| 103 "name>\n"); | 98 "name>\n"); |
| 104 } | 99 } |
| 105 | 100 |
| 106 #define CHECK_RESULT(result) \ | 101 #define CHECK_RESULT(result) \ |
| 107 if (Dart_IsError(result)) { \ | 102 if (Dart_IsError(result)) { \ |
| 108 *error = strdup(Dart_GetError(result)); \ | 103 *error = strdup(Dart_GetError(result)); \ |
| 109 Dart_ExitScope(); \ | 104 Dart_ExitScope(); \ |
| 110 Dart_ShutdownIsolate(); \ | 105 Dart_ShutdownIsolate(); \ |
| 111 return NULL; \ | 106 return NULL; \ |
| 112 } | 107 } |
| 113 | 108 |
| 114 | |
| 115 static Dart_Isolate CreateIsolateAndSetup(const char* script_uri, | 109 static Dart_Isolate CreateIsolateAndSetup(const char* script_uri, |
| 116 const char* main, | 110 const char* main, |
| 117 const char* package_root, | 111 const char* package_root, |
| 118 const char* packages_config, | 112 const char* packages_config, |
| 119 Dart_IsolateFlags* flags, | 113 Dart_IsolateFlags* flags, |
| 120 void* data, | 114 void* data, |
| 121 char** error) { | 115 char** error) { |
| 122 ASSERT(script_uri != NULL); | 116 ASSERT(script_uri != NULL); |
| 123 const bool is_service_isolate = | 117 const bool is_service_isolate = |
| 124 strcmp(script_uri, DART_VM_SERVICE_ISOLATE_NAME) == 0; | 118 strcmp(script_uri, DART_VM_SERVICE_ISOLATE_NAME) == 0; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 return 1; | 262 return 1; |
| 269 } | 263 } |
| 270 if (DynamicAssertionHelper::failed()) { | 264 if (DynamicAssertionHelper::failed()) { |
| 271 return 255; | 265 return 255; |
| 272 } | 266 } |
| 273 return 0; | 267 return 0; |
| 274 } | 268 } |
| 275 | 269 |
| 276 } // namespace dart | 270 } // namespace dart |
| 277 | 271 |
| 278 | |
| 279 int main(int argc, const char** argv) { | 272 int main(int argc, const char** argv) { |
| 280 dart::bin::Platform::Exit(dart::Main(argc, argv)); | 273 dart::bin::Platform::Exit(dart::Main(argc, argv)); |
| 281 } | 274 } |
| OLD | NEW |