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 /** | 5 /** |
6 * Classes and methods for executing tests. | 6 * Classes and methods for executing tests. |
7 * | 7 * |
8 * This module includes: | 8 * This module includes: |
9 * - Managing parallel execution of tests, including timeout checks. | 9 * - Managing parallel execution of tests, including timeout checks. |
10 * - Evaluating the output of each test as pass/fail/crash/timeout. | 10 * - Evaluating the output of each test as pass/fail/crash/timeout. |
(...skipping 1882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1893 watchdogTimer.cancel(); | 1893 watchdogTimer.cancel(); |
1894 } | 1894 } |
1895 } | 1895 } |
1896 } | 1896 } |
1897 | 1897 |
1898 // Close stdin so that tests that try to block on input will fail. | 1898 // Close stdin so that tests that try to block on input will fail. |
1899 process.stdin.close(); | 1899 process.stdin.close(); |
1900 timeoutHandler() async { | 1900 timeoutHandler() async { |
1901 timedOut = true; | 1901 timedOut = true; |
1902 if (process != null) { | 1902 if (process != null) { |
1903 var executable, arguments; | 1903 var executable; |
1904 if (io.Platform.isLinux) { | 1904 if (io.Platform.isLinux) { |
1905 executable = 'eu-stack'; | 1905 executable = 'eu-stack'; |
1906 arguments = ['-p ${process.pid}']; | |
1907 } else if (io.Platform.isMacOS) { | 1906 } else if (io.Platform.isMacOS) { |
1908 // Try to print stack traces of the timed out process. | 1907 // Try to print stack traces of the timed out process. |
1909 // `sample` is a sampling profiler but we ask it sample for 1 | 1908 // `sample` is a sampling profiler but we ask it sample for 1 |
1910 // second with a 4 second delay between samples so that we only | 1909 // second with a 4 second delay between samples so that we only |
1911 // sample the threads once. | 1910 // sample the threads once. |
1912 executable = '/usr/bin/sample'; | 1911 executable = '/usr/bin/sample'; |
1913 arguments = ['${process.pid}', '1', '4000', '-mayDie']; | |
1914 } else if (io.Platform.isWindows) { | 1912 } else if (io.Platform.isWindows) { |
1915 bool is_x64 = command.executable.contains("X64") || | 1913 bool is_x64 = command.executable.contains("X64") || |
1916 command.executable.contains("SIMARM64"); | 1914 command.executable.contains("SIMARM64"); |
1917 executable = configuration['win_sdk_path'] + | 1915 executable = configuration['win_sdk_path'] + |
1918 "\\Debuggers\\" + (is_x64 ? "x64" : "x86") + "\\cdb.exe"; | 1916 "\\Debuggers\\" + (is_x64 ? "x64" : "x86") + "\\cdb.exe"; |
1919 diagnostics.add("Using $executable to print stack traces"); | 1917 diagnostics.add("Using $executable to print stack traces"); |
1920 arguments = ['-p', '${process.pid}', '-c', '!uniqstack;qd']; | 1918 } else { |
1919 diagnostics.add("Capturing stack traces on" | |
1920 "${io.Platform.operatingSystem} not supported"); | |
1921 } | 1921 } |
1922 if (executable != null) { | |
zra
2017/02/09 22:00:46
This is all getting complicated enough that it pro
| |
1923 var pid_list = [process.pid]; | |
1924 var lines; | |
1925 var start_line = 0; | |
1926 if (io.Platform.isLinux || io.Platform.isMacOS) { | |
1927 var result = await io.Process.run("pgrep", | |
1928 ["-P", "${pid_list[0]}"], | |
1929 runInShell: true); | |
1930 lines = result.stdout.split('\n'); | |
1931 } else if (io.Platform.isWindows) { | |
1932 var result = await io.Process.run("wmic", | |
1933 ["process", "where" , "(ParentProcessId=${pid_list[0]})", | |
1934 "get", "ProcessId"], | |
1935 runInShell: true); | |
1936 lines = result.stdout.split('\n'); | |
1937 // Skip first line containing header "ProcessId". | |
1938 start_line = 1; | |
1939 } else { | |
1940 assert(false); | |
1941 } | |
1942 if (lines.length > start_line) { | |
1943 for (int i = start_line; i < lines.length; ++i) { | |
1944 var pid = int.parse(lines[i], onError: (source) => null); | |
1945 if (pid != null) pid_list.add(pid); | |
1946 } | |
1947 } else { | |
1948 diagnostics.add("Could not find child pids"); | |
1949 diagnostics.addAll(lines); | |
1950 } | |
1922 | 1951 |
1923 if (executable != null) { | 1952 diagnostics.add("Process list including children: $pid_list"); |
1924 try { | 1953 for (pid in pid_list) { |
1925 var result = await io.Process.run(executable, arguments); | 1954 var arguments; |
1926 diagnostics.addAll(result.stdout.split('\n')); | 1955 if (io.Platform.isLinux) { |
1927 diagnostics.addAll(result.stderr.split('\n')); | 1956 arguments = ['-p $pid']; |
1928 } catch (error) { | 1957 } else if (io.Platform.isMacOS) { |
1929 diagnostics.add("Unable to capture stack traces: $error"); | 1958 arguments = ['$pid', '1', '4000', '-mayDie']; |
1959 } else if (io.Platform.isWindows) { | |
1960 arguments = ['-p', '$pid', '-c', '!uniqstack;qd']; | |
1961 } else { | |
1962 assert(false); | |
1963 } | |
1964 diagnostics.add("Trying to capture stack trace for pid $pid"); | |
1965 try { | |
1966 var result = await io.Process.run(executable, arguments); | |
1967 diagnostics.addAll(result.stdout.split('\n')); | |
1968 diagnostics.addAll(result.stderr.split('\n')); | |
1969 } catch (error) { | |
1970 diagnostics.add("Unable to capture stack traces: $error"); | |
1971 } | |
1930 } | 1972 } |
1931 } | 1973 } |
1932 | 1974 |
1933 if (!process.kill()) { | 1975 if (!process.kill()) { |
1934 diagnostics.add("Unable to kill ${process.pid}"); | 1976 diagnostics.add("Unable to kill ${process.pid}"); |
1935 } | 1977 } |
1936 } | 1978 } |
1937 } | 1979 } |
1938 | 1980 |
1939 stdoutSubscription.asFuture().then(closeStdout); | 1981 stdoutSubscription.asFuture().then(closeStdout); |
(...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3254 } | 3296 } |
3255 } | 3297 } |
3256 | 3298 |
3257 void eventAllTestsDone() { | 3299 void eventAllTestsDone() { |
3258 for (var listener in _eventListener) { | 3300 for (var listener in _eventListener) { |
3259 listener.allDone(); | 3301 listener.allDone(); |
3260 } | 3302 } |
3261 _allDone(); | 3303 _allDone(); |
3262 } | 3304 } |
3263 } | 3305 } |
OLD | NEW |