1# Copyright 2017 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5from autotest_lib.server import utils
6
7AUTHOR = "mzhuo@chromium.org"
8NAME = "enterprise_CFM_Test.qual"
9TIME = "LONG"
10TEST_CATEGORY = "Functional"
11TEST_CLASS = "enterprise"
12TEST_TYPE = "server"
13DEPENDENCIES = ""
14JOB_RETRIES = 1
15
16DOC = """
17This test runs various tests and verifications for CfM devices.
18Tests and verifications can be selected in control file.
19action_list defines the list of all available tests, which are keys for dict
20action_list, value for the key defines how many times this test will be run
21in each loop.
22verification_list defineds the list of all available verifications,
23which are keys for dict verification_list. True means this verification specified
24by this key will be performed.
25Testing flow can be set in control file.
26
27Example to run it:
28test_that --autotest_dir ~/trunk/src/third_party/autotest/files/ --board=guado
29100.123.174.2 enterprise_CFM_Test.sanity
30
31Note:
321. Modify dict error_key_words to meet each test's need.
332. Modify meeting code which works for domain device is enrolled in.
34"""
35
36args_dict = utils.args_to_dict(args)
37
38error_key_words = {'usb': [
39                   'Setup ERROR: setup context command',
40                   'URB transfer length is wrong',
41                   'device descriptor read',
42                   'unable to enumerate USB device',
43                   'hub_port_status failed',
44                   'cannot reset port',
45                   'nonzero write bulk status received',
46                   'Device not responding to setup address',
47                   'device not accepting address',
48                   'Set SEL for device-initiated U2 failed',
49                   'Set SEL for device-initiated U1 failed',
50                   'Disable of device-initiated U1 failed',
51                   'Disable of device-initiated U2 failed',
52                   'usb_set_interface failed',
53                   'MIMO has wedged; issuing hub reset'
54                  ],
55                   'kernel': [
56                   'Error reading udev log info crash_reporter-udev-collection',
57                   'stuck on bsd ring',
58                   'stuck on render ring',
59                   'GPU hangs can indicate a bug anywhere in the entire gfx stack, including userspace',
60                   'GPU crash dump saved to',
61                   'ERROR Transfer event TRB DMA ptr',
62                   'crashes with segfault',
63                   'segfault at',
64                   'Stored minidump to',
65                   'Leaving core file',
66                   'cut here',
67                   'end trace',
68                   'Failed to resubmit video URB',
69                   'go2001_watchdog:',
70                   'go2001_ctx_error_locked:',
71                   'Out of memory: Kill process',
72                   'Killed process'
73                  ],
74                   'video': [
75                   'uvcvideo: Failed to query',
76                   'uvcvideo: Non-zero status'
77                   'uvcvideo: Failed to set UVC commit control',
78                   'uvcvideo: UVC non compliance',
79                   'Failed to resubmit video URB',
80                   'No streaming interface found',
81                   'Dequeued v4l2 buffer contains corrupted data'
82                  ],
83                   'audio': [
84                   'hw_params: Input/output error: rate:',
85                   'usb_set_interface failed',
86                  ],
87                   'chrome': [
88                   'Cannot get RenderProcess',
89                   'segfault at',
90                   'ERR crash_reporter',
91                   'Watchdog resetting firmware',
92                   'Failed to create scanout buffer',
93                   'Failed to enable controller',
94                   'Failed to configure: device',
95                   'Failed to export buffer to dma_buf',
96                   'Failed to take control of the display',
97                   'Failed to modeset controller',
98                   'Failed to encode frame.'
99                  ],
100                   'atrus': [
101                   'write: Connection timed out',
102                   'Error: report failed',
103                   'write: Broken pipe',
104                   'protocol error'
105                  ],
106                   'usb_stability': [
107                   'USB disconnect',
108                   'New USB device found'
109                  ]
110}
111
112
113# !!! Please change meeting code working for CfM.
114# !!! If meeting_code for different domain is used, meeting might be timeout.
115# vol_change_mode: if set to 1, make one call to set voluem to target volume,
116#                  else, make multiple calls to update volume until volume
117#                  equals to target volume.
118test_config = {
119               'gpio_list': ['218','219', '209'],
120               'gpiopause': 8,
121               'puts': "",
122               'is_meeting': 1,
123               'meeting_code': 'otg-dkps-ovj', # this works for crosprq4.com
124               'repeat': 50,
125               'reboot_timeout': 60,
126               'loop_timeout': 30,
127               'action_timeout': 20,
128               'min_timeout': 10,
129               'debug_timeout': 5,
130               'vol_change_step': 6,
131               'vol_change_mode': 1,
132               'reboot_after_min_meets': 1,
133               'gpio_after_min_meets': 1
134}
135
136#action_config['meeting_test'] should be 0, 1.
137#  0: no meeting test to be done
138#  1: In each loop first CfM joins meeting, after all tests are done,
139#     CfM leaves meeting.
140#the value of 'mute_unmute_camera_test', 'mute_unmute_mic_test' and
141#'speaker_volume_test" and etc is number of test for each key to be done in
142#one meeting.
143action_config = {
144                 'meeting_test': 1,
145                 'mute_unmute_camera_test': 4,
146                 'mute_unmute_mic_test': 4,
147                 'speaker_volume_test': 4,
148                 'gpio_test': 2,
149                 'reboot_test': 2,
150                 'reset_usb_test': 0,
151                 'flap_monitor_test': 0
152}
153
154
155verification_config = {
156                      'check_usb_enumeration':True,
157                      'check_usb_inf_init': True,
158                      'check_v4l2_interface': True,
159                      'check_audio_card':  False,
160                      'check_cras_speaker': True,
161                      'check_cras_mic': True,
162                      'check_cras_pspeaker': True,
163                      'check_cras_pmic': True,
164                      'check_cras_speaker_vol': True,
165                      'check_cras_mic_mute': True,
166                      'check_prefer_camera': False,
167                      'check_camera_mute': False,
168                      'check_audio_stream': True,
169                      'check_video_stream': True,
170                      'check_hotrod_speaker': False,
171                      'check_hotrod_mic': False,
172                      'check_hotrod_camera': False,
173                      'check_hotrod_pspeaker': False,
174                      'check_hotrod_pmic': False,
175                      'check_hotrod_pcamera': False,
176                      'check_hotrod_speaker_vol': False,
177                      'check_hotrod_mic_state': False,
178                      'check_hotrod_camera_state': False,
179                      'check_usb_errorlog': False,
180                      'check_kernel_errorlog': False,
181                      'check_video_errorlog': False,
182                      'check_audio_errorlog': False,
183                      'check_chrome_errorlog': False,
184                      'check_atrus_errorlog': False,
185                      'check_usb_stability': False,
186                      'check_process_crash': True,
187                      'check_kernel_panic': False,
188                      'check_chrome_restarted': True,
189                      'check_cfm_rebooted': True
190}
191
192
193test_flow_control = {
194                     'reboot_before_start': True,
195                     'run_test_only': True,
196                     'setup_cleanup': True,
197                     'abort_on_failure': False,
198                     'random_mode': True,
199                     'recovery_on_fatal_failure': True,
200                     'skip_cfm_check': True,
201                     'report': True
202}
203
204
205servo_args = hosts.CrosHost.get_servo_arguments(args_dict)
206
207
208def run_test(machine):
209    host = hosts.create_host(machine, servo_args=None)
210    run_test_only = test_flow_control['run_test_only']
211    job.run_test('enterprise_CFM_Test', host=host,
212                  run_test_only=run_test_only,
213                  test_config=test_config, action_config=action_config,
214                  verification_config=verification_config,
215                  error_key_words=error_key_words,
216                  test_flow_control=test_flow_control,
217                  tag='qual')
218
219
220parallel_simple(run_test, machines)
221