From 08c3f0f7379eabe51cd965d0dc35626d8939ae27 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Tue, 19 Dec 2023 15:06:11 +0100 Subject: Add test proc/meminfo file and corresponding test --- plugins/tests/test_check_swap.c | 7 ++++-- plugins/tests/var/proc_meminfo | 55 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 plugins/tests/var/proc_meminfo (limited to 'plugins/tests') diff --git a/plugins/tests/test_check_swap.c b/plugins/tests/test_check_swap.c index 42ac0086..86ab188f 100644 --- a/plugins/tests/test_check_swap.c +++ b/plugins/tests/test_check_swap.c @@ -13,9 +13,12 @@ int main() { swap_config config = swap_config_init(); - swap_result test_data = get_swap_data(config); + swap_result test_data = getSwapFromProcMeminfo(config, "./var/proc_meminfo"); - plan_tests(1); + plan_tests(4); ok(test_data.errorcode == 0, "Test whether we manage to retrieve swap data"); + ok(test_data.metrics.total == 34233905152, "Is the total Swap correct"); + ok(test_data.metrics.free == 34231021568, "Is the free Swap correct"); + ok(test_data.metrics.used == 0, "Is the used Swap correct"); } diff --git a/plugins/tests/var/proc_meminfo b/plugins/tests/var/proc_meminfo new file mode 100644 index 00000000..8c94c4e5 --- /dev/null +++ b/plugins/tests/var/proc_meminfo @@ -0,0 +1,55 @@ +MemTotal: 32767776 kB +MemFree: 1693508 kB +MemAvailable: 23807480 kB +Buffers: 438456 kB +Cached: 19124976 kB +SwapCached: 136 kB +Active: 7860680 kB +Inactive: 18886776 kB +Active(anon): 6108756 kB +Inactive(anon): 1364500 kB +Active(file): 1751924 kB +Inactive(file): 17522276 kB +Unevictable: 8548 kB +Mlocked: 8548 kB +SwapTotal: 33431548 kB +SwapFree: 33428732 kB +Zswap: 0 kB +Zswapped: 0 kB +Dirty: 784 kB +Writeback: 0 kB +AnonPages: 7139968 kB +Mapped: 1094916 kB +Shmem: 284160 kB +KReclaimable: 3303788 kB +Slab: 3801908 kB +SReclaimable: 3303788 kB +SUnreclaim: 498120 kB +KernelStack: 32992 kB +PageTables: 68160 kB +SecPageTables: 0 kB +NFS_Unstable: 0 kB +Bounce: 0 kB +WritebackTmp: 0 kB +CommitLimit: 49815436 kB +Committed_AS: 16888536 kB +VmallocTotal: 34359738367 kB +VmallocUsed: 91200 kB +VmallocChunk: 0 kB +Percpu: 41472 kB +HardwareCorrupted: 0 kB +AnonHugePages: 1708032 kB +ShmemHugePages: 0 kB +ShmemPmdMapped: 0 kB +FileHugePages: 0 kB +FilePmdMapped: 0 kB +Unaccepted: 0 kB +HugePages_Total: 0 +HugePages_Free: 0 +HugePages_Rsvd: 0 +HugePages_Surp: 0 +Hugepagesize: 2048 kB +Hugetlb: 0 kB +DirectMap4k: 860468 kB +DirectMap2M: 20023296 kB +DirectMap1G: 12582912 kB -- cgit v1.2.3-74-g34f1