qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: "Cédric Le Goater" <clg@redhat.com>,
	qemu-devel@nongnu.org, qemu-arm@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Steven Lee" <steven_lee@aspeedtech.com>,
	"Troy Lee" <leetroy@gmail.com>,
	"Jamin Lin" <jamin_lin@aspeedtech.com>,
	"Andrew Jeffery" <andrew@codeconstruct.com.au>,
	"Joel Stanley" <joel@jms.id.au>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	berrange@redhat.com
Subject: Re: [PATCH v2] tests/functional: Convert most Aspeed machine tests
Date: Thu, 17 Oct 2024 09:20:44 +0200	[thread overview]
Message-ID: <7e849dbe-6ffa-44f3-8a9e-ab91c234c9b5@redhat.com> (raw)
In-Reply-To: <c7b4442c-5356-4000-bda3-e7239c3eddde@redhat.com>

On 17/10/2024 09.09, Cédric Le Goater wrote:
> On 10/17/24 08:06, Thomas Huth wrote:
>> On 16/10/2024 22.38, Cédric Le Goater wrote:
>>> This is a simple conversion of the tests with some cleanups and
>>> adjustments to match the new test framework. Replace the zephyr image
>>> MD5 hashes with SHA256 hashes while at it.
>>>
>>> The SDK tests depend on a ssh class from avocado.utils which is
>>> difficult to replace. To be addressed separately.
>>>
>>> Signed-off-by: Cédric Le Goater <clg@redhat.com>
...
>>> -    @skipUnless(*has_cmd('swtpm'))
>>> -    def test_arm_ast2600_evb_buildroot_tpm(self):
>>> -        """
>>> -        :avocado: tags=arch:arm
>>> -        :avocado: tags=machine:ast2600-evb
>>> -        """
>>> -
>>> -        image_url = ('https://github.com/legoater/qemu-aspeed-boot/raw/ 
>>> master/'
>>> -                     'images/ast2600-evb/buildroot-2023.02-tpm/flash.img')
>>> -        image_hash = 
>>> ('a46009ae8a5403a0826d607215e731a8c68d27c14c41e55331706b8f9c7bd997')
>>> -        image_path = self.fetch_asset(image_url, asset_hash=image_hash,
>>> -                                      algorithm='sha256')
>>> -
>>> -        # force creation of VM object, which also defines self._sd
>>> -        vm = self.vm
>>> -
>>> -        socket = os.path.join(self._sd.name, 'swtpm-socket')
>>> -
>>> -        subprocess.run(['swtpm', 'socket', '-d', '--tpm2',
>>> -                        '--tpmstate', f'dir={self.vm.temp_dir}',
>>> -                        '--ctrl', f'type=unixio,path={socket}'])
>>> -
>>> -        self.vm.add_args('-chardev', f'socket,id=chrtpm,path={socket}')
>>> -        self.vm.add_args('-tpmdev', 'emulator,id=tpm0,chardev=chrtpm')
>>> -        self.vm.add_args('-device',
>>> -                         'tpm-tis- 
>>> i2c,tpmdev=tpm0,bus=aspeed.i2c.bus.12,address=0x2e')
>>> -        self.do_test_arm_aspeed_buildroot_start(image_path, '0xf00', 
>>> 'Aspeed AST2600 EVB')
>>> -
>>> -        exec_command_and_wait_for_pattern(self,
>>> -            'echo tpm_tis_i2c 0x2e > /sys/bus/i2c/devices/i2c-12/ 
>>> new_device',
>>> -            'tpm_tis_i2c 12-002e: 2.0 TPM (device-id 0x1, rev-id 1)');
>>> -        exec_command_and_wait_for_pattern(self,
>>> -            'cat /sys/class/tpm/tpm0/pcr-sha256/0',
>>> -            
>>> 'B804724EA13F52A9072BA87FE8FDCC497DFC9DF9AA15B9088694639C431688E0');
>>> -
>>> -        self.do_test_arm_aspeed_buildroot_poweroff()
>>>   class AST2x00MachineSDK(QemuSystemTest, LinuxSSHMixIn):
>>
>> You also copied AST2x00MachineMMC but you didn't remove it from the 
>> avocado test yet, so there is a hunk missing here, I think?
> 
> oh. yes, I should remove it from the avocado test.
> 
> I was initially hesitating on having multiple test_arm_aspeed.py files:
> one per machine or one per fw image type. This to set the timeout more
> precisely in the meson.build file, since the SDK FW takes longer to
> boot, and also to handle more complex test scenarios, like the SDK.
> 
> What would be your recommandation ?

If the tests do not share anything at all (neither common python code, nor 
the same firmware binary asset), I think it's maybe better to put them into 
separate files, indeed. That way we can also run the tests in parallel when 
you add "-j$(nproc)" to your "make check-functional" line.

> Btw, I have been trying to rewrite the LinuxSSHMixIn class with a
> minimal ssh Session class. It is not trivial :/

:-(

Did you peek at tests/vm/basevm.py ? I was hoping we could lent some code 
there...

...
>>> +    def test_ast1030_zephyros_1_04(self):
>>> +        kernel_name = "ast1030-evb-demo/zephyr.elf"
>>> +        zip_file = self.ASSET_ZEPHYR_1_04.fetch()
>>> +        with ZipFile(zip_file, 'r') as zf:
>>> +                     zf.extract(kernel_name, path=self.workdir)
>>> +        kernel_file = os.path.join(self.workdir, kernel_name)
>>> +
>>> +        self.set_machine('ast1030-evb')
>>
>> It's slightly better to do the set_machine() at the very top of the 
>> function. set_machine() can cancel the test in case the machine is not 
>> available in the QEMU binary, so this should best be done before fetching 
>> and extracting any assets.
> 
> Should set_machine() be the first call of a test function ?

Yes, either set_machine() or require_netdev() should be at the very top, 
since they could cancel the test.

  Thomas



      reply	other threads:[~2024-10-17  7:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-16 20:38 [PATCH v2] tests/functional: Convert most Aspeed machine tests Cédric Le Goater
2024-10-17  6:06 ` Thomas Huth
2024-10-17  7:09   ` Cédric Le Goater
2024-10-17  7:20     ` Thomas Huth [this message]

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=7e849dbe-6ffa-44f3-8a9e-ab91c234c9b5@redhat.com \
    --to=thuth@redhat.com \
    --cc=andrew@codeconstruct.com.au \
    --cc=berrange@redhat.com \
    --cc=clg@redhat.com \
    --cc=jamin_lin@aspeedtech.com \
    --cc=joel@jms.id.au \
    --cc=leetroy@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=steven_lee@aspeedtech.com \
    /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;
as well as URLs for NNTP newsgroup(s).