library: Fix pids API tests

Update the pids tests for tweaked API. Unsure why the toomany
test doesn't work, may point to a problem in the change as it used
to trigger, or the library has flexibility.
This commit is contained in:
Craig Small 2016-05-22 22:12:54 +10:00
parent 09503dc597
commit b96c994390

View File

@ -23,31 +23,34 @@
#include <proc/procps.h> #include <proc/procps.h>
#include "tests.h" #include "tests.h"
enum pids_item items[] = { PROCPS_PIDS_ID_PID, PROCPS_PIDS_ID_PID };
int check_pids_new_nullinfo(void *data) int check_pids_new_nullinfo(void *data)
{ {
testname = "procps_pids_new() info=NULL returns -EINVAL"; testname = "procps_pids_new() info=NULL returns -EINVAL";
return (procps_pids_new(NULL, 0, NULL) == -EINVAL); return (procps_pids_new(NULL, items, 0) == -EINVAL);
}
int check_pids_new_enum(void *data)
{
testname = "procps_pids_new() items=enum returns -EINVAL";
struct procps_pidsinfo *info;
return (procps_pids_new(&info, 3, PROCPS_PIDS_noop) == -EINVAL);
} }
int check_pids_new_toomany(void *data) int check_pids_new_toomany(void *data)
{ {
struct procps_pidsinfo *info; struct procps_pidsinfo *info;
enum pids_item items[] = { PROCPS_PIDS_ID_PID, PROCPS_PIDS_ID_PID };
testname = "procps_pids_new() too many items returns -EINVAL"; testname = "procps_pids_new() too many items returns -EINVAL";
return (procps_pids_new(&info, 1, items) == -EINVAL); return (procps_pids_new(&info, items, 1) == -EINVAL);
}
int check_pids_new_and_unref(void *data)
{
struct procps_pidsinfo *info;
testname = "procps_pids new then unref";
return ( (procps_pids_new(&info, items, 2) == 0) &&
(procps_pids_unref(&info) == 0) &&
info == NULL);
} }
TestFunction test_funcs[] = { TestFunction test_funcs[] = {
check_pids_new_nullinfo, check_pids_new_nullinfo,
check_pids_new_enum, // skipped, ask Jim check_pids_new_toomany,
check_pids_new_toomany, check_pids_new_and_unref,
NULL }; NULL };
int main(int argc, char *argv[]) int main(int argc, char *argv[])