| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
#include "testutils.h" |
| 24 |
|
| 25 |
|
| 26 |
static _Noreturn void print_version (void) __attribute__((unused)); |
| 27 |
static _Noreturn void usage (FILE * out) __attribute__((unused)); |
| 28 |
|
| 29 |
#define NPL_TESTING |
| 30 |
# include "../plugins/check_paging.c" |
| 31 |
#undef NPL_TESTING |
| 32 |
|
| 33 |
static int |
| 34 |
test_paging_summary (const void *tdata) |
| 35 |
{ |
| 36 |
int ret = 0; |
| 37 |
const char *env_variable = "NPL_TEST_PATH_PROCVMSTAT"; |
| 38 |
paging_data_t paging; |
| 39 |
|
| 40 |
if (setenv (env_variable, NPL_TEST_PATH_PROCVMSTAT, 1) < 0) |
| 41 |
return EXIT_AM_HARDFAIL; |
| 42 |
|
| 43 |
#define CHECK_SUMMARY(SWAPPING_ONLY) \ |
| 44 |
do \ |
| 45 |
{ \ |
| 46 |
get_paging_status (true, SWAPPING_ONLY, &paging); \ |
| 47 |
unsigned long summary = \ |
| 48 |
SWAPPING_ONLY ? (paging.dpswpin + \ |
| 49 |
paging.dpswpout) : paging.dpgmajfault; \ |
| 50 |
if (summary != paging.summary) \ |
| 51 |
ret = -1; \ |
| 52 |
} \ |
| 53 |
while (0) |
| 54 |
|
| 55 |
CHECK_SUMMARY (true); |
| 56 |
CHECK_SUMMARY (false); |
| 57 |
|
| 58 |
return ret; |
| 59 |
} |
| 60 |
|
| 61 |
static int |
| 62 |
mymain (void) |
| 63 |
{ |
| 64 |
int ret = 0; |
| 65 |
|
| 66 |
#define DO_TEST(MSG, FUNC, DATA) \ |
| 67 |
do { if (test_run (MSG, FUNC, DATA) < 0) ret = -1; } while (0) |
| 68 |
|
| 69 |
DO_TEST ("check for get_paging_status() paging.summary", |
| 70 |
test_paging_summary, NULL); |
| 71 |
|
| 72 |
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; |
| 73 |
} |
| 74 |
|
| 75 |
TEST_MAIN (mymain) |