]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
Added cgconfigparser test with fperm and dperm config options
authorJan Safranek <jsafrane@redhat.com>
Tue, 27 Sep 2011 06:50:09 +0000 (08:50 +0200)
committerJan Safranek <jsafrane@redhat.com>
Tue, 27 Sep 2011 06:50:09 +0000 (08:50 +0200)
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
tests/tools/cgconfigparser/Makefile.am
tests/tools/cgconfigparser/cgconfigparser_conf_files/permissions.conf [new file with mode: 0644]
tests/tools/cgconfigparser/permissions [new file with mode: 0755]

index 0866813680d992f1dea16ad8b18a88c36edeba93..1bf0ef882c16c36b16ac2e03482ea8eddbd943ae 100644 (file)
@@ -3,6 +3,7 @@ EXTRA_DIST = cgconfigparser_simple \
              cgconfigparser_conf_files/cgconfig.conf.5.ex1 \
              cgconfigparser_conf_files/cgconfig.conf.5.ex2 \
              cgconfigparser_conf_files/cgconfig.conf.5.ex3 \
-             cgconfigparser_conf_files/cgconfig.conf.5.ex4
+             cgconfigparser_conf_files/cgconfig.conf.5.ex4 \
+             cgconfigparser_conf_files/permissions.conf
 
-TESTS = cgconfigparser_simple cgconfigparser_conf_files_tests
+TESTS = cgconfigparser_simple cgconfigparser_conf_files_tests permissions
diff --git a/tests/tools/cgconfigparser/cgconfigparser_conf_files/permissions.conf b/tests/tools/cgconfigparser/cgconfigparser_conf_files/permissions.conf
new file mode 100644 (file)
index 0000000..e61f4e1
--- /dev/null
@@ -0,0 +1,42 @@
+              mount {
+                     cpu = /TMP/cgroups/cpu;
+                     cpuacct = /TMP/cgroups/cpu;
+              }
+
+              group daemons/www {
+                     perm {
+                            task {
+                                   uid = root;
+                                   gid = nobody;
+                                   fperm = 750;
+                            }
+                            admin {
+                                   uid = root;
+                                   gid = root;
+                                   dperm = 770;
+                                   fperm = 777;
+                            }
+                     }
+                     cpu {
+                            cpu.shares = "1000";
+                     }
+              }
+
+              group daemons/ftp {
+                     perm {
+                            task {
+                                   uid = root;
+                                   gid = nobody;
+                                   fperm = 274;
+                            }
+                            admin {
+                                   uid = root;
+                                   gid = root;
+                                   dperm = 742;
+                                   fperm = 427;
+                            }
+                     }
+                     cpu {
+                            cpu.shares = "500";
+                     }
+              }
diff --git a/tests/tools/cgconfigparser/permissions b/tests/tools/cgconfigparser/permissions
new file mode 100755 (executable)
index 0000000..2caba3f
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/bash
+# this script tests fperm and dperm configuration options
+
+
+. `dirname $0`/../testenv.sh
+
+CONFDIR=$TESTDIR/tools/cgconfigparser/cgconfigparser_conf_files
+
+# all mount points are in /$TMP/cgroups
+mkdir /$TMP/cgroups/ 2>/dev/null
+$TOOLSDIR/cgconfigparser -l `prepare_config $CONFDIR/permissions.conf` || \
+    die "cgconfigparser -l $CONFDIR/permissions.conf failed"
+
+# permissions test
+function check_perm()
+{
+    STEP=$1
+    FILENAME=$2
+    EXPECTED=$3
+    REAL=`stat -c "%a" $FILENAME`
+    if [ "$EXPECTED" != "$REAL" ]; then
+        die "$STEP: Wrong permissions of $FILENAME,"\
+            " expected $EXPECTED, actual $REAL"
+    fi
+}
+
+check_perm "STEP1" "/$TMP/cgroups/cpu/daemons/www" 770
+check_perm "STEP1" "/$TMP/cgroups/cpu/daemons/www/cpu.shares" 666
+check_perm "STEP1" "/$TMP/cgroups/cpu/daemons/www/tasks" 640
+
+check_perm "STEP1" "/$TMP/cgroups/cpu/daemons/ftp" 742
+check_perm "STEP1" "/$TMP/cgroups/cpu/daemons/ftp/cpu.shares" 426
+check_perm "STEP1" "/$TMP/cgroups/cpu/daemons/ftp/tasks" 264
+
+$TOOLSDIR/cgclear || die "cgclear failed"
+
+cleanup
+exit 0