summaryrefslogtreecommitdiff
path: root/tests/access.c
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@strace.io>2021-04-01 08:00:00 +0000
committerDmitry V. Levin <ldv@strace.io>2021-04-01 08:00:00 +0000
commitec976e4f22b685a270bb20d2b210ffa79e2dee85 (patch)
tree1e7f1b137fe4ba46f2c4ff8ad5132ec2053788c1 /tests/access.c
parent2dd0d59a12faefabb5cb599d38d35046997828aa (diff)
downloadstrace-ec976e4f22b685a270bb20d2b210ffa79e2dee85.tar.gz
tests: introduce create_and_enter_subdir and leave_and_remove_subdir
Introduce the pair of functions that is going to be used to make sure the current workdir of the tracee is different from the current workdir of the tracer. Use the new interface in a few tests where the difference is going to be relevant with --secontext option. * tests/subdir.c: New file. * tests/Makefile.am (libtests_a_SOURCES): Add subdir.c. * tests/tests.h (create_and_enter_subdir, leave_and_remove_subdir): New function prototypes. * tests/access.c (main): Use create_and_enter_subdir and leave_and_remove_subdir. * tests/chmod.c (main): Likewise. * tests/execve.c (main): Likewise. * tests/fchmod.c (main): Likewise. * tests/fchmodat.c (main): Likewise. * tests/fchownat.c (main): Likewise. * tests/linkat.c (main): Likewise. * tests/open.c (main): Likewise. * tests/openat.c (main): Likewise.
Diffstat (limited to 'tests/access.c')
-rw-r--r--tests/access.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/access.c b/tests/access.c
index 8bdbb6265..fe7e21d5b 100644
--- a/tests/access.c
+++ b/tests/access.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016-2019 The strace developers.
+ * Copyright (c) 2016-2021 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: GPL-2.0-or-later
@@ -16,6 +16,12 @@
int
main(void)
{
+ /*
+ * Make sure the current workdir of the tracee
+ * is different from the current workdir of the tracer.
+ */
+ create_and_enter_subdir("access_subdir");
+
static const char sample[] = "access_sample";
long rc = syscall(__NR_access, sample, F_OK);
@@ -26,6 +32,8 @@ main(void)
printf("access(\"%s\", R_OK|W_OK|X_OK) = %ld %s (%m)\n",
sample, rc, errno2name());
+ leave_and_remove_subdir();
+
puts("+++ exited with 0 +++");
return 0;
}