Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntdll/tests/env.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/dlls/ntdll/tests/env.c b/dlls/ntdll/tests/env.c index 4865a0a8e51..d476bd65a81 100644 --- a/dlls/ntdll/tests/env.c +++ b/dlls/ntdll/tests/env.c @@ -325,6 +325,11 @@ static WCHAR *get_params_string( RTL_USER_PROCESS_PARAMETERS *params, UNICODE_ST return (WCHAR *)((char *)params + (UINT_PTR)str->Buffer); }
+static UINT_PTR align(UINT_PTR size, unsigned int alignment) +{ + return (size + (alignment - 1)) & ~(alignment - 1); +} + static UINT_PTR check_string_( int line, RTL_USER_PROCESS_PARAMETERS *params, UNICODE_STRING *str, const UNICODE_STRING *expect, UINT_PTR pos ) { @@ -341,9 +346,9 @@ static UINT_PTR check_string_( int line, RTL_USER_PROCESS_PARAMETERS *params, UN ok_(__FILE__,line)( str->Buffer == NULL, "buffer not null %p\n", str->Buffer ); return pos; } - ok_(__FILE__,line)( (UINT_PTR)str->Buffer == ((pos + sizeof(void*) - 1) & ~(sizeof(void *) - 1)) || + ok_(__FILE__,line)( (UINT_PTR)str->Buffer == align(pos, sizeof(void *)) || (!expect && (UINT_PTR)str->Buffer == pos) || /* initial params are not aligned */ - broken( (UINT_PTR)str->Buffer == ((pos + 3) & ~3) ), "wrong buffer %lx/%lx\n", + broken( (UINT_PTR)str->Buffer == align(pos, 4) ), "wrong buffer %lx/%lx\n", (UINT_PTR)str->Buffer, pos ); if (str->Length < str->MaximumLength) { @@ -424,7 +429,7 @@ static void test_process_params(void) pos = check_string( params, ¶ms->Desktop, &empty_str, pos ); pos = check_string( params, ¶ms->ShellInfo, &empty_str, pos ); pos = check_string( params, ¶ms->RuntimeInfo, &null_str, pos ); - pos = (pos + 3) & ~3; + pos = align(pos, 4); ok( pos == params->Size || pos + 4 == params->Size, "wrong pos %lx/%x\n", pos, params->Size ); pos = params->Size; @@ -437,8 +442,8 @@ static void test_process_params(void) while (*str) str += lstrlenW(str) + 1; str++; pos += (str - params->Environment) * sizeof(WCHAR); - ok( ((pos + sizeof(void *) - 1) & ~(sizeof(void *) - 1)) == size || - broken( ((pos + 3) & ~3) == size ), "wrong size %lx/%lx\n", pos, size ); + ok( align(pos, sizeof(void *)) == size || + broken( align(pos, 4) == size ), "wrong size %lx/%lx\n", pos, size ); } else ok( broken(TRUE), "environment not inside block\n" ); /* <= win2k3 */ pRtlDestroyProcessParameters( params ); @@ -478,7 +483,7 @@ static void test_process_params(void) pos = check_string( params, ¶ms->Desktop, &dummy, pos ); pos = check_string( params, ¶ms->ShellInfo, &dummy, pos ); pos = check_string( params, ¶ms->RuntimeInfo, &dummy, pos ); - pos = (pos + 3) & ~3; + pos = align(pos, 4); ok( pos == params->Size || pos + 4 == params->Size, "wrong pos %lx/%x\n", pos, params->Size ); pos = params->Size; @@ -491,8 +496,8 @@ static void test_process_params(void) while (*str) str += lstrlenW(str) + 1; str++; pos += (str - params->Environment) * sizeof(WCHAR); - ok( ((pos + sizeof(void *) - 1) & ~(sizeof(void *) - 1)) == size || - broken( ((pos + 3) & ~3) == size ), "wrong size %lx/%lx\n", pos, size ); + ok( align(pos, sizeof(void *)) == size || + broken( align(pos, 4) == size ), "wrong size %lx/%lx\n", pos, size ); } else ok( broken(TRUE), "environment not inside block\n" ); /* <= win2k3 */ pRtlDestroyProcessParameters( params );
This fixes a common test failure on Wine.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntdll/tests/env.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/tests/env.c b/dlls/ntdll/tests/env.c index d476bd65a81..72bc45cfad4 100644 --- a/dlls/ntdll/tests/env.c +++ b/dlls/ntdll/tests/env.c @@ -537,7 +537,9 @@ static void test_process_params(void) while (*str) str += lstrlenW(str) + 1; str++; } - ok( (char *)str == (char *)cur_params + cur_params->Size, + /* windows doesn't align size for the initial block, but wine does */ + ok( (UINT_PTR)str == (UINT_PTR)cur_params + cur_params->Size || + align((UINT_PTR)str, sizeof(void *)) == (UINT_PTR)cur_params + cur_params->Size, "wrong end ptr %p/%p\n", str, (char *)cur_params + cur_params->Size );
/* initial environment is a separate block */