Yunlian Jiang | 4578ec1 | 2013-05-22 14:54:39 -0700 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
| 7 | import unittest |
| 8 | |
| 9 | from utils import logger |
| 10 | |
| 11 | from results_cache import Result |
| 12 | from results_cache import ResultsCache |
Yunlian Jiang | 9e53333 | 2013-09-30 15:45:46 -0700 | [diff] [blame^] | 13 | from label import MockLabel |
Yunlian Jiang | 4578ec1 | 2013-05-22 14:54:39 -0700 | [diff] [blame] | 14 | import mock_instance |
| 15 | |
| 16 | output = """CMD (True): ./run_remote_tests.sh --remote=172.17.128.241 --board=lumpy LibCBench |
| 17 | CMD (None): cd /usr/local/google/home/yunlian/gd/src/build/images/lumpy/latest/../../../../..; cros_sdk -- ./in_chroot_cmd6X7Cxu.sh |
| 18 | Identity added: /tmp/run_remote_tests.PO1234567/autotest_key (/tmp/run_remote_tests.PO1234567/autotest_key) |
| 19 | INFO : Using emerged autotests already installed at /build/lumpy/usr/local/autotest. |
| 20 | |
| 21 | INFO : Running the following control files 1 times: |
| 22 | INFO : * 'client/site_tests/platform_LibCBench/control' |
| 23 | |
| 24 | INFO : Running client test client/site_tests/platform_LibCBench/control |
| 25 | ./server/autoserv -m 172.17.128.241 --ssh-port 22 -c client/site_tests/platform_LibCBench/control -r /tmp/run_remote_tests.PO1234567/platform_LibCBench --test-retry=0 --args |
| 26 | ERROR:root:import statsd failed, no stats will be reported. |
| 27 | 14:20:22 INFO | Results placed in /tmp/run_remote_tests.PO1234567/platform_LibCBench |
| 28 | 14:20:22 INFO | Processing control file |
| 29 | 14:20:23 INFO | Starting master ssh connection '/usr/bin/ssh -a -x -N -o ControlMaster=yes -o ControlPath=/tmp/_autotmp_VIIP67ssh-master/socket -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o BatchMode=yes -o ConnectTimeout=30 -o ServerAliveInterval=180 -o ServerAliveCountMax=3 -o ConnectionAttempts=4 -o Protocol=2 -l root -p 22 172.17.128.241' |
| 30 | 14:20:23 ERROR| [stderr] Warning: Permanently added '172.17.128.241' (RSA) to the list of known hosts. |
| 31 | 14:20:23 INFO | INFO ---- ---- kernel=3.8.11 localtime=May 22 14:20:23 timestamp=1369257623 |
| 32 | 14:20:23 INFO | Installing autotest on 172.17.128.241 |
| 33 | 14:20:23 INFO | Using installation dir /usr/local/autotest |
| 34 | 14:20:23 WARNI| No job_repo_url for <remote host: 172.17.128.241> |
| 35 | 14:20:23 INFO | Could not install autotest using the packaging system: No repos to install an autotest client from. Trying other methods |
| 36 | 14:20:23 INFO | Installation of autotest completed |
| 37 | 14:20:24 WARNI| No job_repo_url for <remote host: 172.17.128.241> |
| 38 | 14:20:24 INFO | Executing /usr/local/autotest/bin/autotest /usr/local/autotest/control phase 0 |
| 39 | 14:20:24 INFO | Entered autotestd_monitor. |
| 40 | 14:20:24 INFO | Finished launching tail subprocesses. |
| 41 | 14:20:24 INFO | Finished waiting on autotestd to start. |
| 42 | 14:20:26 INFO | START ---- ---- timestamp=1369257625 localtime=May 22 14:20:25 |
| 43 | 14:20:26 INFO | START platform_LibCBench platform_LibCBench timestamp=1369257625 localtime=May 22 14:20:25 |
| 44 | 14:20:30 INFO | GOOD platform_LibCBench platform_LibCBench timestamp=1369257630 localtime=May 22 14:20:30 completed successfully |
| 45 | 14:20:30 INFO | END GOOD platform_LibCBench platform_LibCBench timestamp=1369257630 localtime=May 22 14:20:30 |
| 46 | 14:20:31 INFO | END GOOD ---- ---- timestamp=1369257630 localtime=May 22 14:20:30 |
| 47 | 14:20:31 INFO | Got lock of exit_code_file. |
| 48 | 14:20:31 INFO | Released lock of exit_code_file and closed it. |
| 49 | OUTPUT: ============================== |
| 50 | OUTPUT: Current time: 2013-05-22 14:20:32.818831 Elapsed: 0:01:30 ETA: Unknown |
| 51 | Done: 0% [ ] |
| 52 | OUTPUT: Thread Status: |
| 53 | RUNNING: 1 ('ttt: LibCBench (1)' 0:01:21) |
| 54 | Machine Status: |
| 55 | Machine Thread Lock Status Checksum |
| 56 | 172.17.128.241 ttt: LibCBench (1) True RUNNING 3ba9f2ecbb222f20887daea5583d86ba |
| 57 | |
| 58 | OUTPUT: ============================== |
| 59 | 14:20:33 INFO | Killing child processes. |
| 60 | 14:20:33 INFO | Client complete |
| 61 | 14:20:33 INFO | Finished processing control file |
| 62 | 14:20:33 INFO | Starting master ssh connection '/usr/bin/ssh -a -x -N -o ControlMaster=yes -o ControlPath=/tmp/_autotmp_aVJUgmssh-master/socket -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o BatchMode=yes -o ConnectTimeout=30 -o ServerAliveInterval=180 -o ServerAliveCountMax=3 -o ConnectionAttempts=4 -o Protocol=2 -l root -p 22 172.17.128.241' |
| 63 | 14:20:33 ERROR| [stderr] Warning: Permanently added '172.17.128.241' (RSA) to the list of known hosts. |
| 64 | |
| 65 | INFO : Test results: |
| 66 | ------------------------------------------------------------------- |
| 67 | platform_LibCBench [ PASSED ] |
| 68 | platform_LibCBench/platform_LibCBench [ PASSED ] |
| 69 | platform_LibCBench/platform_LibCBench b_malloc_big1__0_ 0.00375231466667 |
| 70 | platform_LibCBench/platform_LibCBench b_malloc_big2__0_ 0.002951359 |
| 71 | platform_LibCBench/platform_LibCBench b_malloc_bubble__0_ 0.015066374 |
| 72 | platform_LibCBench/platform_LibCBench b_malloc_sparse__0_ 0.015053784 |
| 73 | platform_LibCBench/platform_LibCBench b_malloc_thread_local__0_ 0.01138439 |
| 74 | platform_LibCBench/platform_LibCBench b_malloc_thread_stress__0_ 0.0367894733333 |
| 75 | platform_LibCBench/platform_LibCBench b_malloc_tiny1__0_ 0.000768474333333 |
| 76 | platform_LibCBench/platform_LibCBench b_malloc_tiny2__0_ 0.000581407333333 |
| 77 | platform_LibCBench/platform_LibCBench b_pthread_create_serial1__0_ 0.0291785246667 |
| 78 | platform_LibCBench/platform_LibCBench b_pthread_createjoin_serial1__0_ 0.031907936 |
| 79 | platform_LibCBench/platform_LibCBench b_pthread_createjoin_serial2__0_ 0.043485347 |
| 80 | platform_LibCBench/platform_LibCBench b_pthread_uselesslock__0_ 0.0294113346667 |
| 81 | platform_LibCBench/platform_LibCBench b_regex_compile____a_b_c__d_b__ 0.00529833933333 |
| 82 | platform_LibCBench/platform_LibCBench b_regex_search____a_b_c__d_b__ 0.00165455066667 |
| 83 | platform_LibCBench/platform_LibCBench b_regex_search___a_25_b__ 0.0496191923333 |
| 84 | platform_LibCBench/platform_LibCBench b_stdio_putcgetc__0_ 0.100005711667 |
| 85 | platform_LibCBench/platform_LibCBench b_stdio_putcgetc_unlocked__0_ 0.0371443833333 |
| 86 | platform_LibCBench/platform_LibCBench b_string_memset__0_ 0.00275405066667 |
| 87 | platform_LibCBench/platform_LibCBench b_string_strchr__0_ 0.00456903 |
| 88 | platform_LibCBench/platform_LibCBench b_string_strlen__0_ 0.044893587 |
| 89 | platform_LibCBench/platform_LibCBench b_string_strstr___aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac__ 0.118360778 |
| 90 | platform_LibCBench/platform_LibCBench b_string_strstr___aaaaaaaaaaaaaaaaaaaaaaaaac__ 0.068957325 |
| 91 | platform_LibCBench/platform_LibCBench b_string_strstr___aaaaaaaaaaaaaacccccccccccc__ 0.0135694476667 |
| 92 | platform_LibCBench/platform_LibCBench b_string_strstr___abcdefghijklmnopqrstuvwxyz__ 0.0134553343333 |
| 93 | platform_LibCBench/platform_LibCBench b_string_strstr___azbycxdwevfugthsirjqkplomn__ 0.0133123556667 |
| 94 | platform_LibCBench/platform_LibCBench b_utf8_bigbuf__0_ 0.0473772253333 |
| 95 | platform_LibCBench/platform_LibCBench b_utf8_onebyone__0_ 0.130938538333 |
| 96 | ------------------------------------------------------------------- |
| 97 | Total PASS: 2/2 (100%) |
| 98 | |
| 99 | INFO : Elapsed time: 0m16s |
| 100 | """ |
| 101 | |
| 102 | error = """ |
| 103 | ERROR: Identity added: /tmp/run_remote_tests.Z4Ld/autotest_key (/tmp/run_remote_tests.Z4Ld/autotest_key) |
| 104 | INFO : Using emerged autotests already installed at /build/lumpy/usr/local/autotest. |
| 105 | INFO : Running the following control files 1 times: |
| 106 | INFO : * 'client/site_tests/platform_LibCBench/control' |
| 107 | INFO : Running client test client/site_tests/platform_LibCBench/control |
| 108 | INFO : Test results: |
| 109 | INFO : Elapsed time: 0m18s |
| 110 | """ |
| 111 | |
| 112 | |
| 113 | keyvals = {'': 'PASS', 'b_stdio_putcgetc__0_': '0.100005711667', 'b_string_strstr___azbycxdwevfugthsirjqkplomn__': '0.0133123556667', 'b_malloc_thread_local__0_': '0.01138439', 'b_string_strlen__0_': '0.044893587', 'b_malloc_sparse__0_': '0.015053784', 'b_string_memset__0_': '0.00275405066667', 'platform_LibCBench': 'PASS', 'b_pthread_uselesslock__0_': '0.0294113346667', 'b_string_strchr__0_': '0.00456903', 'b_pthread_create_serial1__0_': '0.0291785246667', 'b_string_strstr___aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac__': '0.118360778', 'b_string_strstr___aaaaaaaaaaaaaacccccccccccc__': '0.0135694476667', 'b_pthread_createjoin_serial1__0_': '0.031907936', 'b_malloc_thread_stress__0_': '0.0367894733333', 'b_regex_search____a_b_c__d_b__': '0.00165455066667', 'b_malloc_bubble__0_': '0.015066374', 'b_malloc_big2__0_': '0.002951359', 'b_stdio_putcgetc_unlocked__0_': '0.0371443833333', 'b_pthread_createjoin_serial2__0_': '0.043485347', 'b_regex_search___a_25_b__': '0.0496191923333', 'b_utf8_bigbuf__0_': '0.0473772253333', 'b_malloc_big1__0_': '0.00375231466667', 'b_regex_compile____a_b_c__d_b__': '0.00529833933333', 'b_string_strstr___aaaaaaaaaaaaaaaaaaaaaaaaac__': '0.068957325', 'b_malloc_tiny2__0_': '0.000581407333333', 'b_utf8_onebyone__0_': '0.130938538333', 'b_malloc_tiny1__0_': '0.000768474333333', 'b_string_strstr___abcdefghijklmnopqrstuvwxyz__': '0.0134553343333'} |
| 114 | |
| 115 | class MockResult(Result): |
| 116 | |
Yunlian Jiang | 9e53333 | 2013-09-30 15:45:46 -0700 | [diff] [blame^] | 117 | def __init__(self, logger, label): |
| 118 | super(MockResult, self).__init__(logger, label) |
Yunlian Jiang | 4578ec1 | 2013-05-22 14:54:39 -0700 | [diff] [blame] | 119 | |
| 120 | def _FindFilesInResultsDir(self, find_args): |
| 121 | return "" |
| 122 | |
| 123 | def _GetKeyvals(self): |
| 124 | return keyvals |
| 125 | |
| 126 | |
| 127 | class ResultTest(unittest.TestCase): |
Yunlian Jiang | 9e53333 | 2013-09-30 15:45:46 -0700 | [diff] [blame^] | 128 | mock_label = MockLabel("mock_label", "chromeos_image", "/tmp", "lumpy", |
| 129 | "remote", "image_args", "image_md5sum", "cache_dir") |
Yunlian Jiang | 4578ec1 | 2013-05-22 14:54:39 -0700 | [diff] [blame] | 130 | def testCreateFromRun(self): |
Yunlian Jiang | 9e53333 | 2013-09-30 15:45:46 -0700 | [diff] [blame^] | 131 | result = MockResult.CreateFromRun(logger.GetLogger(), self.mock_label, |
| 132 | output, error, 0) |
Yunlian Jiang | 4578ec1 | 2013-05-22 14:54:39 -0700 | [diff] [blame] | 133 | self.assertEqual(result.keyvals, keyvals) |
Yunlian Jiang | 9e53333 | 2013-09-30 15:45:46 -0700 | [diff] [blame^] | 134 | self.assertEqual(result.chroot_results_dir, |
| 135 | "/tmp/run_remote_tests.PO1234567/platform_LibCBench") |
| 136 | self.assertEqual(result.results_dir, |
| 137 | "/tmp/chroot/tmp/run_remote_tests.PO1234567/platform_LibCBench") |
Yunlian Jiang | 4578ec1 | 2013-05-22 14:54:39 -0700 | [diff] [blame] | 138 | self.assertEqual(result.retval, 0) |
| 139 | |
| 140 | if __name__ == "__main__": |
| 141 | unittest.main() |