Commit daaae48e authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

advapi32/tests: Fix the backup tests when run in a non-administrator pre-Vista account.

parent 237d7891
......@@ -49,17 +49,27 @@ static void init_function_pointers(void)
pWow64RevertWow64FsRedirection = (void*)GetProcAddress(hkernel32, "Wow64RevertWow64FsRedirection");
}
static void create_backup(const char *filename)
static BOOL create_backup(const char *filename)
{
HANDLE handle;
DWORD rc, attribs;
DeleteFileA(filename);
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);
attribs = GetFileAttributesA(filename);
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)
......@@ -209,11 +219,11 @@ static void test_count(void)
CloseEventLog(handle);
/* 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");
ok(handle != NULL, "Expected a handle, le=%d\n", GetLastError());
/* Does GetNumberOfEventLogRecords work with backup eventlogs? */
count = 0xdeadbeef;
......@@ -226,6 +236,7 @@ static void test_count(void)
CloseEventLog(handle);
DeleteFileA(backup);
}
}
static void test_oldest(void)
......@@ -262,8 +273,8 @@ static void test_oldest(void)
CloseEventLog(handle);
/* 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");
......@@ -279,6 +290,7 @@ static void test_oldest(void)
CloseEventLog(handle);
DeleteFileA(backup);
}
}
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());
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");
todo_wine
ok(GetFileAttributesA(backup) != INVALID_FILE_ATTRIBUTES, "Expected a backup file\n");
......@@ -516,8 +534,8 @@ static void test_openbackup(void)
"Expected RPC_S_SERVER_UNAVAILABLE, got %d\n", GetLastError());
/* Make a backup eventlog to work with */
create_backup(backup);
if (create_backup(backup))
{
/* FIXME: Wine stops here */
if (GetFileAttributesA(backup) == INVALID_FILE_ATTRIBUTES)
{
......@@ -548,6 +566,7 @@ static void test_openbackup(void)
CloseEventLog(handle);
DeleteFileA(backup);
}
/* Is there any content checking done? */
file = CreateFileA(backup, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
......@@ -585,7 +604,8 @@ static void test_clear(void)
ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
/* Make a backup eventlog to work with */
create_backup(backup);
if (!create_backup(backup))
return;
SetLastError(0xdeadbeef);
ret = ClearEventLogA(NULL, backup);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment