diff options
Diffstat (limited to 'meta/lib/oeqa/selftest/devtool.py')
| -rw-r--r-- | meta/lib/oeqa/selftest/devtool.py | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py index 4e22e1dfe4..c4a0399832 100644 --- a/meta/lib/oeqa/selftest/devtool.py +++ b/meta/lib/oeqa/selftest/devtool.py | |||
| @@ -60,6 +60,27 @@ class DevtoolBase(oeSelfTest): | |||
| 60 | self.add_command_to_tearDown('bitbake-layers remove-layer %s || true' % templayerdir) | 60 | self.add_command_to_tearDown('bitbake-layers remove-layer %s || true' % templayerdir) |
| 61 | result = runCmd('bitbake-layers add-layer %s' % templayerdir, cwd=self.builddir) | 61 | result = runCmd('bitbake-layers add-layer %s' % templayerdir, cwd=self.builddir) |
| 62 | 62 | ||
| 63 | def _process_ls_output(self, output): | ||
| 64 | """ | ||
| 65 | Convert ls -l output to a format we can reasonably compare from one context | ||
| 66 | to another (e.g. from host to target) | ||
| 67 | """ | ||
| 68 | filelist = [] | ||
| 69 | for line in output.splitlines(): | ||
| 70 | splitline = line.split() | ||
| 71 | # Remove trailing . on perms | ||
| 72 | splitline[0] = splitline[0].rstrip('.') | ||
| 73 | # Remove leading . on paths | ||
| 74 | splitline[-1] = splitline[-1].lstrip('.') | ||
| 75 | # Drop fields we don't want to compare | ||
| 76 | del splitline[7] | ||
| 77 | del splitline[6] | ||
| 78 | del splitline[5] | ||
| 79 | del splitline[4] | ||
| 80 | del splitline[1] | ||
| 81 | filelist.append(' '.join(splitline)) | ||
| 82 | return filelist | ||
| 83 | |||
| 63 | 84 | ||
| 64 | class DevtoolTests(DevtoolBase): | 85 | class DevtoolTests(DevtoolBase): |
| 65 | 86 | ||
| @@ -796,9 +817,32 @@ class DevtoolTests(DevtoolBase): | |||
| 796 | console.expect("login:", timeout=120) | 817 | console.expect("login:", timeout=120) |
| 797 | # Now really test deploy-target | 818 | # Now really test deploy-target |
| 798 | result = runCmd('devtool deploy-target -c %s root@%s' % (testrecipe, testhost)) | 819 | result = runCmd('devtool deploy-target -c %s root@%s' % (testrecipe, testhost)) |
| 799 | result = runCmd('ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@%s %s' % (testhost, testcommand)) | 820 | # Run a test command to see if it was installed properly |
| 821 | sshargs = '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' | ||
| 822 | result = runCmd('ssh %s root@%s %s' % (sshargs, testhost, testcommand)) | ||
| 823 | # Check if it deployed all of the files with the right ownership/perms | ||
| 824 | # First look on the host - need to do this under pseudo to get the correct ownership/perms | ||
| 825 | installdir = get_bb_var('D', testrecipe) | ||
| 826 | fakerootenv = get_bb_var('FAKEROOTENV', testrecipe) | ||
| 827 | fakerootcmd = get_bb_var('FAKEROOTCMD', testrecipe) | ||
| 828 | result = runCmd('%s %s find . -type f -exec ls -l {} \;' % (fakerootenv, fakerootcmd), cwd=installdir) | ||
| 829 | filelist1 = self._process_ls_output(result.output) | ||
| 830 | |||
| 831 | # Now look on the target | ||
| 832 | tempdir2 = tempfile.mkdtemp(prefix='devtoolqa') | ||
| 833 | self.track_for_cleanup(tempdir2) | ||
| 834 | tmpfilelist = os.path.join(tempdir2, 'files.txt') | ||
| 835 | with open(tmpfilelist, 'w') as f: | ||
| 836 | for line in filelist1: | ||
| 837 | splitline = line.split() | ||
| 838 | f.write(splitline[-1] + '\n') | ||
| 839 | result = runCmd('cat %s | ssh -q %s root@%s \'xargs ls -l\'' % (tmpfilelist, sshargs, testhost)) | ||
| 840 | filelist2 = self._process_ls_output(result.output) | ||
| 841 | filelist1.sort(key=lambda item: item.split()[-1]) | ||
| 842 | filelist2.sort(key=lambda item: item.split()[-1]) | ||
| 843 | self.assertEqual(filelist1, filelist2) | ||
| 800 | # Test undeploy-target | 844 | # Test undeploy-target |
| 801 | result = runCmd('devtool undeploy-target -c %s root@%s' % (testrecipe, testhost)) | 845 | result = runCmd('devtool undeploy-target -c %s root@%s' % (testrecipe, testhost)) |
| 802 | result = runCmd('ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@%s %s' % (testhost, testcommand), ignore_status=True) | 846 | result = runCmd('ssh %s root@%s %s' % (sshargs, testhost, testcommand), ignore_status=True) |
| 803 | self.assertNotEqual(result, 0, 'undeploy-target did not remove command as it should have') | 847 | self.assertNotEqual(result, 0, 'undeploy-target did not remove command as it should have') |
| 804 | console.close() | 848 | console.close() |
