/none/tests/freebsd/bug498317
none/tests/freebsd/bug499212
/none/tests/freebsd/osrel
+/none/tests/freebsd/readlinkat
/none/tests/freebsd/swapcontext
/none/tests/freebsd/fexecve
/none/tests/freebsd/hello_world
ksh_test.stdout.exp \
open_client.vgtest \
open_client.stderr.exp \
+ readlinkat.vgtest \
+ readlinkat.stderr.exp \
sanity_level_thread.vgtest \
sanity_level_thread.stderr.exp \
swapcontext.vgtest \
usrstack.stdout.exp
check_PROGRAMS = \
- auxv bug452274 bug498317 bug499212 fexecve hello_world open_client osrel \
- proc_pid_file sanity_level_thread swapcontext umtx_shm_creat usrstack
+ auxv bug452274 bug498317 bug499212 fexecve hello_world open_client \
+ osrel proc_pid_file readlinkat sanity_level_thread swapcontext \
+ umtx_shm_creat usrstack
AM_CFLAGS += $(AM_FLAG_M3264_PRI)
AM_CXXFLAGS += $(AM_FLAG_M3264_PRI)
hello_world_SOURCES = hello_world.cpp
open_client_SOURCES = open_client.cpp
proc_pid_file_SOURCES = proc_pid_file.cpp
+readlinkat_SOURCES = readlinkat.cpp
sanity_level_thread_SOURCES = sanity_level_thread.cpp
sanity_level_thread_LDFLAGS = ${AM_LDFLAGS} -pthread
--- /dev/null
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/param.h>
+#include <iostream>
+#include <cstring>
+
+int main()
+{
+ char path[MAXPATHLEN];
+ char linkedPath[MAXPATHLEN];
+ char currentDirectory[MAXPATHLEN];
+ char parentDirectory[MAXPATHLEN];
+
+ getcwd(currentDirectory, MAXPATHLEN);
+
+ ssize_t res = readlinkat(AT_FDCWD, "readlinkat_link.cpp", linkedPath, MAXPATHLEN);
+ if (res == -1)
+ {
+ std::cerr << "Error: readlinkat test 1 failed\n";
+ }
+ if (!strcmp(linkedPath, "readlink.cpp"))
+ {
+ std::cerr << "Error: readlinkat test 1 unexpected resolved path - " << linkedPath << '\n';
+ }
+
+ int dotdot;
+ if ((dotdot = open("..", O_DIRECTORY | O_RDONLY)) == -1)
+ {
+ throw std::runtime_error("failed to open .");
+ }
+ else
+ {
+ res = readlinkat(dotdot, "freebsd/readlinkat_link.cpp", linkedPath, MAXPATHLEN);
+ if (res == -1)
+ {
+ std::cerr << "Error: readlinkat test 2 failed\n";
+ }
+ if (!strcmp(linkedPath, "readlink.cpp"))
+ {
+ std::cerr << "Error: readlinkat test 2 unexpected resolved path - " << linkedPath << '\n';
+ }
+ }
+ close(dotdot);
+
+ chdir("..");
+ res = readlinkat(AT_FDCWD, "freebsd/readlinkat_link.cpp", linkedPath, MAXPATHLEN);
+ if (res == -1)
+ {
+ std::cerr << "Error: readlinkat test 3 failed\n";
+ }
+ if (!strcmp(linkedPath, "readlink.cpp"))
+ {
+ std::cerr << "Error: readlinkat test 3 unexpected resolved path - " << linkedPath << '\n';
+ }
+}