From e6dbb9d2037956de2af6ab0d8f3b420ee953f78f Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Wed, 10 Oct 2007 14:40:20 -0700 Subject: [PATCH] crypt32: Allow imprecision of one millisecond in time decoding to fix test failures on Windows. --- dlls/crypt32/tests/encode.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/dlls/crypt32/tests/encode.c b/dlls/crypt32/tests/encode.c index 65b6a0faf4e..421b236c92d 100644 --- a/dlls/crypt32/tests/encode.c +++ b/dlls/crypt32/tests/encode.c @@ -482,17 +482,31 @@ static const char *printFileTime(const FILETIME *ft) return buf; } +static void compareTime(const SYSTEMTIME *expected, const FILETIME *got) +{ + SYSTEMTIME st; + + FileTimeToSystemTime(got, &st); + ok(expected->wYear == st.wYear && + expected->wMonth == st.wMonth && + expected->wDay == st.wDay && + expected->wHour == st.wHour && + expected->wMinute == st.wMinute && + expected->wSecond == st.wSecond && + abs(expected->wMilliseconds - st.wMilliseconds) <= 1, + "Got unexpected value for time decoding:\nexpected %s, got %s\n", + printSystemTime(expected), printFileTime(got)); +} + static void testTimeDecoding(DWORD dwEncoding, LPCSTR structType, const struct encodedFiletime *time) { - FILETIME ft1 = { 0 }, ft2 = { 0 }; - DWORD size = sizeof(ft2); + FILETIME ft = { 0 }; + DWORD size = sizeof(ft); BOOL ret; - ret = SystemTimeToFileTime(&time->sysTime, &ft1); - ok(ret, "SystemTimeToFileTime failed: %d\n", GetLastError()); ret = CryptDecodeObjectEx(dwEncoding, structType, time->encodedTime, - time->encodedTime[1] + 2, 0, NULL, &ft2, &size); + time->encodedTime[1] + 2, 0, NULL, &ft, &size); /* years other than 1950-2050 are not allowed for encodings other than * X509_CHOICE_OF_TIME. */ @@ -501,9 +515,7 @@ static void testTimeDecoding(DWORD dwEncoding, LPCSTR structType, { ok(ret, "CryptDecodeObjectEx failed: %d (0x%08x)\n", GetLastError(), GetLastError()); - ok(!memcmp(&ft1, &ft2, sizeof(ft1)), - "Got unexpected value for time decoding:\nexpected %s, got %s\n", - printSystemTime(&time->sysTime), printFileTime(&ft2)); + compareTime(&time->sysTime, &ft); } else ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG,