Skip to content
Browse files

Bug 783584 Improved SD-card check. r=wlach

  • Loading branch information...
1 parent 56f5c82 commit f5aee6bdf8a23239d645f20084814b2f1c4651c8 @markrcote markrcote committed Aug 20, 2012
Showing with 28 additions and 10 deletions.
  1. +8 −4 smoketest.sh
  2. +20 −6 worker.py
View
12 smoketest.sh
@@ -57,15 +57,19 @@ i=0
while [ $i -le 60 ]
do
i=$(($i+1))
- if [ -a smoketest_pass ]
+ if [ -e smoketest_pass ]
then
echo 'Smoke test passed!'
- break
+ exit 0
fi
- if [ -a smoketest_fail ]
+ if [ -e smoketest_fail ]
then
echo 'Smoke test failed!'
- break
+ exit 1
fi
sleep 5
done
+
+echo 'Smoke test did not finish. The phone might have been disabled.'
+echo 'Check *.log for details.'
+exit 1
View
26 worker.py
@@ -2,6 +2,8 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import with_statement
+
import Queue
import StringIO
import datetime
@@ -10,6 +12,7 @@
import os
import posixpath
import socket
+import tempfile
import time
import traceback
@@ -133,23 +136,29 @@ def status_update(self, msg):
logging.warn('Autophone queue is full!')
def check_sdcard(self):
+ logging.info('checking sd card')
dev_root = self.dm.getDeviceRoot()
if dev_root is None:
logging.error('no response from device when querying device root')
return False
- d = dev_root + '/autophonetest'
+ d = posixpath.join(dev_root, 'autophonetest')
self.dm.removeDir(d)
success = self.dm.mkDir(d) and self.dm.dirExists(d)
+ if success:
+ with tempfile.NamedTemporaryFile() as tmp:
+ tmp.write('autophone test\n')
+ tmp.flush()
+ success = self.dm.pushFile(tmp.name, posixpath.join(d,
+ 'testfile'))
if not success:
logging.error('device root is not writable!')
logging.info('checking sdcard...')
sdcard_writable = self.dm.mkDir('/mnt/sdcard/tests/autophonetest')
if sdcard_writable:
logging.error('weird, sd card is writable but device root isn\'t! I\'m confused and giving up anyway!')
self.clear_test_base_paths()
- return False
self.dm.removeDir(d)
- return True
+ return success
def clear_test_base_paths(self):
for t in self.tests:
@@ -190,7 +199,7 @@ def disable_phone(self, msg_body):
self.status_update(phonetest.PhoneTestMessage(
self.phone_cfg['phoneid'],
phonetest.PhoneTestMessage.DISABLED))
-
+
def ping(self):
logging.info('Pinging phone')
# verify that the phone is still responding
@@ -223,6 +232,11 @@ def loop(self):
last_ping = None
+ if not self.disabled and not self.check_sdcard():
+ self.recover_phone()
+ if self.disabled:
+ logging.error("Initial SD card check failed.")
+
while True:
request = None
try:
@@ -248,7 +262,7 @@ def loop(self):
# still can't access it through adb.
if not self.ping():
self.disable_phone('No response to ping via adb.')
-
+
except KeyboardInterrupt:
return
if not request:
@@ -270,7 +284,7 @@ def loop(self):
self.phone_cfg['phoneid'],
phonetest.PhoneTestMessage.INSTALLING, job['blddate']))
logging.info('Installing build %s.' % datetime.datetime.fromtimestamp(float(job['blddate'])))
-
+
pathOnDevice = posixpath.join(self.dm.getDeviceRoot(),
os.path.basename(job['apkpath']))
self.dm.pushFile(job['apkpath'], pathOnDevice)

0 comments on commit f5aee6b

Please sign in to comment.
Something went wrong with that request. Please try again.