68 lines
1.7 KiB
Bash
Executable File
68 lines
1.7 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
SUCCESS=0;
|
|
FAILURE=1;
|
|
RETCODE=255;
|
|
TMPFILE=/tmp/libhugetlbfs-test.log
|
|
|
|
function check_mem_size {
|
|
# libhugetblfs tests need to allocate 512 hugepages
|
|
# so the system needs to have enough memory to accomodate
|
|
# that request plus an extra to run the code without hiccups
|
|
# in order to provide room for that need, lets ask for, t least,
|
|
# 60% more memory than the hugepage pool size, given the size
|
|
# of the hugepages for this system.
|
|
#MIN_MEM_KB=1872732;
|
|
MIN_MEM_KB=$(awk '/Hugepagesize:/ {print int($2*512*1.6);}' /proc/meminfo);
|
|
SYS_MEM_KB=$(awk '/MemTotal:/ {print $2;}' /proc/meminfo);
|
|
|
|
if [[ $MIN_MEM_KB -gt $SYS_MEM_KB || $MIN_MEM_KB -eq $SYS_MEM_KB ]]; then
|
|
RETCODE=$FAILURE;
|
|
else
|
|
RETCODE=$SUCCESS;
|
|
fi
|
|
}
|
|
|
|
function setup_and_check_hugepages {
|
|
echo 3 > /proc/sys/vm/drop_caches;
|
|
echo 1 > /proc/sys/vm/compact_memory;
|
|
echo 512 > /proc/sys/vm/nr_hugepages;
|
|
|
|
sleep 15;
|
|
|
|
NR_FREE_HP=$(awk '/HugePages_Free:/ {print $2;}' /proc/meminfo);
|
|
|
|
if [ $NR_FREE_HP -lt 512 ]; then
|
|
RETCODE=$FAILURE;
|
|
else
|
|
RETCODE=$SUCCESS;
|
|
fi
|
|
}
|
|
|
|
check_mem_size;
|
|
if [ $RETCODE != $SUCCESS ]; then
|
|
echo "ERROR: system does not have enough RAM";
|
|
exit $RETCODE;
|
|
fi
|
|
|
|
setup_and_check_hugepages;
|
|
if [ $RETCODE != $SUCCESS ]; then
|
|
echo "ERROR: not possible to allocate enough hugepages for a complete test";
|
|
exit $RETCODE;
|
|
fi
|
|
|
|
pushd /usr/lib64/libhugetlbfs/tests/;
|
|
./run_tests.py &> $TMPFILE;
|
|
popd;
|
|
|
|
FAILCNT=$(awk '/ FAIL:/ {print $3+$4}' $TMPFILE);
|
|
|
|
if [ $FAILCNT != 0 ]; then
|
|
cat $TMPFILE
|
|
echo "FAIL";
|
|
exit $FAILURE;
|
|
else
|
|
echo "PASS";
|
|
exit $SUCCESS;
|
|
fi
|