From c823933fe14e2a8bd04793137a6e6dd130766e4b Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Tue, 10 May 2016 21:54:22 +1000 Subject: [PATCH] integration: fix cgroup parsing On some systems, the cgroup hierarchies are grouped together (cpu,cpuacct). In order to avoid fake failures, update the cgroup parsing to just check whether or not the mountinfo options *contain* the cgroup type. Signed-off-by: Aleksa Sarai --- script/test_Dockerfile | 1 + tests/integration/cgroups.bats | 4 ++-- tests/integration/update.bats | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/script/test_Dockerfile b/script/test_Dockerfile index bbb8af45..91641209 100644 --- a/script/test_Dockerfile +++ b/script/test_Dockerfile @@ -6,6 +6,7 @@ RUN echo 'deb http://httpredir.debian.org/debian jessie-backports main' > /etc/a RUN apt-get update && apt-get install -y \ build-essential \ curl \ + gawk \ iptables \ libaio-dev \ libcap-dev \ diff --git a/tests/integration/cgroups.bats b/tests/integration/cgroups.bats index a48024d0..5d63b153 100644 --- a/tests/integration/cgroups.bats +++ b/tests/integration/cgroups.bats @@ -9,8 +9,8 @@ CGROUP_MEMORY="" TEST_CGROUP_NAME="runc-cgroups-integration-test" function init_cgroup_path() { - base_path=$(grep "rw," /proc/self/mountinfo | grep -i -m 1 'MEMORY$' | cut -d ' ' -f 5) - CGROUP_MEMORY="${base_path}/${TEST_CGROUP_NAME}" + base_path=$(grep "cgroup" /proc/self/mountinfo | gawk 'toupper($NF) ~ /\/ { print $5; exit }') + CGROUP_MEMORY="${base_path}/${TEST_CGROUP_NAME}" } function teardown() { diff --git a/tests/integration/update.bats b/tests/integration/update.bats index 036aa608..fe1a0401 100644 --- a/tests/integration/update.bats +++ b/tests/integration/update.bats @@ -11,7 +11,7 @@ CGROUP_BLKIO="" function init_cgroup_path() { for g in MEMORY CPUSET CPU BLKIO; do - base_path=$(grep "rw," /proc/self/mountinfo | grep -i -m 1 "$g\$" | cut -d ' ' -f 5) + base_path=$(grep "cgroup" /proc/self/mountinfo | gawk 'toupper($NF) ~ /\<'${g}'\>/ { print $5; exit }') eval CGROUP_${g}="${base_path}/runc-update-integration-test" done }