From 80e1f90b3ce141c84f3770db522c2861cbad7481 Mon Sep 17 00:00:00 2001 From: Amit Shah Date: Thu, 21 May 2009 17:22:21 +0530 Subject: Support for running test in current dir The test in recent versions only worked by mounting and unmounting partitions where the test is to be run. This was done to correctly measure the time taken to run the tests. However, this meant the tests can't be run on systems that don't have a spare partition (like my development machine). Adding support for running the test in the current working dir here so that the program can be tested. Of course, the results should not be trusted. Signed-off-by: Amit Shah --- test-file-zero-alloc-speed.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/test-file-zero-alloc-speed.c b/test-file-zero-alloc-speed.c index dcfc3b1..f5af84d 100644 --- a/test-file-zero-alloc-speed.c +++ b/test-file-zero-alloc-speed.c @@ -38,12 +38,13 @@ int pre_test_setup(char *source, char *target, char *fstype, { int r; - r = mount(source, target, fstype, mntflags, mntopts); - if (r < 0) { - perror("mount"); - return -1; + if (source) { + r = mount(source, target, fstype, mntflags, mntopts); + if (r < 0) { + perror("mount"); + return -1; + } } - unlink(name); *fd = open(name, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR); if (*fd < 0) { @@ -73,10 +74,11 @@ int post_test_cleanup(char *target, int *fd) if (r < 0) perror("close"); - r = umount(target); - if (r < 0) - perror("unmount"); - + if (strcmp(target, ".")) { + r = umount(target); + if (r < 0) + perror("unmount"); + } return r; } @@ -211,16 +213,22 @@ int main(int argc, char **argv) unsigned long long filesize; /* FIXME! use getopt */ - if (argc < 5) { + if (argc < 2 || argc > 2 && argc < 5) { printf("usage: %s [mntflags] [mntopts]\n", argv[0]); return -1; } filesize = GB(atol(argv[1])); - source = argv[2]; - target = argv[3]; - fstype = argv[4]; + if (argc > 2) { + source = argv[2]; + target = argv[3]; + fstype = argv[4]; + } else { + source = NULL; + target = "."; + fstype = "native"; + } if (argc > 5) mntflags = atol(argv[5]); else -- cgit