ntdll/tests: Allow alternate results in the env test to make it pass on Vista.
This commit is contained in:
parent
517644971c
commit
d1f8dd1549
|
@ -57,6 +57,7 @@ static void testQuery(void)
|
|||
int len;
|
||||
NTSTATUS status;
|
||||
const char *val;
|
||||
NTSTATUS alt;
|
||||
};
|
||||
|
||||
static const struct test tests[] =
|
||||
|
@ -67,12 +68,13 @@ static void testQuery(void)
|
|||
{"foo ", 256, STATUS_VARIABLE_NOT_FOUND, NULL},
|
||||
{"foo", 1, STATUS_BUFFER_TOO_SMALL, "toto"},
|
||||
{"foo", 3, STATUS_BUFFER_TOO_SMALL, "toto"},
|
||||
{"foo", 4, STATUS_SUCCESS, "toto"},
|
||||
{"foo", 4, STATUS_SUCCESS, "toto", STATUS_BUFFER_TOO_SMALL},
|
||||
{"foo", 5, STATUS_SUCCESS, "toto"},
|
||||
{"fooo", 256, STATUS_SUCCESS, "tutu"},
|
||||
{"f", 256, STATUS_VARIABLE_NOT_FOUND, NULL},
|
||||
{"g", 256, STATUS_SUCCESS, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
|
||||
{"sr=an", 256, STATUS_VARIABLE_NOT_FOUND, NULL},
|
||||
{"sr=an", 256, STATUS_SUCCESS, "ouo", STATUS_VARIABLE_NOT_FOUND},
|
||||
{"sr", 256, STATUS_SUCCESS, "an=ouo"},
|
||||
{"=oOH", 256, STATUS_SUCCESS, "III"},
|
||||
{"", 256, STATUS_VARIABLE_NOT_FOUND, NULL},
|
||||
|
@ -99,7 +101,8 @@ static void testQuery(void)
|
|||
|
||||
pRtlMultiByteToUnicodeN( bn, sizeof(bn), NULL, test->var, strlen(test->var)+1 );
|
||||
nts = pRtlQueryEnvironmentVariable_U(small_env, &name, &value);
|
||||
ok( nts == test->status, "[%d]: Wrong status for '%s', expecting %x got %x\n",
|
||||
ok( nts == test->status || (test->alt && nts == test->alt),
|
||||
"[%d]: Wrong status for '%s', expecting %x got %x\n",
|
||||
test - tests, test->var, test->status, nts );
|
||||
if (nts == test->status) switch (nts)
|
||||
{
|
||||
|
@ -120,7 +123,7 @@ static void testQuery(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void testSetHelper(LPWSTR* env, const char* var, const char* val, NTSTATUS ret)
|
||||
static void testSetHelper(LPWSTR* env, const char* var, const char* val, NTSTATUS ret, NTSTATUS alt)
|
||||
{
|
||||
WCHAR bvar[256], bval1[256], bval2[256];
|
||||
UNICODE_STRING uvar;
|
||||
|
@ -139,7 +142,7 @@ static void testSetHelper(LPWSTR* env, const char* var, const char* val, NTSTATU
|
|||
pRtlMultiByteToUnicodeN( bval1, sizeof(bval1), NULL, val, strlen(val)+1 );
|
||||
}
|
||||
nts = pRtlSetEnvironmentVariable(env, &uvar, val ? &uval : NULL);
|
||||
ok(nts == ret, "Setting var %s=%s (%x/%x)\n", var, val, nts, ret);
|
||||
ok(nts == ret || (alt && nts == alt), "Setting var %s=%s (%x/%x)\n", var, val, nts, ret);
|
||||
if (nts == STATUS_SUCCESS)
|
||||
{
|
||||
uval.Length = 0;
|
||||
|
@ -168,31 +171,30 @@ static void testSet(void)
|
|||
int i;
|
||||
|
||||
ok(pRtlCreateEnvironment(FALSE, &env) == STATUS_SUCCESS, "Creating environment\n");
|
||||
memmove(env, small_env, sizeof(small_env));
|
||||
|
||||
testSetHelper(&env, "cat", "dog", STATUS_SUCCESS);
|
||||
testSetHelper(&env, "cat", "horse", STATUS_SUCCESS);
|
||||
testSetHelper(&env, "cat", "zz", STATUS_SUCCESS);
|
||||
testSetHelper(&env, "cat", NULL, STATUS_SUCCESS);
|
||||
testSetHelper(&env, "cat", NULL, STATUS_VARIABLE_NOT_FOUND);
|
||||
testSetHelper(&env, "foo", "meouw", STATUS_SUCCESS);
|
||||
testSetHelper(&env, "me=too", "also", STATUS_INVALID_PARAMETER);
|
||||
testSetHelper(&env, "me", "too=also", STATUS_SUCCESS);
|
||||
testSetHelper(&env, "=too", "also", STATUS_SUCCESS);
|
||||
testSetHelper(&env, "=", "also", STATUS_SUCCESS);
|
||||
testSetHelper(&env, "cat", "dog", STATUS_SUCCESS, 0);
|
||||
testSetHelper(&env, "cat", "horse", STATUS_SUCCESS, 0);
|
||||
testSetHelper(&env, "cat", "zz", STATUS_SUCCESS, 0);
|
||||
testSetHelper(&env, "cat", NULL, STATUS_SUCCESS, 0);
|
||||
testSetHelper(&env, "cat", NULL, STATUS_SUCCESS, STATUS_VARIABLE_NOT_FOUND);
|
||||
testSetHelper(&env, "foo", "meouw", STATUS_SUCCESS, 0);
|
||||
testSetHelper(&env, "me=too", "also", STATUS_INVALID_PARAMETER, 0);
|
||||
testSetHelper(&env, "me", "too=also", STATUS_SUCCESS, 0);
|
||||
testSetHelper(&env, "=too", "also", STATUS_SUCCESS, 0);
|
||||
testSetHelper(&env, "=", "also", STATUS_SUCCESS, 0);
|
||||
|
||||
for (i = 0; i < 128; i++)
|
||||
{
|
||||
sprintf(tmp, "zork%03d", i);
|
||||
testSetHelper(&env, tmp, "is alive", STATUS_SUCCESS);
|
||||
testSetHelper(&env, tmp, "is alive", STATUS_SUCCESS, 0);
|
||||
}
|
||||
|
||||
for (i = 0; i < 128; i++)
|
||||
{
|
||||
sprintf(tmp, "zork%03d", i);
|
||||
testSetHelper(&env, tmp, NULL, STATUS_SUCCESS);
|
||||
testSetHelper(&env, tmp, NULL, STATUS_SUCCESS, 0);
|
||||
}
|
||||
testSetHelper(&env, "fOo", NULL, STATUS_SUCCESS);
|
||||
testSetHelper(&env, "fOo", NULL, STATUS_SUCCESS, 0);
|
||||
|
||||
ok(pRtlDestroyEnvironment(env) == STATUS_SUCCESS, "Destroying environment\n");
|
||||
}
|
||||
|
@ -263,9 +265,6 @@ static void testExpand(void)
|
|||
ok(nts == STATUS_BUFFER_TOO_SMALL, "Call failed (%u)\n", nts);
|
||||
ok(ul == strlen(test->dst) * sizeof(WCHAR) + sizeof(WCHAR),
|
||||
"Wrong returned length for %s (with buffer too small): %u\n", test->src, ul);
|
||||
ok(memcmp(dst, rst, 8*sizeof(WCHAR)) == 0,
|
||||
"Wrong result for %s (with buffer too small): expecting %s\n",
|
||||
test->src, test->dst);
|
||||
ok(dst[8] == '-', "Writing too far in buffer (got %c/%d)\n", dst[8], dst[8]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue