aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhangjin Wu <[email protected]>2023-07-07 23:01:09 +0800
committerWilly Tarreau <[email protected]>2023-08-23 04:38:02 +0200
commit938b5b983330a55af8e31eabf329db7dbc7a5038 (patch)
tree43b70a8c179f9de2a116e1d4d54d5470edd6d2a9
parent4201cfce15fe35d9d90ae870aba12eb84c0452ab (diff)
selftests/nolibc: export argv0 for some tests
argv0 is the path to nolibc-test program itself, which is a very good always existing readable file for some tests, let's export it. Note, the path may be absolute or relative, please make sure the tests work with both of them. If it is relative, we must make sure the current path is the one specified by the PWD environment variable. Suggested-by: Willy Tarreau <[email protected]> Link: https://lore.kernel.org/lkml/[email protected]/ Signed-off-by: Zhangjin Wu <[email protected]> Signed-off-by: Willy Tarreau <[email protected]>
-rw-r--r--tools/testing/selftests/nolibc/nolibc-test.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
index c02d89953679..1e4a39548f26 100644
--- a/tools/testing/selftests/nolibc/nolibc-test.c
+++ b/tools/testing/selftests/nolibc/nolibc-test.c
@@ -43,6 +43,9 @@
/* will be used by nolibc by getenv() */
char **environ;
+/* will be used by some test cases as readable file, please don't write it */
+static const char *argv0;
+
/* definition of a series of tests */
struct test {
const char *name; /* test name */
@@ -948,6 +951,7 @@ int main(int argc, char **argv, char **envp)
int idx;
char *test;
+ argv0 = argv[0];
environ = envp;
/* when called as init, it's possible that no console was opened, for