From: Florian Eder Subject: [PATCH 29/41] robocopy/tests: add conformance tests for /MIN, /MAX Message-Id: <20210906145518.346132-29-others.meder@gmail.com> Date: Mon, 6 Sep 2021 14:55:06 +0000 In-Reply-To: <20210906145518.346132-1-others.meder@gmail.com> References: <20210906145518.346132-1-others.meder@gmail.com> Signed-off-by: Florian Eder --- programs/robocopy/tests/robocopy.c | 160 +++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) diff --git a/programs/robocopy/tests/robocopy.c b/programs/robocopy/tests/robocopy.c index 0f6e07b3d71..38279b643c1 100644 --- a/programs/robocopy/tests/robocopy.c +++ b/programs/robocopy/tests/robocopy.c @@ -548,6 +548,130 @@ static void check_dry_test(void) check_folder_and_delete(L"robocopy_destination", FALSE); } +static void check_max_1_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", FALSE); + 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", FALSE); + check_folder_and_delete(L"robocopy_destination\\folderA\\folderD", TRUE); + 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_max_2_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", FALSE); + check_file_and_delete(L"robocopy_destination\\fileB.b", FALSE); + check_file_and_delete(L"robocopy_destination\\folderA\\fileC.c", TRUE); + 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", FALSE); + check_file_and_delete(L"robocopy_destination\\folderB\\fileG.g", TRUE); + check_folder_and_delete(L"robocopy_destination\\folderA\\folderD", TRUE); + 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_min_1_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", FALSE); + 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", TRUE); + check_file_and_delete(L"robocopy_destination\\folderB\\fileF.f", TRUE); + check_file_and_delete(L"robocopy_destination\\folderB\\fileG.g", FALSE); + check_folder_and_delete(L"robocopy_destination\\folderA\\folderD", TRUE); + 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_min_2_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", FALSE); + check_file_and_delete(L"robocopy_destination\\folderA\\fileD.d", FALSE); + check_file_and_delete(L"robocopy_destination\\folderA\\folderD\\fileE.e", TRUE); + check_file_and_delete(L"robocopy_destination\\folderB\\fileF.f", TRUE); + check_file_and_delete(L"robocopy_destination\\folderB\\fileG.g", FALSE); + check_folder_and_delete(L"robocopy_destination\\folderA\\folderD", TRUE); + 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); +} + START_TEST(robocopy) { WCHAR temp_command_line[2048], previous_cwd_path[4096], temp_path[4096]; @@ -722,6 +846,42 @@ START_TEST(robocopy) check_dry_test(); winetest_pop_context(); + winetest_push_context("MAX test 1"); + create_test_source_folder(); + execute_robocopy(L"robocopy.exe robocopy_source robocopy_destination /max:50 /s /e /r:1 /w:0", 0); + check_max_1_test(); + winetest_pop_context(); + + winetest_push_context("MAX test 2"); + create_test_source_folder(); + execute_robocopy(L"robocopy.exe robocopy_source robocopy_destination /max:1000 /s /e /r:1 /w:0", 1); + check_max_2_test(); + winetest_pop_context(); + + winetest_push_context("MAX test 3"); + create_test_source_folder(); + execute_robocopy(L"robocopy.exe robocopy_source robocopy_destination /max:5000000 /s /e /r:1 /w:0", 1); + check_mir_test(); + winetest_pop_context(); + + winetest_push_context("MIN test 1"); + create_test_source_folder(); + execute_robocopy(L"robocopy.exe robocopy_source robocopy_destination /min:10000 /s /e /r:1 /w:0", 1); + check_min_1_test(); + winetest_pop_context(); + + winetest_push_context("MIN test 2"); + create_test_source_folder(); + execute_robocopy(L"robocopy.exe robocopy_source robocopy_destination /min:500 /s /e /r:1 /w:0", 1); + check_min_2_test(); + winetest_pop_context(); + + winetest_push_context("MIN test 3"); + create_test_source_folder(); + execute_robocopy(L"robocopy.exe robocopy_source robocopy_destination /min:10 /s /e /r:1 /w:0", 1); + check_mir_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 -- 2.32.0