diff mbox series

test/py: mmc: Distinguish b/w ext2/ext4 partitions

Message ID 6cdcaf03750eec78ad7e577edbe81c3e50350aa4.1730797426.git.love.kumar@amd.com
State Accepted
Delegated to: Tom Rini
Headers show
Series test/py: mmc: Distinguish b/w ext2/ext4 partitions | expand

Commit Message

Love Kumar Nov. 12, 2024, 8:57 a.m. UTC
'mmc part' command shows the partition maps and shows the partition type
by displaying number such as 0c, 83 etc. Observed that ext2 and ext4
partitions shows the same number, i.e, 83, so, using the fstype command
to distiniguish between ext2 and ext4 partitions.

Signed-off-by: Love Kumar <love.kumar@amd.com>
---
 test/py/tests/test_mmc.py | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

Comments

Tom Rini Nov. 18, 2024, 2:19 p.m. UTC | #1
On Tue, 12 Nov 2024 14:27:27 +0530, Love Kumar wrote:

> 'mmc part' command shows the partition maps and shows the partition type
> by displaying number such as 0c, 83 etc. Observed that ext2 and ext4
> partitions shows the same number, i.e, 83, so, using the fstype command
> to distiniguish between ext2 and ext4 partitions.
> 
> 

Applied to u-boot/next, thanks!
diff mbox series

Patch

diff --git a/test/py/tests/test_mmc.py b/test/py/tests/test_mmc.py
index a96c4e8fd890..1193f4a95737 100644
--- a/test/py/tests/test_mmc.py
+++ b/test/py/tests/test_mmc.py
@@ -148,7 +148,8 @@  def test_mmc_part(u_boot_console):
 
             lines = output.split('\n')
             part_fat = []
-            part_ext = []
+            part_ext2 = []
+            part_ext4 = []
             for line in lines:
                 obj = re.search(
                         r'(\d)\s+\d+\s+\d+\s+\w+\d+\w+-\d+\s+(\d+\w+)', line)
@@ -161,15 +162,21 @@  def test_mmc_part(u_boot_console):
                         print('Fat detected')
                         part_fat.append(part_id)
                     elif part_type == '83':
-                        print('ext detected')
-                        part_ext.append(part_id)
+                        print('ext(2/4) detected')
+                        output = u_boot_console.run_command(
+                            'fstype mmc %d:%d' % x, part_id
+                        )
+                        if 'ext2' in output:
+                            part_ext2.append(part_id)
+                        elif 'ext4' in output:
+                            part_ext4.append(part_id)
                     else:
                         pytest.fail('Unsupported Filesystem on device %d' % x)
-            devices[x]['ext4'] = part_ext
-            devices[x]['ext2'] = part_ext
+            devices[x]['ext4'] = part_ext4
+            devices[x]['ext2'] = part_ext2
             devices[x]['fat'] = part_fat
 
-            if not part_ext and not part_fat:
+            if not part_ext2 and not part_ext4 and not part_fat:
                 pytest.fail('No partition detected on device %d' % x)
 
 @pytest.mark.buildconfigspec('cmd_mmc')
@@ -463,7 +470,7 @@  def test_mmc_ls(u_boot_console):
     for x in range(0, controllers):
         if devices[x]['detected'] == 'yes':
             u_boot_console.run_command('mmc dev %d' % x)
-            for fs in ['fat', 'ext4']:
+            for fs in ['fat', 'ext4', 'ext2']:
                 try:
                     partitions = devices[x][fs]
                 except:
@@ -494,7 +501,7 @@  def test_mmc_load(u_boot_console):
     for x in range(0, controllers):
         if devices[x]['detected'] == 'yes':
             u_boot_console.run_command('mmc dev %d' % x)
-            for fs in ['fat', 'ext4']:
+            for fs in ['fat', 'ext4', 'ext2']:
                 try:
                     partitions = devices[x][fs]
                 except:
@@ -536,7 +543,7 @@  def test_mmc_save(u_boot_console):
     for x in range(0, controllers):
         if devices[x]['detected'] == 'yes':
             u_boot_console.run_command('mmc dev %d' % x)
-            for fs in ['fat', 'ext4']:
+            for fs in ['fat', 'ext4', 'ext2']:
                 try:
                     partitions = devices[x][fs]
                 except: