4 * Copyright (c) 2013 Kevin Wolf <kwolf@redhat.com>
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
32 #include "libqos/libqos.h"
33 #include "libqos/pci-pc.h"
34 #include "libqos/malloc-pc.h"
36 #include "qemu-common.h"
37 #include "hw/pci/pci_ids.h"
38 #include "hw/pci/pci_regs.h"
40 #define TEST_IMAGE_SIZE 64 * 1024 * 1024
43 #define IDE_PCI_FUNC 1
45 #define IDE_BASE 0x1f0
46 #define IDE_PRIMARY_IRQ 14
48 #define ATAPI_BLOCK_SIZE 2048
50 /* How many bytes to receive via ATAPI PIO at one time.
51 * Must be less than 0xFFFF. */
52 #define BYTE_COUNT_LIMIT 5120
88 CMD_FLUSH_CACHE
= 0xe7,
98 BM_CMD_WRITE
= 0x8, /* write = from device to memory */
108 PRDT_EOT
= 0x80000000,
111 #define assert_bit_set(data, mask) g_assert_cmphex((data) & (mask), ==, (mask))
112 #define assert_bit_clear(data, mask) g_assert_cmphex((data) & (mask), ==, 0)
114 static QPCIBus
*pcibus
= NULL
;
115 static QGuestAllocator
*guest_malloc
;
117 static char tmp_path
[] = "/tmp/qtest.XXXXXX";
118 static char debug_path
[] = "/tmp/qtest-blkdebug.XXXXXX";
120 static void ide_test_start(const char *cmdline_fmt
, ...)
125 va_start(ap
, cmdline_fmt
);
126 cmdline
= g_strdup_vprintf(cmdline_fmt
, ap
);
129 qtest_start(cmdline
);
130 guest_malloc
= pc_alloc_init();
135 static void ide_test_quit(void)
137 pc_alloc_uninit(guest_malloc
);
142 static QPCIDevice
*get_pci_device(uint16_t *bmdma_base
)
145 uint16_t vendor_id
, device_id
;
148 pcibus
= qpci_init_pc();
151 /* Find PCI device and verify it's the right one */
152 dev
= qpci_device_find(pcibus
, QPCI_DEVFN(IDE_PCI_DEV
, IDE_PCI_FUNC
));
153 g_assert(dev
!= NULL
);
155 vendor_id
= qpci_config_readw(dev
, PCI_VENDOR_ID
);
156 device_id
= qpci_config_readw(dev
, PCI_DEVICE_ID
);
157 g_assert(vendor_id
== PCI_VENDOR_ID_INTEL
);
158 g_assert(device_id
== PCI_DEVICE_ID_INTEL_82371SB_1
);
161 *bmdma_base
= (uint16_t)(uintptr_t) qpci_iomap(dev
, 4, NULL
);
163 qpci_device_enable(dev
);
168 static void free_pci_device(QPCIDevice
*dev
)
170 /* libqos doesn't have a function for this, so free it manually */
174 typedef struct PrdtEntry
{
177 } QEMU_PACKED PrdtEntry
;
179 #define assert_bit_set(data, mask) g_assert_cmphex((data) & (mask), ==, (mask))
180 #define assert_bit_clear(data, mask) g_assert_cmphex((data) & (mask), ==, 0)
182 static int send_dma_request(int cmd
, uint64_t sector
, int nb_sectors
,
183 PrdtEntry
*prdt
, int prdt_entries
,
184 void(*post_exec
)(uint64_t sector
, int nb_sectors
))
188 uintptr_t guest_prdt
;
194 dev
= get_pci_device(&bmdma_base
);
202 /* Assuming we only test data reads w/ ATAPI, otherwise we need to know
203 * the SCSI command being sent in the packet, too. */
210 g_assert_not_reached();
213 if (flags
& CMDF_NO_BM
) {
214 qpci_config_writew(dev
, PCI_COMMAND
,
215 PCI_COMMAND_IO
| PCI_COMMAND_MEMORY
);
218 /* Select device 0 */
219 outb(IDE_BASE
+ reg_device
, 0 | LBA
);
221 /* Stop any running transfer, clear any pending interrupt */
222 outb(bmdma_base
+ bmreg_cmd
, 0);
223 outb(bmdma_base
+ bmreg_status
, BM_STS_INTR
);
226 len
= sizeof(*prdt
) * prdt_entries
;
227 guest_prdt
= guest_alloc(guest_malloc
, len
);
228 memwrite(guest_prdt
, prdt
, len
);
229 outl(bmdma_base
+ bmreg_prdt
, guest_prdt
);
231 /* ATA DMA command */
232 if (cmd
== CMD_PACKET
) {
233 /* Enables ATAPI DMA; otherwise PIO is attempted */
234 outb(IDE_BASE
+ reg_feature
, 0x01);
236 outb(IDE_BASE
+ reg_nsectors
, nb_sectors
);
237 outb(IDE_BASE
+ reg_lba_low
, sector
& 0xff);
238 outb(IDE_BASE
+ reg_lba_middle
, (sector
>> 8) & 0xff);
239 outb(IDE_BASE
+ reg_lba_high
, (sector
>> 16) & 0xff);
242 outb(IDE_BASE
+ reg_command
, cmd
);
245 post_exec(sector
, nb_sectors
);
248 /* Start DMA transfer */
249 outb(bmdma_base
+ bmreg_cmd
, BM_CMD_START
| (from_dev
? BM_CMD_WRITE
: 0));
251 if (flags
& CMDF_ABORT
) {
252 outb(bmdma_base
+ bmreg_cmd
, 0);
255 /* Wait for the DMA transfer to complete */
257 status
= inb(bmdma_base
+ bmreg_status
);
258 } while ((status
& (BM_STS_ACTIVE
| BM_STS_INTR
)) == BM_STS_ACTIVE
);
260 g_assert_cmpint(get_irq(IDE_PRIMARY_IRQ
), ==, !!(status
& BM_STS_INTR
));
262 /* Check IDE status code */
263 assert_bit_set(inb(IDE_BASE
+ reg_status
), DRDY
);
264 assert_bit_clear(inb(IDE_BASE
+ reg_status
), BSY
| DRQ
);
266 /* Reading the status register clears the IRQ */
267 g_assert(!get_irq(IDE_PRIMARY_IRQ
));
269 /* Stop DMA transfer if still active */
270 if (status
& BM_STS_ACTIVE
) {
271 outb(bmdma_base
+ bmreg_cmd
, 0);
274 free_pci_device(dev
);
279 static void test_bmdma_simple_rw(void)
285 uintptr_t guest_buf
= guest_alloc(guest_malloc
, len
);
289 .addr
= cpu_to_le32(guest_buf
),
290 .size
= cpu_to_le32(len
| PRDT_EOT
),
295 cmpbuf
= g_malloc(len
);
297 /* Write 0x55 pattern to sector 0 */
298 memset(buf
, 0x55, len
);
299 memwrite(guest_buf
, buf
, len
);
301 status
= send_dma_request(CMD_WRITE_DMA
, 0, 1, prdt
,
302 ARRAY_SIZE(prdt
), NULL
);
303 g_assert_cmphex(status
, ==, BM_STS_INTR
);
304 assert_bit_clear(inb(IDE_BASE
+ reg_status
), DF
| ERR
);
306 /* Write 0xaa pattern to sector 1 */
307 memset(buf
, 0xaa, len
);
308 memwrite(guest_buf
, buf
, len
);
310 status
= send_dma_request(CMD_WRITE_DMA
, 1, 1, prdt
,
311 ARRAY_SIZE(prdt
), NULL
);
312 g_assert_cmphex(status
, ==, BM_STS_INTR
);
313 assert_bit_clear(inb(IDE_BASE
+ reg_status
), DF
| ERR
);
315 /* Read and verify 0x55 pattern in sector 0 */
316 memset(cmpbuf
, 0x55, len
);
318 status
= send_dma_request(CMD_READ_DMA
, 0, 1, prdt
, ARRAY_SIZE(prdt
), NULL
);
319 g_assert_cmphex(status
, ==, BM_STS_INTR
);
320 assert_bit_clear(inb(IDE_BASE
+ reg_status
), DF
| ERR
);
322 memread(guest_buf
, buf
, len
);
323 g_assert(memcmp(buf
, cmpbuf
, len
) == 0);
325 /* Read and verify 0xaa pattern in sector 1 */
326 memset(cmpbuf
, 0xaa, len
);
328 status
= send_dma_request(CMD_READ_DMA
, 1, 1, prdt
, ARRAY_SIZE(prdt
), NULL
);
329 g_assert_cmphex(status
, ==, BM_STS_INTR
);
330 assert_bit_clear(inb(IDE_BASE
+ reg_status
), DF
| ERR
);
332 memread(guest_buf
, buf
, len
);
333 g_assert(memcmp(buf
, cmpbuf
, len
) == 0);
340 static void test_bmdma_short_prdt(void)
347 .size
= cpu_to_le32(0x10 | PRDT_EOT
),
352 status
= send_dma_request(CMD_READ_DMA
, 0, 1,
353 prdt
, ARRAY_SIZE(prdt
), NULL
);
354 g_assert_cmphex(status
, ==, 0);
355 assert_bit_clear(inb(IDE_BASE
+ reg_status
), DF
| ERR
);
357 /* Abort the request before it completes */
358 status
= send_dma_request(CMD_READ_DMA
| CMDF_ABORT
, 0, 1,
359 prdt
, ARRAY_SIZE(prdt
), NULL
);
360 g_assert_cmphex(status
, ==, 0);
361 assert_bit_clear(inb(IDE_BASE
+ reg_status
), DF
| ERR
);
364 static void test_bmdma_one_sector_short_prdt(void)
368 /* Read 2 sectors but only give 1 sector in PRDT */
372 .size
= cpu_to_le32(0x200 | PRDT_EOT
),
377 status
= send_dma_request(CMD_READ_DMA
, 0, 2,
378 prdt
, ARRAY_SIZE(prdt
), NULL
);
379 g_assert_cmphex(status
, ==, 0);
380 assert_bit_clear(inb(IDE_BASE
+ reg_status
), DF
| ERR
);
382 /* Abort the request before it completes */
383 status
= send_dma_request(CMD_READ_DMA
| CMDF_ABORT
, 0, 2,
384 prdt
, ARRAY_SIZE(prdt
), NULL
);
385 g_assert_cmphex(status
, ==, 0);
386 assert_bit_clear(inb(IDE_BASE
+ reg_status
), DF
| ERR
);
389 static void test_bmdma_long_prdt(void)
396 .size
= cpu_to_le32(0x1000 | PRDT_EOT
),
401 status
= send_dma_request(CMD_READ_DMA
, 0, 1,
402 prdt
, ARRAY_SIZE(prdt
), NULL
);
403 g_assert_cmphex(status
, ==, BM_STS_ACTIVE
| BM_STS_INTR
);
404 assert_bit_clear(inb(IDE_BASE
+ reg_status
), DF
| ERR
);
406 /* Abort the request before it completes */
407 status
= send_dma_request(CMD_READ_DMA
| CMDF_ABORT
, 0, 1,
408 prdt
, ARRAY_SIZE(prdt
), NULL
);
409 g_assert_cmphex(status
, ==, BM_STS_INTR
);
410 assert_bit_clear(inb(IDE_BASE
+ reg_status
), DF
| ERR
);
413 static void test_bmdma_no_busmaster(void)
417 /* No PRDT_EOT, each entry addr 0/size 64k, and in theory qemu shouldn't be
418 * able to access it anyway because the Bus Master bit in the PCI command
419 * register isn't set. This is complete nonsense, but it used to be pretty
420 * good at confusing and occasionally crashing qemu. */
421 PrdtEntry prdt
[4096] = { };
423 status
= send_dma_request(CMD_READ_DMA
| CMDF_NO_BM
, 0, 512,
424 prdt
, ARRAY_SIZE(prdt
), NULL
);
426 /* Not entirely clear what the expected result is, but this is what we get
427 * in practice. At least we want to be aware of any changes. */
428 g_assert_cmphex(status
, ==, BM_STS_ACTIVE
| BM_STS_INTR
);
429 assert_bit_clear(inb(IDE_BASE
+ reg_status
), DF
| ERR
);
432 static void test_bmdma_setup(void)
435 "-drive file=%s,if=ide,serial=%s,cache=writeback,format=raw "
436 "-global ide-hd.ver=%s",
437 tmp_path
, "testdisk", "version");
438 qtest_irq_intercept_in(global_qtest
, "ioapic");
441 static void test_bmdma_teardown(void)
446 static void string_cpu_to_be16(uint16_t *s
, size_t bytes
)
448 g_assert((bytes
& 1) == 0);
452 *s
= cpu_to_be16(*s
);
457 static void test_identify(void)
465 "-drive file=%s,if=ide,serial=%s,cache=writeback,format=raw "
466 "-global ide-hd.ver=%s",
467 tmp_path
, "testdisk", "version");
469 /* IDENTIFY command on device 0*/
470 outb(IDE_BASE
+ reg_device
, 0);
471 outb(IDE_BASE
+ reg_command
, CMD_IDENTIFY
);
473 /* Read in the IDENTIFY buffer and check registers */
474 data
= inb(IDE_BASE
+ reg_device
);
475 g_assert_cmpint(data
& DEV
, ==, 0);
477 for (i
= 0; i
< 256; i
++) {
478 data
= inb(IDE_BASE
+ reg_status
);
479 assert_bit_set(data
, DRDY
| DRQ
);
480 assert_bit_clear(data
, BSY
| DF
| ERR
);
482 ((uint16_t*) buf
)[i
] = inw(IDE_BASE
+ reg_data
);
485 data
= inb(IDE_BASE
+ reg_status
);
486 assert_bit_set(data
, DRDY
);
487 assert_bit_clear(data
, BSY
| DF
| ERR
| DRQ
);
489 /* Check serial number/version in the buffer */
490 string_cpu_to_be16(&buf
[10], 20);
491 ret
= memcmp(&buf
[10], "testdisk ", 20);
494 string_cpu_to_be16(&buf
[23], 8);
495 ret
= memcmp(&buf
[23], "version ", 8);
498 /* Write cache enabled bit */
499 assert_bit_set(buf
[85], 0x20);
504 static void test_flush(void)
509 "-drive file=blkdebug::%s,if=ide,cache=writeback,format=raw",
512 /* Delay the completion of the flush request until we explicitly do it */
513 qmp_discard_response("{'execute':'human-monitor-command', 'arguments': {"
515 " 'qemu-io ide0-hd0 \"break flush_to_os A\"'} }");
517 /* FLUSH CACHE command on device 0*/
518 outb(IDE_BASE
+ reg_device
, 0);
519 outb(IDE_BASE
+ reg_command
, CMD_FLUSH_CACHE
);
521 /* Check status while request is in flight*/
522 data
= inb(IDE_BASE
+ reg_status
);
523 assert_bit_set(data
, BSY
| DRDY
);
524 assert_bit_clear(data
, DF
| ERR
| DRQ
);
526 /* Complete the command */
527 qmp_discard_response("{'execute':'human-monitor-command', 'arguments': {"
529 " 'qemu-io ide0-hd0 \"resume A\"'} }");
531 /* Check registers */
532 data
= inb(IDE_BASE
+ reg_device
);
533 g_assert_cmpint(data
& DEV
, ==, 0);
536 data
= inb(IDE_BASE
+ reg_status
);
537 } while (data
& BSY
);
539 assert_bit_set(data
, DRDY
);
540 assert_bit_clear(data
, BSY
| DF
| ERR
| DRQ
);
545 static void test_retry_flush(const char *machine
)
550 prepare_blkdebug_script(debug_path
, "flush_to_disk");
554 "-drive file=blkdebug:%s:%s,if=ide,cache=writeback,format=raw,"
555 "rerror=stop,werror=stop",
556 debug_path
, tmp_path
);
558 /* FLUSH CACHE command on device 0*/
559 outb(IDE_BASE
+ reg_device
, 0);
560 outb(IDE_BASE
+ reg_command
, CMD_FLUSH_CACHE
);
562 /* Check status while request is in flight*/
563 data
= inb(IDE_BASE
+ reg_status
);
564 assert_bit_set(data
, BSY
| DRDY
);
565 assert_bit_clear(data
, DF
| ERR
| DRQ
);
567 qmp_eventwait("STOP");
569 /* Complete the command */
570 s
= "{'execute':'cont' }";
571 qmp_discard_response(s
);
573 /* Check registers */
574 data
= inb(IDE_BASE
+ reg_device
);
575 g_assert_cmpint(data
& DEV
, ==, 0);
578 data
= inb(IDE_BASE
+ reg_status
);
579 } while (data
& BSY
);
581 assert_bit_set(data
, DRDY
);
582 assert_bit_clear(data
, BSY
| DF
| ERR
| DRQ
);
587 static void test_flush_nodev(void)
591 /* FLUSH CACHE command on device 0*/
592 outb(IDE_BASE
+ reg_device
, 0);
593 outb(IDE_BASE
+ reg_command
, CMD_FLUSH_CACHE
);
595 /* Just testing that qemu doesn't crash... */
600 static void test_pci_retry_flush(const char *machine
)
602 test_retry_flush("pc");
605 static void test_isa_retry_flush(const char *machine
)
607 test_retry_flush("isapc");
610 typedef struct Read10CDB
{
618 } __attribute__((__packed__
)) Read10CDB
;
620 static void send_scsi_cdb_read10(uint64_t lba
, int nblocks
)
622 Read10CDB pkt
= { .padding
= 0 };
625 g_assert_cmpint(lba
, <=, UINT32_MAX
);
626 g_assert_cmpint(nblocks
, <=, UINT16_MAX
);
627 g_assert_cmpint(nblocks
, >=, 0);
629 /* Construct SCSI CDB packet */
631 pkt
.lba
= cpu_to_be32(lba
);
632 pkt
.nblocks
= cpu_to_be16(nblocks
);
635 for (i
= 0; i
< sizeof(Read10CDB
)/2; i
++) {
636 outw(IDE_BASE
+ reg_data
, ((uint16_t *)&pkt
)[i
]);
640 static void nsleep(int64_t nsecs
)
642 const struct timespec val
= { .tv_nsec
= nsecs
};
643 nanosleep(&val
, NULL
);
647 static uint8_t ide_wait_clear(uint8_t flag
)
652 /* Wait with a 5 second timeout */
653 for (i
= 0; i
<= 12500000; i
++) {
654 data
= inb(IDE_BASE
+ reg_status
);
655 if (!(data
& flag
)) {
660 g_assert_not_reached();
663 static void ide_wait_intr(int irq
)
668 for (i
= 0; i
<= 12500000; i
++) {
676 g_assert_not_reached();
679 static void cdrom_pio_impl(int nblocks
)
682 int patt_blocks
= MAX(16, nblocks
);
683 size_t patt_len
= ATAPI_BLOCK_SIZE
* patt_blocks
;
684 char *pattern
= g_malloc(patt_len
);
685 size_t rxsize
= ATAPI_BLOCK_SIZE
* nblocks
;
686 uint16_t *rx
= g_malloc0(rxsize
);
691 /* Prepopulate the CDROM with an interesting pattern */
692 generate_pattern(pattern
, patt_len
, ATAPI_BLOCK_SIZE
);
693 fh
= fopen(tmp_path
, "w+");
694 fwrite(pattern
, ATAPI_BLOCK_SIZE
, patt_blocks
, fh
);
697 ide_test_start("-drive if=none,file=%s,media=cdrom,format=raw,id=sr0,index=0 "
698 "-device ide-cd,drive=sr0,bus=ide.0", tmp_path
);
699 qtest_irq_intercept_in(global_qtest
, "ioapic");
701 /* PACKET command on device 0 */
702 outb(IDE_BASE
+ reg_device
, 0);
703 outb(IDE_BASE
+ reg_lba_middle
, BYTE_COUNT_LIMIT
& 0xFF);
704 outb(IDE_BASE
+ reg_lba_high
, (BYTE_COUNT_LIMIT
>> 8 & 0xFF));
705 outb(IDE_BASE
+ reg_command
, CMD_PACKET
);
706 /* HPD0: Check_Status_A State */
708 data
= ide_wait_clear(BSY
);
709 /* HPD1: Send_Packet State */
710 assert_bit_set(data
, DRQ
| DRDY
);
711 assert_bit_clear(data
, ERR
| DF
| BSY
);
713 /* SCSI CDB (READ10) -- read n*2048 bytes from block 0 */
714 send_scsi_cdb_read10(0, nblocks
);
716 /* HPD3: INTRQ_Wait */
717 ide_wait_intr(IDE_PRIMARY_IRQ
);
719 /* HPD2: Check_Status_B */
720 data
= ide_wait_clear(BSY
);
721 assert_bit_set(data
, DRQ
| DRDY
);
722 assert_bit_clear(data
, ERR
| DF
| BSY
);
724 /* Read data back: occurs in bursts of 'BYTE_COUNT_LIMIT' bytes.
725 * If BYTE_COUNT_LIMIT is odd, we transfer BYTE_COUNT_LIMIT - 1 bytes.
726 * We allow an odd limit only when the remaining transfer size is
727 * less than BYTE_COUNT_LIMIT. However, SCSI's read10 command can only
728 * request n blocks, so our request size is always even.
729 * For this reason, we assume there is never a hanging byte to fetch. */
730 g_assert(!(rxsize
& 1));
731 limit
= BYTE_COUNT_LIMIT
& ~1;
732 for (i
= 0; i
< DIV_ROUND_UP(rxsize
, limit
); i
++) {
733 size_t offset
= i
* (limit
/ 2);
734 size_t rem
= (rxsize
/ 2) - offset
;
735 for (j
= 0; j
< MIN((limit
/ 2), rem
); j
++) {
736 rx
[offset
+ j
] = inw(IDE_BASE
+ reg_data
);
738 ide_wait_intr(IDE_PRIMARY_IRQ
);
740 data
= ide_wait_clear(DRQ
);
741 assert_bit_set(data
, DRDY
);
742 assert_bit_clear(data
, DRQ
| ERR
| DF
| BSY
);
744 g_assert_cmpint(memcmp(pattern
, rx
, rxsize
), ==, 0);
747 test_bmdma_teardown();
750 static void test_cdrom_pio(void)
755 static void test_cdrom_pio_large(void)
757 /* Test a few loops of the PIO DRQ mechanism. */
758 cdrom_pio_impl(BYTE_COUNT_LIMIT
* 4 / ATAPI_BLOCK_SIZE
);
762 static void test_cdrom_dma(void)
764 static const size_t len
= ATAPI_BLOCK_SIZE
;
765 char *pattern
= g_malloc(ATAPI_BLOCK_SIZE
* 16);
766 char *rx
= g_malloc0(len
);
771 ide_test_start("-drive if=none,file=%s,media=cdrom,format=raw,id=sr0,index=0 "
772 "-device ide-cd,drive=sr0,bus=ide.0", tmp_path
);
773 qtest_irq_intercept_in(global_qtest
, "ioapic");
775 guest_buf
= guest_alloc(guest_malloc
, len
);
776 prdt
[0].addr
= cpu_to_le32(guest_buf
);
777 prdt
[0].size
= cpu_to_le32(len
| PRDT_EOT
);
779 generate_pattern(pattern
, ATAPI_BLOCK_SIZE
* 16, ATAPI_BLOCK_SIZE
);
780 fh
= fopen(tmp_path
, "w+");
781 fwrite(pattern
, ATAPI_BLOCK_SIZE
, 16, fh
);
784 send_dma_request(CMD_PACKET
, 0, 1, prdt
, 1, send_scsi_cdb_read10
);
786 /* Read back data from guest memory into local qtest memory */
787 memread(guest_buf
, rx
, len
);
788 g_assert_cmpint(memcmp(pattern
, rx
, len
), ==, 0);
792 test_bmdma_teardown();
795 int main(int argc
, char **argv
)
797 const char *arch
= qtest_get_arch();
801 /* Check architecture */
802 if (strcmp(arch
, "i386") && strcmp(arch
, "x86_64")) {
803 g_test_message("Skipping test for non-x86\n");
807 /* Create temporary blkdebug instructions */
808 fd
= mkstemp(debug_path
);
812 /* Create a temporary raw image */
813 fd
= mkstemp(tmp_path
);
815 ret
= ftruncate(fd
, TEST_IMAGE_SIZE
);
820 g_test_init(&argc
, &argv
, NULL
);
822 qtest_add_func("/ide/identify", test_identify
);
824 qtest_add_func("/ide/bmdma/setup", test_bmdma_setup
);
825 qtest_add_func("/ide/bmdma/simple_rw", test_bmdma_simple_rw
);
826 qtest_add_func("/ide/bmdma/short_prdt", test_bmdma_short_prdt
);
827 qtest_add_func("/ide/bmdma/one_sector_short_prdt",
828 test_bmdma_one_sector_short_prdt
);
829 qtest_add_func("/ide/bmdma/long_prdt", test_bmdma_long_prdt
);
830 qtest_add_func("/ide/bmdma/no_busmaster", test_bmdma_no_busmaster
);
831 qtest_add_func("/ide/bmdma/teardown", test_bmdma_teardown
);
833 qtest_add_func("/ide/flush", test_flush
);
834 qtest_add_func("/ide/flush/nodev", test_flush_nodev
);
835 qtest_add_func("/ide/flush/retry_pci", test_pci_retry_flush
);
836 qtest_add_func("/ide/flush/retry_isa", test_isa_retry_flush
);
838 qtest_add_func("/ide/cdrom/pio", test_cdrom_pio
);
839 qtest_add_func("/ide/cdrom/pio_large", test_cdrom_pio_large
);
840 qtest_add_func("/ide/cdrom/dma", test_cdrom_dma
);