Skip to content

Commit

Permalink
tests/hd-geo-test: Skip test when images can not be created
Browse files Browse the repository at this point in the history
In certain environments like restricted containers, we can not create
huge test images. To be able to use "make check" in such container
environments, too, let's skip the hd-geo-test instead of failing when
the test images could not be created.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20191204154618.23560-5-thuth@redhat.com>
  • Loading branch information
huth authored and stsquad committed Dec 18, 2019
1 parent 178d383 commit a0d6d74
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/hd-geo-test.c
Expand Up @@ -34,8 +34,13 @@ static char *create_test_img(int secs)
fd = mkstemp(template);
g_assert(fd >= 0);
ret = ftruncate(fd, (off_t)secs * 512);
g_assert(ret == 0);
close(fd);

if (ret) {
free(template);
template = NULL;
}

return template;
}

Expand Down Expand Up @@ -934,6 +939,10 @@ int main(int argc, char **argv)
for (i = 0; i < backend_last; i++) {
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 {
img_file_name[i] = NULL;
}
Expand Down Expand Up @@ -965,6 +974,7 @@ int main(int argc, char **argv)
"skipping hd-geo/override/* tests");
}

test_add_done:
ret = g_test_run();

for (i = 0; i < backend_last; i++) {
Expand Down

0 comments on commit a0d6d74

Please sign in to comment.