summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2020-05-19 21:55:46 -0600
committerJens Axboe <axboe@kernel.dk>2020-05-19 21:57:40 -0600
commit4124aeb173335c49e0ed53ebbf2672377125d4c0 (patch)
tree96e635b7a8d8ac8888d94a7803089da2ac4022d0 /test
parent312ee7a1801410acd8b479b106aabbfdad0ddb73 (diff)
downloadliburing-4124aeb173335c49e0ed53ebbf2672377125d4c0.tar.gz
liburing-4124aeb173335c49e0ed53ebbf2672377125d4c0.tar.bz2
test/madvise: support configured test files
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'test')
-rw-r--r--test/madvise.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/test/madvise.c b/test/madvise.c
index d994712..e3af4f1 100644
--- a/test/madvise.c
+++ b/test/madvise.c
@@ -172,14 +172,18 @@ int main(int argc, char *argv[])
{
struct io_uring ring;
int ret, i, good, bad;
-
- if (argc > 1)
- return 0;
-
- if (create_file(".madvise.tmp")) {
- fprintf(stderr, "file creation failed\n");
- goto err;
+ char *fname;
+
+ if (argc > 1) {
+ fname = argv[1];
+ } else {
+ fname = ".madvise.tmp";
+ if (create_file(".madvise.tmp")) {
+ fprintf(stderr, "file creation failed\n");
+ goto err;
+ }
}
+
if (io_uring_queue_init(8, &ring, 0)) {
fprintf(stderr, "ring creation failed\n");
goto err;
@@ -187,7 +191,7 @@ int main(int argc, char *argv[])
good = bad = 0;
for (i = 0; i < LOOPS; i++) {
- ret = test_madvise(&ring, ".madvise.tmp");
+ ret = test_madvise(&ring, fname);
if (ret == 1) {
fprintf(stderr, "test_madvise failed\n");
goto err;
@@ -201,10 +205,12 @@ int main(int argc, char *argv[])
if (bad > good)
fprintf(stderr, "Suspicious timings (%u > %u)\n", bad, good);
- unlink(".madvise.tmp");
+ if (fname != argv[1])
+ unlink(fname);
io_uring_queue_exit(&ring);
return 0;
err:
- unlink(".madvise.tmp");
+ if (fname != argv[1])
+ unlink(fname);
return 1;
}