소스 검색

selftest: wic: Add test for --part-name argument

Add test for wic --part-name argument in .wks file.
Test three different cases:
- Set only the --part-name argument.
- Set only the --label argument. In this case the GPT partition label
  is set to the value of --label for compatibility reasons.
- Set both. In this case the code has been changed to set the GPT
  partition label to the --part-name value.

The test uses a test_gpt_partition_name.wks file created for this
purpose.

(From OE-Core rev: 06af6795cf6f079362303bddb39a14459e228e72)

Signed-off-by: Dit Kozmaj <dit.kozmaj@kynetics.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Dit Kozmaj 2 년 전
부모
커밋
a60925d00a
2개의 변경된 파일30개의 추가작업 그리고 0개의 파일을 삭제
  1. 7 0
      meta-selftest/wic/test_gpt_partition_name.wks
  2. 23 0
      meta/lib/oeqa/selftest/cases/wic.py

+ 7 - 0
meta-selftest/wic/test_gpt_partition_name.wks

@@ -0,0 +1,7 @@
+# short-description: image to test part-name in GPT partitions
+
+part --fstype=ext4 --part-name boot-A --label boot --size 1M --align 1024
+part / --source rootfs --fstype=ext4 --part-name root-A --align 1024
+part --fstype=ext4 --label ext-space --size 1M --align 1024
+
+bootloader --ptable gpt

+ 23 - 0
meta/lib/oeqa/selftest/cases/wic.py

@@ -1348,6 +1348,29 @@ class Wic2(WicTestCase):
             if os.path.exists(image_path + '.bak'):
                 os.rename(image_path + '.bak', image_path)
 
+    def test_gpt_partition_name(self):
+        """Test --part-name argument to set partition name in GPT table"""
+        config = 'IMAGE_FSTYPES += "wic"\nWKS_FILE = "test_gpt_partition_name.wks"\n'
+        self.append_config(config)
+        bitbake('core-image-minimal')
+        self.remove_config(config)
+        deploy_dir = get_bb_var('DEPLOY_DIR_IMAGE')
+        machine = self.td['MACHINE']
+
+        image_path = os.path.join(deploy_dir, 'core-image-minimal-%s.wic' % machine)
+        # Image is created
+        self.assertTrue(os.path.exists(image_path))
+
+        # Check the names of the three partitions
+        # as listed in test_gpt_partition_name.wks
+        result = runCmd("sfdisk --part-label %s 1" % image_path)
+        self.assertEqual('boot-A', result.output)
+        result = runCmd("sfdisk --part-label %s 2" % image_path)
+        self.assertEqual('root-A', result.output)
+        # When the --part-name is not defined, the partition name is equal to the --label
+        result = runCmd("sfdisk --part-label %s 3" % image_path)
+        self.assertEqual('ext-space', result.output)
+
 class ModifyTests(WicTestCase):
     def test_wic_ls(self):
         """Test listing image content using 'wic ls'"""