[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/15] tests/qtest/ac97-test: add up-/downsampling tests
From: |
Thomas Huth |
Subject: |
[PULL 12/15] tests/qtest/ac97-test: add up-/downsampling tests |
Date: |
Fri, 26 May 2023 11:08:37 +0200 |
From: Volker Rümelin <vr_qemu@t-online.de>
Test if the audio subsystem can handle extreme up- and down-
sampling ratios like 44100/1 and 1/44100. For some time these
used to trigger QEMU aborts. The test was taken from
https://gitlab.com/qemu-project/qemu/-/issues/71 where it was
used to demonstrate a very different issue.
Suggested-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20230520113313.5177-1-vr_qemu@t-online.de>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/qtest/ac97-test.c | 40 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
diff --git a/tests/qtest/ac97-test.c b/tests/qtest/ac97-test.c
index 74103efdfa..b71bd60a8a 100644
--- a/tests/qtest/ac97-test.c
+++ b/tests/qtest/ac97-test.c
@@ -42,16 +42,54 @@ static void *ac97_create(void *pci_bus, QGuestAllocator
*alloc, void *addr)
return &ac97->obj;
}
+/*
+ * This is rather a test of the audio subsystem and not an AC97 test. Test if
+ * the audio subsystem can handle a 44100/1 upsample ratio. For some time this
+ * used to trigger QEMU aborts.
+ */
+static void ac97_playback_upsample(void *obj, void *data, QGuestAllocator
*alloc)
+{
+ QAC97 *ac97 = obj;
+ QPCIDevice *dev = &ac97->dev;
+ QPCIBar bar0;
+
+ qpci_device_enable(dev);
+ bar0 = qpci_iomap(dev, 0, NULL);
+ /* IOBAR0 offset 0x2c: PCM Front DAC Rate */
+ qpci_io_writew(dev, bar0, 0x2c, 0x1);
+}
+
+/*
+ * This test is similar to the playback upsample test. QEMU shouldn't abort if
+ * asked for a 1/44100 downsample ratio.
+ */
+static void ac97_record_downsample(void *obj, void *data, QGuestAllocator
*alloc)
+{
+ QAC97 *ac97 = obj;
+ QPCIDevice *dev = &ac97->dev;
+ QPCIBar bar0;
+
+ qpci_device_enable(dev);
+ bar0 = qpci_iomap(dev, 0, NULL);
+ /* IOBAR0 offset 0x32: PCM L/R ADC Rate */
+ qpci_io_writew(dev, bar0, 0x32, 0x1);
+}
+
static void ac97_register_nodes(void)
{
QOSGraphEdgeOptions opts = {
- .extra_device_opts = "addr=04.0",
+ .extra_device_opts = "addr=04.0,audiodev=snd0",
+ .after_cmd_line = "-audiodev none,id=snd0"
+ ",out.frequency=44100,in.frequency=44100",
};
add_qpci_address(&opts, &(QPCIAddress) { .devfn = QPCI_DEVFN(4, 0) });
qos_node_create_driver("AC97", ac97_create);
qos_node_produces("AC97", "pci-device");
qos_node_consumes("AC97", "pci-bus", &opts);
+
+ qos_add_test("playback_upsample", "AC97", ac97_playback_upsample, NULL);
+ qos_add_test("record_downsample", "AC97", ac97_record_downsample, NULL);
}
libqos_init(ac97_register_nodes);
--
2.31.1
- [PULL 06/15] hw/arm: Use MachineClass->default_nic in the sbsa-ref machine, (continued)
- [PULL 06/15] hw/arm: Use MachineClass->default_nic in the sbsa-ref machine, Thomas Huth, 2023/05/26
- [PULL 05/15] hw/xtensa: Use MachineClass->default_nic in the virt machine, Thomas Huth, 2023/05/26
- [PULL 08/15] tests/qtest/usb-hcd-uhci-test: Check whether "usb-storage" is available, Thomas Huth, 2023/05/26
- [PULL 10/15] tests/qtest/rtl8139-test: Check whether the rtl8139 device is available, Thomas Huth, 2023/05/26
- [PULL 07/15] hw/mips: Use MachineClass->default_nic in the virt machine, Thomas Huth, 2023/05/26
- [PULL 09/15] tests/qtest: Check for virtio-blk before using -cdrom with the arm virt machine, Thomas Huth, 2023/05/26
- [PULL 11/15] tests/qtest/usb-hcd-ehci-test: Check for EHCI and UHCI HCDs before using them, Thomas Huth, 2023/05/26
- [PULL 13/15] machine: do not crash if default RAM backend name has been stolen, Thomas Huth, 2023/05/26
- [PULL 14/15] lsi53c895a: disable reentrancy detection for MMIO region, too, Thomas Huth, 2023/05/26
- [PULL 15/15] hw/scsi/lsi53c895a: Fix reentrancy issues in the LSI controller (CVE-2023-0330), Thomas Huth, 2023/05/26
- [PULL 12/15] tests/qtest/ac97-test: add up-/downsampling tests,
Thomas Huth <=
- Re: [PULL 00/15] Improve --without-default-devices testing, fix CVE-2023-0330, Richard Henderson, 2023/05/26