summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Salz <jsalz@chromium.org>2012-05-28 08:31:00 (GMT)
committerGerrit <chrome-bot@google.com>2012-05-28 12:31:09 (GMT)
commit79c68dee94dea28a7673ee48ce0148d0e13a4a51 (patch)
tree17711773a01c230ea5d43d38ed3ce43aeb402eeb
parent237c9eb9f541dd0c8936be01dcc4f3efe81c6c11 (diff)
downloadautotest-79c68dee94dea28a7673ee48ce0148d0e13a4a51.tar.gz
autotest-79c68dee94dea28a7673ee48ce0148d0e13a4a51.tar.xz
Finish collecting system info.
BUG=None TEST=Manual Change-Id: Ic561ec514b4cc32e554a6b8a91284222f57ad0a5 Reviewed-on: https://gerrit.chromium.org/gerrit/23827 Tested-by: Jon Salz <jsalz@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org> Commit-Ready: Jon Salz <jsalz@chromium.org>
-rw-r--r--client/cros/factory/js/goofy.js25
-rw-r--r--client/cros/factory/static/goofy.css8
-rw-r--r--client/cros/factory/static/index.html4
-rw-r--r--client/cros/factory/test_environment.py79
-rw-r--r--client/cros/factory/updater.py13
-rwxr-xr-xclient/site_tests/factory_Start/factory_Start.py3
6 files changed, 110 insertions, 22 deletions
diff --git a/client/cros/factory/js/goofy.js b/client/cros/factory/js/goofy.js
index 28e44d0..e06d0b5 100644
--- a/client/cros/factory/js/goofy.js
+++ b/client/cros/factory/js/goofy.js
@@ -70,14 +70,17 @@ cros.factory.Label = function(en, zh) {
* @type Array.<Object.<string, string>>
*/
cros.factory.SYSTEM_INFO_LABELS = [
- {key: 'device_serial_number', label: cros.factory.Label('Serial Number')},
+ {key: 'serial_number', label: cros.factory.Label('Serial Number')},
+ {key: 'factory_image_version',
+ label: cros.factory.Label('Factory Image Version')},
{key: 'wlan0_mac', label: cros.factory.Label('WLAN MAC')},
{key: 'kernel_version', label: cros.factory.Label('Kernel')},
{key: 'ec_version', label: cros.factory.Label('EC')},
{key: 'firmware_version', label: cros.factory.Label('Firmware')},
- {key: 'factory_image', label: cros.factory.Label('Factory Image')},
- {key: 'release_image', label: cros.factory.Label('Release Image')},
- {key: 'factory_md5sum', label: cros.factory.Label('Factory MD5SUM')}
+ {key: 'factory_md5sum', label: cros.factory.Label('Factory MD5SUM'),
+ transform: function(value) {
+ return value || cros.factory.Label('(no update)')
+ }}
];
cros.factory.UNKNOWN_LABEL = '<span class="goofy-unknown">' +
@@ -457,11 +460,17 @@ cros.factory.Goofy.prototype.setSystemInfo = function(systemInfo) {
var table = [];
table.push('<table id="goofy-system-info">');
goog.array.forEach(cros.factory.SYSTEM_INFO_LABELS, function(item) {
- var value = systemInfo[item.key] == undefined ?
- cros.factory.UNKNOWN_LABEL :
- goog.string.htmlEscape(systemInfo[item.key]);
+ var value = systemInfo[item.key];
+ var html;
+ if (item.transform) {
+ html = item.transform(value);
+ } else {
+ html = value == undefined ?
+ cros.factory.UNKNOWN_LABEL :
+ goog.string.htmlEscape(value);
+ }
table.push(
- '<tr><th>' + item.label + '</th><td>' + value +
+ '<tr><th>' + item.label + '</th><td>' + html +
'</td></tr>');
});
table.push('</table>');
diff --git a/client/cros/factory/static/goofy.css b/client/cros/factory/static/goofy.css
index 8452990..252fafe 100644
--- a/client/cros/factory/static/goofy.css
+++ b/client/cros/factory/static/goofy.css
@@ -178,6 +178,7 @@ dl.goofy-history {
padding-top: 1em;
}
#goofy-system-info th, #goofy-system-info td {
+ font-size: 75%;
text-align: left;
padding: 0 .1em 0 .1em;
}
@@ -188,10 +189,9 @@ dl.goofy-history {
text-wrap: none;
}
#goofy-system-info-hover {
- display: none; /* TODO(jsalz) */
- position: absolute;
- right: 5px;
- bottom: 5px;
+ position: fixed;
+ right: 16px;
+ bottom: 2px;
}
.goofy-unknown {
color: darkgray;
diff --git a/client/cros/factory/static/index.html b/client/cros/factory/static/index.html
index be5dd8b..eecafd4 100644
--- a/client/cros/factory/static/index.html
+++ b/client/cros/factory/static/index.html
@@ -28,11 +28,11 @@
</h1>
<div id="goofy-loading"><img src="images/active.gif">Loading test list...</img></div>
<div id="goofy-test-tree"></div>
-
- <img id="goofy-system-info-hover" src="images/info.png">
</div>
<div class="goog-splitpane-handle"></div>
<div id="goofy-main-and-console" class="goog-splitpane-second-container"></div>
</div>
+
+ <img id="goofy-system-info-hover" src="images/info.png">
</body>
</html>
diff --git a/client/cros/factory/test_environment.py b/client/cros/factory/test_environment.py
index 9831776..ddf2c37 100644
--- a/client/cros/factory/test_environment.py
+++ b/client/cros/factory/test_environment.py
@@ -8,13 +8,20 @@ import cPickle as pickle
import hashlib
import logging
import os
+from Queue import Queue
import re
import subprocess
import threading
import time
+import factory_common
from autotest_lib.client.cros import factory
+from autotest_lib.client.cros.factory import shopfloor
from autotest_lib.client.cros.factory import state
+from autotest_lib.client.cros.factory import updater
+
+
+ECTOOL_TIMEOUT_SEC = 0.1
class Environment(object):
@@ -131,10 +138,21 @@ class FakeChrootEnvironment(Environment):
class SystemInfo(object):
'''Information about the system.'''
def __init__(self, env, state):
+ self.serial_number = None
try:
- self.device_serial_number = state.get_shared_data('serial_number')
+ self.serial_number = shopfloor.get_serial_number()
except:
- self.device_serial_number = None
+ pass
+
+ self.factory_image_version = None
+ try:
+ lsb_release = open('/etc/lsb-release').read()
+ match = re.search('^GOOGLE_RELEASE=(.+)$', lsb_release,
+ re.MULTILINE)
+ if match:
+ self.factory_image_version = match.group(1)
+ except:
+ pass
try:
self.wlan0_mac = open('/sys/class/net/wlan0/address').read().strip()
@@ -148,11 +166,56 @@ class SystemInfo(object):
except:
self.kernel_version = None
- # TODO(jsalz): Set these items as well (adding items to env as
- # appropriate for invocations of crossystem, ectool, mosys, etc.),
- # and/or get more items from hwidprobe as available.
self.ec_version = None
+ try:
+ # Call ectool in a separate thread since it may timeout on older
+ # ECs.
+ queue = Queue()
+ def ReadVersion():
+ ectool = subprocess.Popen(['ectool', 'version'],
+ stdout=subprocess.PIPE)
+ stdout, _ = ectool.communicate()
+ queue.put(stdout)
+ ectool.wait()
+ thread = threading.Thread(target=ReadVersion)
+ thread.daemon = True
+ thread.start()
+
+ # Throws Empty exception on timeout; we'll fall through and try
+ # mosys
+ stdout = queue.get(timeout=ECTOOL_TIMEOUT_SEC)
+ match = re.search('^Build info:\s+(.+)$', stdout, re.MULTILINE)
+ if match:
+ self.ec_version = match.group(1)
+ except:
+ pass
+
+ # ectool failed; try mosys
+ if not self.ec_version:
+ try:
+ ectool = subprocess.Popen(['mosys', 'ec', 'info', '-l'],
+ stdout=subprocess.PIPE)
+ stdout, _ = ectool.communicate()
+ match = re.search('^fw_version\s+\|\s+(.+)$', stdout,
+ re.MULTILINE)
+ if match:
+ self.ec_version = match.group(1)
+ except:
+ pass
+
self.firmware_version = None
- self.factory_image = None
- self.release_image = None
- self.factory_md5sum = None
+ try:
+ crossystem = subprocess.Popen(['crossystem', 'fwid'],
+ stdout=subprocess.PIPE)
+ stdout, _ = crossystem.communicate()
+ self.firmware_version = stdout.strip() or None
+ except:
+ pass
+
+ self.factory_md5sum = updater.GetCurrentMD5SUM()
+
+
+if __name__ == '__main__':
+ import yaml
+ print yaml.dump(SystemInfo(None, None).__dict__,
+ default_flow_style=False)
diff --git a/client/cros/factory/updater.py b/client/cros/factory/updater.py
index 3602e1b..9b4d1a3 100644
--- a/client/cros/factory/updater.py
+++ b/client/cros/factory/updater.py
@@ -17,6 +17,19 @@ class UpdaterException(Exception):
pass
+def GetCurrentMD5SUM():
+ '''Returns MD5SUM of the current autotest directory.
+
+ Returns None if there has been no update (i.e., unable to read
+ the MD5SUM file).
+ '''
+ md5sum_file = os.path.join(factory.CLIENT_PATH, 'MD5SUM')
+ if os.path.exists(md5sum_file):
+ return open(md5sum_file, 'r').read().strip()
+ else:
+ return None
+
+
def CheckCriticalFiles(autotest_new_path):
'''Raises an exception if certain critical files are missing.'''
critical_files = [
diff --git a/client/site_tests/factory_Start/factory_Start.py b/client/site_tests/factory_Start/factory_Start.py
index ce7291a..1fcf6e4 100755
--- a/client/site_tests/factory_Start/factory_Start.py
+++ b/client/site_tests/factory_Start/factory_Start.py
@@ -31,6 +31,7 @@ from autotest_lib.client.cros import factory
from autotest_lib.client.cros.factory import shopfloor
from autotest_lib.client.cros.factory import task
from autotest_lib.client.cros.factory import ui
+from autotest_lib.client.cros.factory.event import Event, EventClient
from autotest_lib.client.cros.factory.event_log import EventLog
@@ -165,6 +166,8 @@ class ShopFloorTask(task.FactoryTask):
serial_number=serial)
factory.log('Serial number: %s' % serial)
shopfloor.set_serial_number(serial)
+
+ EventClient().post_event(Event(Event.Type.UPDATE_SYSTEM_INFO))
self.stop()
return True