[PATCH 02/41] robocopy/tests: add stub
Florian Eder
others.meder at gmail.com
Mon Sep 6 09:54:39 CDT 2021
Basic files and required changes to configure(.ac) to create a scaffolding
for the conformance tests for the robocopy utility
Signed-off-by: Florian Eder <others.meder at gmail.com>
---
configure | 1 +
configure.ac | 1 +
programs/robocopy/tests/Makefile.in | 5 ++
programs/robocopy/tests/robocopy.c | 80 +++++++++++++++++++++++++++++
4 files changed, 87 insertions(+)
create mode 100644 programs/robocopy/tests/Makefile.in
create mode 100644 programs/robocopy/tests/robocopy.c
diff --git a/configure b/configure
index 9e2fa9ef009..297b1783575 100755
--- a/configure
+++ b/configure
@@ -21265,6 +21265,7 @@ wine_fn_config_makefile programs/regini enable_regini
wine_fn_config_makefile programs/regsvcs enable_regsvcs
wine_fn_config_makefile programs/regsvr32 enable_regsvr32
wine_fn_config_makefile programs/robocopy enable_robocopy
+wine_fn_config_makefile programs/robocopy/tests enable_tests
wine_fn_config_makefile programs/rpcss enable_rpcss
wine_fn_config_makefile programs/rundll.exe16 enable_win16
wine_fn_config_makefile programs/rundll32 enable_rundll32
diff --git a/configure.ac b/configure.ac
index 88b9426260f..c8aa29b6628 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3964,6 +3964,7 @@ WINE_CONFIG_MAKEFILE(programs/regini)
WINE_CONFIG_MAKEFILE(programs/regsvcs)
WINE_CONFIG_MAKEFILE(programs/regsvr32)
WINE_CONFIG_MAKEFILE(programs/robocopy)
+WINE_CONFIG_MAKEFILE(programs/robocopy/tests)
WINE_CONFIG_MAKEFILE(programs/rpcss)
WINE_CONFIG_MAKEFILE(programs/rundll.exe16,enable_win16)
WINE_CONFIG_MAKEFILE(programs/rundll32)
diff --git a/programs/robocopy/tests/Makefile.in b/programs/robocopy/tests/Makefile.in
new file mode 100644
index 00000000000..146246e4b1a
--- /dev/null
+++ b/programs/robocopy/tests/Makefile.in
@@ -0,0 +1,5 @@
+TESTDLL = robocopy.exe
+IMPORTS = user32
+
+C_SRCS = \
+ robocopy.c
diff --git a/programs/robocopy/tests/robocopy.c b/programs/robocopy/tests/robocopy.c
new file mode 100644
index 00000000000..ca3d8d7da42
--- /dev/null
+++ b/programs/robocopy/tests/robocopy.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2021 Florian Eder
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <wine/test.h>
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <wchar.h>
+
+static DWORD execute_robocopy(const WCHAR *command_line, DWORD expected_exit_code)
+{
+ STARTUPINFOW startup_information;
+ PROCESS_INFORMATION process_information;
+ DWORD return_value;
+ DWORD process_exit_code;
+ WCHAR command_line_copy[2048];
+
+ memset(&startup_information, 0, sizeof(STARTUPINFOW));
+ startup_information.dwFlags = STARTF_USESTDHANDLES;
+
+ /* CreateProcess must not be called with static strings */
+ wcscpy(command_line_copy, command_line);
+
+ if (!CreateProcessW(NULL, command_line_copy, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &startup_information, &process_information))
+ {
+ ok(expected_exit_code == -1, "process execution of \"%S\" failed with error %d\n", command_line_copy, GetLastError());
+ return -1;
+ }
+
+ return_value = WaitForSingleObject(process_information.hProcess, 30000);
+ if (return_value == WAIT_TIMEOUT)
+ {
+ TerminateProcess(process_information.hProcess, 1);
+ ok(FALSE, "process (executing \"%S\") timed out\n", command_line_copy);
+ return -1;
+ }
+
+ GetExitCodeProcess(process_information.hProcess, &process_exit_code);
+
+ CloseHandle(process_information.hThread);
+ CloseHandle(process_information.hProcess);
+
+ /* also accept any exit code if expected exit code is -1 */
+ ok((expected_exit_code == process_exit_code) || (expected_exit_code == -1),
+ "process exit code was %d, but expected %d\n", process_exit_code, expected_exit_code);
+ return process_exit_code;
+}
+
+START_TEST(robocopy)
+{
+ WCHAR previous_cwd_path[4096], temp_path[4096];
+
+ ok(GetFullPathNameW(L".", ARRAY_SIZE(previous_cwd_path), previous_cwd_path, NULL) != 0, "couldn't get CWD path");
+ ok(GetTempPathW(ARRAY_SIZE(temp_path), temp_path) != 0, "couldn't get temp folder path");
+
+ /* robocopy is only available from Vista onwards, abort test if not available */
+ if (execute_robocopy(L"robocopy.exe", -1) == -1) return;
+
+ /* set CWD to temp folder */
+ ok(SetCurrentDirectoryW(temp_path), "couldn't set CWD to temp folder \"%S\"", temp_path);
+
+ /* TODO: conformance tests here */
+
+ /* 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
More information about the wine-devel
mailing list