advapi32/tests: Fix the backup tests when run in a non-administrator pre-Vista account.
This commit is contained in:
parent
237d7891ef
commit
daaae48e8f
|
@ -49,17 +49,27 @@ static void init_function_pointers(void)
|
||||||
pWow64RevertWow64FsRedirection = (void*)GetProcAddress(hkernel32, "Wow64RevertWow64FsRedirection");
|
pWow64RevertWow64FsRedirection = (void*)GetProcAddress(hkernel32, "Wow64RevertWow64FsRedirection");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void create_backup(const char *filename)
|
static BOOL create_backup(const char *filename)
|
||||||
{
|
{
|
||||||
HANDLE handle;
|
HANDLE handle;
|
||||||
|
DWORD rc, attribs;
|
||||||
|
|
||||||
DeleteFileA(filename);
|
DeleteFileA(filename);
|
||||||
handle = OpenEventLogA(NULL, "Application");
|
handle = OpenEventLogA(NULL, "Application");
|
||||||
BackupEventLogA(handle, filename);
|
rc = BackupEventLogA(handle, filename);
|
||||||
|
if (!rc && GetLastError() == ERROR_PRIVILEGE_NOT_HELD)
|
||||||
|
{
|
||||||
|
skip("insufficient privileges to backup the eventlog\n");
|
||||||
|
CloseEventLog(handle);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
ok(rc, "BackupEventLogA failed, le=%u\n", GetLastError());
|
||||||
CloseEventLog(handle);
|
CloseEventLog(handle);
|
||||||
|
|
||||||
|
attribs = GetFileAttributesA(filename);
|
||||||
todo_wine
|
todo_wine
|
||||||
ok(GetFileAttributesA(filename) != INVALID_FILE_ATTRIBUTES, "Expected a backup file\n");
|
ok(attribs != INVALID_FILE_ATTRIBUTES, "Expected a backup file attribs=%#x le=%u\n", attribs, GetLastError());
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_open_close(void)
|
static void test_open_close(void)
|
||||||
|
@ -209,23 +219,24 @@ static void test_count(void)
|
||||||
CloseEventLog(handle);
|
CloseEventLog(handle);
|
||||||
|
|
||||||
/* Make a backup eventlog to work with */
|
/* Make a backup eventlog to work with */
|
||||||
create_backup(backup);
|
if (create_backup(backup))
|
||||||
|
|
||||||
handle = OpenBackupEventLogA(NULL, backup);
|
|
||||||
todo_wine
|
|
||||||
ok(handle != NULL, "Expected a handle\n");
|
|
||||||
|
|
||||||
/* Does GetNumberOfEventLogRecords work with backup eventlogs? */
|
|
||||||
count = 0xdeadbeef;
|
|
||||||
ret = GetNumberOfEventLogRecords(handle, &count);
|
|
||||||
todo_wine
|
|
||||||
{
|
{
|
||||||
ok(ret, "Expected success\n");
|
handle = OpenBackupEventLogA(NULL, backup);
|
||||||
ok(count != 0xdeadbeef, "Expected the number of records\n");
|
todo_wine
|
||||||
}
|
ok(handle != NULL, "Expected a handle, le=%d\n", GetLastError());
|
||||||
|
|
||||||
CloseEventLog(handle);
|
/* Does GetNumberOfEventLogRecords work with backup eventlogs? */
|
||||||
DeleteFileA(backup);
|
count = 0xdeadbeef;
|
||||||
|
ret = GetNumberOfEventLogRecords(handle, &count);
|
||||||
|
todo_wine
|
||||||
|
{
|
||||||
|
ok(ret, "Expected success\n");
|
||||||
|
ok(count != 0xdeadbeef, "Expected the number of records\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseEventLog(handle);
|
||||||
|
DeleteFileA(backup);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_oldest(void)
|
static void test_oldest(void)
|
||||||
|
@ -262,23 +273,24 @@ static void test_oldest(void)
|
||||||
CloseEventLog(handle);
|
CloseEventLog(handle);
|
||||||
|
|
||||||
/* Make a backup eventlog to work with */
|
/* Make a backup eventlog to work with */
|
||||||
create_backup(backup);
|
if (create_backup(backup))
|
||||||
|
|
||||||
handle = OpenBackupEventLogA(NULL, backup);
|
|
||||||
todo_wine
|
|
||||||
ok(handle != NULL, "Expected a handle\n");
|
|
||||||
|
|
||||||
/* Does GetOldestEventLogRecord work with backup eventlogs? */
|
|
||||||
oldest = 0xdeadbeef;
|
|
||||||
ret = GetOldestEventLogRecord(handle, &oldest);
|
|
||||||
todo_wine
|
|
||||||
{
|
{
|
||||||
ok(ret, "Expected success\n");
|
handle = OpenBackupEventLogA(NULL, backup);
|
||||||
ok(oldest != 0xdeadbeef, "Expected the number of the oldest record\n");
|
todo_wine
|
||||||
}
|
ok(handle != NULL, "Expected a handle\n");
|
||||||
|
|
||||||
CloseEventLog(handle);
|
/* Does GetOldestEventLogRecord work with backup eventlogs? */
|
||||||
DeleteFileA(backup);
|
oldest = 0xdeadbeef;
|
||||||
|
ret = GetOldestEventLogRecord(handle, &oldest);
|
||||||
|
todo_wine
|
||||||
|
{
|
||||||
|
ok(ret, "Expected success\n");
|
||||||
|
ok(oldest != 0xdeadbeef, "Expected the number of the oldest record\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseEventLog(handle);
|
||||||
|
DeleteFileA(backup);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_backup(void)
|
static void test_backup(void)
|
||||||
|
@ -306,6 +318,12 @@ static void test_backup(void)
|
||||||
ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
||||||
|
|
||||||
ret = BackupEventLogA(handle, backup);
|
ret = BackupEventLogA(handle, backup);
|
||||||
|
if (!ret && GetLastError() == ERROR_PRIVILEGE_NOT_HELD)
|
||||||
|
{
|
||||||
|
skip("insufficient privileges for backup tests\n");
|
||||||
|
CloseEventLog(handle);
|
||||||
|
return;
|
||||||
|
}
|
||||||
ok(ret, "Expected success\n");
|
ok(ret, "Expected success\n");
|
||||||
todo_wine
|
todo_wine
|
||||||
ok(GetFileAttributesA(backup) != INVALID_FILE_ATTRIBUTES, "Expected a backup file\n");
|
ok(GetFileAttributesA(backup) != INVALID_FILE_ATTRIBUTES, "Expected a backup file\n");
|
||||||
|
@ -516,39 +534,40 @@ static void test_openbackup(void)
|
||||||
"Expected RPC_S_SERVER_UNAVAILABLE, got %d\n", GetLastError());
|
"Expected RPC_S_SERVER_UNAVAILABLE, got %d\n", GetLastError());
|
||||||
|
|
||||||
/* Make a backup eventlog to work with */
|
/* Make a backup eventlog to work with */
|
||||||
create_backup(backup);
|
if (create_backup(backup))
|
||||||
|
|
||||||
/* FIXME: Wine stops here */
|
|
||||||
if (GetFileAttributesA(backup) == INVALID_FILE_ATTRIBUTES)
|
|
||||||
{
|
{
|
||||||
skip("We don't have a backup eventlog to work with\n");
|
/* FIXME: Wine stops here */
|
||||||
return;
|
if (GetFileAttributesA(backup) == INVALID_FILE_ATTRIBUTES)
|
||||||
|
{
|
||||||
|
skip("We don't have a backup eventlog to work with\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetLastError(0xdeadbeef);
|
||||||
|
handle = OpenBackupEventLogA("IDontExist", backup);
|
||||||
|
ok(handle == NULL, "Didn't expect a handle\n");
|
||||||
|
ok(GetLastError() == RPC_S_SERVER_UNAVAILABLE ||
|
||||||
|
GetLastError() == RPC_S_INVALID_NET_ADDR, /* Some Vista and Win7 */
|
||||||
|
"Expected RPC_S_SERVER_UNAVAILABLE, got %d\n", GetLastError());
|
||||||
|
|
||||||
|
/* Empty servername should be read as local server */
|
||||||
|
handle = OpenBackupEventLogA("", backup);
|
||||||
|
ok(handle != NULL, "Expected a handle\n");
|
||||||
|
CloseEventLog(handle);
|
||||||
|
|
||||||
|
handle = OpenBackupEventLogA(NULL, backup);
|
||||||
|
ok(handle != NULL, "Expected a handle\n");
|
||||||
|
|
||||||
|
/* Can we open that same backup eventlog more than once? */
|
||||||
|
handle2 = OpenBackupEventLogA(NULL, backup);
|
||||||
|
ok(handle2 != NULL, "Expected a handle\n");
|
||||||
|
ok(handle2 != handle, "Didn't expect the same handle\n");
|
||||||
|
CloseEventLog(handle2);
|
||||||
|
|
||||||
|
CloseEventLog(handle);
|
||||||
|
DeleteFileA(backup);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetLastError(0xdeadbeef);
|
|
||||||
handle = OpenBackupEventLogA("IDontExist", backup);
|
|
||||||
ok(handle == NULL, "Didn't expect a handle\n");
|
|
||||||
ok(GetLastError() == RPC_S_SERVER_UNAVAILABLE ||
|
|
||||||
GetLastError() == RPC_S_INVALID_NET_ADDR, /* Some Vista and Win7 */
|
|
||||||
"Expected RPC_S_SERVER_UNAVAILABLE, got %d\n", GetLastError());
|
|
||||||
|
|
||||||
/* Empty servername should be read as local server */
|
|
||||||
handle = OpenBackupEventLogA("", backup);
|
|
||||||
ok(handle != NULL, "Expected a handle\n");
|
|
||||||
CloseEventLog(handle);
|
|
||||||
|
|
||||||
handle = OpenBackupEventLogA(NULL, backup);
|
|
||||||
ok(handle != NULL, "Expected a handle\n");
|
|
||||||
|
|
||||||
/* Can we open that same backup eventlog more than once? */
|
|
||||||
handle2 = OpenBackupEventLogA(NULL, backup);
|
|
||||||
ok(handle2 != NULL, "Expected a handle\n");
|
|
||||||
ok(handle2 != handle, "Didn't expect the same handle\n");
|
|
||||||
CloseEventLog(handle2);
|
|
||||||
|
|
||||||
CloseEventLog(handle);
|
|
||||||
DeleteFileA(backup);
|
|
||||||
|
|
||||||
/* Is there any content checking done? */
|
/* Is there any content checking done? */
|
||||||
file = CreateFileA(backup, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
|
file = CreateFileA(backup, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
|
||||||
CloseHandle(file);
|
CloseHandle(file);
|
||||||
|
@ -585,7 +604,8 @@ static void test_clear(void)
|
||||||
ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
|
ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
|
||||||
|
|
||||||
/* Make a backup eventlog to work with */
|
/* Make a backup eventlog to work with */
|
||||||
create_backup(backup);
|
if (!create_backup(backup))
|
||||||
|
return;
|
||||||
|
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = ClearEventLogA(NULL, backup);
|
ret = ClearEventLogA(NULL, backup);
|
||||||
|
|
Loading…
Reference in New Issue