Tests for some mixed flag usage, that could produce quirky behavior, and support for file paths longer than MAX_PATH
Signed-off-by: Florian Eder others.meder@gmail.com --- programs/robocopy/tests/robocopy.c | 196 +++++++++++++++++++++++++++++ 1 file changed, 196 insertions(+)
diff --git a/programs/robocopy/tests/robocopy.c b/programs/robocopy/tests/robocopy.c index 94911cfe632..f699a9dc57b 100644 --- a/programs/robocopy/tests/robocopy.c +++ b/programs/robocopy/tests/robocopy.c @@ -1001,6 +1001,171 @@ static void check_xl_2_test(void) check_folder_and_delete(L"robocopy_destination", TRUE); }
+static void check_mixed_1_test(void) +{ + check_file_and_delete(L"robocopy_source\fileA.a", FALSE); + check_file_and_delete(L"robocopy_source\fileB.b", TRUE); + check_file_and_delete(L"robocopy_source\folderA\fileC.c", TRUE); + check_file_and_delete(L"robocopy_source\folderA\fileD.d", TRUE); + check_file_and_delete(L"robocopy_source\folderA\folderD\fileE.e", TRUE); + check_file_and_delete(L"robocopy_source\folderB\fileF.f", TRUE); + check_file_and_delete(L"robocopy_source\folderB\fileG.g", FALSE); + check_folder_and_delete(L"robocopy_source\folderA\folderD", TRUE); + check_folder_and_delete(L"robocopy_source\folderA\folderE", TRUE); + check_folder_and_delete(L"robocopy_source\folderA", TRUE); + check_folder_and_delete(L"robocopy_source\folderB", TRUE); + check_folder_and_delete(L"robocopy_source\folderC", TRUE); + check_folder_and_delete(L"robocopy_source", TRUE); + + check_file_and_delete(L"robocopy_destination\fileA.a", TRUE); + check_file_and_delete(L"robocopy_destination\fileB.b", FALSE); + check_file_and_delete(L"robocopy_destination\folderA\fileC.c", FALSE); + check_file_and_delete(L"robocopy_destination\folderA\fileD.d", FALSE); + check_file_and_delete(L"robocopy_destination\folderA\folderD\fileE.e", FALSE); + check_file_and_delete(L"robocopy_destination\folderB\fileF.f", FALSE); + check_file_and_delete(L"robocopy_destination\folderB\fileG.g", TRUE); + check_folder_and_delete(L"robocopy_destination\folderA\folderD", FALSE); + check_folder_and_delete(L"robocopy_destination\folderA\folderE", FALSE); + check_folder_and_delete(L"robocopy_destination\folderA", FALSE); + check_folder_and_delete(L"robocopy_destination\folderB", TRUE); + check_folder_and_delete(L"robocopy_destination\folderC", TRUE); + check_folder_and_delete(L"robocopy_destination", TRUE); +} + +static void check_mixed_2_test(void) +{ + check_file_and_delete(L"robocopy_source\fileA.a", FALSE); + check_file_and_delete(L"robocopy_source\fileB.b", FALSE); + check_file_and_delete(L"robocopy_source\folderA\fileC.c", TRUE); + check_file_and_delete(L"robocopy_source\folderA\fileD.d", FALSE); + check_file_and_delete(L"robocopy_source\folderA\folderD\fileE.e", TRUE); + check_file_and_delete(L"robocopy_source\folderB\fileF.f", FALSE); + check_file_and_delete(L"robocopy_source\folderB\fileG.g", FALSE); + check_folder_and_delete(L"robocopy_source\folderA\folderD", TRUE); + check_folder_and_delete(L"robocopy_source\folderA\folderE", FALSE); + check_folder_and_delete(L"robocopy_source\folderA", TRUE); + check_folder_and_delete(L"robocopy_source\folderB", FALSE); + check_folder_and_delete(L"robocopy_source\folderC", FALSE); + check_folder_and_delete(L"robocopy_source", TRUE); + + check_file_and_delete(L"robocopy_destination\fileA.a", TRUE); + check_file_and_delete(L"robocopy_destination\fileB.b", TRUE); + check_file_and_delete(L"robocopy_destination\folderA\fileC.c", FALSE); + check_file_and_delete(L"robocopy_destination\folderA\fileD.d", TRUE); + check_file_and_delete(L"robocopy_destination\folderA\folderD\fileE.e", FALSE); + check_file_and_delete(L"robocopy_destination\folderB\fileF.f", TRUE); + check_file_and_delete(L"robocopy_destination\folderB\fileG.g", TRUE); + check_folder_and_delete(L"robocopy_destination\folderA\folderD", FALSE); + check_folder_and_delete(L"robocopy_destination\folderA\folderE", TRUE); + check_folder_and_delete(L"robocopy_destination\folderA", TRUE); + check_folder_and_delete(L"robocopy_destination\folderB", TRUE); + check_folder_and_delete(L"robocopy_destination\folderC", TRUE); + check_folder_and_delete(L"robocopy_destination", TRUE); +} + +static void check_mixed_3_test(void) +{ + check_file_and_delete(L"robocopy_source\fileA.a", TRUE); + check_file_and_delete(L"robocopy_source\fileB.b", TRUE); + check_file_and_delete(L"robocopy_source\folderA\fileC.c", TRUE); + check_file_and_delete(L"robocopy_source\folderA\fileD.d", TRUE); + check_file_and_delete(L"robocopy_source\folderA\folderD\fileE.e", TRUE); + check_file_and_delete(L"robocopy_source\folderB\fileF.f", TRUE); + check_file_and_delete(L"robocopy_source\folderB\fileG.g", TRUE); + check_folder_and_delete(L"robocopy_source\folderA\folderD", TRUE); + check_folder_and_delete(L"robocopy_source\folderA\folderE", TRUE); + check_folder_and_delete(L"robocopy_source\folderA", TRUE); + check_folder_and_delete(L"robocopy_source\folderB", TRUE); + check_folder_and_delete(L"robocopy_source\folderC", TRUE); + check_folder_and_delete(L"robocopy_source", TRUE); + + check_file_and_delete(L"robocopy_destination\fileA.a", TRUE); + check_file_and_delete(L"robocopy_destination\fileB.b", TRUE); + check_file_and_delete(L"robocopy_destination\folderA\fileC.c", TRUE); + check_file_and_delete(L"robocopy_destination\folderA\fileD.d", FALSE); + check_file_and_delete(L"robocopy_destination\folderA\folderD\fileE.e", FALSE); + check_file_and_delete(L"robocopy_destination\folderB\fileF.f", FALSE); + check_file_and_delete(L"robocopy_destination\folderB\fileG.g", FALSE); + check_folder_and_delete(L"robocopy_destination\folderA\folderD", FALSE); + check_folder_and_delete(L"robocopy_destination\folderA\folderE", FALSE); + check_folder_and_delete(L"robocopy_destination\folderA", TRUE); + check_folder_and_delete(L"robocopy_destination\folderB", TRUE); + check_folder_and_delete(L"robocopy_destination\folderC", TRUE); + check_file_and_delete(L"robocopy_destination\extraFile", TRUE); + check_folder_and_delete(L"robocopy_destination", TRUE); +} + +static void check_long_filename_test(void) +{ + check_file_and_delete(L"robocopy_source\fileA.a", TRUE); + check_file_and_delete(L"robocopy_source\fileB.b", TRUE); + check_file_and_delete(L"robocopy_source\folderA\fileC.c", TRUE); + check_file_and_delete(L"robocopy_source\folderA\fileD.d", TRUE); + check_file_and_delete(L"robocopy_source\folderA\folderD\fileE.e", TRUE); + check_file_and_delete(L"robocopy_source\folderB\fileF.f", TRUE); + check_file_and_delete(L"robocopy_source\folderB\fileG.g", TRUE); + check_folder_and_delete(L"robocopy_source\folderA\folderD", TRUE); + check_folder_and_delete(L"robocopy_source\folderA\folderE", TRUE); + check_folder_and_delete(L"robocopy_source\folderA", TRUE); + check_folder_and_delete(L"robocopy_source\folderB", TRUE); + check_folder_and_delete(L"robocopy_source\folderC", TRUE); + check_folder_and_delete(L"robocopy_source", TRUE); + + check_file_and_delete(L"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\ +cccccccccccccccccccccccccccccccccccccccc\dddddddddddddddddddddddddddddddddddddddd\eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\\ +ffffffffffffffffffffffffffffffffffffffff\gggggggggggggggggggggggggggggggggggggggg\robocopy_destination\fileA.a", TRUE); + check_file_and_delete(L"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\ +cccccccccccccccccccccccccccccccccccccccc\dddddddddddddddddddddddddddddddddddddddd\eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\\ +ffffffffffffffffffffffffffffffffffffffff\gggggggggggggggggggggggggggggggggggggggg\robocopy_destination\fileB.b", TRUE); + check_file_and_delete(L"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\ +cccccccccccccccccccccccccccccccccccccccc\dddddddddddddddddddddddddddddddddddddddd\eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\\ +ffffffffffffffffffffffffffffffffffffffff\gggggggggggggggggggggggggggggggggggggggg\robocopy_destination\folderA\fileC.c", FALSE); + check_file_and_delete(L"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\ +cccccccccccccccccccccccccccccccccccccccc\dddddddddddddddddddddddddddddddddddddddd\eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\\ +ffffffffffffffffffffffffffffffffffffffff\gggggggggggggggggggggggggggggggggggggggg\robocopy_destination\folderA\fileD.d", FALSE); + check_file_and_delete(L"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\ +cccccccccccccccccccccccccccccccccccccccc\dddddddddddddddddddddddddddddddddddddddd\eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\\ +ffffffffffffffffffffffffffffffffffffffff\gggggggggggggggggggggggggggggggggggggggg\robocopy_destination\folderA\folderD\fileE.e", FALSE); + check_file_and_delete(L"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\ +cccccccccccccccccccccccccccccccccccccccc\dddddddddddddddddddddddddddddddddddddddd\eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\\ +ffffffffffffffffffffffffffffffffffffffff\gggggggggggggggggggggggggggggggggggggggg\robocopy_destination\folderB\fileF.f", FALSE); + check_file_and_delete(L"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\ +cccccccccccccccccccccccccccccccccccccccc\dddddddddddddddddddddddddddddddddddddddd\eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\\ +ffffffffffffffffffffffffffffffffffffffff\gggggggggggggggggggggggggggggggggggggggg\robocopy_destination\folderB\fileG.g", FALSE); + check_folder_and_delete(L"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\ +cccccccccccccccccccccccccccccccccccccccc\dddddddddddddddddddddddddddddddddddddddd\eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\\ +ffffffffffffffffffffffffffffffffffffffff\gggggggggggggggggggggggggggggggggggggggg\robocopy_destination\folderA\folderD", FALSE); + check_folder_and_delete(L"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\ +cccccccccccccccccccccccccccccccccccccccc\dddddddddddddddddddddddddddddddddddddddd\eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\\ +ffffffffffffffffffffffffffffffffffffffff\gggggggggggggggggggggggggggggggggggggggg\robocopy_destination\folderA\folderE", FALSE); + check_folder_and_delete(L"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\ +cccccccccccccccccccccccccccccccccccccccc\dddddddddddddddddddddddddddddddddddddddd\eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\\ +ffffffffffffffffffffffffffffffffffffffff\gggggggggggggggggggggggggggggggggggggggg\robocopy_destination\folderA", FALSE); + check_folder_and_delete(L"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\ +cccccccccccccccccccccccccccccccccccccccc\dddddddddddddddddddddddddddddddddddddddd\eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\\ +ffffffffffffffffffffffffffffffffffffffff\gggggggggggggggggggggggggggggggggggggggg\robocopy_destination\folderB", FALSE); + check_folder_and_delete(L"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\ +cccccccccccccccccccccccccccccccccccccccc\dddddddddddddddddddddddddddddddddddddddd\eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\\ +ffffffffffffffffffffffffffffffffffffffff\gggggggggggggggggggggggggggggggggggggggg\robocopy_destination\folderC", FALSE); + check_folder_and_delete(L"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\ +cccccccccccccccccccccccccccccccccccccccc\dddddddddddddddddddddddddddddddddddddddd\eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\\ +ffffffffffffffffffffffffffffffffffffffff\gggggggggggggggggggggggggggggggggggggggg\robocopy_destination", TRUE); + check_folder_and_delete(L"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\ +cccccccccccccccccccccccccccccccccccccccc\dddddddddddddddddddddddddddddddddddddddd\eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\\ +ffffffffffffffffffffffffffffffffffffffff\gggggggggggggggggggggggggggggggggggggggg", TRUE); + check_folder_and_delete(L"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\ +cccccccccccccccccccccccccccccccccccccccc\dddddddddddddddddddddddddddddddddddddddd\eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\\ +ffffffffffffffffffffffffffffffffffffffff", TRUE); + check_folder_and_delete(L"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\ +cccccccccccccccccccccccccccccccccccccccc\dddddddddddddddddddddddddddddddddddddddd\eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", TRUE); + check_folder_and_delete(L"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\ +cccccccccccccccccccccccccccccccccccccccc\dddddddddddddddddddddddddddddddddddddddd", TRUE); + check_folder_and_delete(L"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\ +cccccccccccccccccccccccccccccccccccccccc", TRUE); + check_folder_and_delete(L"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", TRUE); + check_folder_and_delete(L"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", TRUE); +} + START_TEST(robocopy) { WCHAR temp_command_line[2048], previous_cwd_path[4096], temp_path[4096]; @@ -1363,6 +1528,37 @@ START_TEST(robocopy) check_xl_2_test(); winetest_pop_context();
+ winetest_push_context("mixed flags test 1"); + create_test_source_folder(); + execute_robocopy(L"robocopy.exe robocopy_source robocopy_destination /min:100 /max:5000 file?.? /xd folderA /mov /s /e /r:1 /w:0", 1); + check_mixed_1_test(); + winetest_pop_context(); + + winetest_push_context("mixed flags test 2"); + create_test_source_folder(); + execute_robocopy(L"robocopy.exe robocopy_source robocopy_destination /purge /move /s /xd *d /xf *.c /e /r:1 /w:0", 1); + check_mixed_2_test(); + winetest_pop_context(); + + winetest_push_context("mixed flags test 3"); + create_test_source_folder(); + create_test_folder(L"robocopy_destination"); + create_test_file(L"robocopy_destination\extraFile", 9000, 0, -1); + create_test_file(L"robocopy_destination\fileA.a", 9000, 0, -20); + create_test_file(L"robocopy_destination\fileB.b", 10, 0, -20); + execute_robocopy(L"robocopy.exe robocopy_source robocopy_destination /minage:2 /maxage:20210102 /xc /mir /xx /lev:2 /r:1 /w:0", 3); + check_mixed_3_test(); + winetest_pop_context(); + + winetest_push_context("long filenames test"); + create_test_source_folder(); + execute_robocopy(L"robocopy.exe robocopy_source \ +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\cccccccccccccccccccccccccccccccccccccccc\\ +dddddddddddddddddddddddddddddddddddddddd\eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\ffffffffffffffffffffffffffffffffffffffff\\ +gggggggggggggggggggggggggggggggggggggggg\robocopy_destination /r:1 /w:0", 1); + check_long_filename_test(); + winetest_pop_context(); + /* Reset CWD to previous folder */ ok(SetCurrentDirectoryW(previous_cwd_path), "couldn't set CWD to previous CWD folder "%S"", previous_cwd_path); } \ No newline at end of file