diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 411: fixes for lava-test-shell

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

Commit Message

Andy Doan Oct. 22, 2012, 8:57 p.m. UTC
Merge authors:
  Andy Doan (doanac)
Related merge proposals:
  https://code.launchpad.net/~doanac/lava-dispatcher/lava-test-shell-fixes/+merge/130482
  proposed by: Andy Doan (doanac)
  review: Approve - Michael Hudson-Doyle (mwhudson)
------------------------------------------------------------
revno: 411 [merge]
committer: Andy Doan <andy.doan@linaro.org>
branch nick: lava-dispatcher
timestamp: Mon 2012-10-22 15:45:12 -0500
message:
  fixes for lava-test-shell
modified:
  lava_dispatcher/actions/lava_test_shell.py
  lava_dispatcher/device/fastmodel.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_shell.py'
--- lava_dispatcher/actions/lava_test_shell.py	2012-10-17 16:52:36 +0000
+++ lava_dispatcher/actions/lava_test_shell.py	2012-10-18 19:46:30 +0000
@@ -46,7 +46,7 @@ 
 Target.android_deployment_data['lava_test_runner'] = LAVA_TEST_ANDROID
 Target.android_deployment_data['lava_test_shell'] = LAVA_TEST_SHELL
 Target.android_deployment_data['lava_test_sh_cmd'] = '/system/bin/mksh'
-Target.android_deployment_data['lava_test_dir'] = '/system/lava'
+Target.android_deployment_data['lava_test_dir'] = '/data/lava'
 Target.android_deployment_data['lava_test_results_part_attr'] = 'data_part_android_org'
 
 Target.ubuntu_deployment_data['lava_test_runner'] = LAVA_TEST_UBUNTU
@@ -82,7 +82,7 @@ 
 def _configure_android_startup(etcdir):
     logging.info('hacking android start up job')
     with open('%s/mkshrc' % etcdir, 'a') as f:
-        f.write('\n/system/lava/bin/lava-test-runner\n')
+        f.write('\n/data/lava/bin/lava-test-runner\n')
 
 Target.android_deployment_data['lava_test_configure_startup'] = \
         _configure_android_startup
@@ -226,7 +226,10 @@ 
     def _configure_target(self, target, testdef_urls):
         ldir = target.deployment_data['lava_test_dir']
 
-        with target.file_system(target.config.root_part, 'lava') as d:
+        results_part = target.deployment_data['lava_test_results_part_attr']
+        results_part = getattr(target.config, results_part)
+
+        with target.file_system(results_part, 'lava') as d:
             self._mk_runner_dirs(d)
             self._copy_runner(d, target)
             testdirs = []
@@ -240,12 +243,13 @@ 
                 self._copy_test(hdir, tdir, testdef)
                 testdirs.append(tdir)
 
-        with target.file_system(target.config.root_part, 'etc') as d:
-            target.deployment_data['lava_test_configure_startup'](d)
             with open('%s/lava-test-runner.conf' % d, 'w') as f:
                 for testdir in testdirs:
                     f.write('%s\n' % testdir)
 
+        with target.file_system(target.config.root_part, 'etc') as d:
+            target.deployment_data['lava_test_configure_startup'](d)
+
     def _bundle_results(self, target):
         """ Pulls the results from the target device and builds a bundle
         """

=== modified file 'lava_dispatcher/device/fastmodel.py'
--- lava_dispatcher/device/fastmodel.py	2012-10-17 16:52:05 +0000
+++ lava_dispatcher/device/fastmodel.py	2012-10-19 05:16:51 +0000
@@ -200,6 +200,14 @@ 
 
     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()
         if self._sim_proc is not None:
             self._sim_proc.close()

=== modified file 'lava_dispatcher/device/target.py'
--- lava_dispatcher/device/target.py	2012-10-17 16:52:05 +0000
+++ lava_dispatcher/device/target.py	2012-10-19 04:38:47 +0000
@@ -63,6 +63,7 @@ 
         'TESTER_PS1_INCLUDES_RC': True,
     }
 
