blob: 01d5778a37d5bbd1f76fbc1e0f6d8c8e09416e38 [file] [log] [blame]
Yunlian Jiang4578ec12013-05-22 14:54:39 -07001#!/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
7import unittest
8
9from utils import logger
10
11from results_cache import Result
12from results_cache import ResultsCache
Yunlian Jiang9e533332013-09-30 15:45:46 -070013from label import MockLabel
Yunlian Jiang4578ec12013-05-22 14:54:39 -070014import mock_instance
15
16output = """CMD (True): ./run_remote_tests.sh --remote=172.17.128.241 --board=lumpy LibCBench
17CMD (None): cd /usr/local/google/home/yunlian/gd/src/build/images/lumpy/latest/../../../../..; cros_sdk -- ./in_chroot_cmd6X7Cxu.sh
18Identity added: /tmp/run_remote_tests.PO1234567/autotest_key (/tmp/run_remote_tests.PO1234567/autotest_key)
19INFO : Using emerged autotests already installed at /build/lumpy/usr/local/autotest.
20
21INFO : Running the following control files 1 times:
22INFO : * 'client/site_tests/platform_LibCBench/control'
23
24INFO : 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
26ERROR:root:import statsd failed, no stats will be reported.
2714:20:22 INFO | Results placed in /tmp/run_remote_tests.PO1234567/platform_LibCBench
2814:20:22 INFO | Processing control file
2914: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'
3014:20:23 ERROR| [stderr] Warning: Permanently added '172.17.128.241' (RSA) to the list of known hosts.
3114:20:23 INFO | INFO ---- ---- kernel=3.8.11 localtime=May 22 14:20:23 timestamp=1369257623
3214:20:23 INFO | Installing autotest on 172.17.128.241
3314:20:23 INFO | Using installation dir /usr/local/autotest
3414:20:23 WARNI| No job_repo_url for <remote host: 172.17.128.241>
3514:20:23 INFO | Could not install autotest using the packaging system: No repos to install an autotest client from. Trying other methods
3614:20:23 INFO | Installation of autotest completed
3714:20:24 WARNI| No job_repo_url for <remote host: 172.17.128.241>
3814:20:24 INFO | Executing /usr/local/autotest/bin/autotest /usr/local/autotest/control phase 0
3914:20:24 INFO | Entered autotestd_monitor.
4014:20:24 INFO | Finished launching tail subprocesses.
4114:20:24 INFO | Finished waiting on autotestd to start.
4214:20:26 INFO | START ---- ---- timestamp=1369257625 localtime=May 22 14:20:25
4314:20:26 INFO | START platform_LibCBench platform_LibCBench timestamp=1369257625 localtime=May 22 14:20:25
4414:20:30 INFO | GOOD platform_LibCBench platform_LibCBench timestamp=1369257630 localtime=May 22 14:20:30 completed successfully
4514:20:30 INFO | END GOOD platform_LibCBench platform_LibCBench timestamp=1369257630 localtime=May 22 14:20:30
4614:20:31 INFO | END GOOD ---- ---- timestamp=1369257630 localtime=May 22 14:20:30
4714:20:31 INFO | Got lock of exit_code_file.
4814:20:31 INFO | Released lock of exit_code_file and closed it.
49OUTPUT: ==============================
50OUTPUT: Current time: 2013-05-22 14:20:32.818831 Elapsed: 0:01:30 ETA: Unknown
51Done: 0% [ ]
52OUTPUT: Thread Status:
53RUNNING: 1 ('ttt: LibCBench (1)' 0:01:21)
54Machine Status:
55Machine Thread Lock Status Checksum
56172.17.128.241 ttt: LibCBench (1) True RUNNING 3ba9f2ecbb222f20887daea5583d86ba
57
58OUTPUT: ==============================
5914:20:33 INFO | Killing child processes.
6014:20:33 INFO | Client complete
6114:20:33 INFO | Finished processing control file
6214: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'
6314:20:33 ERROR| [stderr] Warning: Permanently added '172.17.128.241' (RSA) to the list of known hosts.
64
65INFO : Test results:
66-------------------------------------------------------------------
67platform_LibCBench [ PASSED ]
68platform_LibCBench/platform_LibCBench [ PASSED ]
69platform_LibCBench/platform_LibCBench b_malloc_big1__0_ 0.00375231466667
70platform_LibCBench/platform_LibCBench b_malloc_big2__0_ 0.002951359
71platform_LibCBench/platform_LibCBench b_malloc_bubble__0_ 0.015066374
72platform_LibCBench/platform_LibCBench b_malloc_sparse__0_ 0.015053784
73platform_LibCBench/platform_LibCBench b_malloc_thread_local__0_ 0.01138439
74platform_LibCBench/platform_LibCBench b_malloc_thread_stress__0_ 0.0367894733333
75platform_LibCBench/platform_LibCBench b_malloc_tiny1__0_ 0.000768474333333
76platform_LibCBench/platform_LibCBench b_malloc_tiny2__0_ 0.000581407333333
77platform_LibCBench/platform_LibCBench b_pthread_create_serial1__0_ 0.0291785246667
78platform_LibCBench/platform_LibCBench b_pthread_createjoin_serial1__0_ 0.031907936
79platform_LibCBench/platform_LibCBench b_pthread_createjoin_serial2__0_ 0.043485347
80platform_LibCBench/platform_LibCBench b_pthread_uselesslock__0_ 0.0294113346667
81platform_LibCBench/platform_LibCBench b_regex_compile____a_b_c__d_b__ 0.00529833933333
82platform_LibCBench/platform_LibCBench b_regex_search____a_b_c__d_b__ 0.00165455066667
83platform_LibCBench/platform_LibCBench b_regex_search___a_25_b__ 0.0496191923333
84platform_LibCBench/platform_LibCBench b_stdio_putcgetc__0_ 0.100005711667
85platform_LibCBench/platform_LibCBench b_stdio_putcgetc_unlocked__0_ 0.0371443833333
86platform_LibCBench/platform_LibCBench b_string_memset__0_ 0.00275405066667
87platform_LibCBench/platform_LibCBench b_string_strchr__0_ 0.00456903
88platform_LibCBench/platform_LibCBench b_string_strlen__0_ 0.044893587
89platform_LibCBench/platform_LibCBench b_string_strstr___aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac__ 0.118360778
90platform_LibCBench/platform_LibCBench b_string_strstr___aaaaaaaaaaaaaaaaaaaaaaaaac__ 0.068957325
91platform_LibCBench/platform_LibCBench b_string_strstr___aaaaaaaaaaaaaacccccccccccc__ 0.0135694476667
92platform_LibCBench/platform_LibCBench b_string_strstr___abcdefghijklmnopqrstuvwxyz__ 0.0134553343333
93platform_LibCBench/platform_LibCBench b_string_strstr___azbycxdwevfugthsirjqkplomn__ 0.0133123556667
94platform_LibCBench/platform_LibCBench b_utf8_bigbuf__0_ 0.0473772253333
95platform_LibCBench/platform_LibCBench b_utf8_onebyone__0_ 0.130938538333
96-------------------------------------------------------------------
97Total PASS: 2/2 (100%)
98
99INFO : Elapsed time: 0m16s
100"""
101
102error = """
103ERROR: Identity added: /tmp/run_remote_tests.Z4Ld/autotest_key (/tmp/run_remote_tests.Z4Ld/autotest_key)
104INFO : Using emerged autotests already installed at /build/lumpy/usr/local/autotest.
105INFO : Running the following control files 1 times:
106INFO : * 'client/site_tests/platform_LibCBench/control'
107INFO : Running client test client/site_tests/platform_LibCBench/control
108INFO : Test results:
109INFO : Elapsed time: 0m18s
110"""
111
112
113keyvals = {'': '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
115class MockResult(Result):
116
Yunlian Jiang9e533332013-09-30 15:45:46 -0700117 def __init__(self, logger, label):
118 super(MockResult, self).__init__(logger, label)
Yunlian Jiang4578ec12013-05-22 14:54:39 -0700119
120 def _FindFilesInResultsDir(self, find_args):
121 return ""
122
123 def _GetKeyvals(self):
124 return keyvals
125
126
127class ResultTest(unittest.TestCase):
Yunlian Jiang9e533332013-09-30 15:45:46 -0700128 mock_label = MockLabel("mock_label", "chromeos_image", "/tmp", "lumpy",
129 "remote", "image_args", "image_md5sum", "cache_dir")
Yunlian Jiang4578ec12013-05-22 14:54:39 -0700130 def testCreateFromRun(self):
Yunlian Jiang9e533332013-09-30 15:45:46 -0700131 result = MockResult.CreateFromRun(logger.GetLogger(), self.mock_label,
132 output, error, 0)
Yunlian Jiang4578ec12013-05-22 14:54:39 -0700133 self.assertEqual(result.keyvals, keyvals)
Yunlian Jiang9e533332013-09-30 15:45:46 -0700134 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 Jiang4578ec12013-05-22 14:54:39 -0700138 self.assertEqual(result.retval, 0)
139
140if __name__ == "__main__":
141 unittest.main()