Commit 61227252 authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

tests: add a test for memory/devices "specialness"

v2: add cgroup04.hook which removes the cgroups in between, so things are
    actually restored :)
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
CC: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent d52a3522
...@@ -71,6 +71,9 @@ int mount_and_add(const char *controller, const char *path, const char *prop, co ...@@ -71,6 +71,9 @@ int mount_and_add(const char *controller, const char *path, const char *prop, co
if (write_value(paux, aux) < 0) if (write_value(paux, aux) < 0)
goto err_rs; goto err_rs;
sprintf(paux, "%s/%s/special_prop_check", subdir, path);
mkdir(paux, 0600);
return 0; return 0;
err_rs: err_rs:
umount(dirname); umount(dirname);
...@@ -110,6 +113,7 @@ int main(int argc, char **argv) ...@@ -110,6 +113,7 @@ int main(int argc, char **argv)
{ {
int ret = -1, i; int ret = -1, i;
char buf[1024], path[PATH_MAX]; char buf[1024], path[PATH_MAX];
struct stat sb;
char *deny[] = { char *deny[] = {
"c *:* m", "c *:* m",
...@@ -161,9 +165,23 @@ int main(int argc, char **argv) ...@@ -161,9 +165,23 @@ int main(int argc, char **argv)
goto out; goto out;
} }
sprintf(path, "%s/devices/%s/special_prop_check", dirname, cgname);
if (stat(path, &sb) < 0) {
fail("special_prop_check doesn't exist?");
goto out;
}
if (!S_ISDIR(sb.st_mode)) {
fail("special_prop_check not a directory?");
goto out;
}
pass(); pass();
ret = 0; ret = 0;
out: out:
sprintf(path, "%s/devices/%s/special_prop_check", dirname, cgname);
rmdir(path);
sprintf(path, "%s/devices/%s", dirname, cgname); sprintf(path, "%s/devices/%s", dirname, cgname);
rmdir(path); rmdir(path);
sprintf(path, "%s/devices", dirname); sprintf(path, "%s/devices", dirname);
......
#!/bin/bash
[ "$1" == "--clean" -o "$1" == "--pre-restore" ] || exit 0
tname=$(mktemp -d cgclean.XXXXXX)
mount -t cgroup none $tname -o "devices"
echo "Cleaning $tname"
set +e
rmdir "$tname/zdtmtst/special_prop_check"
rmdir "$tname/zdtmtst"
set -e
umount "$tname"
rmdir "$tname"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment