tests: add requires cgroups_kmem
On older kernels or kernels were CONFIG_MEMCG_KMEM is not set some cgroup tests cannot be run. We simply test for the existence of the file "${CGROUP_BASE_PATH}/memory/memory.kmem.limit_in_bytes" which should be sufficient to conclude that CONFIG_MEMCG_KMEM is not set. Signed-off-by: Christian Brauner <cbrauner@suse.de>
This commit is contained in:
parent
142df3836b
commit
7c59766049
|
@ -2,13 +2,8 @@
|
|||
|
||||
load helpers
|
||||
|
||||
CGROUP_MEMORY=""
|
||||
TEST_CGROUP_NAME="runc-cgroups-integration-test"
|
||||
|
||||
function init_cgroup_path() {
|
||||
base_path=$(grep "cgroup" /proc/self/mountinfo | gawk 'toupper($NF) ~ /\<MEMORY\>/ { print $5; exit }')
|
||||
CGROUP_MEMORY="${base_path}/${TEST_CGROUP_NAME}"
|
||||
}
|
||||
CGROUP_MEMORY="${CGROUP_BASE_PATH}/${TEST_CGROUP_NAME}"
|
||||
|
||||
function teardown() {
|
||||
rm -f $BATS_TMPDIR/runc-update-integration-test.json
|
||||
|
@ -19,7 +14,6 @@ function teardown() {
|
|||
function setup() {
|
||||
teardown
|
||||
setup_busybox
|
||||
init_cgroup_path
|
||||
}
|
||||
|
||||
function check_cgroup_value() {
|
||||
|
@ -34,6 +28,7 @@ function check_cgroup_value() {
|
|||
}
|
||||
|
||||
@test "runc update --kernel-memory (initialized)" {
|
||||
requires cgroups_kmem
|
||||
# Add cgroup path
|
||||
sed -i 's/\("linux": {\)/\1\n "cgroupsPath": "runc-cgroups-integration-test",/' ${BUSYBOX_BUNDLE}/config.json
|
||||
|
||||
|
@ -61,6 +56,7 @@ EOF
|
|||
}
|
||||
|
||||
@test "runc update --kernel-memory (uninitialized)" {
|
||||
requires cgroups_kmem
|
||||
# Add cgroup path
|
||||
sed -i 's/\("linux": {\)/\1\n "cgroupsPath": "runc-cgroups-integration-test",/' ${BUSYBOX_BUNDLE}/config.json
|
||||
|
||||
|
|
|
@ -28,6 +28,12 @@ KERNEL_MINOR="${KERNEL_MINOR%%.*}"
|
|||
# Root state path.
|
||||
ROOT="$BATS_TMPDIR/runc"
|
||||
|
||||
# Cgroup mount
|
||||
CGROUP_BASE_PATH=$(grep "cgroup" /proc/self/mountinfo | gawk 'toupper($NF) ~ /\<MEMORY\>/ { print $5; exit }')
|
||||
|
||||
# CONFIG_MEMCG_KMEM support
|
||||
KMEM="${CGROUP_BASE_PATH}/memory.kmem.limit_in_bytes"
|
||||
|
||||
# Wrapper for runc.
|
||||
function runc() {
|
||||
run __runc "$@"
|
||||
|
@ -59,6 +65,11 @@ function requires() {
|
|||
skip "Test requires ${var}."
|
||||
fi
|
||||
;;
|
||||
cgroups_kmem)
|
||||
if [ ! -e "$KMEM" ]; then
|
||||
skip "Test requires ${var}."
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
fail "BUG: Invalid requires ${var}."
|
||||
;;
|
||||
|
|
|
@ -48,6 +48,7 @@ function check_cgroup_value() {
|
|||
}
|
||||
|
||||
@test "update" {
|
||||
requires cgroups_kmem
|
||||
# run a few busyboxes detached
|
||||
runc run -d --console /dev/pts/ptmx test_update
|
||||
[ "$status" -eq 0 ]
|
||||
|
|
Loading…
Reference in New Issue