]> granicus.if.org Git - procps-ng/commitdiff
build-sys: added a 'test_Itemtables' to testing scheme
authorJim Warner <james.warner@comcast.net>
Sat, 15 Aug 2020 17:12:12 +0000 (12:12 -0500)
committerCraig Small <csmall@dropbear.xyz>
Mon, 17 Aug 2020 11:49:14 +0000 (21:49 +1000)
This change sets the stage for exploiting the recently
added ITEMTABLE_DEBUG #define. All tests are performed
in a single module (after trying 6 separate programs).

The chances of each test detecting errors is extremely
remote (at least while I'm maintaining these modules).
However, this single program approach has one flaw and
it relates to the response whenever an error is found.

Each of those six new API modules calls Exit() if they
detect an error. Otherwise, incorrect results would be
produced at the least or an abend encountered at most.

This means that multiple 'make check' invocations will
be needed if more than 1 module actually was in error.

All in all, it is a small price for a large assurance.

Reference(s):
https://www.freelists.org/post/procps/keep-on-patchin,7

Signed-off-by: Jim Warner <james.warner@comcast.net>
Makefile.am
proc/.gitignore
proc/test_Itemtables.c [new file with mode: 0644]

index a71f4dadcafea22fc6e8468136177a6ef0651721..f3aac7efa71552f9915d11fc59e7ccb164e6094f 100644 (file)
@@ -328,12 +328,15 @@ lib_test_strtod_nol_SOURCES = lib/test_strtod_nol.c lib/strutils.c
 lib_test_strtod_nol_LDADD = $(CYGWINFLAGS)
 
 noinst_PROGRAMS += \
+       proc/test_Itemtables \
        proc/test_pids \
        proc/test_uptime \
        proc/test_sysinfo \
        proc/test_version \
        proc/test_namespace
 
+proc_test_Itemtables_SOURCES = proc/test_Itemtables.c
+proc_test_Itemtables_LDADD = proc/libprocps.la
 proc_test_pids_SOURCES = proc/test_pids.c
 proc_test_pids_LDADD = proc/libprocps.la
 proc_test_uptime_SOURCES = proc/test_uptime.c
@@ -370,6 +373,7 @@ BUILT_SOURCES = $(top_srcdir)/.version
 
 # Test programs not used by dejagnu but run directly
 TESTS = \
+       proc/test_Itemtables \
        proc/test_pids \
        proc/test_uptime \
        proc/test_sysinfo \
index d3b428d97c9c720f7bb917a0e2e9be8c868130e7..a1db999a1614e692683120d6ed20249f7d640384 100644 (file)
@@ -1,3 +1,4 @@
+test_Itemtables
 test_namespace
 test_pids
 test_sysinfo
diff --git a/proc/test_Itemtables.c b/proc/test_Itemtables.c
new file mode 100644 (file)
index 0000000..fd430bf
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * libprocps - Library to read proc filesystem
+ * Tests for Item_table/enumerator synchronization
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <stdlib.h>
+
+#include <proc/diskstats.h>
+#include <proc/meminfo.h>
+#include <proc/pids.h>
+#include <proc/slabinfo.h>
+#include <proc/stat.h>
+#include <proc/vmstat.h>
+
+#include "tests.h"
+
+static int check_diskstats (void *data) {
+    struct diskstats_info *ctx;
+    testname = "Itemtable check, diskstats";
+    procps_diskstats_new(&ctx);
+    procps_diskstats_unref(&ctx);
+    return (1);
+}
+
+static int check_meminfo (void *data) {
+    struct meminfo_info *ctx;
+    testname = "Itemtable check, meminfo";
+    procps_meminfo_new(&ctx);
+    procps_meminfo_unref(&ctx);
+    return (1);
+}
+
+static int check_pids (void *data) {
+    struct pids_info *ctx;
+    testname = "Itemtable check, pids";
+    procps_pids_new(&ctx, NULL, 0);
+    procps_pids_unref(&ctx);
+    return (1);
+}
+
+static int check_slabinfo (void *data) {
+    struct slabinfo_info *ctx;
+    testname = "Itemtable check, slabinfo";
+    procps_slabinfo_new(&ctx);
+    procps_slabinfo_unref(&ctx);
+    return (1);
+}
+
+static int check_stat (void *data) {
+    struct stat_info *ctx;
+    testname = "Itemtable check, stat";
+    procps_stat_new(&ctx);
+    procps_stat_unref(&ctx);
+    return (1);
+}
+
+static int check_vmstat (void *data) {
+    struct vmstat_info *ctx;
+    testname = "Itemtable check, vmstat";
+    procps_vmstat_new(&ctx);
+    procps_vmstat_unref(&ctx);
+    return (1);
+}
+
+static TestFunction test_funcs[] = {
+    check_diskstats,
+    check_meminfo,
+    check_pids,
+    check_slabinfo,
+    check_stat,
+    check_vmstat,
+    NULL
+};
+
+int main (void) {
+    return run_tests(test_funcs, NULL);
+}