From: "Denis V. Lunev" <den@openvz.org>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, "Denis V. Lunev" <den@openvz.org>,
Fabiano Rosas <farosas@suse.de>, John Snow <jsnow@redhat.com>,
Laurent Vivier <lvivier@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Thomas Huth <thuth@redhat.com>
Subject: [PATCH 3/7] tests/qtest/ahci-test: skip when the scratch files cannot be created
Date: Mon, 24 Aug 2026 22:06:23 +0200 [thread overview]
Message-ID: <20260824200627.2180635-4-den@openvz.org> (raw)
In-Reply-To: <CAFn=p-bCR4TvVvHwagXiK-c0wuY5dACwh92249Wv0C3odCtbOg@mail.gmail.com>
From: Denis V. Lunev <den@openvz.org>
The fallback ahci-test takes when QTEST_QEMU_IMG is unset extends a
raw image to 64 MiB with ftruncate() and asserts it worked, which is
the assert ide-test just lost. The temporary files are asserted on
too, and a file system with no room left fails g_mkstemp() and
g_file_open_tmp() as surely as the ftruncate().
Report the reason and register no tests instead. The cleanup path has
to cope with the files now created after the point of no return.
Cc: Fabiano Rosas <farosas@suse.de>
Cc: John Snow <jsnow@redhat.com>
Cc: Laurent Vivier <lvivier@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
tests/qtest/ahci-test.c | 48 +++++++++++++++++++++++++++++++----------
1 file changed, 37 insertions(+), 11 deletions(-)
diff --git a/tests/qtest/ahci-test.c b/tests/qtest/ahci-test.c
index 71d23fe56a..d6af5b30a0 100644
--- a/tests/qtest/ahci-test.c
+++ b/tests/qtest/ahci-test.c
@@ -2110,8 +2110,10 @@ static void create_ahci_io_test(enum IOMode type, enum AddrMode addr,
int main(int argc, char **argv)
{
+ g_autoptr(GError) error = NULL;
const char *arch, *base;
int ret;
+ int err;
int fd;
int c;
int i, j, k, m;
@@ -2164,30 +2166,49 @@ int main(int argc, char **argv)
/* Create a temporary image */
tmp_path = g_strdup_printf("%s/qtest.XXXXXX", base);
fd = g_mkstemp(tmp_path);
- g_assert(fd >= 0);
+ if (fd < 0) {
+ g_test_message("Could not create %s: %s", tmp_path, strerror(errno));
+ goto test_add_done;
+ }
if (have_qemu_img()) {
imgfmt = "qcow2";
test_image_size_mb = TEST_IMAGE_SIZE_MB_LARGE;
- mkqcow2(tmp_path, TEST_IMAGE_SIZE_MB_LARGE);
+ close(fd);
+ if (!mkqcow2(tmp_path, TEST_IMAGE_SIZE_MB_LARGE)) {
+ g_test_message("Could not create %s with qemu-img", tmp_path);
+ goto test_add_done;
+ }
} else {
g_test_message("QTEST_QEMU_IMG not set or qemu-img missing; "
"skipping LBA48 high-sector tests");
imgfmt = "raw";
test_image_size_mb = TEST_IMAGE_SIZE_MB_SMALL;
ret = ftruncate(fd, test_image_size_mb * 1024 * 1024);
- g_assert(ret == 0);
+ err = errno;
+ close(fd);
+ if (ret < 0) {
+ g_test_message("Could not size %s: %s", tmp_path, strerror(err));
+ goto test_add_done;
+ }
}
- close(fd);
/* Create temporary blkdebug instructions */
debug_path = g_strdup_printf("%s/qtest-blkdebug.XXXXXX", base);
fd = g_mkstemp(debug_path);
- g_assert(fd >= 0);
+ if (fd < 0) {
+ g_test_message("Could not create %s: %s", debug_path,
+ strerror(errno));
+ goto test_add_done;
+ }
close(fd);
/* Reserve a hollow file to use as a socket for migration tests */
- fd = g_file_open_tmp("qtest-migration.XXXXXX", &mig_socket, NULL);
- g_assert(fd >= 0);
+ fd = g_file_open_tmp("qtest-migration.XXXXXX", &mig_socket, &error);
+ if (fd < 0) {
+ g_test_message("Could not create a temporary file: %s",
+ error->message);
+ goto test_add_done;
+ }
close(fd);
/* Run the tests */
@@ -2244,15 +2265,20 @@ int main(int argc, char **argv)
qtest_add_func("/ahci/cdrom/drain/pio", test_atapi_drain_pio);
qtest_add_func("/ahci/cdrom/drain/dma", test_atapi_drain_dma);
+test_add_done:
ret = g_test_run();
/* Cleanup */
unlink(tmp_path);
g_free(tmp_path);
- unlink(debug_path);
- g_free(debug_path);
- unlink(mig_socket);
- g_free(mig_socket);
+ if (debug_path) {
+ unlink(debug_path);
+ g_free(debug_path);
+ }
+ if (mig_socket) {
+ unlink(mig_socket);
+ g_free(mig_socket);
+ }
return ret;
}
--
2.53.0
next prev parent reply other threads:[~2026-08-24 20:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 17:49 IDE failures under netbsd unit tests John Snow
2026-08-24 20:06 ` [PATCH 0/7] tests/qtest: fix the disk tests on a host with a small /tmp Denis V. Lunev
2026-08-27 10:16 ` Thomas Huth
2026-08-27 11:03 ` Daniel P. Berrangé
2026-09-01 13:41 ` Denis V. Lunev
2026-09-03 16:57 ` Fabiano Rosas
2026-09-03 17:04 ` Denis V. Lunev
2026-08-24 20:06 ` [PATCH 1/7] tests/qtest/libqos: let mkqcow2() report failure Denis V. Lunev
2026-08-24 20:06 ` [PATCH 2/7] tests/qtest/ide-test: skip when the scratch files cannot be created Denis V. Lunev
2026-08-24 20:06 ` Denis V. Lunev [this message]
2026-08-24 20:06 ` [PATCH 4/7] tests/qtest/hd-geo-test: skip when the scratch file " Denis V. Lunev
2026-08-24 20:06 ` [PATCH 5/7] tests/qtest/libqtest: create images with a byte-precise size Denis V. Lunev
2026-08-24 20:06 ` [PATCH 6/7] tests/qtest/ide-test: build the shared disks with qemu-img Denis V. Lunev
2026-08-24 20:06 ` [PATCH 7/7] tests/qtest/hd-geo-test: build the test images " Denis V. Lunev
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=20260824200627.2180635-4-den@openvz.org \
--to=den@openvz.org \
--cc=farosas@suse.de \
--cc=jsnow@redhat.com \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.