diff mbox series

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

Message ID 0581a1274f4aefadd5a3df8c503cd59f4f8935a2.1730797446.git.love.kumar@amd.com
State Accepted
Delegated to: Tom Rini
Headers show
Series test/py: usb: Distinguish b/w ext2/ext4 partitions | expand

Commit Message

Love Kumar Nov. 12, 2024, 8:57 a.m. UTC
'usb 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_usb.py | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

Comments

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

> 'usb 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_usb.py b/test/py/tests/test_usb.py
index 2397fd3c2e7a..e1f203b5cbc9 100644
--- a/test/py/tests/test_usb.py
+++ b/test/py/tests/test_usb.py
@@ -227,7 +227,8 @@  def test_usb_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)
                 if obj:
@@ -239,15 +240,21 @@  def test_usb_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 usb %d:%d' % i, 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' % i)
-            devices[i]['ext4'] = part_ext
-            devices[i]['ext2'] = part_ext
+            devices[i]['ext4'] = part_ext4
+            devices[i]['ext2'] = part_ext2
             devices[i]['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' % i)
 
     return devices, controllers, storage_device
@@ -497,7 +504,7 @@  def test_usb_ext2load(u_boot_console):
             for part in partitions:
                 part_detect = 1
                 file, size, expected_crc32 = \
-                    usb_ext4load_ext4write(u_boot_console, 'ext4', x, part)
+                    usb_ext4load_ext4write(u_boot_console, fs, x, part)
                 addr = u_boot_utils.find_ram_base(u_boot_console)
 
                 offset = random.randrange(128, 1024, 128)
@@ -526,7 +533,7 @@  def test_usb_ls(u_boot_console):
     for x in range(0, int(storage_device)):
         if devices[x]['detected'] == 'yes':
             u_boot_console.run_command('usb dev %d' % x)
-            for fs in ['fat', 'ext4']:
+            for fs in ['fat', 'ext2', 'ext4']:
                 try:
                     partitions = devices[x][fs]
                 except:
@@ -556,7 +563,7 @@  def test_usb_load(u_boot_console):
     for x in range(0, int(storage_device)):
         if devices[x]['detected'] == 'yes':
             u_boot_console.run_command('usb dev %d' % x)
-            for fs in ['fat', 'ext4']:
+            for fs in ['fat', 'ext2', 'ext4']:
                 try:
                     partitions = devices[x][fs]
                 except:
@@ -570,7 +577,7 @@  def test_usb_load(u_boot_console):
                     if fs == 'fat':
                         file, size, expected_crc32 = \
                             usb_fatload_fatwrite(u_boot_console, fs, x, part)
-                    elif fs == 'ext4':
+                    elif fs in ['ext4', 'ext2']:
                         file, size, expected_crc32 = \
                             usb_ext4load_ext4write(u_boot_console, fs, x, part)
 
@@ -600,7 +607,7 @@  def test_usb_save(u_boot_console):
     for x in range(0, int(storage_device)):
         if devices[x]['detected'] == 'yes':
             u_boot_console.run_command('usb dev %d' % x)
-            for fs in ['fat', 'ext4']:
+            for fs in ['fat', 'ext2', 'ext4']:
                 try:
                     partitions = devices[x][fs]
                 except: