diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 364: allow clients to recieve custom boot options

Message ID 20120802230911.21293.20091.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Andy Doan Aug. 2, 2012, 11:09 p.m. UTC
Merge authors:
  Andy Doan (doanac)
Related merge proposals:
  https://code.launchpad.net/~doanac/lava-dispatcher/boot-option-support/+merge/117130
  proposed by: Andy Doan (doanac)
  review: Approve - Paul Larson (pwlars)
------------------------------------------------------------
revno: 364 [merge]
committer: Andy Doan <andy.doan@linaro.org>
branch nick: lava-dispatcher
timestamp: Thu 2012-08-02 18:06:22 -0500
message:
  allow clients to recieve custom boot options
modified:
  lava_dispatcher/actions/__init__.py
  lava_dispatcher/actions/boot_control.py
  lava_dispatcher/client/fastmodel.py


--
lp:lava-dispatcher
https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk

You are subscribed to branch lp:lava-dispatcher.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava_dispatcher/actions/__init__.py'
--- lava_dispatcher/actions/__init__.py	2012-03-19 18:25:52 +0000
+++ lava_dispatcher/actions/__init__.py	2012-08-01 19:56:15 +0000
@@ -71,6 +71,7 @@ 
     @classmethod
     def validate_parameters(cls, params):
         if cls.parameters_schema:
+            if params is None: params = {}
             schema = Schema(cls.parameters_schema)
             Validator.validate(schema, params)
 

=== modified file 'lava_dispatcher/actions/boot_control.py'
--- lava_dispatcher/actions/boot_control.py	2012-03-11 22:12:52 +0000
+++ lava_dispatcher/actions/boot_control.py	2012-07-27 16:49:32 +0000
@@ -25,15 +25,24 @@ 
 from lava_dispatcher.actions import BaseAction, null_or_empty_schema
 from lava_dispatcher.client.base import CriticalError
 
+_boot_schema = {
+    'type': 'object',
+    'properties': {
+        'options': {'type': 'array', 'items': {'type': 'string'},
+                    'optional': True},
+        },
+    'additionalProperties': False,
+    }
 
 class cmd_boot_linaro_android_image(BaseAction):
     """ Call client code to boot to the master image
     """
 
-    parameters_schema = null_or_empty_schema
+    parameters_schema = _boot_schema
 
-    def run(self):
+    def run(self, options=[]):
         client = self.client
+        client.boot_options = options
         try:
             client.boot_linaro_android_image()
         except Exception as e:
@@ -44,10 +53,11 @@ 
     """ Call client code to boot to the test image
     """
 
-    parameters_schema = null_or_empty_schema
+    parameters_schema = _boot_schema
 
-    def run(self):
+    def run(self, options=[]):
         client = self.client
+        client.boot_options = options
         status = 'pass'
         try:
             client.boot_linaro_image()

=== modified file 'lava_dispatcher/client/fastmodel.py'
--- lava_dispatcher/client/fastmodel.py	2012-08-02 23:05:53 +0000
+++ lava_dispatcher/client/fastmodel.py	2012-08-02 23:06:22 +0000
@@ -58,6 +58,16 @@ 
     SYS_PARTITION = 2
     DATA_PARTITION = 5
 
+    BOOT_OPTIONS = {
+        'motherboard.smsc_91c111.enabled': '1',
+        'motherboard.hostbridge.userNetworking': '1',
+        'coretile.cache_state_modelled': '0',
+        'coretile.cluster0.cpu0.semihosting-enable': '1',
+    }
+
+    # a list of allowable values for BOOT_OPTIONS
+    BOOT_VALS = [ '0', '1' ]
+
     def __init__(self, context, config):
         super(LavaFastModelClient, self).__init__(context, config)
         self._sim_binary = config.get('simulator_binary', None)
@@ -181,15 +191,27 @@ 
         os.chown(self._axf, st.st_uid, st.st_gid)
         os.chown(self._sd_image, st.st_uid, st.st_gid)
 
+    def _boot_options(self):
+        options = dict(self.BOOT_OPTIONS)
+        for option in self.boot_options:
+            keyval = option.split('=')
+            if len(keyval) != 2:
+                logging.warn("Invalid boot option format: %s" % option)
+            elif keyval[0] not in self.BOOT_OPTIONS:
+                logging.warn("Invalid boot option: %s" % keyval[0])
+            elif keyval[1] not in self.BOOT_VALS:
+                logging.warn("Invalid boot option value: %s" % option)
+            else:
+                options[keyval[0]] = keyval[1]
+
+        return ' '.join(['-C %s=%s' %(k,v) for k,v in options.iteritems()])
+
     def _get_sim_cmd(self):
+        options = self._boot_options()
         return ("%s -a coretile.cluster0.*=%s "
-            "-C motherboard.smsc_91c111.enabled=1 "
-            "-C motherboard.hostbridge.userNetworking=1 "
             "-C motherboard.mmc.p_mmc_file=%s "
-            "-C coretile.cache_state_modelled=0 "
-            "-C coretile.cluster0.cpu0.semihosting-enable=1 "
-            "-C motherboard.hostbridge.userNetPorts='5555=5555'") % (
-            self._sim_binary, self._axf, self._sd_image)
+            "-C motherboard.hostbridge.userNetPorts='5555=5555' %s") % (
+            self._sim_binary, self._axf, self._sd_image, options)
 
     def _stop(self):
         if self.proc is not None: