Skip to content

Commit

Permalink
test owner_pid for threads in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbo committed Mar 5, 2024
1 parent d3d302d commit 44be9b5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/unit/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ char *test_LM_EnumThreads(struct thread_args *thrarg)

mu_assert("failed to enumerate threads", LM_EnumThreads(_LM_EnumThreadsCallback, (lm_void_t *)&arg) == LM_TRUE);
mu_assert("could not find current thread", arg.check == LM_TRUE);
mu_assert("thread owner_pid does not match the expected process id", arg.thread->owner_pid == thrarg->pcurproc->pid);
mu_assert("function attempted to run with bad arguments", LM_EnumThreads(LM_NULLPTR, LM_NULLPTR) == LM_FALSE);

return NULL;
Expand All @@ -50,6 +51,7 @@ char *test_LM_GetThreadEx(struct thread_args *thrarg)

mu_assert("failed to get a thread from the target process", LM_GetThreadEx(ptargetproc, ptargetthread) == LM_TRUE);
mu_assert("retrieved thread is invalid", CHECK_THREAD(ptargetthread));
mu_assert("thread owner_pid does not match the expected process id", ptargetthread->owner_pid == ptargetproc->pid);
mu_assert("function attempted to run with bad arguments (invalid proc)", LM_GetThreadEx(LM_NULLPTR, ptargetthread) == LM_FALSE);
mu_assert("function attempted to run with bad arguments (invalid thread)", LM_GetThreadEx(ptargetproc, LM_NULLPTR) == LM_FALSE);

Expand All @@ -66,6 +68,7 @@ char *test_LM_EnumThreadsEx(struct thread_args *thrarg)

mu_assert("failed to enumerate threads", LM_EnumThreadsEx(ptargetproc, _LM_EnumThreadsCallback, (lm_void_t *)&arg) == LM_TRUE);
mu_assert("could not find retrieved thread", arg.check == LM_TRUE);
mu_assert("thread owner_pid does not match the expected process id", arg.thread->owner_pid == ptargetproc->pid);
mu_assert("function attempted to run with bad arguments (invalid proc)", LM_EnumThreadsEx(LM_NULLPTR, _LM_EnumThreadsCallback, LM_NULLPTR) == LM_FALSE);
mu_assert("function attempted to run with bad arguments (invalid callback)", LM_EnumThreadsEx(ptargetproc, LM_NULLPTR, LM_NULLPTR) == LM_FALSE);

Expand All @@ -85,4 +88,4 @@ char *test_LM_GetThreadProcess(struct thread_args *thrarg)
mu_assert("function attempted to run with bad arguments (invalid proc)", LM_GetThreadProcess(pcurthread, LM_NULLPTR) == LM_FALSE);

return NULL;
}
}

0 comments on commit 44be9b5

Please sign in to comment.