diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 451: simplify the sync/power_off logic in device implementations

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

Commit Message

Andy Doan Nov. 16, 2012, 12:45 a.m. UTC
Merge authors:
  Andy Doan (doanac)
Related merge proposals:
  https://code.launchpad.net/~doanac/lava-dispatcher/sync-sanity/+merge/134569
  proposed by: Andy Doan (doanac)
------------------------------------------------------------
revno: 451 [merge]
committer: Andy Doan <andy.doan@linaro.org>
branch nick: lava-dispatcher
timestamp: Thu 2012-11-15 18:44:40 -0600
message:
  simplify the sync/power_off logic in device implementations
modified:
  lava_dispatcher/actions/lava_test.py
  lava_dispatcher/device/fastmodel.py
  lava_dispatcher/device/master.py
  lava_dispatcher/device/qemu.py
  lava_dispatcher/device/target.py
  lava_test_shell/lava-test-runner-android
  lava_test_shell/lava-test-runner-ubuntu


--
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/lava_test.py'
--- lava_dispatcher/actions/lava_test.py	2012-10-24 01:15:37 +0000
+++ lava_dispatcher/actions/lava_test.py	2012-11-15 21:23:20 +0000
@@ -95,6 +95,10 @@ 
                     logging.exception("killing test failed, rebooting")
                     self.client.boot_linaro_image()
                 raise
+            finally:
+                # try to make sure the test bundle is safely written to disk
+                session.run('sync', timeout=60)
+
             if rc is None:
                 raise OperationFailed("test case getting return value failed")
             elif rc != 0:

=== modified file 'lava_dispatcher/device/fastmodel.py'
--- lava_dispatcher/device/fastmodel.py	2012-11-15 22:07:29 +0000
+++ lava_dispatcher/device/fastmodel.py	2012-11-16 00:44:40 +0000
@@ -185,17 +185,8 @@ 
             return ("%s --image=%s --block-device=%s --network=nat %s") % (
                 self._sim_binary, self._axf, self._sd_image, options)
 
-    def _power_off(self, proc):
-        if proc is not None:
-            # attempt to turn off cleanly. lava-test-shell for ubuntu builds
-            # require this or the result files don't get flushed (even with
-            # the "sync" being called in self.power_off
-            try:
-                proc.sendline('halt')
-                proc.expect('Will now halt', timeout=20)
-            except:
-                logging.warn('timed out while trying to halt cleanly')
-            proc.close()
+    def power_off(self, proc):
+        super(FastModelTarget, self).power_off(proc)
         if self._sim_proc is not None:
             self._sim_proc.close()
 

=== modified file 'lava_dispatcher/device/master.py'
--- lava_dispatcher/device/master.py	2012-11-15 22:07:29 +0000
+++ lava_dispatcher/device/master.py	2012-11-16 00:44:40 +0000
@@ -90,7 +90,7 @@ 
         self._boot_linaro_image()
         return self.proc
 
-    def _power_off(self, proc):
+    def power_off(self, proc):
         # we always leave master image devices powered on
         pass
 

=== modified file 'lava_dispatcher/device/qemu.py'
--- lava_dispatcher/device/qemu.py	2012-11-09 20:25:51 +0000
+++ lava_dispatcher/device/qemu.py	2012-11-15 21:23:20 +0000
@@ -69,10 +69,6 @@ 
             tb = download_image(tarball_url, self.context, decompress=False)
             extract_targz(tb, '%s/%s' % (mntdir, directory))
 
-    def _power_off(self, proc):
-        if proc is not None:
-            proc.close()
-
     def power_on(self):
         qemu_cmd = ('%s -M %s -drive if=%s,cache=writeback,file=%s '
                     '-clock unix -device usb-kbd -device usb-mouse -usb '

=== modified file 'lava_dispatcher/device/target.py'
--- lava_dispatcher/device/target.py	2012-11-09 20:25:51 +0000
+++ lava_dispatcher/device/target.py	2012-11-15 21:23:20 +0000
@@ -86,11 +86,6 @@ 
         """
         raise NotImplementedError('power_on')
 
-    def _power_off(self, proc):
-        """ responsible for powering off the target device.
-        """
-        raise NotImplementedError('_power_off')
-
     def deploy_linaro(self, hwpack, rfs):
         raise NotImplementedError('deploy_image')
 
@@ -101,16 +96,8 @@ 
         raise NotImplementedError('deploy_linaro_prebuilt')
 
     def power_off(self, proc):
-        """ tries to safely power off the device by running a sync
-        operation first
-        """
-        runner = self._get_runner(proc)
-        try:
-            logging.info('attempting a filesystem sync before power_off')
-            runner.run('sync', timeout=20)
-        except:
-            logging.exception('calling sync failed')
-        self._power_off(proc)
+        if proc is not None:
+            proc.close()
 
     @contextlib.contextmanager
     def file_system(self, partition, directory):

=== modified file 'lava_test_shell/lava-test-runner-android'
--- lava_test_shell/lava-test-runner-android	2012-11-02 08:33:10 +0000
+++ lava_test_shell/lava-test-runner-android	2012-11-15 21:21:10 +0000
@@ -35,8 +35,19 @@ 
 	[ -f ${pkgs} ] || pm list packages -v > ${pkgs}
 }
 
+cleanup()
+{
+	# just adds a little handy debugging
+	ls ${RESULTSDIR}
+	echo "${PREFIX} calling sync"
+	sync
+	echo "${PREFIX} exiting"
+}
+
 # in background, since we don't have this working as a proper android service
 {
+	trap cleanup INT TERM EXIT
+
 	export PATH=${BINDIR}:${PATH}
 	echo "${PREFIX} started"
 	[ -d ${RESULTSDIR} ] || mkdir -p ${RESULTSDIR}
@@ -85,11 +96,5 @@ 
 		lava-test-shell --output_dir ${odir} /system/bin/sh -e "${line}/run.sh"
 		echo "${PREFIX} ${test} exited with: `cat ${odir}/return_code`"
 	done < ${WORKFILE}
-
- 	# just adds a little handy debugging as to what result the target
-	# thinks exists
-	ls /data/lava/results
-
-	echo "${PREFIX} exiting"
 } &
 

=== modified file 'lava_test_shell/lava-test-runner-ubuntu'
--- lava_test_shell/lava-test-runner-ubuntu	2012-11-02 08:33:10 +0000
+++ lava_test_shell/lava-test-runner-ubuntu	2012-11-15 21:21:10 +0000
@@ -28,6 +28,17 @@ 
 	[ -f ${pkgs} ]  || dpkg-query -W -f '${status} ${package} : ${version}\n' | sed -n 's/^install ok installed/package:/p'  > ${pkgs}
 }
 
+
+cleanup()
+{
+	# just adds a little handy debugging
+	ls ${RESULTSDIR}
+	echo "${PREFIX} calling sync"
+	sync
+	echo "${PREFIX} exiting"
+}
+trap cleanup INT TERM EXIT
+
 export PATH=${BINDIR}:${PATH}
 echo "${PREFIX} started"
 [ -d ${RESULTSDIR} ] || mkdir -p ${RESULTSDIR}
@@ -70,8 +81,3 @@ 
 	echo "${PREFIX} ${test} exited with: `cat ${odir}/return_code`"
 done < ${WORKFILE}
 
-# just adds a little handy debugging as to what result the target thinks exist
-ls /lava/results
-
-echo "${PREFIX} exiting"
-