summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2017-04-01 23:11:28 +0000
committerDmitry V. Levin <ldv@altlinux.org>2017-04-03 01:06:11 +0000
commit3e15e018efc5ed08eba647305ebd70e695a50967 (patch)
tree392f84fb04220e02edc00f4d1bcf8b6bec08047e
parentc5c64110a8158e5227b1ade518e1cc35fe398d22 (diff)
downloadstrace-3e15e018efc5ed08eba647305ebd70e695a50967.tar.gz
tests: make test executables invocable outside current work directory
Most of test executables were ready for the upcoming change, this change prepares all the rest. * tests/getdents.c (main): Use fixed name for the sample directory. * tests/getdents64.c (main): Likewise. * tests/readdir.c (main): Likewise. * tests/mknod.c (sample): Change to a pointer. (main): Use av[0] as a sample. * tests/symlink.c (main): Use av[0] as a linkpath. * tests/umode_t.c (sample): Change to a pointer. (test_syscall): Fix expected output. (main): Use av[0] as a sample.
-rw-r--r--tests/getdents.c6
-rw-r--r--tests/getdents64.c6
-rw-r--r--tests/mknod.c5
-rw-r--r--tests/readdir.c6
-rw-r--r--tests/symlink.c10
-rw-r--r--tests/umode_t.c9
6 files changed, 18 insertions, 24 deletions
diff --git a/tests/getdents.c b/tests/getdents.c
index b787c837b..7ee7d77a8 100644
--- a/tests/getdents.c
+++ b/tests/getdents.c
@@ -92,12 +92,10 @@ print_dirent(const kernel_dirent *d)
}
int
-main(int ac, const char **av)
+main(void)
{
- char *dname;
+ static const char dname[] = "getdents.test.tmp.dir";
- assert(ac == 1);
- assert(asprintf(&dname, "%s.test.tmp.dir", av[0]) > 0);
assert(!mkdir(dname, 0700));
assert(!chdir(dname));
(void) close(0);
diff --git a/tests/getdents64.c b/tests/getdents64.c
index 9da2a23c2..0e7085b71 100644
--- a/tests/getdents64.c
+++ b/tests/getdents64.c
@@ -98,12 +98,10 @@ print_dirent(const kernel_dirent64 *d)
}
int
-main(int ac, const char **av)
+main(void)
{
- char *dname;
+ static const char dname[] = "getdents64.test.tmp.dir";
- assert(ac == 1);
- assert(asprintf(&dname, "%s.test.tmp.dir", av[0]) > 0);
assert(!mkdir(dname, 0700));
assert(!chdir(dname));
(void) close(0);
diff --git a/tests/mknod.c b/tests/mknod.c
index 4cc1c5cb7..b38714990 100644
--- a/tests/mknod.c
+++ b/tests/mknod.c
@@ -8,7 +8,7 @@
# include <sys/sysmacros.h>
# include <unistd.h>
-static const char sample[] = "mknod";
+static const char *sample;
static long
call_mknod(unsigned short mode, unsigned long dev)
@@ -18,9 +18,10 @@ call_mknod(unsigned short mode, unsigned long dev)
}
int
-main(void)
+main(int ac, char **av)
{
unsigned long dev = (unsigned long) 0xdeadbeefbadc0dedULL;
+ sample = av[0];
long rc = call_mknod(0, dev);
printf("mknod(\"%s\", 000) = %ld %s (%m)\n",
diff --git a/tests/readdir.c b/tests/readdir.c
index 8c4836200..6431f5a91 100644
--- a/tests/readdir.c
+++ b/tests/readdir.c
@@ -58,9 +58,9 @@ static const char qname[] =
"A\\nA\\nA\\nA\\nA\\nA\\nA\\nA\\nA\\nA\\nA\\nA\\nA\\nA\\nA\\nZ";
int
-main(int ac, const char **av)
+main(void)
{
- char *dname;
+ static const char dname[] = "readdir.test.tmp.dir";
struct {
unsigned long d_ino;
unsigned long d_off;
@@ -69,8 +69,6 @@ main(int ac, const char **av)
} e;
int rc;
- assert(ac == 1);
- assert(asprintf(&dname, "%s.test.tmp.dir", av[0]) > 0);
assert(!mkdir(dname, 0700));
assert(!chdir(dname));
(void) close(0);
diff --git a/tests/symlink.c b/tests/symlink.c
index 72cb49085..3e01cf211 100644
--- a/tests/symlink.c
+++ b/tests/symlink.c
@@ -7,14 +7,12 @@
# include <unistd.h>
int
-main(void)
+main(int ac, char **av)
{
- static const char sample_1[] = "symlink_new";
- static const char sample_2[] = "symlink";
+ static const char sample[] = "symlink.sample";
- long rc = syscall(__NR_symlink, sample_1, sample_2);
- printf("symlink(\"%s\", \"%s\") = %ld %s (%m)\n",
- sample_1, sample_2, rc, errno2name());
+ long rc = syscall(__NR_symlink, sample, av[0]);
+ printf("symlink(\"%s\", \"%s\") = %s\n", sample, av[0], sprintrc(rc));
puts("+++ exited with 0 +++");
return 0;
diff --git a/tests/umode_t.c b/tests/umode_t.c
index 5041638ee..0fb9a513e 100644
--- a/tests/umode_t.c
+++ b/tests/umode_t.c
@@ -38,7 +38,7 @@
# define TEST_SYSCALL_PREFIX_STR ""
#endif
-static const char sample[] = TEST_SYSCALL_STR;
+static const char *sample;
static void
test_syscall(unsigned short mode)
@@ -49,17 +49,18 @@ test_syscall(unsigned short mode)
if (mode <= 07)
printf("%s(%s\"%s\", 00%d) = %ld %s (%m)\n",
- sample, TEST_SYSCALL_PREFIX_STR,
+ TEST_SYSCALL_STR, TEST_SYSCALL_PREFIX_STR,
sample, (int) mode, rc, errno2name());
else
printf("%s(%s\"%s\", %#03ho) = %ld %s (%m)\n",
- sample, TEST_SYSCALL_PREFIX_STR,
+ TEST_SYSCALL_STR, TEST_SYSCALL_PREFIX_STR,
sample, mode, rc, errno2name());
}
int
-main(void)
+main(int ac, char **av)
{
+ sample = av[0];
test_syscall(0);
test_syscall(0xffff);
test_syscall(06);