summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libc/Makefile4
-rw-r--r--src/regress/lib/libc/getexecpath/Makefile8
-rw-r--r--src/regress/lib/libc/getexecpath/getexecpath.c24
3 files changed, 34 insertions, 2 deletions
diff --git a/src/regress/lib/libc/Makefile b/src/regress/lib/libc/Makefile
index 555b826e96..c43cb5aa6c 100644
--- a/src/regress/lib/libc/Makefile
+++ b/src/regress/lib/libc/Makefile
@@ -1,11 +1,11 @@
1# $OpenBSD: Makefile,v 1.64 2026/06/27 17:52:29 jca Exp $ 1# $OpenBSD: Makefile,v 1.65 2026/08/31 15:17:51 deraadt Exp $
2 2
3SUBDIR+= _setjmp 3SUBDIR+= _setjmp
4SUBDIR+= alloca arc4random-fork atexit 4SUBDIR+= alloca arc4random-fork atexit
5SUBDIR+= basename 5SUBDIR+= basename
6SUBDIR+= cephes cxa-atexit 6SUBDIR+= cephes cxa-atexit
7SUBDIR+= db dirname 7SUBDIR+= db dirname
8SUBDIR+= elf_aux_info 8SUBDIR+= elf_aux_info getexecpath
9SUBDIR+= env explicit_bzero 9SUBDIR+= env explicit_bzero
10SUBDIR+= ffs fmemopen fnmatch fpclassify fread freeaddrinfo 10SUBDIR+= ffs fmemopen fnmatch fpclassify fread freeaddrinfo
11SUBDIR+= gcvt getaddrinfo getcap getopt getopt_long glob 11SUBDIR+= gcvt getaddrinfo getcap getopt getopt_long glob
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}