+
     def __init__(self, context, device_config):
         self.context = context
         self.config = device_config
@@ -97,11 +98,7 @@ 
         """ tries to safely power off the device by running a sync
         operation first
         """
-        from lava_dispatcher.client.base import CommandRunner
-        runner = CommandRunner(
-                proc,
-                self.deployment_data['TESTER_PS1_PATTERN'],
-                self.deployment_data['TESTER_PS1_INCLUDES_RC'])
+        runner = self._get_runner(proc)
         try:
             logging.info('attempting a filesystem sync before power_off')
             runner.run('sync', timeout=20)
@@ -135,16 +132,18 @@ 
         proc = runner = None
         try:
             proc = self.power_on()
-            from lava_dispatcher.client.base import CommandRunner
-            runner = CommandRunner(
-                proc,
-                self.deployment_data['TESTER_PS1_PATTERN'],
-                self.deployment_data['TESTER_PS1_INCLUDES_RC'])
+            runner = self._get_runner(proc)
             yield runner
         finally:
             if proc and runner:
                 self.power_off(proc)
 
+    def _get_runner(self, proc):
+        from lava_dispatcher.client.base import CommandRunner
+        pat = self.deployment_data['TESTER_PS1_PATTERN']
+        incrc = self.deployment_data['TESTER_PS1_INCLUDES_RC']
+        return CommandRunner(proc, pat, incrc)
+
     def get_test_data_attachments(self):
         return []
 

=== modified file 'lava_test_shell/lava-test-runner-android'
--- lava_test_shell/lava-test-runner-android	2012-10-04 05:05:26 +0000
+++ lava_test_shell/lava-test-runner-android	2012-10-22 20:41:43 +0000
@@ -13,9 +13,9 @@ 
 exec >/dev/console
 
 PREFIX="<LAVA_TEST_RUNNER>:"
-WORKFILE="/etc/lava-test-runner.conf"
+WORKFILE="/data/lava/lava-test-runner.conf"
 RESULTSDIR="/data/lava/results"
-BINDIR="/system/lava/bin"
+BINDIR="/data/lava/bin"
 
 hwcontext()
 {
@@ -44,6 +44,12 @@ 
 	echo "${PREFIX} disabling suspend and waiting for home screen ..."
 	disablesuspend.sh
 
+	# move the workfile to something timestamped and run that. This
+	# prevents us from running the same thing again after a reboot
+	TS=`date +%s`
+	mv ${WORKFILE} ${WORKFILE}-${TS}
+	WORKFILE=${WORKFILE}-${TS}
+
 	echo "${PREFIX} looking for installation work in ${WORKFILE}"
 	while read line ; do
 		test=`basename $line`
@@ -79,6 +85,11 @@ 
 		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-10-04 05:05:26 +0000
+++ lava_test_shell/lava-test-runner-ubuntu	2012-10-22 20:41:43 +0000
@@ -4,7 +4,7 @@ 
 exec >/dev/console
 
 PREFIX="<LAVA_TEST_RUNNER>:"
-WORKFILE="/etc/lava-test-runner.conf"
+WORKFILE="/lava/lava-test-runner.conf"
 RESULTSDIR="/lava/results"
 BINDIR="/lava/bin"
 
@@ -32,6 +32,12 @@ 
 echo "${PREFIX} started"
 [ -d ${RESULTSDIR} ] || mkdir -p ${RESULTSDIR}
 
+# move the workfile to something timestamped and run that. This
+# prevents us from running the same thing again after a reboot
+TS=`date +%s`
+mv ${WORKFILE} ${WORKFILE}-${TS}
+WORKFILE=${WORKFILE}-${TS}
+
 echo "${PREFIX} looking for installation work in ${WORKFILE}"
 while read line ; do
 	test=`basename $line`
@@ -63,5 +69,9 @@ 
 	lava-test-shell --output_dir ${odir} /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 exist
+ls /lava/results
+
 echo "${PREFIX} exiting"