diff options
Diffstat (limited to 'meta-yocto-bsp/lib/oeqa')
4 files changed, 259 insertions, 0 deletions
diff --git a/meta-yocto-bsp/lib/oeqa/controllers/__init__.py b/meta-yocto-bsp/lib/oeqa/controllers/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/meta-yocto-bsp/lib/oeqa/controllers/__init__.py | |||
diff --git a/meta-yocto-bsp/lib/oeqa/controllers/beaglebonetarget.py b/meta-yocto-bsp/lib/oeqa/controllers/beaglebonetarget.py new file mode 100644 index 0000000000..0f1aeb398f --- /dev/null +++ b/meta-yocto-bsp/lib/oeqa/controllers/beaglebonetarget.py | |||
@@ -0,0 +1,98 @@ | |||
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 BeagleBone (original "white" or Black models). The device must | ||
7 | # be set up as per README.hardware and the master image should be deployed | ||
8 | # onto the card so that it boots into it by default. For booting into the | ||
9 | # image under test we interact with u-boot over serial, so for the | ||
10 | # BeagleBone Black you will need an additional TTL serial cable since a | ||
11 | # serial interface isn't automatically provided over the USB connection as | ||
12 | # it is on the original BeagleBone ("white") version. The separate ext3 | ||
13 | # partition that will contain the image to be tested must be labelled | ||
14 | # "testrootfs" so that the deployment code below can find it. | ||
15 | # | ||
16 | # NOTE: for the BeagleBone "white" (original version) you may need to use | ||
17 | # a script which handles the serial device disappearing on power down, such | ||
18 | # as scripts/contrib/serdevtry in OE-Core. | ||
19 | |||
20 | import os | ||
21 | import bb | ||
22 | import time | ||
23 | import subprocess | ||
24 | import sys | ||
25 | import pexpect | ||
26 | |||
27 | import oeqa.utils.sshcontrol as sshcontrol | ||
28 | from oeqa.controllers.masterimage import MasterImageHardwareTarget | ||
29 | |||
30 | |||
31 | class BeagleBoneTarget(MasterImageHardwareTarget): | ||
32 | |||
33 | dtbs = {'uImage-am335x-bone.dtb': 'am335x-bone.dtb', 'uImage-am335x-boneblack.dtb': 'am335x-boneblack.dtb'} | ||
34 | |||
35 | @classmethod | ||
36 | def get_extra_files(self): | ||
37 | return list(self.dtbs.keys()) | ||
38 | |||
39 | def __init__(self, d): | ||
40 | super(BeagleBoneTarget, self).__init__(d) | ||
41 | |||
42 | self.image_fstype = self.get_image_fstype(d) | ||
43 | self.deploy_cmds = [ | ||
44 | 'mkdir -p /mnt/testrootfs', | ||
45 | 'mount -L testrootfs /mnt/testrootfs', | ||
46 | 'rm -rf /mnt/testrootfs/*', | ||
47 | 'tar xvf ~/test-rootfs.%s -C /mnt/testrootfs' % self.image_fstype, | ||
48 | '[ -e /mnt/testrootfs/boot/uImage ] || [ -L /mnt/testrootfs/boot/uImage ] || cp ~/test-kernel /mnt/testrootfs/boot/uImage', | ||
49 | ] | ||
50 | |||
51 | for _, dtbfn in self.dtbs.iteritems(): | ||
52 | # Kernel and dtb files may not be in the image, so copy them if not | ||
53 | self.deploy_cmds.append('[ -e /mnt/testrootfs/boot/{0} ] || cp ~/{0} /mnt/testrootfs/boot/'.format(dtbfn)) | ||
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 /boot; umount /mnt/testrootfs;") | ||
61 | self.master.ignore_status = False | ||
62 | # Kernel and dtb files may not be in the image, so copy them just in case | ||
63 | self.master.copy_to(self.kernel, "~/test-kernel") | ||
64 | kernelpath = os.path.dirname(self.kernel) | ||
65 | for dtborig, dtbfn in self.dtbs.iteritems(): | ||
66 | dtbfile = os.path.join(kernelpath, dtborig) | ||
67 | if os.path.exists(dtbfile): | ||
68 | self.master.copy_to(dtbfile, "~/%s" % dtbfn) | ||
69 | self.master.copy_to(self.rootfs, "~/test-rootfs.%s" % self.image_fstype) | ||
70 | for cmd in self.deploy_cmds: | ||
71 | self.master.run(cmd) | ||
72 | |||
73 | def _start(self, params=None): | ||
74 | self.power_cycle(self.master) | ||
75 | try: | ||
76 | serialconn = pexpect.spawn(self.serialcontrol_cmd, env=self.origenv, logfile=sys.stdout) | ||
77 | # We'd wait for "U-Boot" here but sometimes we connect too late on BeagleBone white to see it | ||
78 | serialconn.expect("NAND:") | ||
79 | serialconn.expect("MMC:") | ||
80 | serialconn.sendline("a") | ||
81 | serialconn.expect("U-Boot#") | ||
82 | serialconn.sendline("setenv bootpart 0:3") | ||
83 | serialconn.expect("U-Boot#") | ||
84 | serialconn.sendline("setenv mmcroot /dev/mmcblk0p3 ro") | ||
85 | serialconn.expect("U-Boot#") | ||
86 | serialconn.sendline("boot") | ||
87 | serialconn.expect("login:", timeout=120) | ||
88 | serialconn.close() | ||
89 | except pexpect.ExceptionPexpect as e: | ||
90 | bb.fatal('Serial interaction failed: %s' % str(e)) | ||
91 | |||
92 | def _wait_until_booted(self): | ||
93 | try: | ||
94 | serialconn = pexpect.spawn(self.serialcontrol_cmd, env=self.origenv, logfile=sys.stdout) | ||
95 | serialconn.expect("login:", timeout=120) | ||
96 | serialconn.close() | ||
97 | except pexpect.ExceptionPexpect as e: | ||
98 | bb.fatal('Serial interaction failed: %s' % str(e)) | ||
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..b3338ca859 --- /dev/null +++ b/meta-yocto-bsp/lib/oeqa/controllers/edgeroutertarget.py | |||
@@ -0,0 +1,90 @@ | |||
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.image_fstype = self.get_image_fstype(d) | ||
48 | self.deploy_cmds = [ | ||
49 | 'mount -L boot /boot', | ||
50 | 'mkdir -p /mnt/testrootfs', | ||
51 | 'mount -L testrootfs /mnt/testrootfs', | ||
52 | 'cp ~/test-kernel /boot', | ||
53 | 'rm -rf /mnt/testrootfs/*', | ||
54 | 'tar xvf ~/test-rootfs.%s -C /mnt/testrootfs' % self.image_fstype | ||
55 | ] | ||
56 | if not self.serialcontrol_cmd: | ||
57 | bb.fatal("This TEST_TARGET needs a TEST_SERIALCONTROL_CMD defined in local.conf.") | ||
58 | |||
59 | |||
60 | def _deploy(self): | ||
61 | self.master.run("umount /mnt/testrootfs;") | ||
62 | self.master.ignore_status = False | ||
63 | self.master.copy_to(self.kernel, "~/test-kernel") | ||
64 | self.master.copy_to(self.rootfs, "~/test-rootfs.%s" % self.image_fstype) | ||
65 | for cmd in self.deploy_cmds: | ||
66 | self.master.run(cmd) | ||
67 | |||
68 | def _start(self, params=None): | ||
69 | self.power_cycle(self.master) | ||
70 | try: | ||
71 | serialconn = pexpect.spawn(self.serialcontrol_cmd, env=self.origenv, logfile=sys.stdout) | ||
72 | serialconn.expect("U-Boot") | ||
73 | serialconn.sendline("a") | ||
74 | serialconn.expect("Octeon ubnt_e100#") | ||
75 | serialconn.sendline("fatload usb 0:1 $loadaddr test-kernel") | ||
76 | serialconn.expect(" bytes read") | ||
77 | serialconn.expect("Octeon ubnt_e100#") | ||
78 | serialconn.sendline("bootoctlinux $loadaddr coremask=0x3 root=/dev/sda3 rw rootwait mtdparts=phys_mapped_flash:512k(boot0),512k(boot1),64k@3072k(eeprom)") | ||
79 | serialconn.expect("login:", timeout=120) | ||
80 | serialconn.close() | ||
81 | except pexpect.ExceptionPexpect as e: | ||
82 | bb.fatal('Serial interaction failed: %s' % str(e)) | ||
83 | |||
84 | def _wait_until_booted(self): | ||
85 | try: | ||
86 | serialconn = pexpect.spawn(self.serialcontrol_cmd, env=self.origenv, logfile=sys.stdout) | ||
87 | serialconn.expect("login:", timeout=120) | ||
88 | serialconn.close() | ||
89 | except pexpect.ExceptionPexpect as e: | ||
90 | bb.fatal('Serial interaction failed: %s' % str(e)) | ||
diff --git a/meta-yocto-bsp/lib/oeqa/controllers/grubtarget.py b/meta-yocto-bsp/lib/oeqa/controllers/grubtarget.py new file mode 100644 index 0000000000..7bc807d2bc --- /dev/null +++ b/meta-yocto-bsp/lib/oeqa/controllers/grubtarget.py | |||
@@ -0,0 +1,71 @@ | |||
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 Generic PC that boots using grub bootloader. The device must | ||
7 | # be set up as per README.hardware and the master image should be deployed | ||
8 | # onto the harddisk so that it boots into it by default.For booting into the | ||
9 | # image under test we interact with grub over serial, so for the | ||
10 | # Generic PC you will need an additional serial cable and device under test | ||
11 | # needs to have a serial interface. The separate ext3 | ||
12 | # partition that will contain the image to be tested must be labelled | ||
13 | # "testrootfs" so that the deployment code below can find it. | ||
14 | |||
15 | import os | ||
16 | import bb | ||
17 | import time | ||
18 | import subprocess | ||
19 | import sys | ||
20 | import pexpect | ||
21 | |||
22 | import oeqa.utils.sshcontrol as sshcontrol | ||
23 | from oeqa.controllers.masterimage import MasterImageHardwareTarget | ||
24 | |||
25 | class GrubTarget(MasterImageHardwareTarget): | ||
26 | |||
27 | def __init__(self, d): | ||
28 | super(GrubTarget, self).__init__(d) | ||
29 | self.deploy_cmds = [ | ||
30 | 'mount -L boot /boot', | ||
31 | 'mkdir -p /mnt/testrootfs', | ||
32 | 'mount -L testrootfs /mnt/testrootfs', | ||
33 | 'cp ~/test-kernel /boot', | ||
34 | 'rm -rf /mnt/testrootfs/*', | ||
35 | 'tar xvf ~/test-rootfs.%s -C /mnt/testrootfs' % self.image_fstype, | ||
36 | ] | ||
37 | |||
38 | if not self.serialcontrol_cmd: | ||
39 | bb.fatal("This TEST_TARGET needs a TEST_SERIALCONTROL_CMD defined in local.conf.") | ||
40 | |||
41 | |||
42 | def _deploy(self): | ||
43 | # make sure these aren't mounted | ||
44 | self.master.run("umount /boot; umount /mnt/testrootfs;") | ||
45 | self.master.ignore_status = False | ||
46 | # Kernel files may not be in the image, so copy them just in case | ||
47 | self.master.copy_to(self.rootfs, "~/test-rootfs." + self.image_fstype) | ||
48 | self.master.copy_to(self.kernel, "~/test-kernel") | ||
49 | for cmd in self.deploy_cmds: | ||
50 | self.master.run(cmd) | ||
51 | |||
52 | def _start(self, params=None): | ||
53 | self.power_cycle(self.master) | ||
54 | try: | ||
55 | serialconn = pexpect.spawn(self.serialcontrol_cmd, env=self.origenv, logfile=sys.stdout) | ||
56 | serialconn.expect("GNU GRUB version 2.00") | ||
57 | serialconn.expect("Linux") | ||
58 | serialconn.sendline("x") | ||
59 | serialconn.expect("login:", timeout=120) | ||
60 | serialconn.close() | ||
61 | except pexpect.ExceptionPexpect as e: | ||
62 | bb.fatal('Serial interaction failed: %s' % str(e)) | ||
63 | |||
64 | def _wait_until_booted(self): | ||
65 | try: | ||
66 | serialconn = pexpect.spawn(self.serialcontrol_cmd, env=self.origenv, logfile=sys.stdout) | ||
67 | serialconn.expect("login:", timeout=120) | ||
68 | serialconn.close() | ||
69 | except pexpect.ExceptionPexpect as e: | ||
70 | bb.fatal('Serial interaction failed: %s' % str(e)) | ||
71 | |||