summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-07-27 14:04:06 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-07-27 23:29:15 +0100
commitedc7780ab749534176780a247ab36d4a1575bc30 (patch)
treeb4f9a308475716b9aec3924537a8b0d4e922b968
parentc256bbc44d250ce0baf842397b5f710c7e56c5e0 (diff)
downloadpoky-edc7780ab749534176780a247ab36d4a1575bc30.tar.gz
oeqa/selftest/devtool: use new runqemu function
Use the common code we now have to run QEMU instead of running it ourselves, avoiding reliance on the machine showing up at 192.168.7.2. This also makes a copy of the image rather than using -snapshot so if we need to inspect the image after a failure, we can. Fixes [YOCTO #7928]. (From OE-Core rev: 3d3748a237bb06ce7d9520bf485ef0c6cf1adc86) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/selftest/devtool.py72
1 files changed, 34 insertions, 38 deletions
diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py
index 21cd7f5291..c833e5439c 100644
--- a/meta/lib/oeqa/selftest/devtool.py
+++ b/meta/lib/oeqa/selftest/devtool.py
@@ -8,7 +8,7 @@ import glob
8 8
9import oeqa.utils.ftools as ftools 9import oeqa.utils.ftools as ftools
10from oeqa.selftest.base import oeSelfTest 10from oeqa.selftest.base import oeSelfTest
11from oeqa.utils.commands import runCmd, bitbake, get_bb_var, create_temp_layer 11from oeqa.utils.commands import runCmd, bitbake, get_bb_var, create_temp_layer, runqemu
12from oeqa.utils.decorators import testcase 12from oeqa.utils.decorators import testcase
13 13
14class DevtoolBase(oeSelfTest): 14class DevtoolBase(oeSelfTest):
@@ -799,12 +799,10 @@ class DevtoolTests(DevtoolBase):
799 self.skipTest('No tap devices found - you must set up tap devices with scripts/runqemu-gen-tapdevs before running this test') 799 self.skipTest('No tap devices found - you must set up tap devices with scripts/runqemu-gen-tapdevs before running this test')
800 workspacedir = os.path.join(self.builddir, 'workspace') 800 workspacedir = os.path.join(self.builddir, 'workspace')
801 self.assertTrue(not os.path.exists(workspacedir), 'This test cannot be run with a workspace directory under the build directory') 801 self.assertTrue(not os.path.exists(workspacedir), 'This test cannot be run with a workspace directory under the build directory')
802 import pexpect
803 # Definitions 802 # Definitions
804 testrecipe = 'mdadm' 803 testrecipe = 'mdadm'
805 testfile = '/sbin/mdadm' 804 testfile = '/sbin/mdadm'
806 testimage = 'oe-selftest-image' 805 testimage = 'oe-selftest-image'
807 testhost = '192.168.7.2'
808 testcommand = '/sbin/mdadm --help' 806 testcommand = '/sbin/mdadm --help'
809 # Build an image to run 807 # Build an image to run
810 bitbake("%s qemu-native qemu-helper-native" % testimage) 808 bitbake("%s qemu-native qemu-helper-native" % testimage)
@@ -821,44 +819,42 @@ class DevtoolTests(DevtoolBase):
821 self.add_command_to_tearDown('bitbake -c clean %s' % testrecipe) 819 self.add_command_to_tearDown('bitbake -c clean %s' % testrecipe)
822 result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir)) 820 result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir))
823 # Test that deploy-target at this point fails (properly) 821 # Test that deploy-target at this point fails (properly)
824 result = runCmd('devtool deploy-target -n %s root@%s' % (testrecipe, testhost), ignore_status=True) 822 result = runCmd('devtool deploy-target -n %s root@localhost' % testrecipe, ignore_status=True)
825 self.assertNotEqual(result.output, 0, 'devtool deploy-target should have failed, output: %s' % result.output) 823 self.assertNotEqual(result.output, 0, 'devtool deploy-target should have failed, output: %s' % result.output)
826 self.assertNotIn(result.output, 'Traceback', 'devtool deploy-target should have failed with a proper error not a traceback, output: %s' % result.output) 824 self.assertNotIn(result.output, 'Traceback', 'devtool deploy-target should have failed with a proper error not a traceback, output: %s' % result.output)
827 result = runCmd('devtool build %s' % testrecipe) 825 result = runCmd('devtool build %s' % testrecipe)
828 # First try a dry-run of deploy-target 826 # First try a dry-run of deploy-target
829 result = runCmd('devtool deploy-target -n %s root@%s' % (testrecipe, testhost)) 827 result = runCmd('devtool deploy-target -n %s root@localhost' % testrecipe)
830 self.assertIn(' %s' % testfile, result.output) 828 self.assertIn(' %s' % testfile, result.output)
831 # Boot the image 829 # Boot the image
832 console = pexpect.spawn('runqemu %s %s qemuparams="-snapshot" nographic' % (machine, testimage)) 830 with runqemu(testimage, self) as qemu:
833 console.expect("login:", timeout=120) 831 # Now really test deploy-target
834 # Now really test deploy-target 832 result = runCmd('devtool deploy-target -c %s root@%s' % (testrecipe, qemu.ip))
835 result = runCmd('devtool deploy-target -c %s root@%s' % (testrecipe, testhost)) 833 # Run a test command to see if it was installed properly
836 # Run a test command to see if it was installed properly 834 sshargs = '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
837 sshargs = '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' 835 result = runCmd('ssh %s root@%s %s' % (sshargs, qemu.ip, testcommand))
838 result = runCmd('ssh %s root@%s %s' % (sshargs, testhost, testcommand)) 836 # Check if it deployed all of the files with the right ownership/perms
839 # Check if it deployed all of the files with the right ownership/perms 837 # First look on the host - need to do this under pseudo to get the correct ownership/perms
840 # First look on the host - need to do this under pseudo to get the correct ownership/perms 838 installdir = get_bb_var('D', testrecipe)
841 installdir = get_bb_var('D', testrecipe) 839 fakerootenv = get_bb_var('FAKEROOTENV', testrecipe)
842 fakerootenv = get_bb_var('FAKEROOTENV', testrecipe) 840 fakerootcmd = get_bb_var('FAKEROOTCMD', testrecipe)
843 fakerootcmd = get_bb_var('FAKEROOTCMD', testrecipe) 841 result = runCmd('%s %s find . -type f -exec ls -l {} \;' % (fakerootenv, fakerootcmd), cwd=installdir)
844 result = runCmd('%s %s find . -type f -exec ls -l {} \;' % (fakerootenv, fakerootcmd), cwd=installdir) 842 filelist1 = self._process_ls_output(result.output)
845 filelist1 = self._process_ls_output(result.output) 843
846 844 # Now look on the target
847 # Now look on the target 845 tempdir2 = tempfile.mkdtemp(prefix='devtoolqa')
848 tempdir2 = tempfile.mkdtemp(prefix='devtoolqa') 846 self.track_for_cleanup(tempdir2)
849 self.track_for_cleanup(tempdir2) 847 tmpfilelist = os.path.join(tempdir2, 'files.txt')
850 tmpfilelist = os.path.join(tempdir2, 'files.txt') 848 with open(tmpfilelist, 'w') as f:
851 with open(tmpfilelist, 'w') as f: 849 for line in filelist1:
852 for line in filelist1: 850 splitline = line.split()
853 splitline = line.split() 851 f.write(splitline[-1] + '\n')
854 f.write(splitline[-1] + '\n') 852 result = runCmd('cat %s | ssh -q %s root@%s \'xargs ls -l\'' % (tmpfilelist, sshargs, qemu.ip))
855 result = runCmd('cat %s | ssh -q %s root@%s \'xargs ls -l\'' % (tmpfilelist, sshargs, testhost)) 853 filelist2 = self._process_ls_output(result.output)
856 filelist2 = self._process_ls_output(result.output) 854 filelist1.sort(key=lambda item: item.split()[-1])
857 filelist1.sort(key=lambda item: item.split()[-1]) 855 filelist2.sort(key=lambda item: item.split()[-1])
858 filelist2.sort(key=lambda item: item.split()[-1]) 856 self.assertEqual(filelist1, filelist2)
859 self.assertEqual(filelist1, filelist2) 857 # Test undeploy-target
860 # Test undeploy-target 858 result = runCmd('devtool undeploy-target -c %s root@%s' % (testrecipe, qemu.ip))
861 result = runCmd('devtool undeploy-target -c %s root@%s' % (testrecipe, testhost)) 859 result = runCmd('ssh %s root@%s %s' % (sshargs, qemu.ip, testcommand), ignore_status=True)
862 result = runCmd('ssh %s root@%s %s' % (sshargs, testhost, testcommand), ignore_status=True) 860 self.assertNotEqual(result, 0, 'undeploy-target did not remove command as it should have')
863 self.assertNotEqual(result, 0, 'undeploy-target did not remove command as it should have')
864 console.close()