2020-08-15 22:42:12 +05:30
|
|
|
/*
|
|
|
|
* 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>
|
|
|
|
|
2022-08-29 14:32:44 +05:30
|
|
|
#include "diskstats.h"
|
|
|
|
#include "meminfo.h"
|
|
|
|
#include "pids.h"
|
|
|
|
#include "slabinfo.h"
|
|
|
|
#include "stat.h"
|
|
|
|
#include "vmstat.h"
|
2020-08-15 22:42:12 +05:30
|
|
|
|
|
|
|
#include "tests.h"
|
|
|
|
|
|
|
|
static int check_diskstats (void *data) {
|
2020-08-17 18:17:39 +05:30
|
|
|
struct diskstats_info *ctx = NULL;
|
2020-08-15 22:42:12 +05:30
|
|
|
testname = "Itemtable check, diskstats";
|
2020-08-17 22:42:12 +05:30
|
|
|
if (0 == procps_diskstats_new(&ctx))
|
|
|
|
procps_diskstats_unref(&ctx);
|
|
|
|
return 1;
|
2020-08-15 22:42:12 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
static int check_meminfo (void *data) {
|
2020-08-17 18:17:39 +05:30
|
|
|
struct meminfo_info *ctx = NULL;
|
2020-08-15 22:42:12 +05:30
|
|
|
testname = "Itemtable check, meminfo";
|
2020-08-17 22:42:12 +05:30
|
|
|
if (0 == procps_meminfo_new(&ctx))
|
|
|
|
procps_meminfo_unref(&ctx);
|
|
|
|
return 1;
|
2020-08-15 22:42:12 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
static int check_pids (void *data) {
|
2020-08-17 22:42:12 +05:30
|
|
|
struct pids_info *ctx = NULL;
|
2020-08-15 22:42:12 +05:30
|
|
|
testname = "Itemtable check, pids";
|
2020-08-17 22:42:12 +05:30
|
|
|
if (0 == procps_pids_new(&ctx, NULL, 0))
|
|
|
|
procps_pids_unref(&ctx);
|
|
|
|
return 1;
|
2020-08-15 22:42:12 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
static int check_slabinfo (void *data) {
|
2020-08-17 18:17:39 +05:30
|
|
|
struct slabinfo_info *ctx = NULL;
|
2020-08-15 22:42:12 +05:30
|
|
|
testname = "Itemtable check, slabinfo";
|
2020-08-17 22:42:12 +05:30
|
|
|
if (0 == procps_slabinfo_new(&ctx))
|
|
|
|
procps_slabinfo_unref(&ctx);
|
|
|
|
return 1;
|
2020-08-15 22:42:12 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
static int check_stat (void *data) {
|
2020-08-17 18:17:39 +05:30
|
|
|
struct stat_info *ctx = NULL;
|
2020-08-15 22:42:12 +05:30
|
|
|
testname = "Itemtable check, stat";
|
2020-08-17 22:42:12 +05:30
|
|
|
if (0 == procps_stat_new(&ctx))
|
|
|
|
procps_stat_unref(&ctx);
|
|
|
|
return 1;
|
2020-08-15 22:42:12 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
static int check_vmstat (void *data) {
|
2020-08-17 18:17:39 +05:30
|
|
|
struct vmstat_info *ctx = NULL;
|
2020-08-15 22:42:12 +05:30
|
|
|
testname = "Itemtable check, vmstat";
|
2020-08-17 22:42:12 +05:30
|
|
|
if (0 == procps_vmstat_new(&ctx))
|
|
|
|
procps_vmstat_unref(&ctx);
|
|
|
|
return 1;
|
2020-08-15 22:42:12 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
static TestFunction test_funcs[] = {
|
|
|
|
check_diskstats,
|
|
|
|
check_meminfo,
|
|
|
|
check_pids,
|
2020-08-17 22:42:12 +05:30
|
|
|
check_slabinfo,
|
2020-08-15 22:42:12 +05:30
|
|
|
check_stat,
|
|
|
|
check_vmstat,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
int main (void) {
|
|
|
|
return run_tests(test_funcs, NULL);
|
|
|
|
}
|