Author: tfaber
Date: Wed Oct 3 20:52:33 2012
New Revision: 57469
URL:
http://svn.reactos.org/svn/reactos?rev=57469&view=rev
Log:
[KMTEST:KE]
- Show that Mutexes disable APCs when acquired, while Mutants don't
Modified:
trunk/rostests/kmtests/ntos_ke/KeMutex.c
Modified: trunk/rostests/kmtests/ntos_ke/KeMutex.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/ntos_ke/KeMutex.c…
==============================================================================
--- trunk/rostests/kmtests/ntos_ke/KeMutex.c [iso-8859-1] (original)
+++ trunk/rostests/kmtests/ntos_ke/KeMutex.c [iso-8859-1] Wed Oct 3 20:52:33 2012
@@ -51,43 +51,88 @@
ok_eq_uint((Mutex)->ApcDisable, ExpectedApcDisable); \
} while (0)
+#define CheckApcs(KernelApcsDisabled, SpecialApcsDisabled, AllApcsDisabled, Irql) do
\
+{
\
+ ok_eq_bool(KeAreApcsDisabled(), KernelApcsDisabled || SpecialApcsDisabled);
\
+ ok_eq_int(Thread->KernelApcDisable, KernelApcsDisabled);
\
+ ok_eq_bool(KeAreAllApcsDisabled(), AllApcsDisabled);
\
+ ok_eq_int(Thread->SpecialApcDisable, SpecialApcsDisabled);
\
+ ok_irql(Irql);
\
+} while (0)
+
static
VOID
TestMutant(VOID)
{
+ NTSTATUS Status;
KMUTANT Mutant;
LONG State;
+ PKTHREAD Thread = KeGetCurrentThread();
+ CheckApcs(0, 0, FALSE, PASSIVE_LEVEL);
RtlFillMemory(&Mutant, sizeof(Mutant), 0x55);
KeInitializeMutant(&Mutant, FALSE);
- ok_irql(PASSIVE_LEVEL);
CheckMutex(&Mutant, FALSE, TRUE, 0);
+ CheckApcs(0, 0, FALSE, PASSIVE_LEVEL);
RtlFillMemory(&Mutant, sizeof(Mutant), 0x55);
KeInitializeMutant(&Mutant, TRUE);
- ok_irql(PASSIVE_LEVEL);
+ CheckApcs(0, 0, FALSE, PASSIVE_LEVEL);
CheckMutex(&Mutant, TRUE, TRUE, 0);
State = KeReleaseMutant(&Mutant, 1, FALSE, FALSE);
ok_eq_long(State, 0);
- ok_irql(PASSIVE_LEVEL);
CheckMutex(&Mutant, FALSE, FALSE, 0);
+ CheckApcs(0, 0, FALSE, PASSIVE_LEVEL);
+
+ /* Acquire and release */
+ Status = KeWaitForSingleObject(&Mutant,
+ Executive,
+ KernelMode,
+ FALSE,
+ NULL);
+ ok_eq_hex(Status, STATUS_SUCCESS);
+ CheckMutex(&Mutant, TRUE, TRUE, 0);
+ CheckApcs(0, 0, FALSE, PASSIVE_LEVEL);
+
+ State = KeReleaseMutant(&Mutant, 1, FALSE, FALSE);
+ ok_eq_long(State, 0);
+ CheckMutex(&Mutant, FALSE, FALSE, 0);
+ CheckApcs(0, 0, FALSE, PASSIVE_LEVEL);
}
static
VOID
TestMutex(VOID)
{
+ NTSTATUS Status;
KMUTEX Mutex;
+ LONG State;
+ PKTHREAD Thread = KeGetCurrentThread();
+ CheckApcs(0, 0, FALSE, PASSIVE_LEVEL);
RtlFillMemory(&Mutex, sizeof(Mutex), 0x55);
KeInitializeMutex(&Mutex, 0);
- ok_irql(PASSIVE_LEVEL);
CheckMutex(&Mutex, FALSE, TRUE, 1);
+ CheckApcs(0, 0, FALSE, PASSIVE_LEVEL);
RtlFillMemory(&Mutex, sizeof(Mutex), 0x55);
KeInitializeMutex(&Mutex, 123);
- ok_irql(PASSIVE_LEVEL);
CheckMutex(&Mutex, FALSE, TRUE, 1);
+ CheckApcs(0, 0, FALSE, PASSIVE_LEVEL);
+
+ Status = KeWaitForSingleObject(&Mutex,
+ Executive,
+ KernelMode,
+ FALSE,
+ NULL);
+ ok_eq_hex(Status, STATUS_SUCCESS);
+ CheckMutex(&Mutex, TRUE, FALSE, 1);
+ CheckApcs(-1, 0, FALSE, PASSIVE_LEVEL);
+
+ State = KeReleaseMutex(&Mutex, FALSE);
+ ok_eq_long(State, 0);
+ CheckMutex(&Mutex, FALSE, FALSE, 1);
+ CheckApcs(0, 0, FALSE, PASSIVE_LEVEL);
}
START_TEST(KeMutex)