public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: dit.kozmaj@kynetics.com
To: openembedded-core@lists.openembedded.org
Cc: Dit Kozmaj <dit.kozmaj@kynetics.com>
Subject: [PATCH 2/3] selftest: wic: Add test for --part-name argument
Date: Thu,  6 Apr 2023 10:44:16 +0200	[thread overview]
Message-ID: <20230406084417.34931-2-dit.kozmaj@kynetics.com> (raw)
In-Reply-To: <20230406084417.34931-1-dit.kozmaj@kynetics.com>

From: Dit Kozmaj <dit.kozmaj@kynetics.com>

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.

Signed-off-by: Dit Kozmaj <dit.kozmaj@kynetics.com>
---
 meta-selftest/wic/test_gpt_partition_name.wks |  7 ++++++
 meta/lib/oeqa/selftest/cases/wic.py           | 23 +++++++++++++++++++
 2 files changed, 30 insertions(+)
 create mode 100644 meta-selftest/wic/test_gpt_partition_name.wks

diff --git a/meta-selftest/wic/test_gpt_partition_name.wks b/meta-selftest/wic/test_gpt_partition_name.wks
new file mode 100644
index 0000000000..7db6da9aee
--- /dev/null
+++ b/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
diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index b26b649c3a..0b0ca90c1e 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/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'"""
-- 
2.34.1



  reply	other threads:[~2023-04-06  8:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-06  8:44 [PATCH 1/3] wic: use part_name when defined dit.kozmaj
2023-04-06  8:44 ` dit.kozmaj [this message]
2023-04-06  8:44 ` [PATCH 3/3] kickstart: Expand label and part-name doc dit.kozmaj

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230406084417.34931-2-dit.kozmaj@kynetics.com \
    --to=dit.kozmaj@kynetics.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox