summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmit Shah <amit.shah@redhat.com>2009-05-21 17:22:21 +0530
committerAmit Shah <amit.shah@redhat.com>2009-05-21 17:22:21 +0530
commit80e1f90b3ce141c84f3770db522c2861cbad7481 (patch)
tree7605661ac7b2551236c5428b143b628be2b07478
parent7ea205fbf513452edc3f680120dab47a7e52f433 (diff)
downloadalloc-perf-master.zip
alloc-perf-master.tar.gz
alloc-perf-master.tar.xz
Support for running test in current dirHEADmaster
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 <amit.shah@redhat.com>
-rw-r--r--test-file-zero-alloc-speed.c34
1 files 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 <filesize-in-gb> <device> <mountpoint> <fstype> [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