shell32/tests: Remove atime tests in ITEMIDLIST_format test.
Austin Lund
austin.lund at gmail.com
Fri Nov 20 17:18:05 CST 2009
2009/11/21 Austin Lund <austin.lund at gmail.com>:
> 2009/11/21 Paul Vriens <paul.vriens.wine at gmail.com>:
>
>> if (abs(date2 - date1) == 1)
>> skip("We dont't check access times on a FAT filesystem\n");
>
>
>> "The date is always within 1 day (plus or minus)."
>
> It isn't quite that easy as the date field is a bitpacked struct
> holding the year, month and day. So you have to account for month and
> year boundaries. In the absence of any other ideas or tips to where I
> can find a function to do this for me, I implement the calendaring
> increments and send a patch which follows the above idea.
>
Here is an attempt at doing this. Is there a better/cleaner way to do this?
-------------- next part --------------
From 9015746671f61a2e2ab40c21fb390915331ebaad Mon Sep 17 00:00:00 2001
From: Austin Lund <austin.lund at gmail.com>
Date: Sat, 21 Nov 2009 09:02:32 +1000
Subject: [PATCH] shell32/tests: Fix ITEMIDLIST_format test when running on FAT filesystems
---
dlls/shell32/tests/shlfolder.c | 32 +++++++++++++++++++++++++++++---
1 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/dlls/shell32/tests/shlfolder.c b/dlls/shell32/tests/shlfolder.c
index ed3a8b5..f3ea7a9 100644
--- a/dlls/shell32/tests/shlfolder.c
+++ b/dlls/shell32/tests/shlfolder.c
@@ -1403,6 +1403,10 @@ struct FileStructW {
};
#include "poppack.h"
+#define DOSDATE_DAY(dosdatetime) (dosdatetime & 0x1F)
+#define DOSDATE_MONTH(dosdatetime) ((pFileStructA->uFileDate >> 5) & 0xF)
+#define DOSDATE_YEAR(dosdatetime) ((pFileStructA->uFileDate >> 9) & 0x7F)
+
static void test_ITEMIDLIST_format(void) {
WCHAR wszPersonal[MAX_PATH];
LPSHELLFOLDER psfDesktop, psfPersonal;
@@ -1514,6 +1518,8 @@ static void test_ITEMIDLIST_format(void) {
"FileStructW's offset and length should add up to the PIDL's length!\n");
if (pidlFile->mkid.cb == cbOffset + pFileStructW->cbLen) {
+ BOOL testgood = FALSE;
+
/* Since we just created the file, time of creation,
* time of last access and time of last write access just be the same.
* These tests seem to fail sometimes (on WinXP), if the test is run again shortly
@@ -1524,9 +1530,29 @@ static void test_ITEMIDLIST_format(void) {
pFileStructA->uFileTime == pFileStructW->uTime,
"Last write time should match creation time!\n");
- ok (pFileStructA->uFileDate == pFileStructW->uDate2 &&
- pFileStructA->uFileTime == pFileStructW->uTime2,
- "Last write time should match last access time!\n");
+ /* On FAT filesystems the last access time is midnight local time, so the values of
+ uDate2 and uTime2 will depend on the local timezone. If the date and time are
+ not exactly equal, then perform the lesser test of being within one day or one
+ month or one year.
+ */
+ if (pFileStructA->uFileDate == pFileStructW->uDate2 &&
+ pFileStructA->uFileTime == pFileStructW->uTime2)
+ {
+ testgood = TRUE;
+ }
+ else
+ {
+ if (abs(DOSDATE_DAY(pFileStructA->uFileDate) - DOSDATE_DAY(pFileStructW->uDate2)) <= 1)
+ testgood = TRUE;
+ else if (abs(DOSDATE_MONTH(pFileStructA->uFileDate) - DOSDATE_MONTH(pFileStructW->uDate2)) <= 1 &&
+ (DOSDATE_DAY(pFileStructA->uFileDate) == 1 || DOSDATE_DAY(pFileStructW->uDate2) == 1))
+ testgood = TRUE;
+ else if (abs(DOSDATE_YEAR(pFileStructA->uFileDate) - DOSDATE_YEAR(pFileStructW->uDate2)) <= 1 &&
+ (DOSDATE_MONTH(pFileStructA->uFileDate) == 1 || DOSDATE_MONTH(pFileStructW->uDate2) == 1))
+ testgood = TRUE;
+ }
+ ok(testgood == TRUE, "Access times not equal and not within 1 day (%x %x %x %x)\n",
+ pFileStructA->uFileDate, pFileStructA->uFileTime, pFileStructW->uDate2, pFileStructW->uTime2);
ok (!lstrcmpW(wszFile[i], pFileStructW->wszName) ||
!lstrcmpW(wszFile[i], (WCHAR *)(pFileStructW->abFooBar2 + 22)), /* Vista */
--
1.6.3.3
More information about the wine-devel
mailing list