From f0b3db3f1e8ccfd3d9584738aa5431ab0040c5a0 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Fri, 2 Oct 2015 17:11:56 -0700 Subject: [PATCH] autobuild: FreeBSD portability fixes Change-Id: Id6db5d80ee7fa602da8763372f92555e7e299445 Signed-off-by: Daniel Verkamp --- autobuild.sh | 13 ++++++------- autopackage.sh | 8 ++++---- autotest.sh | 14 ++------------ scripts/autotest_common.sh | 17 +++++++++++++++++ scripts/cleanup.sh | 27 +++++++++++++++++++++++++++ scripts/configure_hugepages.sh | 3 ++- 6 files changed, 58 insertions(+), 24 deletions(-) create mode 100755 scripts/cleanup.sh diff --git a/autobuild.sh b/autobuild.sh index e66a64459..f1b6c570b 100755 --- a/autobuild.sh +++ b/autobuild.sh @@ -3,10 +3,9 @@ set -e src=$(readlink -f $(dirname $0)) -out=$PWD +source "$src/scripts/autotest_common.sh" -MAKEFLAGS=${MAKEFLAGS:--j16} -DPDK_DIR=/usr/local/dpdk-2.1.0/x86_64-native-linuxapp-gcc +out=$PWD umask 022 @@ -19,16 +18,16 @@ if hash scan-build; then scanbuild="scan-build -o $out/scan-build-tmp --status-bugs" fi -make $MAKEFLAGS clean +$MAKE $MAKEFLAGS clean fail=0 -time $scanbuild make $MAKEFLAGS DPDK_DIR=$DPDK_DIR || fail=1 +time $scanbuild $MAKE $MAKEFLAGS DPDK_DIR=$DPDK_DIR || fail=1 # Check that header file dependencies are working correctly by # capturing a binary's stat data before and after touching a # header file and re-making. STAT1=`stat examples/nvme/identify/identify` touch lib/nvme/nvme_internal.h -make $MAKEFLAGS DPDK_DIR=$DPDK_DIR || fail=1 +$MAKE $MAKEFLAGS DPDK_DIR=$DPDK_DIR || fail=1 STAT2=`stat examples/nvme/identify/identify` if [ "$STAT1" == "$STAT2" ]; then @@ -43,7 +42,7 @@ if [ -d $out/scan-build-tmp ]; then fi if hash doxygen; then - (cd "$src"/doc; make $MAKEFLAGS) + (cd "$src"/doc; $MAKE $MAKEFLAGS) mkdir -p "$out"/doc for d in "$src"/doc/output.*; do component=$(basename "$d" | sed -e 's/^output.//') diff --git a/autopackage.sh b/autopackage.sh index 33d67fd37..08a092fa9 100755 --- a/autopackage.sh +++ b/autopackage.sh @@ -2,15 +2,15 @@ set -xe -DPDK_DIR=/usr/local/dpdk-2.1.0/x86_64-native-linuxapp-gcc - src=$(readlink -f $(dirname $0)) +source "$src/scripts/autotest_common.sh" + out=$PWD MAKEFLAGS=${MAKEFLAGS:--j16} cd $src -make clean +$MAKE clean if [ `git status --porcelain | wc -l` -ne 0 ]; then echo make clean left the following files: @@ -36,6 +36,6 @@ tar -C "$tmpdir" -xf $out/$tarball cd "$tmpdir"/spdk-* cp CONFIG CONFIG.orig sed -e 's/CONFIG_DEBUG=y/CONFIG_DEBUG=n/' CONFIG - time make ${MAKEFLAGS} DPDK_DIR=$DPDK_DIR + time $MAKE ${MAKEFLAGS} DPDK_DIR=$DPDK_DIR ) rm -rf "$tmpdir" diff --git a/autotest.sh b/autotest.sh index 898e2ac01..3f1671535 100755 --- a/autotest.sh +++ b/autotest.sh @@ -10,7 +10,7 @@ if [ $EUID -ne 0 ]; then exit 1 fi -trap "process_core; exit 1" SIGINT SIGTERM EXIT +trap "process_core; $rootdir/scripts/cleanup.sh; exit 1" SIGINT SIGTERM EXIT timing_enter autotest @@ -36,17 +36,7 @@ time test/lib/memory/memory.sh timing_exit lib -# detach pci devices from uio driver -grep -q "^uio_pci_generic" /proc/modules && rmmod uio_pci_generic - -# bind NVMe devices to NVMe driver if no kernel device -if [ -d "/sys/bus/pci/drivers/nvme" ]; then - device=`find /sys/bus/pci/drivers/nvme -name "0000*" -print` - if [ -z "$device" ]; then - rmmod nvme - modprobe nvme - fi -fi +./scripts/cleanup.sh timing_exit autotest chmod a+r $output_dir/timing.txt diff --git a/scripts/autotest_common.sh b/scripts/autotest_common.sh index 0db270f67..5e752196e 100755 --- a/scripts/autotest_common.sh +++ b/scripts/autotest_common.sh @@ -1,6 +1,23 @@ set -xe ulimit -c unlimited +case `uname` in + FreeBSD) + DPDK_DIR=/usr/local/share/dpdk/x86_64-native-bsdapp-clang + MAKE=gmake + ;; + Linux) + DPDK_DIR=/usr/local/dpdk-2.1.0/x86_64-native-linuxapp-gcc + MAKE=make + ;; + *) + echo "Unknown OS in $0" + exit 1 + ;; +esac + +MAKEFLAGS=${MAKEFLAGS:--j16} + if [ -z "$rootdir" ] || [ ! -d "$rootdir/../output" ]; then output_dir=. else diff --git a/scripts/cleanup.sh b/scripts/cleanup.sh new file mode 100755 index 000000000..7f189429c --- /dev/null +++ b/scripts/cleanup.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -e + +function cleanup_linux() { + # detach pci devices from uio driver + grep -q "^uio_pci_generic" /proc/modules && rmmod uio_pci_generic + + # bind NVMe devices to NVMe driver if no kernel device + if [ -d "/sys/bus/pci/drivers/nvme" ]; then + device=`find /sys/bus/pci/drivers/nvme -name "0000*" -print` + if [ -z "$device" ]; then + rmmod nvme + modprobe nvme + fi + fi +} + +function cleanup_freebsd { + kldunload contigmem.ko || true +} + +if [ `uname` = Linux ]; then + cleanup_linux +else + cleanup_freebsd +fi diff --git a/scripts/configure_hugepages.sh b/scripts/configure_hugepages.sh index 32bff91ec..84ca1bc8d 100755 --- a/scripts/configure_hugepages.sh +++ b/scripts/configure_hugepages.sh @@ -18,9 +18,10 @@ function configure_linux { } function configure_freebsd { + kldunload contigmem.ko || true kenv hw.contigmem.num_buffers=16 kenv hw.contigmem.buffer_size=33554432 - kldload `find . -name contigmem.ko | head -1` + kldload contigmem.ko } if [ `uname` = Linux ]; then