Support specifying a given shellball when running firmware update FAFTs

Provide an argument "shellball" in the firmware update FAFTs. If the arguemnt
is left blank, it used /usr/sbin/chromeos-firmwareupdate as shellball.

This version only modifies one test case.

BUG=chrome-os-partner:14361
TEST=run_remote_tests.sh -a "shellball=[given_shellball]" [test]

Change-Id: If517bd69dade0ce00fecc1e1e87fed56076449c4
Reviewed-on: https://gerrit.chromium.org/gerrit/34266
Reviewed-by: Tom Wai-Hong Tam <waihong@chromium.org>
Commit-Ready: Chun-Ting Chang <ctchang@chromium.org>
Tested-by: Chun-Ting Chang <ctchang@chromium.org>
diff --git a/client/cros/faft_client.py b/client/cros/faft_client.py
index 78c1e1f..516d667 100644
--- a/client/cros/faft_client.py
+++ b/client/cros/faft_client.py
@@ -662,11 +662,14 @@
         return self._cgpt_state.get_step()
 
 
-    def setup_firmwareupdate_temp_dir(self):
+    def setup_firmwareupdate_temp_dir(self, shellball=None):
         """Setup temporary directory.
 
-        Devkeys are copied to _key_path. Then, shellball,
-        /usr/sbin/chromeos-firmwareupdate, is extracted to _work_path.
+        Devkeys are copied to _key_path. Then, shellball (default:
+        /usr/sbin/chromeos-firmwareupdate) is extracted to _work_path.
+
+        Args:
+            shellball: Path of shellball.
         """
 
         self.cleanup_firmwareupdate_temp_dir()
@@ -676,9 +679,17 @@
 
         os.mkdir(self._work_path)
         shutil.copytree('/usr/share/vboot/devkeys/', self._keys_path)
+
+        shellball_path = os.path.join(self._temp_path,
+                                      'chromeos-firmwareupdate')
+
+        if shellball:
+            shutil.copyfile(shellball, shellball_path)
+        else:
+            shutil.copyfile('/usr/sbin/chromeos-firmwareupdate',
+                            shellball_path)
         self.run_shell_command(
-                'sh /usr/sbin/chromeos-firmwareupdate  --sb_extract %s'
-                % self._work_path)
+            'sh %s --sb_extract %s' % (shellball_path, self._work_path))
 
 
     def retrieve_shellball_fwid(self):
@@ -776,6 +787,13 @@
                            'chromeos-firmwareupdate-%s' % append))
 
 
+    def run_firmware_factory_install(self):
+        """ Do firmwareupdate with factory_install mode using new shellball."""
+        self.run_shell_command(
+            '/bin/sh %s --mode factory_install --noupdate_ec'
+            % os.path.join(self._temp_path, 'chromeos-firmwareupdate'))
+
+
     def run_firmware_bootok(self, append):
         """Do bootok mode using new shellball.
 
@@ -788,11 +806,9 @@
 
     def run_firmware_recovery(self):
         """Recovery to original shellball."""
-        args = ['/usr/sbin/chromeos-firmwareupdate']
-        args.append('--mode recovery')
-        args.append('--noupdate_ec')
-        cmd = '/bin/sh %s' % ' '.join(args)
-        self.run_shell_command(cmd)
+        self.run_shell_command(
+            '/bin/sh %s --mode recovery --noupdate_ec' % os.path.join(
+                self._temp_path, 'chromeos-firmwareupdate'))
 
 
     def get_temp_path(self):