Commit 73057d67 authored by Ramon Nou's avatar Ramon Nou
Browse files

Test directories does not find sfind executable. Added verbosity option to...

Test directories does not find sfind executable. Added verbosity option to gfind, removed warnings and segfault
parent e0a1a1ed
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3,6 +3,6 @@ add_executable(sfind sfind.cpp)

if(GKFS_INSTALL_TESTS)
    install(TARGETS sfind 
        DESTINATION ${CMAKE_INSTALL_BINDIR}
        DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/gkfs/tests/integration
    )
endif()
+13 −9
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ typedef struct {
  regex_t name_regex;
  uint64_t size;

  int num_servers;
  unsigned int num_servers;
  char *mountdir;
  // optimizing parameters NOT USED
  int queue_length;
@@ -99,12 +99,12 @@ static void pfind_print_help(pfind_options_t *res) {
         "\tworkdir = \"%s\"\n"
         "\t-newer = \"%s\"\n"
         "\t-name|-regex = \"%s\"\n"
         "\t-S: num servers = \"%s\"\n"
         "\t-S: num servers = \"%d\"\n"
         "\t-M: mountdir = \"%s\"\n"
         "Optional flags\n"
         "\t-h: prints the help\n"
         "\t--help: prints the help without initializing MPI\n",
         res->workdir, res->timestamp_file, res->name_pattern, res->num_servers,
         res->workdir.c_str(), res->timestamp_file, res->name_pattern, res->num_servers,
         res->mountdir);
}
MPI_Comm pfind_com;
@@ -314,12 +314,12 @@ void dirProcess(const string path, unsigned long long &checked,
  if (servers_per_node == 0)
     servers_per_node++;
  for (int it = 0; it < servers_per_node; it++) {
      auto server = (world_rank - 1) * servers_per_node + it;
      unsigned int server = (world_rank - 1) * servers_per_node + it;
      if (server >= opt->num_servers)
        break;

      unsigned long long total_size = 0;
      auto n = gkfs_getsingleserverdir(
      unsigned long long n = gkfs_getsingleserverdir(
          path.c_str(), getdir,
          (sizeof(struct dirent_extended) + 255) * 1024 * 100, server);
      struct dirent_extended *temp = getdir;
@@ -339,17 +339,23 @@ void dirProcess(const string path, unsigned long long &checked,
                                                     temp->d_reclen);
          continue;
        }
   	
        /* Find filtering */
        auto timeOK = true;
	auto match = false;
        if (opt->timestamp_file) {
          if ((uint64_t)temp->ctime < runtime.ctime_min)
            timeOK = false;
        }

        if (timeOK and (temp->size == opt->size or opt->size == std::numeric_limits<uint64_t>::max()))
          if (!(opt->name_pattern &&
                regexec(&opt->name_regex, temp->d_name, 0, nullptr, 0)))
                regexec(&opt->name_regex, temp->d_name, 0, nullptr, 0))) {
            found++;
	    match = true;
          }
        checked++;
        if (opt->verbosity) cout << temp->d_name << " -- " << opt->name_pattern << " MATCH : " << match << endl;
	temp =
            reinterpret_cast<dirent_extended *>(reinterpret_cast<char *>(temp) + temp->d_reclen);
       }
@@ -362,7 +368,6 @@ int process(char *processor_name, int world_rank, int world_size,

  // INIT PFIND
  memset(&runtime, 0, sizeof(pfind_runtime_options_t));
  int ret;
  /* Get timestamp file */
  if (opt->timestamp_file) {
    if (pfind_rank == 0) {
@@ -377,7 +382,6 @@ int process(char *processor_name, int world_rank, int world_size,
    MPI_Bcast(&runtime.ctime_min, 1, MPI_INT, 0, pfind_com);
  }

  auto iterations = 0;
  if (world_rank == 0) {
    queue<string> dirs;
    string workdir = opt->workdir;
+4 −6
Original line number Diff line number Diff line
@@ -98,11 +98,11 @@ static void pfind_print_help(pfind_options_t *res) {
         "\tworkdir = \"%s\"\n"
         "\t-newer = \"%s\"\n"
         "\t-name|-regex = \"%s\"\n"
         "\t-S: num servers = \"%s\"\n"
         "\t-S: num servers = \"%d\"\n"
         "\t-M: mountdir = \"%s\"\n"
         "Optional flags\n"
         "\t-h: prints the help\n"
         "\t--help: prints the help without initializing MPI\n",res->workdir,
         "\t--help: prints the help without initializing MPI\n",res->workdir.c_str(),
         res->timestamp_file, res->name_pattern, res->num_servers,
         res->mountdir );
}
@@ -153,7 +153,7 @@ pfind_options_t *pfind_parse_args(int argc, char **argv, int force_print_help){
      char *str = argv[i + 1];
      char *out = res->name_pattern;
      auto pos = 0;
      for (auto i = 0; i < strlen(str); i++) {
      for (size_t i = 0; i < strlen(str); i++) {
        if (str[i] == '*') {
          pos += sprintf(out + pos, ".*");
        } else if (str[i] == '.') {
@@ -285,7 +285,7 @@ void dirProcess(const string path, unsigned long long &checked,

  for (auto server = 0; server < opt->num_servers; server++) {
    unsigned long long total_size = 0;
    auto n = gkfs_getsingleserverdir(
    unsigned long long n = gkfs_getsingleserverdir(
        path.c_str(), getdir,
        (sizeof(struct dirent_extended) + 255) * 1024 * 100, server);
    struct dirent_extended *temp = getdir;
@@ -328,7 +328,6 @@ int process(pfind_options_t *opt) {
  found = 0;
  checked = 0;
  memset(&runtime, 0, sizeof(pfind_runtime_options_t));
  auto ret = 0;
  /* Get timestamp file */
  if (opt->timestamp_file) {
    if (pfind_rank == 0) {
@@ -342,7 +341,6 @@ int process(pfind_options_t *opt) {
    }
  }

  auto iterations = 0;
  queue<string> dirs;
  string workdir = opt->workdir;
  workdir = workdir.substr(strlen(opt->mountdir), workdir.size());
+1 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ add_subdirectory(harness)
gkfs_enable_python_testing(
    BINARY_DIRECTORIES ${CMAKE_BINARY_DIR}/src/daemon/
                       ${CMAKE_BINARY_DIR}/src/client/
                       ${CMAKE_BINARY_DIR}/
                       ${CMAKE_BINARY_DIR}/tests/integration/harness/
    LIBRARY_PREFIX_DIRECTORIES ${CMAKE_PREFIX_PATH}
)
+1 −1
Original line number Diff line number Diff line
@@ -221,7 +221,7 @@ def test_extended(gkfs_daemon, gkfs_shell, gkfs_client):

    assert ret.retval == 1
    preload = 'LIBGKFS_HOSTS_FILE='+str(gkfs_client._patched_env['LIBGKFS_HOSTS_FILE'])+' LD_PRELOAD='+str(gkfs_client._preload_library)
    stream = os.popen(preload+' '+str(gkfs_daemon._workspace.bindirs[1])+'/sfind '+str(topdir)+' -M '+str(gkfs_daemon.mountdir)+' -S 1 -name "*_k*"');
    stream = os.popen(preload+' ./sfind '+str(topdir)+' -M '+str(gkfs_daemon.mountdir)+' -S 1 -name "*_k*"');
    output = stream.read()
    assert output == "MATCHED 0/4\n"