All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mattijs Korpershoek <mkorpershoek@kernel.org>
To: Igor Opaniuk <igor.opaniuk@gmail.com>, u-boot@lists.u-boot-project.org
Cc: Jan Kehren <jan.kehren@emteria.com>,
	 Guillaume La Roque <glaroque@baylibre.com>,
	Tom Rini <trini@konsulko.com>,  Simon Glass <sjg@chromium.org>,
	 Mattijs Korpershoek <mkorpershoek@kernel.org>,
	 Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Subject: [PATCH v2 08/10] test/py: avb: Move mmc device number to a pytest fixture
Date: Tue, 20 Oct 2026 11:25:57 +0200	[thread overview]
Message-ID: <20261020-test-avb-fixes-v2-8-997f8f04fd3f@kernel.org> (raw)
In-Reply-To: <20261020-test-avb-fixes-v2-0-997f8f04fd3f@kernel.org>

The AVB tests hardcode mmc device 1, which is usually correct on real
hardware. On sandbox, this is not the case because mmc1.img contains a
fedora image.

Replace the module-level mmc_dev constant with an avb_device_id
fixture so that a subsequent commit can override the device number
for sandbox.

Reviewed-by: Guillaume La Roque <glaroque@baylibre.com>
Reviewed-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Tested-by: Guillaume La Roque <glaroque@baylibre.com>
Tested-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
---
 test/py/tests/test_android/test_avb.py | 38 ++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/test/py/tests/test_android/test_avb.py b/test/py/tests/test_android/test_avb.py
index c66ef0cc52d5..34cddc485ebc 100644
--- a/test/py/tests/test_android/test_avb.py
+++ b/test/py/tests/test_android/test_avb.py
@@ -16,20 +16,26 @@ For configuration verification:
 
 import pytest
 
-# defauld mmc id
-mmc_dev = 1
 temp_addr = 0x90000000
 temp_addr2 = 0x90002000
 
+@pytest.fixture(scope='function')
+def avb_device_id(ubman):
+    """Returns the device id number for AVB
+    """
+
+    # default mmc id
+    return 1
+
 @pytest.mark.buildconfigspec('cmd_avb')
 @pytest.mark.buildconfigspec('cmd_mmc')
-def test_avb_verify(ubman):
+def test_avb_verify(ubman, avb_device_id):
     """Run AVB 2.0 boot verification chain with avb subset of commands
     """
 
     success_str = "Verification passed successfully"
 
-    response = ubman.run_command('avb init %x' % mmc_dev)
+    response = ubman.run_command('avb init %x' % avb_device_id)
     assert response == ''
     response = ubman.run_command('avb verify')
     assert response.find(success_str)
@@ -38,15 +44,15 @@ def test_avb_verify(ubman):
 @pytest.mark.buildconfigspec('cmd_avb')
 @pytest.mark.buildconfigspec('cmd_mmc')
 @pytest.mark.notbuildconfigspec('sandbox')
-def test_avb_mmc_uuid(ubman):
+def test_avb_mmc_uuid(ubman, avb_device_id):
     """Check if 'avb get_uuid' works, compare results with
     'part list mmc 1' output
     """
 
-    response = ubman.run_command('avb init %x' % mmc_dev)
+    response = ubman.run_command('avb init %x' % avb_device_id)
     assert response == ''
 
-    response = ubman.run_command('mmc rescan; mmc dev %d' % mmc_dev)
+    response = ubman.run_command('mmc rescan; mmc dev %d' % avb_device_id)
     assert response.find('is current device')
 
     part_lines = ubman.run_command('mmc part').splitlines()
@@ -70,11 +76,11 @@ def test_avb_mmc_uuid(ubman):
 
 
 @pytest.mark.buildconfigspec('cmd_avb')
-def test_avb_read_rb(ubman):
+def test_avb_read_rb(ubman, avb_device_id):
     """Test reading rollback indexes
     """
 
-    response = ubman.run_command('avb init %x' % mmc_dev)
+    response = ubman.run_command('avb init %x' % avb_device_id)
     assert response == ''
 
     response = ubman.run_command('avb read_rb 1')
@@ -82,11 +88,11 @@ def test_avb_read_rb(ubman):
 
 
 @pytest.mark.buildconfigspec('cmd_avb')
-def test_avb_is_unlocked(ubman):
+def test_avb_is_unlocked(ubman, avb_device_id):
     """Test if device is in the unlocked state
     """
 
-    response = ubman.run_command('avb init %x' % mmc_dev)
+    response = ubman.run_command('avb init %x' % avb_device_id)
     assert response == ''
 
     response = ubman.run_command('avb is_unlocked')
