summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGuillem Jover <guillem@hadrons.org>2020-02-08 23:16:51 +0100
committerGuillem Jover <guillem@hadrons.org>2020-02-14 14:39:28 +0100
commit8bf676e03ad94d3ad57936cf55f52e711d26bdc9 (patch)
treeffc1fd9cf61b178f60371cfee5c50325e120071e /test
parent1fb4160e7d3ae9e34ab88e0bc56f0bb831379649 (diff)
downloadliburing-8bf676e03ad94d3ad57936cf55f52e711d26bdc9.tar.gz
liburing-8bf676e03ad94d3ad57936cf55f52e711d26bdc9.tar.bz2
test: Cleanup file artifacts on early exits
We should either unlink(2) the files after the first open in case we do not need them anymore, or when doing an early exit(2) to skip a test or from an error. Signed-off-by: Guillem Jover <guillem@hadrons.org>
Diffstat (limited to 'test')
-rw-r--r--test/fadvise.c1
-rw-r--r--test/madvise.c1
-rw-r--r--test/short-read.c5
3 files changed, 6 insertions, 1 deletions
diff --git a/test/fadvise.c b/test/fadvise.c
index cb18adc..7484c7b 100644
--- a/test/fadvise.c
+++ b/test/fadvise.c
@@ -91,6 +91,7 @@ static int do_fadvise(struct io_uring *ring, int fd, off_t offset, off_t len,
ret = cqe->res;
if (ret == -EINVAL || ret == -EBADF) {
fprintf(stdout, "Fadvise not supported, skipping\n");
+ unlink(".fadvise.tmp");
exit(0);
} else if (ret) {
fprintf(stderr, "cqe->res=%d\n", cqe->res);
diff --git a/test/madvise.c b/test/madvise.c
index 1b11092..e9101c0 100644
--- a/test/madvise.c
+++ b/test/madvise.c
@@ -92,6 +92,7 @@ static int do_madvise(struct io_uring *ring, void *addr, off_t len, int advice)
ret = cqe->res;
if (ret == -EINVAL || ret == -EBADF) {
fprintf(stdout, "Madvise not supported, skipping\n");
+ unlink(".madvise.tmp");
exit(0);
} else if (ret) {
fprintf(stderr, "cqe->res=%d\n", cqe->res);
diff --git a/test/short-read.c b/test/short-read.c
index 94a148f..2519a74 100644
--- a/test/short-read.c
+++ b/test/short-read.c
@@ -34,7 +34,7 @@ static int create_file(const char *file)
int main(int argc, char *argv[])
{
- int ret, fd;
+ int ret, fd, save_errno;
struct io_uring ring;
struct io_uring_sqe *sqe;
struct io_uring_cqe *cqe;
@@ -49,6 +49,9 @@ int main(int argc, char *argv[])
}
fd = open(".short-read", O_RDONLY);
+ save_errno = errno;
+ unlink(".short-read");
+ errno = save_errno;
if (fd < 0) {
perror("file open");
return 1;