GBP: redirect contracts
[vpp.git] / test / sys_req / dev_shm_size.sh
1 #!/bin/sh
2
3 # this script verifies that /dev/shm is big enough for test purposes
4 # 512MB seems to be enough with room to spare at the time of writing this test
5 # (motivation for this check is the default docker /dev/shm size of 64M, which
6 # was occasionally overrun when running the tests)
7 req_min_size_megabytes=512
8
9 cur_size=`df -BM --output=size /dev/shm | awk ' NR==2 { print $1 } ' | cut -f 1 -d 'M'`
10
11 if test "$V" = "2"
12 then
13         echo -n "Checking /dev/shm size..."
14 fi
15
16 if test "$cur_size" -lt "$req_min_size_megabytes"
17 then
18         echo "/dev/shm size ${cur_size}M is too small, attempting to enlarge to ${req_min_size_megabytes}M."
19         sudo mount -o remount /dev/shm -o size=512M
20         cur_size=`df -BM --output=size /dev/shm | awk ' NR==2 { print $1 } ' | cut -f 1 -d 'M'`
21         if test "$cur_size" -lt "$req_min_size_megabytes"
22         then
23                 echo "Couldn't enlarge /dev/shm. Please enlarge it manually so that it's at least ${req_min_size_megabytes}M big."
24                 exit 1
25         fi
26         echo "/dev/shm successfully enlarged."
27 elif test "$V" = "2"
28 then
29         echo "OK (current size: ${cur_size}M, required size: ${req_min_size_megabytes}M)"
30 fi