Skip to content

Commit

Permalink
lkl: Fix INSTALL_PATH error, add more test options
Browse files Browse the repository at this point in the history
This changes arck/lkl/Makefile to build the $(INSTALL_PATH)/lib
directory if it doesn't already exist, which would otherwise cause the
install to fail if INSTALL_PATH != tools/lkl. It also adds a test
target for running tools/lkl/tests/boot under gdb, and adds a few
options to provide more fine-grained control over which tests run.

Signed-off-by: Patrick Collins <pscollins@google.com>
  • Loading branch information
pscollins committed Jan 28, 2016
1 parent 4688ebc commit f0eab6e
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 19 deletions.
1 change: 1 addition & 0 deletions arch/lkl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ arch/lkl/include/generated/uapi/asm/syscall_defs.h: vmlinux

install: lkl.o __headers arch/lkl/include/generated/uapi/asm/syscall_defs.h
@echo " INSTALL $(INSTALL_PATH)/lib/lkl.o"
@mkdir -p $(INSTALL_PATH)/lib/
@cp lkl.o $(INSTALL_PATH)/lib/
@arch/lkl/scripts/headers_install.py \
$(subst -j,-j$(NPROC),$(findstring -j,$(MAKEFLAGS))) \
Expand Down
9 changes: 4 additions & 5 deletions tools/lkl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ endif

OUTPUT_FORMAT=$(shell $(LD) -r -print-output-format)

TEST_TARGETS=test valgrind gdb

lib_source = $(filter-out %-host.c,$(wildcard lib/*.c))
source = $(wildcard tests/*.c)
lib = lib/liblkl.a
Expand Down Expand Up @@ -83,8 +85,5 @@ endif
cpfromfs: cptofs
if ! [ -e $@ ]; then ln -s $< $@; fi

test:
$(MAKE) -C tests

valgrind:
$(MAKE) -C tests valgrind
$(TEST_TARGETS): all
$(MAKE) -C tests $@
51 changes: 40 additions & 11 deletions tools/lkl/tests/Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,52 @@
define valgrind_test
VALGRIND_CMD="valgrind --suppressions=valgrind.supp --leak-check=full --show-leak-kinds=all --xml=yes --xml-file=valgrind-$1.xml" \
TEST_CMD="valgrind --suppressions=valgrind.supp --leak-check=full --show-leak-kinds=all --xml=yes --xml-file=valgrind-$1.xml" \
./boot.sh -t $1 ; \
./valgrind2xunit.py valgrind-$1.xml
endef

define valgrind_test_text
VALGRIND_CMD="valgrind --suppressions=valgrind.supp --leak-check=full --show-leak-kinds=all" \
TEST_CMD="valgrind --suppressions=valgrind.supp --leak-check=full --show-leak-kinds=all" \
./boot.sh -t $1
endef

define gdb_test
TEST_CMD="gdb --args" ./boot.sh -t $1
endef

define for_fs
for fs in $(FS_TYPES); do $(call $1,$$fs); done
endef

define run
for fs in $(FS_TYPES); do ./boot.sh -t $$fs; done
endef

QUICK?=0
VALGRIND_TEXT?=0
FS_TYPES?=ext4 btrfs vfat xfs

# The hijack tests are very time consuming, so run with `QUICK=1 make
# test` if you want to stick to the unit tests
ifeq ($(QUICK),1)
HIJACK_TEST=
else
HIJACK_TEST="./hijack-test.sh"
endif

ifeq ($(VALGRIND_TEXT),1)
VALGRIND_CMD=valgrind_test_text
else
VALGRIND_CMD=valgrind_test
endif

all:
./boot.sh -t ext4
./boot.sh -t btrfs
./boot.sh -t vfat
./boot.sh -t xfs
./hijack-test.sh
$(call run,)
$(HIJACK_TEST)

test: all

valgrind:
$(call valgrind_test,ext4)
$(call valgrind_test,btrfs)
$(call valgrind_test,vfat)
$(call valgrind_test,xfs)
$(call for_fs,$(VALGRIND_CMD))

gdb:
$(call for_fs,gdb_test)
6 changes: 4 additions & 2 deletions tools/lkl/tests/boot.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash -e
#!/bin/bash

set -e

if [ "$1" = "-t" ]; then
shift
Expand All @@ -25,7 +27,7 @@ if file ./boot | grep PE32; then
WINE=wine
fi

${VALGRIND_CMD} $WINE ./boot -d $file -t $fstype $tap_args $LKL_TEST_DEBUG $@ || err=$?
${TEST_CMD} $WINE ./boot -d $file -t $fstype $tap_args $LKL_TEST_DEBUG $@ || err=$?

if [ -c /dev/net/tun ]; then
sudo ip tuntap del dev lkl_boot mode tap || true
Expand Down
1 change: 0 additions & 1 deletion tools/lkl/tests/hijack-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ rm ping6

echo "== TAP tests =="
if [ -c /dev/net/tun ]; then
sudo ip link set dev lkl_ptt0 down || true
sudo ip tuntap del dev lkl_ptt0 mode tap || true
sudo ip tuntap add dev lkl_ptt0 mode tap user $USER
sudo ip link set dev lkl_ptt0 up
Expand Down

0 comments on commit f0eab6e

Please sign in to comment.