4 basedir=$(dirname "$0")
5 . "${basedir}"/check-dpdk-supported-arch.sh
7 # Overall that could require up to 1.2G for hugepages in the test environment
9 # Some page sizes like e.g. 1G might not be available in all test environments
10 # The test still configures 1 page of 1G size.
11 # One of two things will happen, depending on the test environment:
12 # - has 1G huge page size => they will tried to be allocated (usually env is
13 # too small, but we want to see it fail gracefully for that)
14 # We will not check for the 1G alloc, as we know it often fails in small adt's
15 # - has no 1G huge page size (HW feature) => we check if it fails gracefully
18 DPDK_CONF="/etc/dpdk/dpdk.conf"
19 DPDK_INTERF="/etc/dpdk/interfaces"
22 MMDIR="/sys/kernel/mm/hugepages/${1}"
24 if [ -d "$MMDIR" -a -r "$MMDIR/nr_hugepages" ]; then
25 hpcount=$(cat "$MMDIR/nr_hugepages")
26 if [ "${hpcount}" -ne "${EXPECTHP}" ]; then
27 echo "Hugepages (${hpcount}) not as expected (${EXPECTHP})"
30 echo "Hugepages ok (${hpcount})"
41 echo "Status after ${MARK}"
42 echo "Status of the Service"
43 ${PRE} status "${POST}" || true
45 GOTSTATUS=$(${PRE} status "${POST}" | awk '/^ *Active: / { print $2 }')
46 if [ "${GOTSTATUS}" != "${EXPECTEDSTATUS}" ]; then
47 echo "Service status (${GOTSTATUS}) not as expected (${EXPECTEDSTATUS})"
50 echo "Service status (${GOTSTATUS}) as expected"
53 echo "Status of hugetlbfs mount points"
54 # this section is ok to create bad RCs when no mounts are available
56 grep hugetlbfs < /proc/mounts
57 htlbfscount=$(grep -c hugetlbfs < /proc/mounts)
60 # we have to reduce the expected mountpoint count in case some sizes are
61 # not supported by the current kernel/environment
62 if [ ${EXPMPCOUNT} -gt 0 ]; then
63 if [ ! -d /sys/kernel/mm/hugepages/hugepages-2048kB ]; then
64 EXPMPCOUNT=$((EXPMPCOUNT-1))
66 if [ ! -d /sys/kernel/mm/hugepages/hugepages-1048576kB ]; then
67 EXPMPCOUNT=$((EXPMPCOUNT-1))
71 if [ "${htlbfscount}" -eq "${EXPMPCOUNT}" ]; then
72 echo "MP Count (${htlbfscount}) as expected (${EXPMPCOUNT})"
74 echo "MP Count (${htlbfscount}) not as expected (${EXPMPCOUNT})"
78 # check if setting HP worked
79 if [ "${EXPMPCOUNT}" -ne "0" ]; then
80 checkhp "hugepages-2048kB" "${EXPECT2MHP}"
81 # We do not check 1G alloc, as it is known to be often not available
86 # help a bit with memory fragmentation regarding huge page allocation
88 echo 3 > /proc/sys/vm/drop_caches
90 # stopping and resetting Service
91 systemctl stop dpdk.service || /bin/true
92 systemctl reset-failed dpdk.service || /bin/true
94 echo "Unmounting all potential hugetlbfs mounts"
95 awk '/hugetlbfs/ {print $2}' /proc/mounts | while read hugetlbmount; do
96 umount -v "$hugetlbmount"
101 # We want to verify that
102 # - initially our environment has no hugetlbfs mount
103 # - a system without hugetlbfs mount gets it mounted
104 # - a restart of the service does neither drop nor duplicate the mount
108 printf "\n\n### Checking Type %s ###\n" "${TYPE}"
110 checkstatus "${TYPE}-BEGIN" 0 "${PRE}" "${POST}" "inactive"
111 echo "### Starting Service ###"
112 ${PRE} start "${POST}"
113 checkstatus "${TYPE}-START" 2 "${PRE}" "${POST}" "active"
114 echo "### Restarting Service ###"
115 ${PRE} restart "${POST}"
116 checkstatus "${TYPE}-RESTART" 2 "${PRE}" "${POST}" "active"
119 echo "NR_2M_PAGES=$EXPECT2MHP" >> ${DPDK_CONF}
120 echo "NR_1G_PAGES=$EXPECT1GHP" >> ${DPDK_CONF}
122 # We can't rely on any real device for DPDK tests in adt-* environments. But
123 # we can expect all kind of broken configuration not to break it (would be
124 # detected via set -e).
125 # So add all kind of known-to-be-broken definitions and expect it not to fail.
126 cat <<EOF > ${DPDK_INTERF}
128 pTi 0000:04:00.0 uio-pci-generic
130 0000:04:00.0 uio-pci-generic
133 # non existing device
134 pci 1234:56:78.9 uio-pci-generic
137 # some had issues in the past caused by different init systems, so we test all
139 checkinitstyle "/etc/init.d/dpdk" "" "Direct"
140 # System V style init
141 checkinitstyle "service dpdk" "" "SysV"
143 checkinitstyle "systemctl" "dpdk.service" "SystemD"