g_assert(memcmp(buf, cmpbuf, len) == 0);
+ free_pci_device(dev);
g_free(buf);
g_free(cmpbuf);
}
prdt, ARRAY_SIZE(prdt), NULL);
g_assert_cmphex(status, ==, 0);
assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), DF | ERR);
+ free_pci_device(dev);
}
static void test_bmdma_one_sector_short_prdt(void)
prdt, ARRAY_SIZE(prdt), NULL);
g_assert_cmphex(status, ==, 0);
assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), DF | ERR);
+ free_pci_device(dev);
}
static void test_bmdma_long_prdt(void)
prdt, ARRAY_SIZE(prdt), NULL);
g_assert_cmphex(status, ==, BM_STS_INTR);
assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), DF | ERR);
+ free_pci_device(dev);
}
static void test_bmdma_no_busmaster(void)
* in practice. At least we want to be aware of any changes. */
g_assert_cmphex(status, ==, BM_STS_ACTIVE | BM_STS_INTR);
assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), DF | ERR);
+ free_pci_device(dev);
}
static void test_bmdma_setup(void)
assert_bit_set(buf[85], 0x20);
ide_test_quit();
+ free_pci_device(dev);
}
/*
guest_buf = guest_alloc(guest_malloc, len);
buf = g_malloc(len);
+ memset(buf, rand() % 255 + 1, len);
g_assert(guest_buf);
g_assert(buf);
assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), DF | ERR);
g_free(buf);
+ free_pci_device(dev);
}
static void test_flush(void)
assert_bit_clear(data, BSY | DF | ERR | DRQ);
ide_test_quit();
+ free_pci_device(dev);
}
static void test_retry_flush(const char *machine)
prepare_blkdebug_script(debug_path, "flush_to_disk");
ide_test_start(
- "-vnc none "
"-drive file=blkdebug:%s:%s,if=ide,cache=writeback,format=raw,"
"rerror=stop,werror=stop",
debug_path, tmp_path);
assert_bit_clear(data, BSY | DF | ERR | DRQ);
ide_test_quit();
+ free_pci_device(dev);
}
static void test_flush_nodev(void)
/* Just testing that qemu doesn't crash... */
+ free_pci_device(dev);
+ ide_test_quit();
+}
+
+static void test_flush_empty_drive(void)
+{
+ QPCIDevice *dev;
+ QPCIBar bmdma_bar, ide_bar;
+
+ ide_test_start("-device ide-cd,bus=ide.0");
+ dev = get_pci_device(&bmdma_bar, &ide_bar);
+
+ /* FLUSH CACHE command on device 0 */
+ qpci_io_writeb(dev, ide_bar, reg_device, 0);
+ qpci_io_writeb(dev, ide_bar, reg_command, CMD_FLUSH_CACHE);
+
+ /* Just testing that qemu doesn't crash... */
+
+ free_pci_device(dev);
ide_test_quit();
}
while (true) {
data = qpci_io_readb(dev, ide_bar, reg_status);
if (!(data & flag)) {
+ free_pci_device(dev);
return data;
}
if (difftime(time(NULL), st) > 5.0) {
int i, j;
uint8_t data;
uint16_t limit;
+ size_t ret;
/* Prepopulate the CDROM with an interesting pattern */
generate_pattern(pattern, patt_len, ATAPI_BLOCK_SIZE);
fh = fopen(tmp_path, "w+");
- fwrite(pattern, ATAPI_BLOCK_SIZE, patt_blocks, fh);
+ ret = fwrite(pattern, ATAPI_BLOCK_SIZE, patt_blocks, fh);
+ g_assert_cmpint(ret, ==, patt_blocks);
fclose(fh);
ide_test_start("-drive if=none,file=%s,media=cdrom,format=raw,id=sr0,index=0 "
g_free(pattern);
g_free(rx);
test_bmdma_teardown();
+ free_pci_device(dev);
}
static void test_cdrom_pio(void)
static void test_cdrom_dma(void)
{
static const size_t len = ATAPI_BLOCK_SIZE;
+ size_t ret;
char *pattern = g_malloc(ATAPI_BLOCK_SIZE * 16);
char *rx = g_malloc0(len);
uintptr_t guest_buf;
generate_pattern(pattern, ATAPI_BLOCK_SIZE * 16, ATAPI_BLOCK_SIZE);
fh = fopen(tmp_path, "w+");
- fwrite(pattern, ATAPI_BLOCK_SIZE, 16, fh);
+ ret = fwrite(pattern, ATAPI_BLOCK_SIZE, 16, fh);
+ g_assert_cmpint(ret, ==, 16);
fclose(fh);
send_dma_request(CMD_PACKET, 0, 1, prdt, 1, send_scsi_cdb_read10);
qtest_add_func("/ide/flush", test_flush);
qtest_add_func("/ide/flush/nodev", test_flush_nodev);
+ qtest_add_func("/ide/flush/empty_drive", test_flush_empty_drive);
qtest_add_func("/ide/flush/retry_pci", test_pci_retry_flush);
qtest_add_func("/ide/flush/retry_isa", test_isa_retry_flush);