| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 <fcntl.h> | 5 #include <fcntl.h> |
| 6 #include <launchpad/launchpad.h> | 6 #include <launchpad/launchpad.h> |
| 7 #include <magenta/syscalls.h> | 7 #include <magenta/syscalls.h> |
| 8 #include <mxio/util.h> | 8 #include <mxio/util.h> |
| 9 #include <pthread.h> | 9 #include <pthread.h> |
| 10 #include <runtime/sysinfo.h> | 10 #include <runtime/sysinfo.h> |
| 11 #include <stdbool.h> | 11 #include <stdbool.h> |
| 12 #include <stdio.h> | 12 #include <stdio.h> |
| 13 #include <stdlib.h> | 13 #include <stdlib.h> |
| 14 #include <string.h> | 14 #include <string.h> |
| 15 #include <unistd.h> | 15 #include <unistd.h> |
| 16 | 16 |
| 17 // This program runs Dart VM unit tests. The Dart VM unit tests are contained | 17 // This program runs Dart VM unit tests. The Dart VM unit tests are contained |
| 18 // in a separate binary whose location is defined in kRunVmTestsPath below. | 18 // in a separate binary whose location is defined in kRunVmTestsPath below. |
| 19 // That program accepts a command line argument --list to list all the available | 19 // That program accepts a command line argument --list to list all the available |
| 20 // tests, or the name of a single test to run. This program accepts a single | 20 // tests, or the name of a single test to run. This program accepts a single |
| 21 // command line argument which is the path to a file containing a list of tests | 21 // command line argument which is the path to a file containing a list of tests |
| 22 // to run, one per line. | 22 // to run, one per line. |
| 23 | 23 |
| 24 // TODO(zra): Make this a command line argument |
| 24 const char* kRunVmTestsPath = "/boot/bin/dart_vm_tests"; | 25 const char* kRunVmTestsPath = "/boot/bin/dart_vm_tests"; |
| 25 | 26 |
| 27 // The simulator only has 512MB; |
| 28 const intptr_t kOldGenHeapSizeMB = 256; |
| 29 |
| 26 // Tests that are invalid, wedge, or cause panics. | 30 // Tests that are invalid, wedge, or cause panics. |
| 27 const char* kSkip[] = { | 31 const char* kSkip[] = { |
| 28 // These expect a file to exist that we aren't putting in the image. | 32 // These expect a file to exist that we aren't putting in the image. |
| 29 "Read", | 33 "Read", |
| 30 "FileLength", | 34 "FileLength", |
| 31 "FilePosition", | 35 "FilePosition", |
| 32 // Hangs. | 36 // Hangs. |
| 33 "ArrayLengthMaxElements", | 37 "ArrayLengthMaxElements", |
| 34 "Int8ListLengthMaxElements", | 38 "Int8ListLengthMaxElements", |
| 35 "LargeMap", | 39 "LargeMap", |
| (...skipping 20 matching lines...) Expand all Loading... |
| 56 "Profiler_StringAllocation", | 60 "Profiler_StringAllocation", |
| 57 "Profiler_StringInterpolation", | 61 "Profiler_StringInterpolation", |
| 58 "Profiler_ToggleRecordAllocation", | 62 "Profiler_ToggleRecordAllocation", |
| 59 "Profiler_TrivialRecordAllocation", | 63 "Profiler_TrivialRecordAllocation", |
| 60 "Profiler_TypedArrayAllocation", | 64 "Profiler_TypedArrayAllocation", |
| 61 "Profiler_GetSourceReport", | 65 "Profiler_GetSourceReport", |
| 62 "Service_Profile", | 66 "Service_Profile", |
| 63 // No realpath. | 67 // No realpath. |
| 64 "Dart2JSCompilerStats", | 68 "Dart2JSCompilerStats", |
| 65 "Dart2JSCompileAll", | 69 "Dart2JSCompileAll", |
| 70 // Uses too much memory. |
| 71 "PrintJSON", |
| 66 }; | 72 }; |
| 67 | 73 |
| 68 // Expected to fail/crash. | 74 // Expected to fail/crash. |
| 69 const char* kExpectFail[] = { | 75 const char* kExpectFail[] = { |
| 70 "Fail0", | 76 "Fail0", |
| 71 "Fail1", | 77 "Fail1", |
| 72 "Fail2", | 78 "Fail2", |
| 73 "IsolateReload_PendingUnqualifiedCall_InstanceToStatic", | 79 "IsolateReload_PendingUnqualifiedCall_InstanceToStatic", |
| 74 "IsolateReload_PendingUnqualifiedCall_StaticToInstance", | 80 "IsolateReload_PendingUnqualifiedCall_StaticToInstance", |
| 75 "IsolateReload_PendingConstructorCall_AbstractToConcrete", | 81 "IsolateReload_PendingConstructorCall_AbstractToConcrete", |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 kExpectFail, sizeof(kExpectFail) / sizeof(kExpectFail[0]), test); | 138 kExpectFail, sizeof(kExpectFail) / sizeof(kExpectFail[0]), test); |
| 133 } | 139 } |
| 134 | 140 |
| 135 | 141 |
| 136 static bool isBug(const char* test) { | 142 static bool isBug(const char* test) { |
| 137 return contains(kBugs, sizeof(kBugs) / sizeof(kBugs[0]), test); | 143 return contains(kBugs, sizeof(kBugs) / sizeof(kBugs[0]), test); |
| 138 } | 144 } |
| 139 | 145 |
| 140 | 146 |
| 141 static int run_test(const char* test_name) { | 147 static int run_test(const char* test_name) { |
| 142 const intptr_t kArgc = 2; | 148 const intptr_t kArgc = 3; |
| 143 const char* argv[3]; | 149 const char* argv[kArgc]; |
| 150 |
| 151 char old_gen_arg[64]; |
| 152 snprintf(old_gen_arg, sizeof(old_gen_arg), "--old_gen_heap_size=%ld", |
| 153 kOldGenHeapSizeMB); |
| 154 |
| 144 argv[0] = kRunVmTestsPath; | 155 argv[0] = kRunVmTestsPath; |
| 145 argv[1] = test_name; | 156 argv[1] = old_gen_arg; |
| 157 argv[2] = test_name; |
| 146 | 158 |
| 147 mx_handle_t p = launchpad_launch(argv[0], kArgc, argv); | 159 mx_handle_t p = launchpad_launch(argv[0], kArgc, argv); |
| 148 if (p < 0) { | 160 if (p < 0) { |
| 149 fprintf(stderr, "process failed to start\n"); | 161 fprintf(stderr, "process failed to start\n"); |
| 150 return -1; | 162 return -1; |
| 151 } | 163 } |
| 152 | 164 |
| 153 mx_signals_state_t state; | 165 mx_signals_state_t state; |
| 154 mx_status_t r = mx_handle_wait_one( | 166 mx_status_t r = mx_handle_wait_one( |
| 155 p, MX_SIGNAL_SIGNALED, MX_TIME_INFINITE, &state); | 167 p, MX_SIGNAL_SIGNALED, MX_TIME_INFINITE, &state); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 free(test_list); | 323 free(test_list); |
| 312 pthread_mutex_destroy(&args_mutex); | 324 pthread_mutex_destroy(&args_mutex); |
| 313 | 325 |
| 314 if (test_list_index != lines_count) { | 326 if (test_list_index != lines_count) { |
| 315 fprintf(stderr, "Failed to attempt all the tests!\n"); | 327 fprintf(stderr, "Failed to attempt all the tests!\n"); |
| 316 return -1; | 328 return -1; |
| 317 } | 329 } |
| 318 | 330 |
| 319 return 0; | 331 return 0; |
| 320 } | 332 } |
| OLD | NEW |