From: Denis V. Lunev <[email protected]> Commit a0d6d7454a ("tests/hd-geo-test: Skip test when images can not be created") skips when the 4 GiB image cannot be sized, but the temporary file itself is still asserted on, and a file system with no room left fails g_file_open_tmp() as surely as the ftruncate().
Skip there too and say why in both cases, from inside create_test_img() where the GError is. Unlink the image that could not be sized while here. Cc: John Snow <[email protected]> Cc: Thomas Huth <[email protected]> Signed-off-by: Denis V. Lunev <[email protected]> --- tests/qtest/hd-geo-test.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/qtest/hd-geo-test.c b/tests/qtest/hd-geo-test.c index 41481a5e09..e3b4a4db31 100644 --- a/tests/qtest/hd-geo-test.c +++ b/tests/qtest/hd-geo-test.c @@ -27,15 +27,24 @@ static char *create_test_img(int secs) { + g_autoptr(GError) error = NULL; char *template; - int fd, ret; + int fd, ret, err; + + fd = g_file_open_tmp("qtest.XXXXXX", &template, &error); + if (fd < 0) { + g_test_message("Could not create a temporary file: %s", + error->message); + return NULL; + } - fd = g_file_open_tmp("qtest.XXXXXX", &template, NULL); - g_assert(fd >= 0); ret = ftruncate(fd, (off_t)secs * 512); + err = errno; close(fd); if (ret) { + g_test_message("Could not size %s: %s", template, strerror(err)); + unlink(template); g_free(template); template = NULL; } @@ -1059,7 +1068,6 @@ int main(int argc, char **argv) if (img_secs[i] >= 0) { img_file_name[i] = create_test_img(img_secs[i]); if (!img_file_name[i]) { - g_test_message("Could not create test images."); goto test_add_done; } } else { -- 2.53.0
