[KMTESTS]

- Skip the remaining tests that result in assertions
- Hide KeProcessor test, as it takes very long

svn path=/branches/GSoC_2011/KMTestSuite/; revision=53669
This commit is contained in:
Thomas Faber 2011-09-10 10:48:07 +00:00
parent 21494c6ffa
commit 34e64d7748
5 changed files with 143 additions and 107 deletions

View file

@ -61,7 +61,7 @@ const KMT_TEST TestList[] =
{ "KeEvent", Test_KeEvent }, { "KeEvent", Test_KeEvent },
{ "KeGuardedMutex", Test_KeGuardedMutex }, { "KeGuardedMutex", Test_KeGuardedMutex },
{ "KeIrql", Test_KeIrql }, { "KeIrql", Test_KeIrql },
{ "KeProcessor", Test_KeProcessor }, { "-KeProcessor", Test_KeProcessor },
{ "-KernelType", Test_KernelType }, { "-KernelType", Test_KernelType },
{ "ObReference", Test_ObReference }, { "ObReference", Test_ObReference },
{ "ObType", Test_ObType }, { "ObType", Test_ObType },

View file

@ -52,12 +52,6 @@ TestFastMutex(
ExiReleaseFastMutex(Mutex); ExiReleaseFastMutex(Mutex);
CheckMutex(Mutex, 1L, NULL, 0LU, OriginalIrql, OriginalIrql); CheckMutex(Mutex, 1L, NULL, 0LU, OriginalIrql, OriginalIrql);
/* acquire/release unsafe */
ExAcquireFastMutexUnsafe(Mutex);
CheckMutex(Mutex, 0L, Thread, 0LU, OriginalIrql, OriginalIrql);
ExReleaseFastMutexUnsafe(Mutex);
CheckMutex(Mutex, 1L, NULL, 0LU, OriginalIrql, OriginalIrql);
/* try to acquire */ /* try to acquire */
ok_bool_true(ExTryToAcquireFastMutex(Mutex), "ExTryToAcquireFastMutex returned"); ok_bool_true(ExTryToAcquireFastMutex(Mutex), "ExTryToAcquireFastMutex returned");
CheckMutex(Mutex, 0L, Thread, 0LU, OriginalIrql, APC_LEVEL); CheckMutex(Mutex, 0L, Thread, 0LU, OriginalIrql, APC_LEVEL);
@ -69,33 +63,45 @@ TestFastMutex(
ok_bool_true(KeAreApcsDisabled(), "KeAreApcsDisabled returned"); ok_bool_true(KeAreApcsDisabled(), "KeAreApcsDisabled returned");
ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(Mutex); ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(Mutex);
/* mismatched acquire/release */ /* acquire/release unsafe */
ExAcquireFastMutex(Mutex); if (!KmtIsCheckedBuild || OriginalIrql == APC_LEVEL)
CheckMutex(Mutex, 0L, Thread, 0LU, OriginalIrql, APC_LEVEL); {
ExReleaseFastMutexUnsafe(Mutex); ExAcquireFastMutexUnsafe(Mutex);
CheckMutex(Mutex, 1L, NULL, 0LU, OriginalIrql, APC_LEVEL); CheckMutex(Mutex, 0L, Thread, 0LU, OriginalIrql, OriginalIrql);
KmtSetIrql(OriginalIrql); ExReleaseFastMutexUnsafe(Mutex);
CheckMutex(Mutex, 1L, NULL, 0LU, OriginalIrql, OriginalIrql); CheckMutex(Mutex, 1L, NULL, 0LU, OriginalIrql, OriginalIrql);
Mutex->OldIrql = 0x55555555LU; /* mismatched acquire/release */
ExAcquireFastMutexUnsafe(Mutex); ExAcquireFastMutex(Mutex);
CheckMutex(Mutex, 0L, Thread, 0LU, 0x55555555LU, OriginalIrql); CheckMutex(Mutex, 0L, Thread, 0LU, OriginalIrql, APC_LEVEL);
Mutex->OldIrql = PASSIVE_LEVEL; ExReleaseFastMutexUnsafe(Mutex);
ExReleaseFastMutex(Mutex); CheckMutex(Mutex, 1L, NULL, 0LU, OriginalIrql, APC_LEVEL);
CheckMutex(Mutex, 1L, NULL, 0LU, PASSIVE_LEVEL, PASSIVE_LEVEL); KmtSetIrql(OriginalIrql);
KmtSetIrql(OriginalIrql); CheckMutex(Mutex, 1L, NULL, 0LU, OriginalIrql, OriginalIrql);
CheckMutex(Mutex, 1L, NULL, 0LU, PASSIVE_LEVEL, OriginalIrql);
/* release without acquire */ Mutex->OldIrql = 0x55555555LU;
ExReleaseFastMutexUnsafe(Mutex); ExAcquireFastMutexUnsafe(Mutex);
CheckMutex(Mutex, 2L, NULL, 0LU, PASSIVE_LEVEL, OriginalIrql); CheckMutex(Mutex, 0L, Thread, 0LU, 0x55555555LU, OriginalIrql);
--Mutex->Count; Mutex->OldIrql = PASSIVE_LEVEL;
Mutex->OldIrql = OriginalIrql; ExReleaseFastMutex(Mutex);
ExReleaseFastMutex(Mutex); CheckMutex(Mutex, 1L, NULL, 0LU, PASSIVE_LEVEL, PASSIVE_LEVEL);
CheckMutex(Mutex, 2L, NULL, 0LU, OriginalIrql, OriginalIrql); KmtSetIrql(OriginalIrql);
ExReleaseFastMutex(Mutex); CheckMutex(Mutex, 1L, NULL, 0LU, PASSIVE_LEVEL, OriginalIrql);
CheckMutex(Mutex, 3L, NULL, 0LU, OriginalIrql, OriginalIrql); }
Mutex->Count -= 2;
if (!KmtIsCheckedBuild)
{
/* release without acquire */
ExReleaseFastMutexUnsafe(Mutex);
CheckMutex(Mutex, 2L, NULL, 0LU, PASSIVE_LEVEL, OriginalIrql);
--Mutex->Count;
Mutex->OldIrql = OriginalIrql;
ExReleaseFastMutex(Mutex);
CheckMutex(Mutex, 2L, NULL, 0LU, OriginalIrql, OriginalIrql);
ExReleaseFastMutex(Mutex);
CheckMutex(Mutex, 3L, NULL, 0LU, OriginalIrql, OriginalIrql);
Mutex->Count -= 2;
}
/* make sure we survive this in case of error */ /* make sure we survive this in case of error */
ok_eq_long(Mutex->Count, 1L); ok_eq_long(Mutex->Count, 1L);

View file

@ -86,8 +86,9 @@ TestResourceSharedAccess(
ok_bool_false(ExAcquireResourceExclusiveLite(Res, FALSE), "ExAcquireResourceExclusiveLite returned"); ok_bool_false(ExAcquireResourceExclusiveLite(Res, FALSE), "ExAcquireResourceExclusiveLite returned");
CheckResourceStatus(Res, FALSE, Count, 0LU, 0LU); CheckResourceStatus(Res, FALSE, Count, 0LU, 0LU);
/* this must not crash or deadlock (but can assert) */ /* this asserts */
ExConvertExclusiveToSharedLite(Res); if (!KmtIsCheckedBuild)
ExConvertExclusiveToSharedLite(Res);
CheckResourceStatus(Res, FALSE, Count, 0LU, 0LU); CheckResourceStatus(Res, FALSE, Count, 0LU, 0LU);
while (Count--) while (Count--)

View file

@ -16,11 +16,15 @@ static VOID FsRtlIsNameInExpressionTest()
{ {
UNICODE_STRING Expression, Name; UNICODE_STRING Expression, Name;
RtlInitUnicodeString(&Expression, L"*"); /* !Name->Length || !Expression->Length asserts */
RtlInitUnicodeString(&Name, L""); if (!KmtIsCheckedBuild)
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); {
RtlInitUnicodeString(&Expression, L""); RtlInitUnicodeString(&Expression, L"*");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); RtlInitUnicodeString(&Name, L"");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Expression, L"");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
}
RtlInitUnicodeString(&Expression, L"ntdll.dll"); RtlInitUnicodeString(&Expression, L"ntdll.dll");
RtlInitUnicodeString(&Name, L"."); RtlInitUnicodeString(&Name, L".");
@ -125,8 +129,11 @@ static VOID FsRtlIsNameInExpressionTest()
RtlInitUnicodeString(&Expression, L"*.?.c.d"); RtlInitUnicodeString(&Expression, L"*.?.c.d");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Expression, L"*?"); RtlInitUnicodeString(&Expression, L"*?");
RtlInitUnicodeString(&Name, L""); if (!KmtIsCheckedBuild)
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); {
RtlInitUnicodeString(&Name, L"");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
}
RtlInitUnicodeString(&Name, L"a"); RtlInitUnicodeString(&Name, L"a");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Name, L"aa"); RtlInitUnicodeString(&Name, L"aa");
@ -134,8 +141,11 @@ static VOID FsRtlIsNameInExpressionTest()
RtlInitUnicodeString(&Name, L"aaa"); RtlInitUnicodeString(&Name, L"aaa");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Expression, L"?*?"); RtlInitUnicodeString(&Expression, L"?*?");
RtlInitUnicodeString(&Name, L""); if (!KmtIsCheckedBuild)
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); {
RtlInitUnicodeString(&Name, L"");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
}
RtlInitUnicodeString(&Name, L"a"); RtlInitUnicodeString(&Name, L"a");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Name, L"aa"); RtlInitUnicodeString(&Name, L"aa");
@ -166,11 +176,14 @@ static VOID FsRtlIsDbcsInExpressionTest()
{ {
ANSI_STRING Expression, Name; ANSI_STRING Expression, Name;
RtlInitAnsiString(&Expression, "*"); if (!KmtIsCheckedBuild)
RtlInitAnsiString(&Name, ""); {
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); RtlInitAnsiString(&Expression, "*");
RtlInitAnsiString(&Expression, ""); RtlInitAnsiString(&Name, "");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE"); ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Expression, "");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
}
RtlInitAnsiString(&Expression, "ntdll.dll"); RtlInitAnsiString(&Expression, "ntdll.dll");
RtlInitAnsiString(&Name, "."); RtlInitAnsiString(&Name, ".");
@ -275,8 +288,11 @@ static VOID FsRtlIsDbcsInExpressionTest()
RtlInitAnsiString(&Expression, "*.?.c.d"); RtlInitAnsiString(&Expression, "*.?.c.d");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE"); ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Expression, "*?"); RtlInitAnsiString(&Expression, "*?");
RtlInitAnsiString(&Name, ""); if (!KmtIsCheckedBuild)
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); {
RtlInitAnsiString(&Name, "");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
}
RtlInitAnsiString(&Name, "a"); RtlInitAnsiString(&Name, "a");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE"); ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Name, "aa"); RtlInitAnsiString(&Name, "aa");
@ -284,8 +300,11 @@ static VOID FsRtlIsDbcsInExpressionTest()
RtlInitAnsiString(&Name, "aaa"); RtlInitAnsiString(&Name, "aaa");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE"); ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Expression, "?*?"); RtlInitAnsiString(&Expression, "?*?");
RtlInitAnsiString(&Name, ""); if (!KmtIsCheckedBuild)
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); {
RtlInitAnsiString(&Name, "");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
}
RtlInitAnsiString(&Name, "a"); RtlInitAnsiString(&Name, "a");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Name, "aa"); RtlInitAnsiString(&Name, "aa");

