summaryrefslogtreecommitdiff
path: root/src/regress/lib/libc/getexecpath
diff options
context:
space:
mode:
authorderaadt <>2026-08-31 15:17:53 +0000
committerderaadt <>2026-08-31 15:17:53 +0000
commitb8f8f8a555b51a55550edea2b563ad914ef4da5c (patch)
tree46bc2840a88794872a032a9eb8fd115b331fb085 /src/regress/lib/libc/getexecpath
parentdaea0693c19acb492f94b5a2d2b6217e7ce9c124 (diff)
downloadopenbsd-master.tar.gz
openbsd-master.tar.bz2
openbsd-master.zip
small regression test for getexecpath(3)HEADmaster
Diffstat (limited to 'src/regress/lib/libc/getexecpath')
-rw-r--r--src/regress/lib/libc/getexecpath/Makefile8
-rw-r--r--src/regress/lib/libc/getexecpath/getexecpath.c24
2 files changed, 32 insertions, 0 deletions
diff --git a/src/regress/lib/libc/getexecpath/Makefile b/src/regress/lib/libc/getexecpath/Makefile
new file mode 100644
index 0000000000..c952c5cb38
--- /dev/null
+++ b/src/regress/lib/libc/getexecpath/Makefile
@@ -0,0 +1,8 @@
1PROG=getexecpath
2
3WARNINGS=yes
4
5run-regress-${PROG}: ${PROG}
6 ./${PROG} `cd ${.OBJDIR} && pwd -P`/${PROG}
7
8.include <bsd.regress.mk>
diff --git a/src/regress/lib/libc/getexecpath/getexecpath.c b/src/regress/lib/libc/getexecpath/getexecpath.c
new file mode 100644
index 0000000000..c0ee005ca2
--- /dev/null
+++ b/src/regress/lib/libc/getexecpath/getexecpath.c
@@ -0,0 +1,24 @@
1#include <sys/types.h>
2#include <sys/auxv.h>
3#include <stdlib.h>
4#include <string.h>
5#include <unistd.h>
6#include <limits.h>
7#include <stdio.h>
8#include <err.h>
9
10int
11main(int argc, char *argv[])
12{
13 char path[PATH_MAX];
14
15 if (argc < 1)
16 errx(1, "usage: getexecpath expected-path");
17
18 if (getexecpath(path, sizeof path) == -1)
19 err(1, "getexepath: on path");
20 if (strcmp(path, argv[1]) != 0)
21 exit(1);
22 printf("getexecpath(3) is working\n");
23 exit(0);
24}