kernel32/tests: Add more tests for DefineDosDevice().
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
1f2a7da28a
commit
4ab43e28d0
|
@ -24,6 +24,7 @@
|
||||||
#include "ntddstor.h"
|
#include "ntddstor.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "ddk/ntddcdvd.h"
|
#include "ddk/ntddcdvd.h"
|
||||||
|
#include "ddk/mountmgr.h"
|
||||||
|
|
||||||
#include <pshpack1.h>
|
#include <pshpack1.h>
|
||||||
struct COMPLETE_DVD_LAYER_DESCRIPTOR
|
struct COMPLETE_DVD_LAYER_DESCRIPTOR
|
||||||
|
@ -105,11 +106,12 @@ static void test_query_dos_deviceA(void)
|
||||||
HeapFree( GetProcessHeap(), 0, buffer );
|
HeapFree( GetProcessHeap(), 0, buffer );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_define_dos_deviceA(void)
|
static void test_dos_devices(void)
|
||||||
{
|
{
|
||||||
|
char buf[MAX_PATH], buf2[400];
|
||||||
char drivestr[3];
|
char drivestr[3];
|
||||||
char buf[MAX_PATH];
|
HANDLE file;
|
||||||
DWORD ret;
|
BOOL ret;
|
||||||
|
|
||||||
/* Find an unused drive letter */
|
/* Find an unused drive letter */
|
||||||
drivestr[1] = ':';
|
drivestr[1] = ':';
|
||||||
|
@ -123,20 +125,65 @@ static void test_define_dos_deviceA(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Map it to point to the current directory */
|
ret = DefineDosDeviceA( 0, drivestr, "C:/windows/" );
|
||||||
ret = GetCurrentDirectoryA(sizeof(buf), buf);
|
todo_wine ok(ret, "failed to define drive %s, error %u\n", drivestr, GetLastError());
|
||||||
ok(ret, "GetCurrentDir\n");
|
|
||||||
|
|
||||||
ret = DefineDosDeviceA(0, drivestr, buf);
|
ret = QueryDosDeviceA( drivestr, buf, sizeof(buf) );
|
||||||
todo_wine
|
todo_wine ok(ret, "failed to query drive %s, error %u\n", drivestr, GetLastError());
|
||||||
ok(ret, "Could not make drive %s point to %s!\n", drivestr, buf);
|
todo_wine ok(!strcmp(buf, "\\??\\C:\\windows\\"), "got path %s\n", debugstr_a(buf));
|
||||||
|
|
||||||
if (!ret) {
|
sprintf(buf, "%s/system32", drivestr);
|
||||||
skip("can't test removing fake drive\n");
|
file = CreateFileA( buf, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
|
||||||
} else {
|
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL );
|
||||||
ret = DefineDosDeviceA(DDD_REMOVE_DEFINITION, drivestr, NULL);
|
todo_wine ok(file != INVALID_HANDLE_VALUE, "got error %u\n", GetLastError());
|
||||||
ok(ret, "Could not remove fake drive %s!\n", drivestr);
|
CloseHandle( file );
|
||||||
}
|
|
||||||
|
/* but it's not a volume mount point */
|
||||||
|
|
||||||
|
sprintf(buf, "%s\\", drivestr);
|
||||||
|
ret = GetVolumeNameForVolumeMountPointA( buf, buf2, sizeof(buf2) );
|
||||||
|
ok(!ret, "expected failure\n");
|
||||||
|
todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %u\n", GetLastError());
|
||||||
|
|
||||||
|
ret = DefineDosDeviceA(DDD_REMOVE_DEFINITION, drivestr, NULL);
|
||||||
|
todo_wine ok(ret, "failed to remove drive %s, error %u\n", drivestr, GetLastError());
|
||||||
|
|
||||||
|
ret = QueryDosDeviceA( drivestr, buf, sizeof(buf) );
|
||||||
|
ok(!ret, "expected failure\n");
|
||||||
|
ok(GetLastError() == ERROR_FILE_NOT_FOUND, "got error %u\n", GetLastError());
|
||||||
|
|
||||||
|
sprintf(buf, "%s/system32", drivestr);
|
||||||
|
file = CreateFileA( buf, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
|
||||||
|
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL );
|
||||||
|
ok(file == INVALID_HANDLE_VALUE, "expected failure\n");
|
||||||
|
todo_wine ok(GetLastError() == ERROR_PATH_NOT_FOUND, "got error %u\n", GetLastError());
|
||||||
|
|
||||||
|
/* try with DDD_RAW_TARGET_PATH */
|
||||||
|
|
||||||
|
ret = DefineDosDeviceA( DDD_RAW_TARGET_PATH, drivestr, "\\??\\C:\\windows\\" );
|
||||||
|
ok(ret, "failed to define drive %s, error %u\n", drivestr, GetLastError());
|
||||||
|
|
||||||
|
ret = QueryDosDeviceA( drivestr, buf, sizeof(buf) );
|
||||||
|
todo_wine ok(ret, "failed to query drive %s, error %u\n", drivestr, GetLastError());
|
||||||
|
todo_wine ok(!strcmp(buf, "\\??\\C:\\windows\\"), "got path %s\n", debugstr_a(buf));
|
||||||
|
|
||||||
|
sprintf(buf, "%s/system32", drivestr);
|
||||||
|
file = CreateFileA( buf, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
|
||||||
|
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL );
|
||||||
|
todo_wine ok(file != INVALID_HANDLE_VALUE, "got error %u\n", GetLastError());
|
||||||
|
CloseHandle( file );
|
||||||
|
|
||||||
|
sprintf(buf, "%s\\", drivestr);
|
||||||
|
ret = GetVolumeNameForVolumeMountPointA( buf, buf2, sizeof(buf2) );
|
||||||
|
ok(!ret, "expected failure\n");
|
||||||
|
todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %u\n", GetLastError());
|
||||||
|
|
||||||
|
ret = DefineDosDeviceA(DDD_REMOVE_DEFINITION, drivestr, NULL);
|
||||||
|
ok(ret, "failed to remove drive %s, error %u\n", drivestr, GetLastError());
|
||||||
|
|
||||||
|
ret = QueryDosDeviceA( drivestr, buf, sizeof(buf) );
|
||||||
|
ok(!ret, "expected failure\n");
|
||||||
|
ok(GetLastError() == ERROR_FILE_NOT_FOUND, "got error %u\n", GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_FindFirstVolume(void)
|
static void test_FindFirstVolume(void)
|
||||||
|
@ -1272,7 +1319,7 @@ START_TEST(volume)
|
||||||
pGetVolumePathNamesForVolumeNameW = (void *) GetProcAddress(hdll, "GetVolumePathNamesForVolumeNameW");
|
pGetVolumePathNamesForVolumeNameW = (void *) GetProcAddress(hdll, "GetVolumePathNamesForVolumeNameW");
|
||||||
|
|
||||||
test_query_dos_deviceA();
|
test_query_dos_deviceA();
|
||||||
test_define_dos_deviceA();
|
test_dos_devices();
|
||||||
test_FindFirstVolume();
|
test_FindFirstVolume();
|
||||||
test_GetVolumePathNameA();
|
test_GetVolumePathNameA();
|
||||||
test_GetVolumePathNameW();
|
test_GetVolumePathNameW();
|
||||||
|
|
Loading…
Reference in New Issue