Hugh McMaster : reg/tests: Add tests for importing Windows 3.1 registry data.

Alexandre Julliard julliard at winehq.org
Tue Aug 8 07:36:37 CDT 2017


Module: wine
Branch: master
Commit: f95f3fb1bf6abb4e6f2767f557bedd2377edb4d0
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f95f3fb1bf6abb4e6f2767f557bedd2377edb4d0

Author: Hugh McMaster <hugh.mcmaster at outlook.com>
Date:   Mon Aug  7 12:28:35 2017 +0000

reg/tests: Add tests for importing Windows 3.1 registry data.

Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 programs/reg/tests/reg.c | 118 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 118 insertions(+)

diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
index 941d325..a2728ca 100644
--- a/programs/reg/tests/reg.c
+++ b/programs/reg/tests/reg.c
@@ -4053,6 +4053,123 @@ static void test_unicode_import_with_whitespace(void)
     todo_wine ok(err == ERROR_SUCCESS, "RegDeleteKeyA failed: got %d, expected 0\n", err);
 }
 
+static void test_import_31(void)
+{
+    LONG err;
+    HKEY hkey;
+    DWORD r;
+
+    err = RegDeleteKeyA(HKEY_CLASSES_ROOT, KEY_BASE);
+    ok(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND, "RegDeleteKeyA failed: %d\n", err);
+
+    /* Check if reg.exe is running with elevated privileges */
+    err = RegCreateKeyExA(HKEY_CLASSES_ROOT, KEY_BASE, 0, NULL, REG_OPTION_NON_VOLATILE,
+                          KEY_READ|KEY_SET_VALUE, NULL, &hkey, NULL);
+    if (err == ERROR_ACCESS_DENIED)
+    {
+        win_skip("reg.exe is not running with elevated privileges; "
+                 "skipping Windows 3.1 import tests\n");
+        return;
+    }
+
+    /* Test simple value */
+    test_import_str("REGEDIT\r\n"
+		    "HKEY_CLASSES_ROOT\\" KEY_BASE " = Value0\r\n", &r);
+    todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+    todo_wine verify_reg(hkey, "", REG_SZ, "Value0", 7, 0);
+
+    /* Test proper handling of spaces and equals signs */
+    test_import_str("REGEDIT\r\n"
+                    "HKEY_CLASSES_ROOT\\" KEY_BASE " =Value1\r\n", &r);
+    todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+    todo_wine verify_reg(hkey, "", REG_SZ, "Value1", 7, 0);
+
+    test_import_str("REGEDIT\r\n"
+                    "HKEY_CLASSES_ROOT\\" KEY_BASE " =  Value2\r\n", &r);
+    todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+    todo_wine verify_reg(hkey, "", REG_SZ, " Value2", 8, 0);
+
+    test_import_str("REGEDIT\r\n"
+                    "HKEY_CLASSES_ROOT\\" KEY_BASE " = Value3 \r\n", &r);
+    todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+    todo_wine verify_reg(hkey, "", REG_SZ, "Value3 ", 8, 0);
+
+    test_import_str("REGEDIT\r\n"
+                    "HKEY_CLASSES_ROOT\\" KEY_BASE " Value4\r\n", &r);
+    todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+    todo_wine verify_reg(hkey, "", REG_SZ, "Value4", 7, 0);
+
+    test_import_str("REGEDIT\r\n"
+                    "HKEY_CLASSES_ROOT\\" KEY_BASE "  Value5\r\n", &r);
+    todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+    todo_wine verify_reg(hkey, "", REG_SZ, "Value5", 7, 0);
+
+    test_import_str("REGEDIT\r\n"
+                    "HKEY_CLASSES_ROOT\\" KEY_BASE "\r\n", &r);
+    todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+    todo_wine verify_reg(hkey, "", REG_SZ, "", 1, 0);
+
+    test_import_str("REGEDIT\r\n"
+                    "HKEY_CLASSES_ROOT\\" KEY_BASE "  \r\n", &r);
+    todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+    todo_wine verify_reg(hkey, "", REG_SZ, "", 1, 0);
+
+    test_import_str("REGEDIT\r\n"
+                    "HKEY_CLASSES_ROOT\\" KEY_BASE " = No newline", &r);
+    todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+    todo_wine verify_reg(hkey, "", REG_SZ, "No newline", 11, 0);
+
+    err = RegDeleteValueW(hkey, NULL);
+    todo_wine ok(err == ERROR_SUCCESS, "RegDeleteValue failed: %d\n", err);
+
+    /* Test character validity at the start of the line */
+    test_import_str("REGEDIT\r\n"
+                    " HKEY_CLASSES_ROOT\\" KEY_BASE " = Value1a\r\n", &r);
+    todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+    verify_reg_nonexist(hkey, "");
+
+    test_import_str("REGEDIT\r\n"
+                    "  HKEY_CLASSES_ROOT\\" KEY_BASE " = Value1b\r\n", &r);
+    todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+    verify_reg_nonexist(hkey, "");
+
+    test_import_str("REGEDIT\r\n"
+                    "\tHKEY_CLASSES_ROOT\\" KEY_BASE " = Value1c\r\n", &r);
+    todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+    verify_reg_nonexist(hkey, "");
+
+    test_import_str("REGEDIT\r\n"
+                    ";HKEY_CLASSES_ROOT\\" KEY_BASE " = Value2a\r\n", &r);
+    todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+    verify_reg_nonexist(hkey, "");
+
+    test_import_str("REGEDIT\r\n"
+                    "#HKEY_CLASSES_ROOT\\" KEY_BASE " = Value2b\r\n", &r);
+    todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+    verify_reg_nonexist(hkey, "");
+
+    /* Test case sensitivity */
+    test_import_str("REGEDIT\r\n"
+                    "hkey_classes_root\\" KEY_BASE " = Value3a\r\n", &r);
+    todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+    verify_reg_nonexist(hkey, "");
+
+    test_import_str("REGEDIT\r\n"
+                    "hKEY_CLASSES_ROOT\\" KEY_BASE " = Value3b\r\n", &r);
+    todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+    verify_reg_nonexist(hkey, "");
+
+    test_import_str("REGEDIT\r\n"
+                    "Hkey_Classes_Root\\" KEY_BASE " = Value3c\r\n", &r);
+    todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+    verify_reg_nonexist(hkey, "");
+
+    RegCloseKey(hkey);
+
+    err = RegDeleteKeyA(HKEY_CLASSES_ROOT, KEY_BASE);
+    ok(err == ERROR_SUCCESS, "RegDeleteKeyA failed: %d\n", err);
+}
+
 START_TEST(reg)
 {
     DWORD r;
@@ -4069,4 +4186,5 @@ START_TEST(reg)
     test_unicode_import();
     test_import_with_whitespace();
     test_unicode_import_with_whitespace();
+    test_import_31();
 }




More information about the wine-cvs mailing list