Mobile/Fennec Unittests/Remote Testing
Overview
While battling Windows Mobile and python, [we came to the conclusion] that we needed to shift out of our model where we run everything on the device and allow for some or all test tools and data to be run remotely.
This has proven to be a reliable model and will meet our needs with Android. We also have found this very useful for investigating tests on Maemo as we don't need to ssh to the device and do all the setup.
Requirements / Setup
Testing remote requires a few things:
- a platform that you can install an agent on (currently, Windows Mobile (c++), Android (java), and Maemo/Linux (python). NOTE: a generic C++ linux agent is in development
- a recent build or downloaded tests package (from mozilla-central, not 1.9.2)
- the ip address of your device
- python on your host machine to run the test harness runners
To set this up, you need to first get the test agent for your platform [here. Copy that to your device and set it up to run automatically on boot.
- NOTE: fully implemented agents have a GUI and will give you useful information like ip address, commands running, and audible alerts
Next you need to determine your ip address. This can be done with a fully implemented agent, command line tools, or looking at your router.
Once this is running lets test it from your desktop (host):
- telnet <ip> 20701
Now that you have verified you can connect, the next step is to start writing python code. We have a library (devicemanager.py) which allows you to do common (file and process) operations across the telnet interface.
Available Agent Commands
run [executable] [args] - start program no wait
exec [executable] [args] - start program wait
fire [executable] [args] - start program no wait
arun [executable] [args] - start program no wait
kill [program name] - kill program no path
ps - list of running processes
info - list of device info
[os] - os version for device
[id] - unique identifier for device
[uptime] - uptime for device
[systime] - current system time on device
[screen] - width, height and bits per pixel for device
[memory] - physical, free, available, storage memory for device
[processes] - list of running processes see 'ps'
alrt [on/off] - start or stop sysalert behavior
disk [arg] - prints disk space info
cp file1 file2 - copy file1 to file2 on device
time file - timestamp for file on device
hash file - generate hash for file on device
cd directory - change cwd on device
cat file - cat file on device
cwd - display cwd on device
mv file1 file2 - move file1 to file2 on device
push filename - push file to device
rm file - delete file on device
rmdr directory - delete empty directory on device
prune directory - delete directory on device even if not empty
mkdr directory - create directory on device
dirw directory - tests whether the directory is writable on the device
stat processid - stat process on device
dead processid - print whether the process is alive or hung on device
mems - dump memory stats on device
ls - print directory on device
tmpd - print temp directory on device
ping [hostname/ipaddr] - ping a network device
rebt - reboot device
unzp archivename [dir] - unzip a zipfile respecting directories optionally into dir
clok - print current device time
quit - reset all network connections on SUTAgent
exit - shutdown the SUTAgent
help - you're reading it
DeviceManager library
sendCMD(cmdline, newline = True, sleep = 0) stripPrompt(data) pushFile(localname, destname) mkDir(name) mkDirs(filename) pushDir(localDir, remoteDir) dirExists(dirname) fileExists(filepath) listFiles(rootdir) removeFile(filename) removeDir(remoteDir) getProcessList() getMemInfo() fireProcess(appname) launchProcess(cmd, outputFile = "process.txt", cwd = '') communicate(process, timeout = 600) poll(process) processExist(appname) killProcess(appname) getTempDir() getFile(remoteFile, localFile = '') getDirectory(remoteDir, localDir) validateFile(remoteFile, localFile) getRemoteHash(filename) getLocalHash(filename) getDeviceRoot() getAppRoot() getTestRoot(type) signal(processID, signalType, signalAction) getReturnCode(processID) unpackFile(filename) reboot(wait = False) validateDir(localDir, remoteDir)
Mozilla Unittests
DeviceManager Examples
Copy File to device:
import devicemanager
dm = devicemanager.DeviceManager('192.168.1.103', 20701)
dm.pushFile('/home/joel/config.txt', '/config.txt')