Skip to content

Commit

Permalink
Fix tests on most BSD systems
Browse files Browse the repository at this point in the history
  • Loading branch information
rikyoz committed Jun 29, 2024
1 parent b7435f6 commit c48394d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tests/src/utils/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
#include <array>
#include <libproc.h> // for proc_pidpath and PROC_PIDPATHINFO_MAXSIZE
#include <unistd.h> // for getpid
#elif defined( __FreeBSD__ ) || defined( __DragonFly__ )
constexpr auto self_exe_path = "/proc/curproc/file";
#elif defined( __NetBSD__ )
constexpr auto self_exe_path = "/proc/curproc/exe";
#elif defined( __sun )
constexpr auto self_exe_path = "/proc/self/path/a.out";
#else
constexpr auto self_exe_path = "/proc/self/exe";
#endif

#include <internal/fs.hpp>
Expand All @@ -39,8 +47,8 @@ inline auto exe_path() -> fs::path {
return ( result_size > 0 ) ? std::string( result.data(), result_size ) : "";
#else
std::error_code error;
const fs::path result = fs::read_symlink( "/proc/self/exe", error );
return error ? "" : result;
const fs::path result = fs::read_symlink( self_exe_path, error );
return error ? "unknown" : result;
#endif
}

Expand Down

0 comments on commit c48394d

Please sign in to comment.