Branch: Tag:

2018-06-11

2018-06-11 13:37:56 by Martin Karlgren <marty@roxen.com>

WebDAV testsuite: write Unicode filenames directly rather than via WebDAV to avoid normalization in PUT.

This tests that NFD-normalized filenames on disk are accessible via WebDAV.

64:      protected string filesystem_read_file(string path);    + protected int(0..1) filesystem_mkdir_recursive(string(8bit) path); +  + //! Writes a file to @[path], which is used verbatim without any normalization. + protected int(0..) filesystem_direct_write(string(8bit) path, string(8bit) data); +    // protected int filesystem_recursive_rm(string path);      protected int filesystem_check_content(string path, string expected_data)
352:    int expected_status_code)   {    bool src_equals_dst = false; -  if (case_sensitive()) { +  if (non_normalizing_filesystem()) {    src_equals_dst = Unicode.normalize(utf8_to_string(src_path), "NFC") ==    Unicode.normalize(utf8_to_string(dst_path), "NFC");    } else {
487:    do_webdav_ls(path, expected, true, expected_status_code);   }    - protected bool case_sensitive() + protected bool non_normalizing_filesystem()   {    string sysname = System.uname()->sysname;    if (sysname == "Darwin") { // OS X
2107:   public void test_x_ls()   {    int count = 0; -  bool caseSensitive = case_sensitive(); +  bool caseSensitive = non_normalizing_filesystem();    int w = sizeof("" + (sizeof(FILENAMES)*2*3) );    foreach (FILENAMES, string str) {    // TODO: Skip the following 2 loops and just pick an encoding and a case for the src, or?
2130:    make_filenames(this::testcase_dir, filename, "NFC", false);    mapping(string:string) exp_file = make_filenames("", filename,    "NFC", false); -  webdav_mkcol(new_dir, STATUS_CREATED); +  ASSERT_EQUAL(filesystem_mkdir_recursive(new_dir), 1);    if (case_create == case_ls) {    webdav_ls(dir_ls, ({ exp_dir[case_ls] }) );    } else {    webdav_ls(dir_ls, ({ exp_dir[case_ls] }),    caseSensitive && STATUS_NOT_FOUND);    } -  webdav_put(new_dir + "/" + new_file, "FILE " + count, STATUS_CREATED); -  if (case_create == case_ls) { +  string testdata = "FILE " + count; +  ASSERT_EQUAL(filesystem_direct_write(new_dir + "/" + new_file, +  testdata), +  sizeof(testdata)); +  if (case_create == case_ls && +  unicode_method_create == unicode_method_ls) {    webdav_ls(dir_ls,    ({ exp_dir[case_ls],    exp_dir[case_ls] + "/" + exp_file[case_create] }) );
2200:   public void test_x_put()   {    int count = 0; -  bool caseSensitive = case_sensitive(); +  bool caseSensitive = non_normalizing_filesystem();    int w = sizeof("" + (sizeof(FILENAMES)*2*3) );    foreach (FILENAMES, string str) {    // TODO: Skip the following 2 loops and just pick an encoding and a case for the src, or?
2261:   public void test_x_copy_file()   {    int count = 0; -  bool caseSensitive = case_sensitive(); +  bool caseSensitive = non_normalizing_filesystem();    int w = sizeof("" + (sizeof(FILENAMES)*2*3) );    foreach (FILENAMES, string str) {    // TODO: Skip the following 2 loops and just pick an encoding and a case for the src, or?
2297:   public void test_x_mkcol()   {    int count = 0; -  bool caseSensitive = case_sensitive(); +  bool caseSensitive = non_normalizing_filesystem();    int w = sizeof("" + (sizeof(FILENAMES)*2*3) );    foreach (FILENAMES, string str) {    // TODO: Skip the following 2 loops and just pick an encoding and a case for the src, or?
2332:   public void test_x_move_file()   {    int count = 0; -  bool caseSensitive = case_sensitive(); +  bool caseSensitive = non_normalizing_filesystem();    int w = sizeof("" + (sizeof(FILENAMES)*2*3) );    foreach (FILENAMES, string str) {    // TODO: Skip the following 2 loops and just pick an encoding and a case for the src, or?
2371:   // Runs only on case insensitive systems.   public void test_x_put_copy_move_delete()   { -  if (case_sensitive()) { +  if (non_normalizing_filesystem()) {    return;    }    string mv_dst = Stdio.append_path(this::testcase_dir, "mv_dst");
2433:   // We satisfy with taking a lock on a resource with mixed case and later   // creating a file with the same case.   { -  bool caseSensitive = case_sensitive(); +  bool caseSensitive = non_normalizing_filesystem();    array(string) cases = ({"mc", "lc", "uc"});    if (caseSensitive) {    cases = ({ "mc" });