aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar Miklos Szeredi <mszeredi@suse.cz>2013-09-20 13:57:41 +0200
committerGravatar Miklos Szeredi <mszeredi@suse.cz>2013-09-20 13:57:41 +0200
commit1c3ce3dc6a7e7b605a3c8620d6febcf1a8e8b27c (patch)
treeb36d9bc1472145dd7c7ac3260c812c9b2ce594c1 /test
parent4ef37a8340ad303c415f8c66383ab34d34e409f7 (diff)
test: add a realdir option
Diffstat (limited to 'test')
-rw-r--r--test/test.c51
1 files changed, 38 insertions, 13 deletions
diff --git a/test/test.c b/test/test.c
index c421cda..5d5750d 100644
--- a/test/test.c
+++ b/test/test.c
@@ -17,6 +17,13 @@ static char testfile2[1024];
static char testdir[1024];
static char testdir2[1024];
static char subfile[1024];
+
+static char testfile_r[1024];
+static char testfile2_r[1024];
+static char testdir_r[1024];
+static char testdir2_r[1024];
+static char subfile_r[1024];
+
static char testname[256];
static char testdata[] = "abcdefghijklmnopqrstuvwxyz";
static char testdata2[] = "1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./";
@@ -834,7 +841,7 @@ static int do_test_open(int exist, int flags, const char *flags_str, int mode)
start_test("open(%s, %s, 0%03o)", exist ? "+" : "-", flags_str, mode);
unlink(testfile);
if (exist) {
- res = create_file(testfile, testdata2, testdata2len);
+ res = create_file(testfile_r, testdata2, testdata2len);
if (res == -1)
return -1;
@@ -965,6 +972,9 @@ static int do_test_open(int exist, int flags, const char *flags_str, int mode)
res = check_nonexist(testfile);
if (res == -1)
return -1;
+ res = check_nonexist(testfile_r);
+ if (res == -1)
+ return -1;
if (err)
return -1;
@@ -1382,29 +1392,37 @@ static int do_test_create_ro_dir(int flags, const char *flags_str)
int main(int argc, char *argv[])
{
const char *basepath;
+ const char *realpath;
int err = 0;
+ int a;
umask(0);
- if (argc < 2 || argc > 3) {
- fprintf(stderr, "usage: %s testdir [test#]\n", argv[0]);
+ if (argc < 2 || argc > 4) {
+ fprintf(stderr, "usage: %s testdir [:realdir] [[-]test#]\n", argv[0]);
return 1;
}
basepath = argv[1];
- if (argc == 3) {
+ realpath = basepath;
+ for (a = 2; a < argc; a++) {
char *endptr;
- char *arg = argv[2];
- if (arg[0] == '-') {
- arg++;
- skip_test = strtoul(arg, &endptr, 10);
+ char *arg = argv[a];
+ if (arg[0] == ':') {
+ realpath = arg + 1;
} else {
- select_test = strtoul(argv[2], &endptr, 10);
- }
- if (arg[0] == '\0' || *endptr != '\0') {
- fprintf(stderr, "invalid number: '%s'\n", arg);
- return 1;
+ if (arg[0] == '-') {
+ arg++;
+ skip_test = strtoul(arg, &endptr, 10);
+ } else {
+ select_test = strtoul(arg, &endptr, 10);
+ }
+ if (arg[0] == '\0' || *endptr != '\0') {
+ fprintf(stderr, "invalid number: '%s'\n", arg);
+ return 1;
+ }
}
}
assert(strlen(basepath) < 512);
+ assert(strlen(realpath) < 512);
if (basepath[0] != '/') {
fprintf(stderr, "testdir must be an absolute path\n");
return 1;
@@ -1415,6 +1433,13 @@ int main(int argc, char *argv[])
sprintf(testdir, "%s/testdir", basepath);
sprintf(testdir2, "%s/testdir2", basepath);
sprintf(subfile, "%s/subfile", testdir2);
+
+ sprintf(testfile_r, "%s/testfile", realpath);
+ sprintf(testfile2_r, "%s/testfile2", realpath);
+ sprintf(testdir_r, "%s/testdir", realpath);
+ sprintf(testdir2_r, "%s/testdir2", realpath);
+ sprintf(subfile_r, "%s/subfile", testdir2_r);
+
err += test_create();
err += test_create_unlink();
err += test_mknod();