[advapi32/tests 3/3] Add some tests for handling a backup file

View: New views
1 Messages — Rating Filter:   Alert me  

[advapi32/tests 3/3] Add some tests for handling a backup file

by Paul Vriens-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Added some tests to show that some functions work with backup eventlogs
(see previous patches) and some don't.

Changelog
   Add some tests for handling a backup file

--
Cheers,

Paul.



>From d06cee69fb3a59dba115778df2c8f38bfb5c3b31 Mon Sep 17 00:00:00 2001
From: Paul Vriens <Paul.Vriens.Wine@...>
Date: Wed, 4 Nov 2009 08:02:09 +0100
Subject: [PATCH 4/4] Add some tests for handling a backup file

---
 dlls/advapi32/tests/eventlog.c |   58 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 57 insertions(+), 1 deletions(-)

diff --git a/dlls/advapi32/tests/eventlog.c b/dlls/advapi32/tests/eventlog.c
index 6bc9a24..3c932ea 100644
--- a/dlls/advapi32/tests/eventlog.c
+++ b/dlls/advapi32/tests/eventlog.c
@@ -164,6 +164,7 @@ static void test_count(void)
     HANDLE handle;
     BOOL ret;
     DWORD count;
+    const char backup[] = "backup.evt";
 
     SetLastError(0xdeadbeef);
     ret = GetNumberOfEventLogRecords(NULL, NULL);
@@ -190,6 +191,25 @@ static void test_count(void)
     ok(count != 0xdeadbeef, "Expected the number of records\n");
 
     CloseEventLog(handle);
+
+    /* Make a backup eventlog to work with */
+    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 succes\n");
+    ok(count != 0xdeadbeef, "Expected the number of records\n");
+    }
+
+    CloseEventLog(handle);
+    DeleteFileA(backup);
 }
 
 static void test_oldest(void)
@@ -197,6 +217,7 @@ static void test_oldest(void)
     HANDLE handle;
     BOOL ret;
     DWORD oldest;
+    const char backup[] = "backup.evt";
 
     SetLastError(0xdeadbeef);
     ret = GetOldestEventLogRecord(NULL, NULL);
@@ -223,6 +244,25 @@ static void test_oldest(void)
     ok(oldest != 0xdeadbeef, "Expected the number of the oldest record\n");
 
     CloseEventLog(handle);
+
+    /* Make a backup eventlog to work with */
+    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 succes\n");
+    ok(oldest != 0xdeadbeef, "Expected the number of the oldest record\n");
+    }
+
+    CloseEventLog(handle);
+    DeleteFileA(backup);
 }
 
 static void test_backup(void)
@@ -230,6 +270,7 @@ static void test_backup(void)
     HANDLE handle;
     BOOL ret;
     const char backup[] = "backup.evt";
+    const char backup2[] = "backup2.evt";
 
     SetLastError(0xdeadbeef);
     ret = BackupEventLogA(NULL, NULL);
@@ -251,7 +292,7 @@ static void test_backup(void)
     ret = BackupEventLogA(handle, backup);
     ok(ret, "Expected succes\n");
     todo_wine
-    ok(GetFileAttributesA("backup.evt") != INVALID_FILE_ATTRIBUTES, "Expected a backup file\n");
+    ok(GetFileAttributesA(backup) != INVALID_FILE_ATTRIBUTES, "Expected a backup file\n");
 
     /* Try to overwrite */
     SetLastError(0xdeadbeef);
@@ -263,7 +304,22 @@ static void test_backup(void)
     }
 
     CloseEventLog(handle);
+
+    /* Can we make a backup of a backup? */
+    handle = OpenBackupEventLogA(NULL, backup);
+    todo_wine
+    ok(handle != NULL, "Expected a handle\n");
+
+    ret = BackupEventLogA(handle, backup2);
+    todo_wine
+    {
+    ok(ret, "Expected succes\n");
+    ok(GetFileAttributesA(backup2) != INVALID_FILE_ATTRIBUTES, "Expected a backup file\n");
+    }
+
+    CloseEventLog(handle);
     DeleteFileA(backup);
+    DeleteFileA(backup2);
 }
 
 static void test_read(void)
--
1.6.2.5