mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
[NTDLL_APITEST] Add testcase for process priority class. CORE-16757
Currently the testcase function only addresses the behaviour of getting an unaligned buffer (either of correct length size or not) for now.
This commit is contained in:
parent
f5658fd3b4
commit
fcb156388d
1 changed files with 69 additions and 0 deletions
|
@ -185,6 +185,74 @@ Test_ProcessTimes(void)
|
|||
#undef SPIN_TIME
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
Test_ProcessPriorityClassAlignment(void)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PPROCESS_PRIORITY_CLASS ProcPriority;
|
||||
|
||||
/* Allocate some memory for the priority class structure */
|
||||
ProcPriority = malloc(sizeof(PROCESS_PRIORITY_CLASS));
|
||||
if (ProcPriority == NULL)
|
||||
{
|
||||
skip("Failed to allocate memory for PROCESS_PRIORITY_CLASS!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the PriorityClass member to ensure the test won't randomly succeed (if such data is uninitialized).
|
||||
* Filling 85 to the data member makes sure that if the test fails continously then NtQueryInformationProcess()
|
||||
* didn't initialize the structure with data.
|
||||
*/
|
||||
RtlFillMemory(&ProcPriority->PriorityClass, sizeof(ProcPriority->PriorityClass), 0x55);
|
||||
|
||||
/* Unaligned buffer -- wrong size */
|
||||
Status = NtQueryInformationProcess(NtCurrentProcess(),
|
||||
ProcessPriorityClass,
|
||||
(PVOID)1,
|
||||
0,
|
||||
NULL);
|
||||
ok_hex(Status, STATUS_INFO_LENGTH_MISMATCH);
|
||||
|
||||
/* Unaligned buffer -- correct size */
|
||||
Status = NtQueryInformationProcess(NtCurrentProcess(),
|
||||
ProcessPriorityClass,
|
||||
(PVOID)1,
|
||||
sizeof(PROCESS_PRIORITY_CLASS),
|
||||
NULL);
|
||||
ok_hex(Status, STATUS_DATATYPE_MISALIGNMENT);
|
||||
|
||||
/* Unaligned buffer -- wrong size (but this time do with an alignment of 2) */
|
||||
Status = NtQueryInformationProcess(NtCurrentProcess(),
|
||||
ProcessPriorityClass,
|
||||
(PVOID)2,
|
||||
0,
|
||||
NULL);
|
||||
ok_hex(Status, STATUS_INFO_LENGTH_MISMATCH);
|
||||
|
||||
/* Unaligned buffer -- correct size (but this time do with an alignment of 2) */
|
||||
Status = NtQueryInformationProcess(NtCurrentProcess(),
|
||||
ProcessPriorityClass,
|
||||
(PVOID)2,
|
||||
sizeof(PROCESS_PRIORITY_CLASS),
|
||||
NULL);
|
||||
ok_hex(Status, STATUS_DATATYPE_MISALIGNMENT);
|
||||
|
||||
/* Do not care for the length but expect to return the priority class */
|
||||
Status = NtQueryInformationProcess(NtCurrentProcess(),
|
||||
ProcessPriorityClass,
|
||||
ProcPriority,
|
||||
sizeof(PROCESS_PRIORITY_CLASS),
|
||||
NULL);
|
||||
ok_hex(Status, STATUS_SUCCESS);
|
||||
|
||||
/* Make sure the returned priority class is a valid number (non negative) but also it should be within the PROCESS_PRIORITY_CLASS range */
|
||||
ok(ProcPriority->PriorityClass > PROCESS_PRIORITY_CLASS_INVALID && ProcPriority->PriorityClass <= PROCESS_PRIORITY_CLASS_ABOVE_NORMAL,
|
||||
"Expected a valid number from priority class range but got %d\n", ProcPriority->PriorityClass);
|
||||
free(ProcPriority);
|
||||
}
|
||||
|
||||
START_TEST(NtQueryInformationProcess)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
@ -193,4 +261,5 @@ START_TEST(NtQueryInformationProcess)
|
|||
ok_hex(Status, STATUS_SUCCESS);
|
||||
|
||||
Test_ProcessTimes();
|
||||
Test_ProcessPriorityClassAlignment();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue