[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 40/54] tests/qtest: ide-test: Open file in binary mode
From: |
Bin Meng |
Subject: |
[PATCH v3 40/54] tests/qtest: ide-test: Open file in binary mode |
Date: |
Sun, 25 Sep 2022 19:30:18 +0800 |
From: Xuzhou Cheng <xuzhou.cheng@windriver.com>
By default Windows opens file in text mode, while a POSIX compliant
implementation treats text files and binary files the same.
The fopen() 'mode' string can include the letter 'b' to indicate
binary mode shall be used. POSIX spec says the character 'b' shall
have no effect, but is allowed for ISO C standard conformance.
Let's add the letter 'b' which works on both POSIX and Windows.
Signed-off-by: Xuzhou Cheng <xuzhou.cheng@windriver.com>
Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
(no changes since v2)
Changes in v2:
- Drop ahci-test.c changes that are no longer needed
tests/qtest/ide-test.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/qtest/ide-test.c b/tests/qtest/ide-test.c
index 5e3e28aea2..4ea89c26c9 100644
--- a/tests/qtest/ide-test.c
+++ b/tests/qtest/ide-test.c
@@ -892,7 +892,7 @@ static void cdrom_pio_impl(int nblocks)
/* Prepopulate the CDROM with an interesting pattern */
generate_pattern(pattern, patt_len, ATAPI_BLOCK_SIZE);
- fh = fopen(tmp_path, "w+");
+ fh = fopen(tmp_path, "wb+");
ret = fwrite(pattern, ATAPI_BLOCK_SIZE, patt_blocks, fh);
g_assert_cmpint(ret, ==, patt_blocks);
fclose(fh);
@@ -993,7 +993,7 @@ static void test_cdrom_dma(void)
prdt[0].size = cpu_to_le32(len | PRDT_EOT);
generate_pattern(pattern, ATAPI_BLOCK_SIZE * 16, ATAPI_BLOCK_SIZE);
- fh = fopen(tmp_path, "w+");
+ fh = fopen(tmp_path, "wb+");
ret = fwrite(pattern, ATAPI_BLOCK_SIZE, 16, fh);
g_assert_cmpint(ret, ==, 16);
fclose(fh);
--
2.34.1
- [PATCH v3 32/54] tests/qtest: libqtest: Adapt global_qtest declaration for win32, (continued)
- [PATCH v3 32/54] tests/qtest: libqtest: Adapt global_qtest declaration for win32, Bin Meng, 2022/09/25
- [PATCH v3 33/54] tests/qtest: Use send/recv for socket communication, Bin Meng, 2022/09/25
- [PATCH v3 34/54] tests/qtest: libqtest: Exclude the *_fds APIs for win32, Bin Meng, 2022/09/25
- [PATCH v3 36/54] tests/qtest: Support libqtest to build and run on Windows, Bin Meng, 2022/09/25
- [PATCH v3 42/54] chardev/char-file: Add FILE_SHARE_WRITE when opening the file for win32, Bin Meng, 2022/09/25
- [PATCH v3 35/54] tests/qtest: libqtest: Install signal handler via signal(), Bin Meng, 2022/09/25
- [PATCH v3 40/54] tests/qtest: ide-test: Open file in binary mode,
Bin Meng <=
- [PATCH v3 44/54] tests/qtest: microbit-test: Fix socket access for win32, Bin Meng, 2022/09/25
- [PATCH v3 38/54] tests/qtest: bios-tables-test: Adapt the case for win32, Bin Meng, 2022/09/25
- [PATCH v3 39/54] tests/qtest: migration-test: Disable IO redirection for win32, Bin Meng, 2022/09/25
- [PATCH v3 41/54] tests/qtest: virtio-net-failover: Disable migration tests for win32, Bin Meng, 2022/09/25
- [PATCH v3 43/54] tests/qtest: migration-test: Make sure QEMU process "to" exited after migration is canceled, Bin Meng, 2022/09/25
- [PATCH v3 37/54] tests/qtest: {ahci, ide}-test: Use relative path for temporary files for win32, Bin Meng, 2022/09/25
- [PATCH v3 48/54] io/channel-watch: Drop the unnecessary cast, Bin Meng, 2022/09/25