ntdll-LZNT1_Compression: Fix test failures on systems with broken RtlDecompressBuffer.

This commit is contained in:
Sebastian Lackner 2015-03-10 20:13:07 +01:00
parent 4b41a20552
commit 28ddd8d7d5
2 changed files with 151 additions and 0 deletions

View File

@ -0,0 +1,149 @@
From 8a8496e747ef2dff43763a3d3dfd7f1d68160adc Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Tue, 10 Mar 2015 20:09:59 +0100
Subject: ntdll/tests: Fix various test failures caused by broken
RtlDecompressBuffer results.
---
dlls/ntdll/tests/rtl.c | 41 ++++++++++++++++++-----------------------
1 file changed, 18 insertions(+), 23 deletions(-)
diff --git a/dlls/ntdll/tests/rtl.c b/dlls/ntdll/tests/rtl.c
index 2f6c421..843e8e7 100644
--- a/dlls/ntdll/tests/rtl.c
+++ b/dlls/ntdll/tests/rtl.c
@@ -1664,9 +1664,7 @@ static BOOL is_incomplete_chunk(const UCHAR *compressed, ULONG compressed_size,
}
#define DECOMPRESS_BROKEN_TRUNCATED 1
-#define DECOMPRESS_BROKEN_FRAGMENT0 2
-#define DECOMPRESS_BROKEN_FRAGMENT1 4
-#define DECOMPRESS_BROKEN_FRAGMENT4095 8
+#define DECOMPRESS_BROKEN_FRAGMENT 2
static void test_RtlDecompressBuffer(void)
{
@@ -1690,9 +1688,7 @@ static void test_RtlDecompressBuffer(void)
STATUS_SUCCESS,
"Wine",
4,
- DECOMPRESS_BROKEN_FRAGMENT4095 |
- DECOMPRESS_BROKEN_FRAGMENT1 |
- DECOMPRESS_BROKEN_FRAGMENT0
+ DECOMPRESS_BROKEN_FRAGMENT
},
/* 8 byte uncompressed chunk */
{
@@ -1701,9 +1697,7 @@ static void test_RtlDecompressBuffer(void)
STATUS_SUCCESS,
"WineWine",
8,
- DECOMPRESS_BROKEN_FRAGMENT4095 |
- DECOMPRESS_BROKEN_FRAGMENT1 |
- DECOMPRESS_BROKEN_FRAGMENT0
+ DECOMPRESS_BROKEN_FRAGMENT
},
/* 4 byte compressed chunk */
{
@@ -1763,9 +1757,7 @@ static void test_RtlDecompressBuffer(void)
STATUS_SUCCESS,
"Wine",
4,
- DECOMPRESS_BROKEN_FRAGMENT4095 |
- DECOMPRESS_BROKEN_FRAGMENT1 |
- DECOMPRESS_BROKEN_FRAGMENT0
+ DECOMPRESS_BROKEN_FRAGMENT
},
/* compressed chunk using backwards reference with 4 bit offset, 12 bit length */
{
@@ -1796,9 +1788,7 @@ static void test_RtlDecompressBuffer(void)
STATUS_SUCCESS,
"Wine",
4,
- DECOMPRESS_BROKEN_FRAGMENT4095 |
- DECOMPRESS_BROKEN_FRAGMENT1 |
- DECOMPRESS_BROKEN_FRAGMENT0
+ DECOMPRESS_BROKEN_FRAGMENT
},
/* compressed chunk with invalid magic */
{
@@ -1923,7 +1913,8 @@ static void test_RtlDecompressBuffer(void)
memset(buf, 0x11, sizeof(buf));
status = pRtlDecompressBuffer(COMPRESSION_FORMAT_LZNT1, buf, sizeof(buf), test_lznt[i].compressed,
test_lznt[i].compressed_size, &final_size);
- ok(status == test_lznt[i].status, "%d: got wrong status 0x%08x\n", i, status);
+ ok(status == test_lznt[i].status || broken(status == STATUS_BAD_COMPRESSION_BUFFER &&
+ (test_lznt[i].broken_flags & DECOMPRESS_BROKEN_FRAGMENT)), "%d: got wrong status 0x%08x\n", i, status);
if (!status)
{
ok(final_size == test_lznt[i].uncompressed_size,
@@ -1939,7 +1930,8 @@ static void test_RtlDecompressBuffer(void)
memset(buf, 0x11, sizeof(buf));
status = pRtlDecompressBuffer(COMPRESSION_FORMAT_LZNT1 | COMPRESSION_ENGINE_MAXIMUM, buf, sizeof(buf),
test_lznt[i].compressed, test_lznt[i].compressed_size, &final_size);
- ok(status == test_lznt[i].status, "%d: got wrong status 0x%08x\n", i, status);
+ ok(status == test_lznt[i].status || broken(status == STATUS_BAD_COMPRESSION_BUFFER &&
+ (test_lznt[i].broken_flags & DECOMPRESS_BROKEN_FRAGMENT)), "%d: got wrong status 0x%08x\n", i, status);
if (!status)
{
ok(final_size == test_lznt[i].uncompressed_size,
@@ -2011,7 +2003,7 @@ static void test_RtlDecompressBuffer(void)
status = pRtlDecompressFragment(COMPRESSION_FORMAT_LZNT1, buf, sizeof(buf), test_lznt[i].compressed,
test_lznt[i].compressed_size, 0, &final_size, workspace);
ok(status == test_lznt[i].status || broken(status == STATUS_BAD_COMPRESSION_BUFFER &&
- (test_lznt[i].broken_flags & DECOMPRESS_BROKEN_FRAGMENT0)), "%d: got wrong status 0x%08x\n", i, status);
+ (test_lznt[i].broken_flags & DECOMPRESS_BROKEN_FRAGMENT)), "%d: got wrong status 0x%08x\n", i, status);
if (!status)
{
ok(final_size == test_lznt[i].uncompressed_size,
@@ -2028,7 +2020,7 @@ static void test_RtlDecompressBuffer(void)
status = pRtlDecompressFragment(COMPRESSION_FORMAT_LZNT1, buf, sizeof(buf), test_lznt[i].compressed,
test_lznt[i].compressed_size, 1, &final_size, workspace);
ok(status == test_lznt[i].status || broken(status == STATUS_BAD_COMPRESSION_BUFFER &&
- (test_lznt[i].broken_flags & DECOMPRESS_BROKEN_FRAGMENT1)), "%d: got wrong status 0x%08x\n", i, status);
+ (test_lznt[i].broken_flags & DECOMPRESS_BROKEN_FRAGMENT)), "%d: got wrong status 0x%08x\n", i, status);
if (!status)
{
if (test_lznt[i].uncompressed_size == 0)
@@ -2057,7 +2049,7 @@ static void test_RtlDecompressBuffer(void)
status = pRtlDecompressFragment(COMPRESSION_FORMAT_LZNT1, buf, sizeof(buf), test_lznt[i].compressed,
test_lznt[i].compressed_size, 4095, &final_size, workspace);
ok(status == test_lznt[i].status || broken(status == STATUS_BAD_COMPRESSION_BUFFER &&
- (test_lznt[i].broken_flags & DECOMPRESS_BROKEN_FRAGMENT4095)), "%d: got wrong status 0x%08x\n", i, status);
+ (test_lznt[i].broken_flags & DECOMPRESS_BROKEN_FRAGMENT)), "%d: got wrong status 0x%08x\n", i, status);
if (!status)
{
todo_wine
@@ -2092,7 +2084,8 @@ static void test_RtlDecompressBuffer(void)
memset(buf, 0x11, sizeof(buf));
status = pRtlDecompressBuffer(COMPRESSION_FORMAT_LZNT1, buf, sizeof(buf), test_multiple_chunks,
sizeof(test_multiple_chunks), &final_size);
- ok(status == STATUS_SUCCESS, "got wrong status 0x%08x\n", status);
+ ok(status == STATUS_SUCCESS || broken(status == STATUS_BAD_COMPRESSION_BUFFER),
+ "got wrong status 0x%08x\n", status);
if (!status)
{
ok(final_size == 4100, "got wrong final_size %d\n", final_size);
@@ -2106,7 +2099,8 @@ static void test_RtlDecompressBuffer(void)
memset(buf, 0x11, sizeof(buf));
status = pRtlDecompressBuffer(COMPRESSION_FORMAT_LZNT1, buf, 4097, test_multiple_chunks,
sizeof(test_multiple_chunks), &final_size);
- ok(status == STATUS_SUCCESS, "got wrong status 0x%08x\n", status);
+ ok(status == STATUS_SUCCESS || broken(status == STATUS_BAD_COMPRESSION_BUFFER),
+ "got wrong status 0x%08x\n", status);
if (!status)
{
ok(final_size == 4097, "got wrong final_size %d\n", final_size);
@@ -2120,7 +2114,8 @@ static void test_RtlDecompressBuffer(void)
memset(buf, 0x11, sizeof(buf));
status = pRtlDecompressBuffer(COMPRESSION_FORMAT_LZNT1, buf, 4096, test_multiple_chunks,
sizeof(test_multiple_chunks), &final_size);
- ok(status == STATUS_SUCCESS, "got wrong status 0x%08x\n", status);
+ ok(status == STATUS_SUCCESS || broken(status == STATUS_BAD_COMPRESSION_BUFFER),
+ "got wrong status 0x%08x\n", status);
if (!status)
{
ok(final_size == 4, "got wrong final_size %d\n", final_size);
--
2.3.1

View File

@ -2857,11 +2857,13 @@ if test "$enable_ntdll_LZNT1_Compression" -eq 1; then
patch_apply ntdll-LZNT1_Compression/0002-ntdll-Implement-semi-stub-for-RtlCompressBuffer.patch
patch_apply ntdll-LZNT1_Compression/0003-ntdll-Implement-LZNT1-algorithm-for-RtlDecompressBuf.patch
patch_apply ntdll-LZNT1_Compression/0004-ntdll-tests-Add-tests-for-Rtl-Decompress-Compress-Bu.patch
patch_apply ntdll-LZNT1_Compression/0005-ntdll-tests-Fix-various-test-failures-caused-by-brok.patch
(
echo '+ { "Sebastian Lackner", "ntdll: Implement semi-stub for RtlGetCompressionWorkSpaceSize.", 1 },';
echo '+ { "Sebastian Lackner", "ntdll: Implement semi-stub for RtlCompressBuffer.", 1 },';
echo '+ { "Sebastian Lackner", "ntdll: Implement LZNT1 algorithm for RtlDecompressBuffer.", 1 },';
echo '+ { "Sebastian Lackner", "ntdll/tests: Add tests for Rtl[Decompress|Compress]Buffer and RtlGetCompressionWorkSpaceSize.", 1 },';
echo '+ { "Sebastian Lackner", "ntdll/tests: Fix various test failures caused by broken RtlDecompressBuffer results.", 1 },';
) >> "$patchlist"
fi