[PATCH v3 2/6] robocopy/tests: Add stub

Florian Eder others.meder at gmail.com
Fri Sep 17 02:34:13 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>
---
v3: Identical to patch sent in v2
---
 configure                           |  1 +
 configure.ac                        |  1 +
 programs/robocopy/tests/Makefile.in |  4 ++
 programs/robocopy/tests/robocopy.c  | 66 +++++++++++++++++++++++++++++
 4 files changed, 72 insertions(+)
 create mode 100644 programs/robocopy/tests/Makefile.in
 create mode 100644 programs/robocopy/tests/robocopy.c

diff --git a/configure b/configure
index a5767af3c60..d63321522f4 100755
--- a/configure
+++ b/configure
@@ -21235,6 +21235,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 97c46565db3..6d89ceea089 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3959,6 +3959,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..d86e70f4c43
--- /dev/null
+++ b/programs/robocopy/tests/Makefile.in
@@ -0,0 +1,4 @@
+TESTDLL   = robocopy.exe
+
+C_SRCS = \
+	robocopy.c
diff --git a/programs/robocopy/tests/robocopy.c b/programs/robocopy/tests/robocopy.c
new file mode 100644
index 00000000000..02798663ba5
--- /dev/null
+++ b/programs/robocopy/tests/robocopy.c
@@ -0,0 +1,66 @@
+/*
+ * 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 *cmd_line)
+{
+    STARTUPINFOW startup_info;
+    PROCESS_INFORMATION process_info;
+    DWORD exit_code;
+    WCHAR cmd_line_copy[2048];
+
+    memset(&startup_info, 0, sizeof(STARTUPINFOW));
+    startup_info.dwFlags = STARTF_USESTDHANDLES;
+
+    /* CreateProcess must not be called with static strings */
+    wcscpy(cmd_line_copy, cmd_line);
+
+    if (!CreateProcessW(NULL, cmd_line_copy, NULL, NULL, TRUE, 0, NULL, NULL, &startup_info, &process_info))
+        return -1;
+
+    if (WaitForSingleObject(process_info.hProcess, 30000) == WAIT_TIMEOUT)
+        return -1;
+
+    GetExitCodeProcess(process_info.hProcess, &exit_code);
+
+    CloseHandle(process_info.hThread);
+    CloseHandle(process_info.hProcess);
+
+    return 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) return;
+
+    ok(SetCurrentDirectoryW(temp_path), "couldn't set CWD to temp folder \"%S\"", temp_path);
+
+    /* TODO: conformance tests here */
+
+    ok(SetCurrentDirectoryW(previous_cwd_path), "couldn't set CWD to previous CWD folder \"%S\"", previous_cwd_path);
+}
-- 
2.32.0




More information about the wine-devel mailing list