Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: client/site_tests/hardware_VideoOutSemiAuto/hardware_VideoOutSemiAuto.py

Issue 4104001: autotest: Update path in hardware_VideoOutSemiAuto. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 import os.path 6 import os.path
7 7
8 from autotest_lib.client.bin import test, utils 8 from autotest_lib.client.bin import test, utils
9 from autotest_lib.client.common_lib import error, site_ui 9 from autotest_lib.client.common_lib import error, site_ui
10 10
11 class hardware_VideoOutSemiAuto(test.test): 11 class hardware_VideoOutSemiAuto(test.test):
12 version = 1 12 version = 1
13 XRANDR_PATH = "/usr/bin/xrandr" 13 XRANDR_PATH = "/usr/bin/xrandr"
14 RECONFIG_PATH = "/usr/sbin/monitor_reconfigure" 14 RECONFIG_PATH = "/usr/bin/monitor_reconfigure"
15 HDMI_ID = "HDMI" 15 HDMI_ID = "HDMI"
16 VGA_ID = "VGA" 16 VGA_ID = "VGA"
17 17
18 18
19 # Returns True if given |output| port is found on system. 19 # Returns True if given |output| port is found on system.
20 def __query_for_output(self, output): 20 def __query_for_output(self, output):
21 query_cmd = "%s -q | grep %s -c" % (self.XRANDR_PATH, output) 21 query_cmd = "%s -q | grep %s -c" % (self.XRANDR_PATH, output)
22 xrandr_out = utils.system_output(site_ui.xcommand(query_cmd), 22 xrandr_out = utils.system_output(site_ui.xcommand(query_cmd),
23 ignore_status=True) 23 ignore_status=True)
24 return int(xrandr_out) > 0 24 return int(xrandr_out) > 0
(...skipping 10 matching lines...) Expand all
35 35
36 # Returns if given |output| port has a device that has been configured 36 # Returns if given |output| port has a device that has been configured
37 # otherwise raises TestFail 37 # otherwise raises TestFail
38 def __output_is_set(self, output): 38 def __output_is_set(self, output):
39 query_cmd = "%s -q | grep '%s[0-9] connected' -n" % \ 39 query_cmd = "%s -q | grep '%s[0-9] connected' -n" % \
40 (self.XRANDR_PATH, output) 40 (self.XRANDR_PATH, output)
41 start_line = int( 41 start_line = int(
42 utils.system_output(site_ui.xcommand(query_cmd)).split(':')[0] 42 utils.system_output(site_ui.xcommand(query_cmd)).split(':')[0]
43 ) 43 )
44 44
45 # Gets 100 lines (to be safe) after context to get output after 45 # Gets 100 lines (to be safe) after context to get output after
46 query_cmd = \ 46 query_cmd = \
47 "%s -q | grep '%s[0-9] connected' -n -A 100 | grep connected" % \ 47 "%s -q | grep '%s[0-9] connected' -n -A 100 | grep connected" % \
48 (self.XRANDR_PATH, output) 48 (self.XRANDR_PATH, output)
49 49
50 try: 50 try:
51 end_line = int(utils.system_output( 51 end_line = int(utils.system_output(
52 site_ui.xcommand(query_cmd)).split('\n')[1].split('-')[0]) 52 site_ui.xcommand(query_cmd)).split('\n')[1].split('-')[0])
53 except: 53 except:
54 logging.info("End line not found, assuming last output") 54 logging.info("End line not found, assuming last output")
55 end_line = -1 55 end_line = -1
56 56
57 if end_line != -1: 57 if end_line != -1:
58 lines_between = end_line - start_line - 1 58 lines_between = end_line - start_line - 1
59 else: 59 else:
60 line_between = 100 60 line_between = 100
61 query_cmd = "%s -q | grep '%s[0-9] connected' -A %d | grep \\*" % \ 61 query_cmd = "%s -q | grep '%s[0-9] connected' -A %d | grep \\*" % \
62 (self.XRANDR_PATH, output, lines_between) 62 (self.XRANDR_PATH, output, lines_between)
63 try: 63 try:
64 utils.system(site_ui.xcommand(query_cmd)) 64 utils.system(site_ui.xcommand(query_cmd))
65 except: 65 except:
66 raise error.TestFail("%s not set with monitor_reconfigure" % output) 66 raise error.TestFail("%s not set with monitor_reconfigure" % output)
67 67
68 68
69 # Configures |output| and returns if |output| has been configured. 69 # Configures |output| and returns if |output| has been configured.
70 # Also will return false immediately if no device detected on the port 70 # Also will return false immediately if no device detected on the port
71 def __configure_and_check_output(self, output): 71 def __configure_and_check_output(self, output):
72 connected = self.__output_connected(output) 72 connected = self.__output_connected(output)
73 if not connected: 73 if not connected:
74 logging.warning( 74 logging.warning(
75 "%s port detected but no connected device" % output 75 "%s port detected but no connected device" % output
76 ) 76 )
77 return False 77 return False
78 else: 78 else:
79 #TODO(sosa@chromium.org) - Verify this is synchronous. 79 #TODO(sosa@chromium.org) - Verify this is synchronous.
80 utils.system(site_ui.xcommand(self.RECONFIG_PATH)) 80 utils.system(site_ui.xcommand(self.RECONFIG_PATH))
81 self.__output_is_set(output) 81 self.__output_is_set(output)
82 return True 82 return True
83 83
84 84
85 def run_once(self): 85 def run_once(self):
86 # Sanity check for xrandr application. 86 # Sanity check for xrandr application.
87 if not os.path.isfile(self.XRANDR_PATH): 87 if not os.path.isfile(self.XRANDR_PATH):
88 raise error.TestFail(""" 88 raise error.TestFail("xrandr not at %s" % self.XRANDR_PATH)
89 XRandr missing from device cannot complete test
90 """)
91 89
92 # Determine if devices of interest are on system. 90 # Determine if devices of interest are on system.
93 hdmi_exists = self.__query_for_output(self.HDMI_ID) 91 hdmi_exists = self.__query_for_output(self.HDMI_ID)
94 vga_exists = self.__query_for_output(self.VGA_ID) 92 vga_exists = self.__query_for_output(self.VGA_ID)
95 93
96 # Raises NAError since these are optional devices. 94 # Raises NAError since these are optional devices.
97 if (not hdmi_exists) and (not vga_exists): 95 if (not hdmi_exists) and (not vga_exists):
98 raise error.TestFail("Neither VGA or HDMI ports detected") 96 raise error.TestFail("Neither VGA nor HDMI ports detected")
99 97
100 # Sanity check to make sure we can configure the devices. 98 # Sanity check to make sure we can configure the devices.
101 if not os.path.isfile(self.RECONFIG_PATH): 99 if not os.path.isfile(self.RECONFIG_PATH):
102 raise error.TestFail(""" 100 raise error.TestFail("monitor_reconfigure not at %s" %
103 Device detected but missing monitor_reconfigure tool 101 self.RECONFIG_PATH);
104 """)
105 102
106 # If either device is connected and able to be configured 103 # If either device is connected and able to be configured
107 # the test is successful. 104 # the test is successful.
108 success = False 105 success = False
109 106
110 # If devices exist, we should be able to configure and enable them 107 # If devices exist, we should be able to configure and enable them
111 if hdmi_exists: 108 if hdmi_exists:
112 success |= self.__configure_and_check_output(self.HDMI_ID) 109 success |= self.__configure_and_check_output(self.HDMI_ID)
113 if vga_exists: 110 if vga_exists:
114 success |= self.__configure_and_check_output(self.VGA_ID) 111 success |= self.__configure_and_check_output(self.VGA_ID)
115 112
116 if not success: 113 if not success:
117 raise error.TestFail(""" 114 raise error.TestFail("""
118 HDMI port or VGA port detected but no actual device connected. 115 HDMI port or VGA port detected but no actual device connected.
119 """) 116 """)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698