1
0
mirror of https://github.com/lxc/lxcfs.git synced 2026-02-05 09:46:18 +01:00
Files
lxcfs/tests/test_meminfo_hierarchy.sh
Christian Brauner db0463bf22 tree-wide: align lxcfs and lxc licensing
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-05 12:06:52 +01:00

40 lines
817 B
Bash
Executable File

#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
set -eux
LXCFSDIR=${LXCFSDIR:-/var/lib/lxcfs}
cg1=$(uuidgen).$$
cg2=$(uuidgen).$$
cleanup() {
if [ $FAILED -eq 1 ]; then
echo "Failed"
exit 1
fi
echo "Passed"
exit 0
}
FAILED=1
trap cleanup EXIT HUP INT TERM
[ ! -d /sys/fs/cgroup/memory ] && exit 0
initmemory=`awk -F: '/memory/ { print $3 }' /proc/1/cgroup`
mempath=/sys/fs/cgroup/memory/${initmemory}
rmdir ${mempath}/${cg1} || true
rmdir ${mempath}/${cg2} || true
mkdir ${mempath}/${cg1}
echo 500000000 > ${mempath}/${cg1}/memory.limit_in_bytes
echo 1 > ${mempath}/${cg1}/tasks
m1=`awk '/^MemTotal:/ { print $2 }' ${LXCFSDIR}/proc/meminfo`
mkdir ${mempath}/${cg1}/${cg2}
echo 1 > ${mempath}/${cg1}/${cg2}/tasks
m2=`awk '/^MemTotal:/ { print $2 }' ${LXCFSDIR}/proc/meminfo`
[ $m1 -eq $m2 ]
FAILED=0