Skip to contentSkip to conversation

Automated hardware testing bugfixes and grub target controller feature

PATCH New Cristian Iorga 1 participant 6 messages Jun 20, 2014

lore
Share & tools
lore
#0 lore raw

cover Automated hardware testing bugfixes and grub target controller feature

Various fixes related to master image install script and GRUB targets controller implemented.

The following changes since commit 7c1a975a1c2fd884aa9f6f4736656d854a6c5edb:

bitbake: toaster: Fix spacing and layout in no image files notification (2014-06-20 14:03:58 +0100)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib ciorga/YB5615
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=ciorga/YB5615

Cristian Iorga (5):
init-install-testfs: add grub serial line support oe-core/init-install-testfs.sh: do not overwrite /etc/mtab if the link
already exist
init-install-testfs: fix typo
init-install-testfs: create signature file for master image
meta-yocto-bsp: oeqa/controllers: add GrubTarget

 meta-yocto-bsp/lib/oeqa/controllers/grubtarget.py  | 71 ++++++++++++++++++++++
 .../initrdscripts/files/init-install-testfs.sh     | 15 ++++-
 2 files changed, 84 insertions(+), 2 deletions(-)
 create mode 100644 meta-yocto-bsp/lib/oeqa/controllers/grubtarget.py
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/5 init-install-testfs: add grub serial line support

For automated hardware testing, boot process control via serial interface is needed. As such, in grub, serial line support is added upon testmaster image install.

Also add a specific timeout to automatically start the master image upon start of testing phase.

Tested on multiple hardware targets without issues.

---
 meta/recipes-core/initrdscripts/files/init-install-testfs.sh | 5 +++++
 1 file changed, 5 insertions(+)
meta/recipes-core/initrdscripts/files/init-install-testfs.sh +5 -0
index 116a6b7..6faa233 100644
@@ -172,6 +172,11 @@ if [ -f /etc/grub.d/00_header ] ; then
     GRUBCFG="/boot/grub/grub.cfg"
     mkdir -p $(dirname $GRUBCFG)
     cat >$GRUBCFG <<_EOF 
+serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1
+terminal_input --append  serial
+terminal_output --append serial
+set timeout_style=hidden
+set timeout=5
 menuentry "Linux" {
     set root=(hd0,1)
     linux /vmlinuz root=$rootfs $rootwait rw $5 $3 $4 quiet
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/5 oe-core/init-install-testfs.sh: do not overwrite /etc/mtab if the link already exist

In reply to Cristian Iorga

Overwriting of /etc/mtab would fail as below if the /etc/mtab link already exist during installation phase, this patch fix this problem by checking existance of the link before try to overwrite it.

Error message during installation if the /etc/mtab exists:
"cat: /proc/mounts: input file is output file"

---
 meta/recipes-core/initrdscripts/files/init-install-testfs.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta/recipes-core/initrdscripts/files/init-install-testfs.sh +3 -1
index 6faa233..d2cc6ac 100644
@@ -90,7 +90,9 @@ if [ ! -b /dev/loop0 ] ; then
 fi
 
 mkdir -p /tmp
-cat /proc/mounts > /etc/mtab
+if [ ! -L /etc/mtab ]; then
+	cat /proc/mounts > /etc/mtab
+fi
 
 disk_size=$(parted /dev/${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//")
 
Signature · 1 line
1.9.1
#3 lore raw

PATCH 3/5 init-install-testfs: fix typo

In reply to Cristian Iorga

_EOF marker was not used properly
(space left before end of line).

---
 meta/recipes-core/initrdscripts/files/init-install-testfs.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-core/initrdscripts/files/init-install-testfs.sh +1 -1
index d2cc6ac..cf290a5 100644
@@ -183,7 +183,7 @@ menuentry "Linux" {
     set root=(hd0,1)
     linux /vmlinuz root=$rootfs $rootwait rw $5 $3 $4 quiet
 }
-_EOF 
+_EOF
     # Add the test label
     echo -ne "\nmenuentry 'test' {\nlinux /test-kernel root=$testfs rw $rootwait quiet\n}\n" >> $GRUBCFG
 
Signature · 1 line
1.9.1
#4 lore raw

PATCH 4/5 init-install-testfs: create signature file for master image

In reply to Cristian Iorga

Also small cosmetic changes.

---
 meta/recipes-core/initrdscripts/files/init-install-testfs.sh | 4 ++++
 1 file changed, 4 insertions(+)
meta/recipes-core/initrdscripts/files/init-install-testfs.sh +4 -0
index cf290a5..618a53d 100644
@@ -154,8 +154,12 @@ mkdir -p /boot
 # Handling of the target root partition
 mount $rootfs /tgt_root
 mount -o rw,loop,noatime,nodiratime /run/media/$1/$2 /src_root
+
 echo "Copying rootfs files..."
 cp -a /src_root/* /tgt_root
+
+touch /tgt_root/etc/masterimage
+
 if [ -d /tgt_root/etc/ ] ; then
     echo "$bootfs              /boot            ext3       defaults              1  2" >> /tgt_root/etc/fstab
     # We dont want udev to mount our root device while we're booting...
Signature · 1 line
1.9.1
#5 lore raw

PATCH 5/5 meta-yocto-bsp: oeqa/controllers: add GrubTarget

In reply to Cristian Iorga

add control for generic grub pc via serial line

Implementation [YOCTO #5615].

---
 meta-yocto-bsp/lib/oeqa/controllers/grubtarget.py | 71 +++++++++++++++++++++++
 1 file changed, 71 insertions(+)
 create mode 100644 meta-yocto-bsp/lib/oeqa/controllers/grubtarget.py
meta-yocto-bsp/lib/oeqa/controllers/grubtarget.py new file +71 -0
new file mode 100644
index 0000000..02ada65
@@ -0,0 +1,71 @@
+# Copyright (C) 2014 Intel Corporation
+#
+# Released under the MIT license (see COPYING.MIT)
+
+# This module adds support to testimage.bbclass to deploy images and run
+# tests on a Generic PC that boots using grub bootloader. The device must
+# be set up as per README.hardware and the master image should be deployed
+# onto the harddisk so that it boots into it by default.For booting into the
+# image under test we interact with grub over serial, so for the
+# Generic PC you will need an additional serial cable and device under test
+# needs to have a serial interface. The separate ext3
+# partition that will contain the image to be tested must be labelled
+# "testrootfs" so that the deployment code below can find it.
+
+import os
+import bb
+import time
+import subprocess
+import sys
+import pexpect
+
+import oeqa.utils.sshcontrol as sshcontrol
+from oeqa.controllers.masterimage import MasterImageHardwareTarget
+
+class GrubTarget(MasterImageHardwareTarget):
+
+    def __init__(self, d):
+        super(GrubTarget, self).__init__(d)
+        self.deploy_cmds = [
+                'mount -L boot /boot',
+                'mkdir -p /mnt/testrootfs',
+                'mount -L testrootfs /mnt/testrootfs',
+                'cp ~/test-kernel /boot',
+                'rm -rf /mnt/testrootfs/*',
+                'tar xvf ~/test-rootfs.%s -C /mnt/testrootfs' % self.image_fstype,
+                ]
+
+        if not self.serialcontrol_cmd:
+            bb.fatal("This TEST_TARGET needs a TEST_SERIALCONTROL_CMD defined in local.conf.")
+
+
+    def _deploy(self):
+        # make sure these aren't mounted
+        self.master.run("umount /boot; umount /mnt/testrootfs;")
+        self.master.ignore_status = False
+        # Kernel files may not be in the image, so copy them just in case
+        self.master.copy_to(self.rootfs, "~/test-rootfs." + self.image_fstype)
+        self.master.copy_to(self.kernel, "~/test-kernel")
+        for cmd in self.deploy_cmds:
+            self.master.run(cmd)
+
+    def _start(self, params=None):
+        self.power_cycle(self.master)
+        try:
+            serialconn = pexpect.spawn(self.serialcontrol_cmd, env=self.origenv, logfile=sys.stdout)
+            serialconn.expect("GNU GRUB  version 2.00")
+            serialconn.expect("Linux")
+            serialconn.sendline("OB\r")
+            serialconn.expect("login:", timeout=120)
+            serialconn.close()
+        except pexpect.ExceptionPexpect as e:
+            bb.fatal('Serial interaction failed: %s' % str(e))
+
+    def _wait_until_booted(self):
+        try:
+            serialconn = pexpect.spawn(self.serialcontrol_cmd, env=self.origenv, logfile=sys.stdout)
+            serialconn.expect("login:", timeout=120)
+            serialconn.close()
+        except pexpect.ExceptionPexpect as e:
+            bb.fatal('Serial interaction failed: %s' % str(e))
+
Signature · 1 line
1.9.1