Branch: Tag:

2018-07-04

2018-07-04 09:16:24 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Testsuite [WebDAV]: Fix test_x_ls() some more for NT.

This fixes the case where "NFC"/"NFD" doesn't affect the filename
on caseinsentitive but not normalizing platforms (ie NT).

As a side-effect this also cleans up the code somewhat.

Potential fix for [WS-325].

2156:    ASSERT_EQUAL(filesystem_mkdir_recursive(new_dir), 1);    string exp_path = exp_dir[case_ls] + "/" + exp_file[case_ls];    +  // NB: In normalizing (which implies !casesensitive) mode +  // the paths should always match. +  int exp_match = 1; +  if (!normalizing) { +  // NB: In casesensitive mode the paths only match if they +  // are coded identically. +  exp_match = (string_to_utf8(exp_path) == +  Stdio.append_path(new_dir, new_file)); +  if (!exp_match && !casesensitive) { +  // NB: To handle cases where the NFC and NFD normalizations +  // are equal (eg ascii or kanji) it is not sufficient +  // to just look at whether unicode_method_create is +  // "NFC" or "NFD". +  exp_match = (new_dir == +  make_filenames(this::testcase_dir, filename, +  "NFC", true)[case_create]); +  } +  }   #if 0    werror("normalizing: %d\n"    "casesensitive: %d\n"
2172: Inside #if 0
   "ed: %O\n"    "ef: %O\n"    "ep: %O\n" +  "em: %O\n"    "--------\n"    "utf8(ep): %O\n"    "ap(nd, nf): %O\n",
2181: Inside #if 0
   filename,    new_dir, new_file,    dir_ls, file_ls, -  exp_dir, exp_file, exp_path, +  exp_dir, exp_file, exp_path, exp_match,    string_to_utf8(exp_path),    Stdio.append_path(new_dir, new_file));   #endif    -  if (string_to_utf8 (exp_path) == -  Stdio.append_path (new_dir, new_file)) { +  if (exp_match) {    webdav_ls(dir_ls, ({ exp_dir[case_ls] }) );    } else { -  webdav_ls(dir_ls, ({ exp_dir[case_ls] }), -  !normalizing && STATUS_NOT_FOUND); +  webdav_ls(dir_ls, ({}), STATUS_NOT_FOUND);    }    string testdata = "FILE " + count;    ASSERT_EQUAL(filesystem_direct_write(new_dir + "/" + new_file,    testdata),    sizeof(testdata)); -  if (string_to_utf8 (exp_path) == -  Stdio.append_path (new_dir, new_file)) { +  if (exp_match) {    // In this case we should always get a successful listing.    webdav_ls(dir_ls,    ({ exp_dir[case_ls],
2209:    webdav_ls(dir_ls + "/" + file_ls,    ({ exp_dir[case_ls] + "/" + exp_file[case_ls] }) );    } else { -  // In this case the result depends on whether the WebDAV backend -  // is normalizing or not. For our WebServer tests it depends on -  // the OS but other WebDAV modules may implement normalization -  // themselves (then filesystem_behavior() is typically -  // overridden by the test subclass.) -  if (normalizing || -  (!casesensitive && (unicode_method_create == "NFC"))) { -  webdav_ls(dir_ls, -  ({ exp_dir[case_ls], -  exp_dir[case_ls] + "/" + exp_file[case_create] }), -  STATUS_MULTI_STATUS); -  -  // When listing a file directly, it will have equivalent case -  // in the returned list. -  webdav_ls(dir_ls + "/" + file_ls, -  ({ exp_dir[case_ls] + "/" + exp_file[case_ls] }), -  STATUS_MULTI_STATUS); -  } else { +     webdav_ls(dir_ls, ({}), STATUS_NOT_FOUND);    webdav_ls(dir_ls + "/" + file_ls, ({ }), STATUS_NOT_FOUND);    }
2236:    }    }    } - } +       // Test create directory and file containing special chars.   public void test_x_special_chars()