View file

@ -71,24 +71,27 @@ START_TEST(KeApc)
CheckApcs(0, 0, FALSE, PASSIVE_LEVEL); CheckApcs(0, 0, FALSE, PASSIVE_LEVEL);
/* leave without entering */ /* leave without entering */
KeLeaveCriticalRegion(); if (!KmtIsCheckedBuild)
CheckApcs(1, 0, FALSE, PASSIVE_LEVEL); {
KeEnterCriticalRegion(); KeLeaveCriticalRegion();
CheckApcs(0, 0, FALSE, PASSIVE_LEVEL); CheckApcs(1, 0, FALSE, PASSIVE_LEVEL);
KeEnterCriticalRegion();
CheckApcs(0, 0, FALSE, PASSIVE_LEVEL);
KeLeaveGuardedRegion(); KeLeaveGuardedRegion();
CheckApcs(0, 1, TRUE, PASSIVE_LEVEL); CheckApcs(0, 1, TRUE, PASSIVE_LEVEL);
KeEnterGuardedRegion(); KeEnterGuardedRegion();
CheckApcs(0, 0, FALSE, PASSIVE_LEVEL); CheckApcs(0, 0, FALSE, PASSIVE_LEVEL);
KeLeaveCriticalRegion(); KeLeaveCriticalRegion();
CheckApcs(1, 0, FALSE, PASSIVE_LEVEL); CheckApcs(1, 0, FALSE, PASSIVE_LEVEL);
KeLeaveGuardedRegion(); KeLeaveGuardedRegion();
CheckApcs(1, 1, TRUE, PASSIVE_LEVEL); CheckApcs(1, 1, TRUE, PASSIVE_LEVEL);
KeEnterCriticalRegion(); KeEnterCriticalRegion();
CheckApcs(0, 1, TRUE, PASSIVE_LEVEL); CheckApcs(0, 1, TRUE, PASSIVE_LEVEL);
KeEnterGuardedRegion(); KeEnterGuardedRegion();
CheckApcs(0, 0, FALSE, PASSIVE_LEVEL); CheckApcs(0, 0, FALSE, PASSIVE_LEVEL);
}
/* manually disable APCs */ /* manually disable APCs */
Thread->KernelApcDisable = -1; Thread->KernelApcDisable = -1;
@ -126,51 +129,58 @@ START_TEST(KeApc)
KeLeaveCriticalRegion(); KeLeaveCriticalRegion();
CheckApcs(0, 0, TRUE, HIGH_LEVEL); CheckApcs(0, 0, TRUE, HIGH_LEVEL);
KeEnterGuardedRegion(); /* Ke*GuardedRegion assert at > APC_LEVEL */
CheckApcs(0, -1, TRUE, HIGH_LEVEL); if (!KmtIsCheckedBuild)
KeLeaveGuardedRegion(); {
KeEnterGuardedRegion();
CheckApcs(0, -1, TRUE, HIGH_LEVEL);
KeLeaveGuardedRegion();
}
CheckApcs(0, 0, TRUE, HIGH_LEVEL); CheckApcs(0, 0, TRUE, HIGH_LEVEL);
KeLowerIrql(Irql); KeLowerIrql(Irql);
CheckApcs(0, 0, FALSE, PASSIVE_LEVEL); CheckApcs(0, 0, FALSE, PASSIVE_LEVEL);
KeRaiseIrql(HIGH_LEVEL, &Irql); if (!KmtIsCheckedBuild)
CheckApcs(0, 0, TRUE, HIGH_LEVEL); {
KeEnterCriticalRegion(); KeRaiseIrql(HIGH_LEVEL, &Irql);
CheckApcs(-1, 0, TRUE, HIGH_LEVEL); CheckApcs(0, 0, TRUE, HIGH_LEVEL);
KeEnterGuardedRegion(); KeEnterCriticalRegion();
CheckApcs(-1, -1, TRUE, HIGH_LEVEL); CheckApcs(-1, 0, TRUE, HIGH_LEVEL);
KeLowerIrql(Irql); KeEnterGuardedRegion();
CheckApcs(-1, -1, TRUE, PASSIVE_LEVEL); CheckApcs(-1, -1, TRUE, HIGH_LEVEL);
KeLeaveCriticalRegion(); KeLowerIrql(Irql);
CheckApcs(0, -1, TRUE, PASSIVE_LEVEL); CheckApcs(-1, -1, TRUE, PASSIVE_LEVEL);
KeLeaveGuardedRegion(); KeLeaveCriticalRegion();
CheckApcs(0, 0, FALSE, PASSIVE_LEVEL); CheckApcs(0, -1, TRUE, PASSIVE_LEVEL);
KeLeaveGuardedRegion();
CheckApcs(0, 0, FALSE, PASSIVE_LEVEL);
KeEnterGuardedRegion(); KeEnterGuardedRegion();
CheckApcs(0, -1, TRUE, PASSIVE_LEVEL); CheckApcs(0, -1, TRUE, PASSIVE_LEVEL);
KeRaiseIrql(HIGH_LEVEL, &Irql); KeRaiseIrql(HIGH_LEVEL, &Irql);
CheckApcs(0, -1, TRUE, HIGH_LEVEL); CheckApcs(0, -1, TRUE, HIGH_LEVEL);
KeEnterCriticalRegion(); KeEnterCriticalRegion();
CheckApcs(-1, -1, TRUE, HIGH_LEVEL); CheckApcs(-1, -1, TRUE, HIGH_LEVEL);
KeLeaveGuardedRegion(); KeLeaveGuardedRegion();
CheckApcs(-1, 0, TRUE, HIGH_LEVEL); CheckApcs(-1, 0, TRUE, HIGH_LEVEL);
KeLowerIrql(Irql); KeLowerIrql(Irql);
CheckApcs(-1, 0, FALSE, PASSIVE_LEVEL); CheckApcs(-1, 0, FALSE, PASSIVE_LEVEL);
KeLeaveCriticalRegion(); KeLeaveCriticalRegion();
CheckApcs(0, 0, FALSE, PASSIVE_LEVEL); CheckApcs(0, 0, FALSE, PASSIVE_LEVEL);
KeEnterCriticalRegion(); KeEnterCriticalRegion();
CheckApcs(-1, 0, FALSE, PASSIVE_LEVEL); CheckApcs(-1, 0, FALSE, PASSIVE_LEVEL);
KeRaiseIrql(HIGH_LEVEL, &Irql); KeRaiseIrql(HIGH_LEVEL, &Irql);
CheckApcs(-1, 0, TRUE, HIGH_LEVEL); CheckApcs(-1, 0, TRUE, HIGH_LEVEL);
KeEnterGuardedRegion(); KeEnterGuardedRegion();
CheckApcs(-1, -1, TRUE, HIGH_LEVEL); CheckApcs(-1, -1, TRUE, HIGH_LEVEL);
KeLeaveCriticalRegion(); KeLeaveCriticalRegion();
CheckApcs(0, -1, TRUE, HIGH_LEVEL); CheckApcs(0, -1, TRUE, HIGH_LEVEL);
KeLowerIrql(Irql); KeLowerIrql(Irql);
CheckApcs(0, -1, TRUE, PASSIVE_LEVEL); CheckApcs(0, -1, TRUE, PASSIVE_LEVEL);
KeLeaveGuardedRegion(); KeLeaveGuardedRegion();
CheckApcs(0, 0, FALSE, PASSIVE_LEVEL); CheckApcs(0, 0, FALSE, PASSIVE_LEVEL);
}
KeEnterCriticalRegion(); KeEnterCriticalRegion();
CheckApcs(-1, 0, FALSE, PASSIVE_LEVEL); CheckApcs(-1, 0, FALSE, PASSIVE_LEVEL);