[PATCH v6 09/15] selftests/nolibc: export argv0 for some tests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <w@xxxxxx>
Link: https://lore.kernel.org/lkml/ZKKbS3cwKcHgnGwu@xxxxxx/
Signed-off-by: Zhangjin Wu <falcon@xxxxxxxxxxx>
---
 tools/testing/selftests/nolibc/nolibc-test.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
index 486334981e60..88b840f86f52 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
-- 
2.25.1




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux