]> granicus.if.org Git - procps-ng/commitdiff
testsuite: Add test for fatal_proc_unmounted
authorCraig Small <csmall@dropbear.xyz>
Mon, 1 Aug 2022 12:23:38 +0000 (22:23 +1000)
committerCraig Small <csmall@dropbear.xyz>
Mon, 1 Aug 2022 12:23:38 +0000 (22:23 +1000)
Adding a check to ensure that fatal_proc_unmounted returns
values for things that do not just sit in /proc/self/stat

References:
 commit 52bd019d8ca09ecfec34b5020eb7b8d612c315f8

proc/test_pids.c

index 633c7298ac357acd8e2914ed83db8f1b97da9459..6435b9551301ac94415dda4477305ec684e4fe1b 100644 (file)
@@ -24,6 +24,7 @@
 #include "tests.h"
 
 enum pids_item items[] = { PIDS_ID_PID, PIDS_ID_PID };
+enum pids_item items2[] = { PIDS_ID_PID, PIDS_VM_RSS };
 
 int check_pids_new_nullinfo(void *data)
 {
@@ -47,10 +48,23 @@ int check_pids_new_and_unref(void *data)
              info == NULL);
 }
 
+int check_fatal_proc_unmounted(void *data)
+{
+    struct pids_info *info = NULL;
+    struct pids_stack *stack;
+    testname = "check_fatal_proc_unmounted";
+
+    return ( (procps_pids_new(&info, items2, 2) == 0) &&
+           ( (stack = fatal_proc_unmounted(info, 1)) != NULL) &&
+           ( PIDS_VAL(0, s_int, stack, info) > 0) &&
+           ( PIDS_VAL(1, u_int, stack, info) > 0));
+}
+
 TestFunction test_funcs[] = {
     check_pids_new_nullinfo,
     // skipped, ask Jim check_pids_new_toomany,
     check_pids_new_and_unref,
+    check_fatal_proc_unmounted,
     NULL };
 
 int main(int argc, char *argv[])