@@ -96,17 +102,17 @@ def test_avb_is_unlocked(ubman):
 @pytest.mark.buildconfigspec('cmd_avb')
 @pytest.mark.buildconfigspec('cmd_mmc')
 @pytest.mark.notbuildconfigspec('sandbox')
-def test_avb_mmc_read(ubman):
+def test_avb_mmc_read(ubman, avb_device_id):
     """Test mmc read operation
     """
 
-    response = ubman.run_command('mmc rescan; mmc dev %d 0' % mmc_dev)
+    response = ubman.run_command('mmc rescan; mmc dev %d 0' % avb_device_id)
     assert response.find('is current device')
 
     response = ubman.run_command('mmc read 0x%x 0x100 0x1' % temp_addr)
     assert response.find('read: OK')
 
-    response = ubman.run_command('avb init %x' % mmc_dev)
+    response = ubman.run_command('avb init %x' % avb_device_id)
     assert response == ''
 
     response = ubman.run_command('avb read_part xloader 0 100 0x%x' %
@@ -121,11 +127,11 @@ def test_avb_mmc_read(ubman):
 
 @pytest.mark.buildconfigspec('cmd_avb')
 @pytest.mark.buildconfigspec('optee_ta_avb')
-def test_avb_persistent_values(ubman):
+def test_avb_persistent_values(ubman, avb_device_id):
     """Test reading/writing persistent storage to avb
     """
 
-    response = ubman.run_command('avb init %x' % mmc_dev)
+    response = ubman.run_command('avb init %x' % avb_device_id)
     assert response == ''
 
     response = ubman.run_command('avb write_pvalue test value_value')

-- 
2.56.0


  parent reply	other threads:[~2026-10-20  9:26 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20  9:25 [PATCH v2 00/10] Fix AVB pytest suite for sandbox Mattijs Korpershoek
2026-10-20  9:25 ` [PATCH v2 01/10] avb: Use map_to_sysmem() for flush_cache() address Mattijs Korpershoek
2026-10-22  8:25   ` Simon Glass
2026-10-20  9:25 ` [PATCH v2 02/10] test/py: android: Move android image creation to a dedicated file Mattijs Korpershoek
2026-10-22  8:25   ` Simon Glass
2026-10-20  9:25 ` [PATCH v2 03/10] test/py: android: Drop verbose printing and unused return Mattijs Korpershoek
2026-10-22  8:25   ` Simon Glass
2026-10-20  9:25 ` [PATCH v2 04/10] test/py: android: Use for loop to create the images / update disks Mattijs Korpershoek
2026-10-22  8:25   ` Simon Glass
2026-10-20  9:25 ` [PATCH v2 05/10] test/py: android: Add create_gpt_image() for image creation Mattijs Korpershoek
2026-10-20 15:07   ` Guillaume La Roque
2026-10-22  8:26   ` Simon Glass
2026-10-22 13:24     ` Mattijs Korpershoek
2026-10-20  9:25 ` [PATCH v2 06/10] test/py: android: Add setup_android_v{4,2}_image subfunctions Mattijs Korpershoek
2026-10-22  8:26   ` [PATCH v2 06/10] test/py: android: Add setup_android_v{4, 2}_image subfunctions Simon Glass
2026-10-20  9:25 ` [PATCH v2 07/10] test/py: avb: Use format specifiers instead of str() for mmc_dev Mattijs Korpershoek
2026-10-22  8:59   ` Simon Glass
2026-10-20  9:25 ` Mattijs Korpershoek [this message]
2026-10-22  8:26   ` [PATCH v2 08/10] test/py: avb: Move mmc device number to a pytest fixture Simon Glass
2026-10-20  9:25 ` [PATCH v2 09/10] test/py: avb: Add sandbox AVB testing with dedicated mmc12 device Mattijs Korpershoek
2026-10-22  8:26   ` Simon Glass
2026-10-22 12:53     ` Mattijs Korpershoek
2026-10-20  9:25 ` [PATCH v2 10/10] test/py: avb: Fix find() logic when matching response strings Mattijs Korpershoek
2026-10-20 15:07   ` Guillaume La Roque
2026-10-22  8:26   ` Simon Glass
2026-10-22 12:22     ` Mattijs Korpershoek

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=20261020-test-avb-fixes-v2-8-997f8f04fd3f@kernel.org \
    --to=mkorpershoek@kernel.org \
    --cc=glaroque@baylibre.com \
    --cc=igor.opaniuk@gmail.com \
    --cc=igor.opaniuk@oss.qualcomm.com \
    --cc=jan.kehren@emteria.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.