From 5058d87a7e7fea00564b1b5cadbb75b0634a5857 Mon Sep 17 00:00:00 2001 From: Balbir Singh Date: Wed, 17 Dec 2008 15:02:54 +0000 Subject: [PATCH] libcgroup Test: libcgrouptest-multimnt-sanitycheck Hi The following patch adds the sanity check in c file for multiple mount case. The parameter passed to the function decides whether the check is for single mount or multiple mount. Signed-off-by: Sudhir Kumar git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@246 4f4bb910-9a46-0410-90c8-c897d4f1cd53 --- tests/libcgrouptest.h | 2 +- tests/libcgrouptest01.c | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/tests/libcgrouptest.h b/tests/libcgrouptest.h index 63696fc1..35832891 100644 --- a/tests/libcgrouptest.h +++ b/tests/libcgrouptest.h @@ -68,7 +68,7 @@ static int set_controller(int controller, char *controller_name, static int group_modified(char *path_control_file, int value_type); struct cgroup *new_cgroup(char *group, char *controller_name, char *control_file, int value_type); -int check_fsmounted(); +int check_fsmounted(int multimnt); static int check_task(char *tasksfile); static inline pid_t cgrouptest_gettid() diff --git a/tests/libcgrouptest01.c b/tests/libcgrouptest01.c index 2139ffa3..7cd70c42 100644 --- a/tests/libcgrouptest01.c +++ b/tests/libcgrouptest01.c @@ -159,7 +159,7 @@ int main(int argc, char *argv[]) case FS_MOUNTED: /* Do a sanity check if cgroup fs is mounted */ - if (check_fsmounted()) { + if (check_fsmounted(0)) { printf("Sanity check fails. cgroup fs not mounted\n"); printf("Exiting without running this set of tests\n"); exit(1); @@ -397,6 +397,14 @@ int main(int argc, char *argv[]) break; case FS_MULTI_MOUNTED: + + /* Do a sanity check if cgroup fs is multi mounted */ + if (check_fsmounted(1)) { + printf("Sanity check fails. cgroup fs not multi mounted\n"); + printf("Exiting without running this set of tests\n"); + exit(1); + } + /* * Test01: call apis and check return values * Exp outcome: @@ -862,8 +870,9 @@ struct cgroup *new_cgroup(char *group, char *controller_name, return newcgroup; } -int check_fsmounted() +int check_fsmounted(int multimnt) { + int count = 0; struct mntent *entry, *tmp_entry; /* Need a better mechanism to decide memory allocation size here */ char entry_buffer[FILENAME_MAX * 4]; @@ -882,8 +891,16 @@ int check_fsmounted() } while ((entry = getmntent_r(proc_file, tmp_entry, entry_buffer, FILENAME_MAX*4)) != NULL) { if (!strncmp(entry->mnt_type, "cgroup", strlen("cgroup"))) { - printf("sanity check pass.... %s\n", entry->mnt_type); - return 0; + count++; + if (multimnt) { + if (count >= 2) { + printf("sanity check pass.... %s\n", entry->mnt_type); + return 0; + } + } else { + printf("sanity check pass.... %s\n", entry->mnt_type); + return 0; + } } } return 1; -- 2.47.2