diff options
| author | Daniel Gomez <daniel@qtec.com> | 2021-08-17 22:11:15 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-08-20 08:53:03 +0100 |
| commit | 9986923d05f87101a56f85c9a27258fd82d8b1ef (patch) | |
| tree | 89aed186ad529daa9115ac1a5f1f7eb28a58c129 | |
| parent | 6fdbc5144f3505b11f09364775a0c08cf62f4d21 (diff) | |
| download | poky-9986923d05f87101a56f85c9a27258fd82d8b1ef.tar.gz | |
oeqa: wic: Add tests for --no-fstab-update
Add tests for the --no-fstab-update wic part command.
(From OE-Core rev: 90141d41a370ff377d95fb3dd144b63a85e22f8e)
Signed-off-by: Daniel Gomez <daniel@qtec.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/lib/oeqa/selftest/cases/wic.py | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py index 2efbe514c1..3b4143414f 100644 --- a/meta/lib/oeqa/selftest/cases/wic.py +++ b/meta/lib/oeqa/selftest/cases/wic.py | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | import os | 11 | import os |
| 12 | import sys | 12 | import sys |
| 13 | import unittest | 13 | import unittest |
| 14 | import hashlib | ||
| 14 | 15 | ||
| 15 | from glob import glob | 16 | from glob import glob |
| 16 | from shutil import rmtree, copy | 17 | from shutil import rmtree, copy |
| @@ -686,6 +687,63 @@ part /etc --source rootfs --fstype=ext4 --change-directory=etc | |||
| 686 | % (wks_file, self.resultdir), ignore_status=True).status) | 687 | % (wks_file, self.resultdir), ignore_status=True).status) |
| 687 | os.remove(wks_file) | 688 | os.remove(wks_file) |
| 688 | 689 | ||
| 690 | def test_no_fstab_update(self): | ||
| 691 | """Test --no-fstab-update wks option.""" | ||
| 692 | |||
| 693 | oldpath = os.environ['PATH'] | ||
| 694 | os.environ['PATH'] = get_bb_var("PATH", "wic-tools") | ||
| 695 | |||
| 696 | # Get stock fstab from base-files recipe | ||
| 697 | self.assertEqual(0, bitbake('base-files -c do_install').status) | ||
| 698 | bf_fstab = os.path.join(get_bb_var('D', 'base-files'), 'etc/fstab') | ||
| 699 | self.assertEqual(True, os.path.exists(bf_fstab)) | ||
| 700 | bf_fstab_md5sum = runCmd('md5sum %s 2>/dev/null' % bf_fstab).output.split(" ")[0] | ||
| 701 | |||
| 702 | try: | ||
| 703 | no_fstab_update_path = os.path.join(self.resultdir, 'test-no-fstab-update') | ||
| 704 | os.makedirs(no_fstab_update_path) | ||
| 705 | wks_file = os.path.join(no_fstab_update_path, 'temp.wks') | ||
| 706 | with open(wks_file, 'w') as wks: | ||
| 707 | wks.writelines(['part / --source rootfs --fstype=ext4 --label rootfs\n', | ||
| 708 | 'part /mnt/p2 --source rootfs --rootfs-dir=core-image-minimal ', | ||
| 709 | '--fstype=ext4 --label p2 --no-fstab-update\n']) | ||
| 710 | runCmd("wic create %s -e core-image-minimal -o %s" \ | ||
| 711 | % (wks_file, self.resultdir)) | ||
| 712 | |||
| 713 | part_fstab_md5sum = [] | ||
| 714 | for i in range(1, 3): | ||
| 715 | part = glob(os.path.join(self.resultdir, 'temp-*.direct.p') + str(i))[0] | ||
| 716 | part_fstab = runCmd("debugfs -R 'cat etc/fstab' %s 2>/dev/null" % (part)) | ||
| 717 | part_fstab_md5sum.append(hashlib.md5((part_fstab.output + "\n\n").encode('utf-8')).hexdigest()) | ||
| 718 | |||
| 719 | # '/etc/fstab' in partition 2 should contain the same stock fstab file | ||
| 720 | # as the one installed by the base-file recipe. | ||
| 721 | self.assertEqual(bf_fstab_md5sum, part_fstab_md5sum[1]) | ||
| 722 | |||
| 723 | # '/etc/fstab' in partition 1 should contain an updated fstab file. | ||
| 724 | self.assertNotEqual(bf_fstab_md5sum, part_fstab_md5sum[0]) | ||
| 725 | |||
| 726 | finally: | ||
| 727 | os.environ['PATH'] = oldpath | ||
| 728 | |||
| 729 | def test_no_fstab_update_errors(self): | ||
| 730 | """Test --no-fstab-update wks option error handling.""" | ||
| 731 | wks_file = 'temp.wks' | ||
| 732 | |||
| 733 | # Absolute argument. | ||
| 734 | with open(wks_file, 'w') as wks: | ||
| 735 | wks.write("part / --source rootfs --fstype=ext4 --no-fstab-update /etc") | ||
| 736 | self.assertNotEqual(0, runCmd("wic create %s -e core-image-minimal -o %s" \ | ||
| 737 | % (wks_file, self.resultdir), ignore_status=True).status) | ||
| 738 | os.remove(wks_file) | ||
| 739 | |||
| 740 | # Argument pointing to parent directory. | ||
| 741 | with open(wks_file, 'w') as wks: | ||
| 742 | wks.write("part / --source rootfs --fstype=ext4 --no-fstab-update ././..") | ||
| 743 | self.assertNotEqual(0, runCmd("wic create %s -e core-image-minimal -o %s" \ | ||
| 744 | % (wks_file, self.resultdir), ignore_status=True).status) | ||
| 745 | os.remove(wks_file) | ||
| 746 | |||
| 689 | class Wic2(WicTestCase): | 747 | class Wic2(WicTestCase): |
| 690 | 748 | ||
| 691 | def test_bmap_short(self): | 749 | def test_bmap_short(self): |
