Andrew Eikum : winmm/tests: Test mmioOpen with long file name.

Alexandre Julliard julliard at winehq.org
Mon Apr 6 15:53:23 CDT 2020


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

Author: Andrew Eikum <aeikum at codeweavers.com>
Date:   Mon Apr  6 13:24:04 2020 -0500

winmm/tests: Test mmioOpen with long file name.

Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winmm/tests/mmio.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/dlls/winmm/tests/mmio.c b/dlls/winmm/tests/mmio.c
index 5501c319c5..e3984fbaf3 100644
--- a/dlls/winmm/tests/mmio.c
+++ b/dlls/winmm/tests/mmio.c
@@ -471,6 +471,58 @@ static void test_mmioOpen(char *fname)
     mmioClose(hmmio, 0);
 }
 
+static void test_mmioOpen_create(void)
+{
+    HMMIO hmmio;
+    HANDLE handle;
+    WCHAR cwd[MAX_PATH], temp_dir[MAX_PATH];
+    /* According to docs, filename must be no more than 128 bytes, but it will
+     * actually allow longer than that. */
+    WCHAR filename[] = L"very_long_filename_"
+        L"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+        L"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+        L"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
+
+    GetCurrentDirectoryW(ARRAY_SIZE(cwd), cwd);
+    GetTempPathW(ARRAY_SIZE(temp_dir), temp_dir);
+    SetCurrentDirectoryW(temp_dir);
+
+    DeleteFileW(filename);
+
+    /* open with MMIO_DENYNONE */
+    hmmio = mmioOpenW(filename, NULL, MMIO_CREATE | MMIO_WRITE | MMIO_DENYNONE);
+    ok(hmmio != NULL, "mmioOpen failed\n");
+
+    /* MMIO_DENYNONE lets us open it here, too */
+    handle = CreateFileW(filename, GENERIC_READ,
+            FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE, NULL,
+            OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+    ok(handle != INVALID_HANDLE_VALUE, "Couldn't open non-exclusive file\n");
+    CloseHandle(handle);
+
+    mmioClose(hmmio, 0);
+
+    DeleteFileW(filename);
+
+    /* open with MMIO_EXCLUSIVE */
+    hmmio = mmioOpenW(filename, NULL, MMIO_CREATE | MMIO_WRITE | MMIO_EXCLUSIVE);
+    ok(hmmio != NULL, "mmioOpen failed\n");
+
+    /* should fail due to MMIO_EXCLUSIVE */
+    handle = CreateFileW(filename, GENERIC_READ,
+            FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE, NULL,
+            OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+    ok(handle == INVALID_HANDLE_VALUE, "Opening exclusive file should have failed\n");
+    if(handle != INVALID_HANDLE_VALUE)
+        CloseHandle(handle);
+
+    mmioClose(hmmio, 0);
+
+    DeleteFileW(filename);
+
+    SetCurrentDirectoryW(cwd);
+}
+
 static void test_mmioSetBuffer(char *fname)
 {
     char buf[256];
@@ -1016,6 +1068,7 @@ START_TEST(mmio)
     test_mmioDescend(fname);
     test_mmioOpen(NULL);
     test_mmioOpen(fname);
+    test_mmioOpen_create();
     test_mmioSetBuffer(NULL);
     test_mmioSetBuffer(fname);
     test_mmioOpen_fourcc();




More information about the wine-cvs mailing list