X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/eb6b6ca394357805f2bdba989abae309f718b4d8..f427ee49d309d8fc33ebf3042c3a775f2f530ded:/tests/pid_for_task_test.c?ds=sidebyside diff --git a/tests/pid_for_task_test.c b/tests/pid_for_task_test.c new file mode 100644 index 000000000..8f8437eb9 --- /dev/null +++ b/tests/pid_for_task_test.c @@ -0,0 +1,17 @@ +#include +#include +#include + +T_DECL(pid_for_task_test, "Test pid_for_task with task name port") +{ + kern_return_t kr; + mach_port_t tname; + pid_t pid; + + kr = task_name_for_pid(mach_task_self(), getpid(), &tname); + T_EXPECT_EQ(kr, 0, "task_name_for_pid should succeed on current pid"); + pid_for_task(tname, &pid); + T_EXPECT_EQ(pid, getpid(), "pid_for_task should return the same value as getpid()"); + + mach_port_deallocate(mach_task_self(), tname); +}