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

Unified Diff: client/site_tests/hardware_Components/hardware_Components.py

Issue 2279001: Check the two files to ensure the present of Ethernet device and fix bug (Closed) Base URL: ssh://git@chromiumos-git/autotest.git
Patch Set: simply return _not_present if without the 2 files Created 10 years, 7 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/site_tests/hardware_Components/hardware_Components.py
diff --git a/client/site_tests/hardware_Components/hardware_Components.py b/client/site_tests/hardware_Components/hardware_Components.py
index 29535a4ca482c8452b32883b47b03059f64d387f..157ac86d023ca79785eb353f2c2433d12aad23c6 100644
--- a/client/site_tests/hardware_Components/hardware_Components.py
+++ b/client/site_tests/hardware_Components/hardware_Components.py
@@ -96,11 +96,14 @@ class hardware_Components(test.test):
"""
# Ethernet is optional so mark it as not present. A human
# operator needs to decide if this is acceptable or not.
- if not os.path.exists('/sys/class/net/eth0'):
- return self._not_present
- part_id = utils.read_one_line('/sys/class/net/eth0/device/device')
- vendor_id = utils.read_one_line('/sys/class/net/eth0/device/vendor')
- return "%s:%s" % (vendor_id.replace('0x',''), part_id.replace('0x',''))
+ vendor_file = '/sys/class/net/eth0/device/vendor'
+ part_file = '/sys/class/net/eth0/device/device'
+ if os.path.exists(part_file) and os.path.exists(vendor_file):
+ vendor_id = utils.read_one_line(vendor_file).replace('0x', '')
+ part_id = utils.read_one_line(part_file).replace('0x', '')
+ return "%s:%s" % (vendor_id, part_id)
+ else:
+ return self._not_present
def get_part_id_flash_chip(self):
@@ -149,9 +152,11 @@ class hardware_Components(test.test):
for device in approved_devices:
try:
- utils.system(cmd % device)
- self._system[cid] = [ device ]
- return
+ output = utils.system_output(cmd % device)
+ # If it shows something, means found.
+ if output:
+ self._system[cid] = [ device ]
+ return
except:
pass
self._failures[cid] = [ 'No match' ]
« 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