]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
libcgroup Test: libcgrouptest-multimnt-sanitycheck
authorBalbir Singh <balbir@linux.vnet.ibm.com>
Wed, 17 Dec 2008 15:02:54 +0000 (15:02 +0000)
committerBalbir Singh <balbir@linux.vnet.ibm.com>
Wed, 17 Dec 2008 15:02:54 +0000 (15:02 +0000)
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 <skumar@linux.vnet.ibm.com>
git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@246 4f4bb910-9a46-0410-90c8-c897d4f1cd53

tests/libcgrouptest.h
tests/libcgrouptest01.c

index 63696fc17d4b38d901ad143fae259943367776f2..35832891738ebfa8a33d8197a12f4701d1c29cef 100644 (file)
@@ -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()
index 2139ffa35a7c1a60825101e04c067b5903e5f662..7cd70c427fba18424a5efdc444dc95d89adf085f 100644 (file)
@@ -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;