summaryrefslogtreecommitdiff
path: root/tests/openat.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/openat.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/openat.c')
-rw-r--r--tests/openat.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/openat.c b/tests/openat.c
index 8d1bca0bb..0c4bb3d10 100644
--- a/tests/openat.c
+++ b/tests/openat.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2016 Katerina Koukiou <k.koukiou@gmail.com>
- * 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
@@ -39,6 +39,12 @@ test_mode_flag(unsigned int mode_val, const char *mode_str,
int
main(void)
{
+ /*
+ * Make sure the current workdir of the tracee
+ * is different from the current workdir of the tracer.
+ */
+ create_and_enter_subdir("openat_subdir");
+
long fd = syscall(__NR_openat, -100, sample, O_RDONLY|O_CREAT, 0400);
printf("openat(AT_FDCWD, \"%s\", O_RDONLY|O_CREAT, 0400) = %s\n",
sample, sprintrc(fd));
@@ -101,6 +107,8 @@ main(void)
test_mode_flag(modes[m].val, modes[m].str,
flags[f].val, flags[f].str);
+ leave_and_remove_subdir();
+
puts("+++ exited with 0 +++");
return 0;
}