zircon/system/ulib/zbitl/test/tests.cc
// TODO: make the non-fuchsia part of this a general utility that can be shared
// across host-side tests.
make the non-fuchsia part of this a general utility that can be shared
across host-side tests.
make the non - fuchsia part of this a general utility that can be shared across host - side tests .
std::filesystem::path GetTestDataPath(std::string_view filename) {
  std::filesystem::path path;
#if defined(__Fuchsia__)
  path.append(kTestDataDir);
#elif defined(__APPLE__)
  uint32_t length = PATH_MAX;
  char self_path[PATH_MAX];
  char self_path_symlink[PATH_MAX];
  _NSGetExecutablePath(self_path_symlink, &length);
  const char* bin_dir = dirname(realpath(self_path_symlink, self_path));
  path.append(bin_dir).append(kTestDataDir);
#elif defined(__linux__)
  char self_path[PATH_MAX];
  const char* bin_dir = dirname(realpath("/proc/self/exe", self_path));
  path.append(bin_dir).append(kTestDataDir);
#else
#error unknown platform.
#endif
  path.append(filename);
  return path;
}
std :: filesystem :: path GetTestDataPath ( std :: string_view filename ) { std :: filesystem :: path path ; #if defined ( __Fuchsia__ ) path . append ( kTestDataDir ) ; #elif defined ( __APPLE__ ) uint32_t length = PATH_MAX ; char self_path [ PATH_MAX ] ; char self_path_symlink [ PATH_MAX ] ; _NSGetExecutablePath ( self_path_symlink , & length ) ; const char * bin_dir = dirname ( realpath ( self_path_symlink , self_path ) ) ; path . append ( bin_dir ) . append ( kTestDataDir ) ; #elif defined ( __linux__ ) char self_path [ PATH_MAX ] ; const char * bin_dir = dirname ( realpath ( " " , self_path ) ) ; path . append ( bin_dir ) . append ( kTestDataDir ) ; #else #error  unknown platform. #endif path . append ( filename ) ; return path ; }
TODO: make the non-fuchsia part of this a general utility that can be shared
across host-side tests.
TODO : make the non - fuchsia part of this a general utility that can be shared across host - side tests .