diff options
Diffstat (limited to 'meta-yocto-bsp/lib/oeqa')
-rw-r--r-- | meta-yocto-bsp/lib/oeqa/controllers/edgeroutertarget.py | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/meta-yocto-bsp/lib/oeqa/controllers/edgeroutertarget.py b/meta-yocto-bsp/lib/oeqa/controllers/edgeroutertarget.py new file mode 100644 index 0000000000..5df9fda09e --- /dev/null +++ b/meta-yocto-bsp/lib/oeqa/controllers/edgeroutertarget.py | |||
@@ -0,0 +1,89 @@ | |||
1 | # Copyright (C) 2014 Intel Corporation | ||
2 | # | ||
3 | # Released under the MIT license (see COPYING.MIT) | ||
4 | |||
5 | # This module adds support to testimage.bbclass to deploy images and run | ||
6 | # tests on a Ubiquiti Networks EdgeRouter Lite. The device must be set up | ||
7 | # to boot into the master image already - the easiest way to do that is as | ||
8 | # follows: | ||
9 | # | ||
10 | # 1. Take out the internal USB drive and plug it into your PC | ||
11 | # 2. Repartition the USB drive so that you have three partitions in this | ||
12 | # order: | ||
13 | # 1: vfat, labelled "boot" (it will need to be formatted with mkfs.vfat | ||
14 | # for this to be possible, since FAT partitions formatted under | ||
15 | # DOS/Windows will only support uppercase labels) | ||
16 | # 2: ext3 (for master image) labelled "testmaster" | ||
17 | # 3: ext3 (for image under test) labelled "testrootfs" | ||
18 | # 3. Copy the kernel to be used by the master image to the FAT partition | ||
19 | # (it should be named "vmlinux.64" with the factory u-boot configuration) | ||
20 | # 4. Install the master image onto the "testmaster" ext3 partition. If | ||
21 | # you do this by just extracting the contents of an image onto the | ||
22 | # partition, you will also likely need to create the master image marker | ||
23 | # file /etc/masterimage within this partition so that we can tell when | ||
24 | # we're booted into it that it is the master image. | ||
25 | # 5. Put the USB drive back into the device, and ensure the console port | ||
26 | # and first ethernet port are connected before powering on | ||
27 | # | ||
28 | # TEST_SERIALCONTROL_CMD will need to be set in local.conf so that we can | ||
29 | # interact with u-boot over the serial console port. | ||
30 | |||
31 | import os | ||
32 | import bb | ||
33 | import time | ||
34 | import subprocess | ||
35 | import sys | ||
36 | import pexpect | ||
37 | |||
38 | import oeqa.utils.sshcontrol as sshcontrol | ||
39 | from oeqa.controllers.masterimage import MasterImageHardwareTarget | ||
40 | |||
41 | |||
42 | class EdgeRouterTarget(MasterImageHardwareTarget): | ||
43 | |||
44 | def __init__(self, d): | ||
45 | super(EdgeRouterTarget, self).__init__(d) | ||
46 | |||
47 | self.deploy_cmds = [ | ||
48 | 'mount -L boot /boot', | ||
49 | 'mkdir -p /mnt/testrootfs', | ||
50 | 'mount -L testrootfs /mnt/testrootfs', | ||
51 | 'cp ~/test-kernel /boot', | ||
52 | 'rm -rf /mnt/testrootfs/*', | ||
53 | 'tar xzvf ~/test-rootfs.tar.gz -C /mnt/testrootfs' | ||
54 | ] | ||
55 | if not self.serialcontrol_cmd: | ||
56 | bb.fatal("This TEST_TARGET needs a TEST_SERIALCONTROL_CMD defined in local.conf.") | ||
57 | |||
58 | |||
59 | def _deploy(self): | ||
60 | self.master.run("umount /mnt/testrootfs;") | ||
61 | self.master.ignore_status = False | ||
62 | self.master.copy_to(self.kernel, "~/test-kernel") | ||
63 | self.master.copy_to(self.rootfs, "~/test-rootfs.tar.gz") | ||
64 | for cmd in self.deploy_cmds: | ||
65 | self.master.run(cmd) | ||
66 | |||
67 | def _start(self, params=None): | ||
68 | self.power_cycle(self.master) | ||
69 | try: | ||
70 | serialconn = pexpect.spawn(self.serialcontrol_cmd, env=self.origenv, logfile=sys.stdout) | ||
71 | serialconn.expect("U-Boot") | ||
72 | serialconn.sendline("a") | ||
73 | serialconn.expect("Octeon ubnt_e100#") | ||
74 | serialconn.sendline("fatload usb 0:1 $loadaddr test-kernel") | ||
75 | serialconn.expect(" bytes read") | ||
76 | serialconn.expect("Octeon ubnt_e100#") | ||
77 | serialconn.sendline("bootoctlinux $loadaddr coremask=0x3 root=/dev/sda3 rw rootwait mtdparts=phys_mapped_flash:512k(boot0),512k(boot1),64k@3072k(eeprom)") | ||
78 | serialconn.expect("login:", timeout=120) | ||
79 | serialconn.close() | ||
80 | except pexpect.ExceptionPexpect as e: | ||
81 | bb.fatal('Serial interaction failed: %s' % str(e)) | ||
82 | |||
83 | def _wait_until_booted(self): | ||
84 | try: | ||
85 | serialconn = pexpect.spawn(self.serialcontrol_cmd, env=self.origenv, logfile=sys.stdout) | ||
86 | serialconn.expect("login:", timeout=120) | ||
87 | serialconn.close() | ||
88 | except pexpect.ExceptionPexpect as e: | ||
89 | bb.fatal('Serial interaction failed: %s' % str(e)) | ||