Roxen.git / server / etc / test / modules / TEST.pmod / http.pmod / WebDAV.pmod / TestBase.pike

version» Context lines:

Roxen.git/server/etc/test/modules/TEST.pmod/http.pmod/WebDAV.pmod/TestBase.pike:2108:         // -----------------------------------------------------------------------------   // Special testcases combining different encodings and mixed/lower/upper case   // letters.   // -----------------------------------------------------------------------------      #ifdef WEBDAV_TEST_ASCII_ONLY   protected constant FILENAMES =    ({ -  "myFile", // To compare with +  "Ascii-myFile", // To compare with    });   #else   protected constant FILENAMES =    ({ -  "myFile", // To compare with -  "åÅäÄöÖæÆüÜñÑ@", // Some Latin 1 chars -  "ąĄŁůŮăĂçÇ", // Some Latin 2 chars -  "фщъЂЃЄЉЖ", // Some Cyrillic chars -  "ώψφλξβΩΠΞΔ€", // Some Greek chars +  "Ascii-myFile", // To compare with +  "Latin1-åÅäÄöÖæÆüÜñÑ@", // Some Latin 1 chars +  "Latin2-ąĄŁůŮăĂçÇ", // Some Latin 2 chars +  "Cyrillic-фщъЂЃЄЉЖ", // Some Cyrillic chars +  "Greek-ώψφλξβΩΠΞΔ€", // Some Greek chars    });   #endif      // Create directory and file using one encoding and mixed, lower or upper case.   // Then do ls for all combinations of (same encoding, other encoding) x   // (mixed case, lower case, upper case).   public void test_x_ls()   {    int count = 0;    bool normalizing = !non_normalizing_filesystem();
Roxen.git/server/etc/test/modules/TEST.pmod/http.pmod/WebDAV.pmod/TestBase.pike:2154:    unicode_method_ls, true)[case_ls];    string file_ls = make_filenames("", filename, unicode_method_ls,    true)[case_ls];    mapping(string:string) exp_dir =    make_filenames(this::testcase_dir, filename, "NFC", false);    mapping(string:string) exp_file = make_filenames("", filename,    "NFC", false);    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"    "str: %O\n"    "umc: %O\n"    "cc: %O\n"    "uml: %O\n"    "cls: %O\n"    "fn: %O\n"    "nd: %O\n"    "nf: %O\n"    "dls: %O\n"    "fls: %O\n"    "ed: %O\n"    "ef: %O\n"    "ep: %O\n" -  +  "em: %O\n"    "--------\n"    "utf8(ep): %O\n"    "ap(nd, nf): %O\n",    normalizing, casesensitive,    str, unicode_method_create, case_create,    unicode_method_ls, case_ls,    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],    exp_dir[case_ls] + "/" + exp_file[case_create] }) );       // 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] }) );    } 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);    }    }    }    }    }    }   } - } +       // Test create directory and file containing special chars.   public void test_x_special_chars()   {    string testdir = this::testcase_dir;    // If you want to try single chars, just ad them as new strings to the array    // below.    array(string) FILENAMES = ({   #ifdef __NT__    /* NB: *, ? and | are apparently invalid characters in NTFS. */