]>
Commit | Line | Data |
---|---|---|
906f4458 CB |
1 | #!/bin/sh |
2 | # SPDX-License-Identifier: LGPL-2.1+ | |
3 | ||
4 | set -eu | |
5 | [ -n "${DEBUG:-}" ] && set -x | |
6 | ||
7 | PASS=0 | |
8 | ||
9 | cleanup() { | |
10 | [ "$PASS" = "1" ] || (echo FAIL && exit 1) | |
11 | } | |
12 | ||
13 | trap cleanup EXIT HUP INT TERM | |
14 | ||
15 | LXCFSDIR=${LXCFSDIR:-/var/lib/lxcfs} | |
16 | ||
17 | if ! mountpoint -q ${LXCFSDIR}; then | |
18 | echo "lxcfs isn't mounted on ${LXCFSDIR}" | |
19 | exit 1 | |
20 | fi | |
21 | ||
ce26ced7 CB |
22 | echo "==> Setting up memory cgroup in lxcfs_test_proc" |
23 | [ ! -d /sys/fs/cgroup/memory ] && exit 0 | |
906f4458 | 24 | |
ce26ced7 CB |
25 | initmemory=`awk -F: '/memory/ { print $3 }' /proc/1/cgroup` |
26 | mempath=/sys/fs/cgroup/memory/${initmemory} | |
27 | rmdir ${mempath}/lxcfs_test_proc 2>/dev/null || true | |
28 | mkdir ${mempath}/lxcfs_test_proc | |
29 | echo 1 > ${mempath}/lxcfs_test_proc/tasks | |
30 | ||
31 | echo $((64*1024*1024)) > ${mempath}/lxcfs_test_proc/memory.limit_in_bytes | |
32 | ||
33 | # Test meminfo | |
34 | echo "==> Testing /proc/meminfo" | |
35 | [ "$(grep "^MemTotal:.*kB$" ${LXCFSDIR}/proc/meminfo)" = "$(grep "^MemTotal:.*kB$" /proc/meminfo)" ] | |
906f4458 CB |
36 | |
37 | PASS=1 |