diff --git a/kernel/linux/Makefile b/kernel/linux/Makefile index 9e18d3e7c..524096190 100644 --- a/kernel/linux/Makefile +++ b/kernel/linux/Makefile @@ -7,7 +7,9 @@ # make TSWG_DEBUG=y # enable DEBUG and the built-in selftests KDIR ?= /lib/modules/$(shell uname -r)/build -SRC := $(CURDIR)/src +# SRC may point at a copy of src/ so that builds for different kernels +# don't share object files. +SRC ?= $(CURDIR)/src AUTOCONF := $(SRC)/compat/generated/autoconf.h all: module diff --git a/kernel/linux/scripts/build-for-ubuntu.sh b/kernel/linux/scripts/build-for-ubuntu.sh new file mode 100755 index 000000000..f43be7399 --- /dev/null +++ b/kernel/linux/scripts/build-for-ubuntu.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# +# build-for-ubuntu.sh builds tswg.ko for the given Ubuntu kernel release +# (such as 6.8.0-106-generic) in a private copy of src/ under OUTDIR, and +# prints the path of the resulting tswg.ko to stdout. All build output goes +# to stderr. +# +# usage: build-for-ubuntu.sh KERNEL_RELEASE OUTDIR + +set -eu + +if [ $# -ne 2 ]; then + echo "usage: $0 KERNEL_RELEASE OUTDIR" >&2 + exit 2 +fi +kver=$1 +out=$2 +top=$(cd "$(dirname "$0")/.." && pwd) + +kdir=$("$top/scripts/ubuntu-headers.sh" "$kver") + +mkdir -p "$out" +rm -rf "$out/src" +cp -r "$top/src" "$out/src" +make -C "$top" KDIR="$kdir" SRC="$out/src" >&2 +echo "$out/src/tswg.ko" diff --git a/kernel/linux/scripts/vmtest.sh b/kernel/linux/scripts/vmtest.sh new file mode 100755 index 000000000..c9f776112 --- /dev/null +++ b/kernel/linux/scripts/vmtest.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# +# vmtest.sh runs the tswg natlab vmtests, which live in a tailscale.com +# checkout (default ~/src/tailscale.com-tswg, override with $TAILSCALE_DIR) +# under tstest/natlab/vmtest. Extra arguments are passed to "go test". +# +# usage: vmtest.sh [TEST_REGEXP [go test flags...]] + +set -eu + +top=$(cd "$(dirname "$0")/.." && pwd) +ts=${TAILSCALE_DIR:-$HOME/src/tailscale.com-tswg} +run=${1:-TestTSWG} +[ $# -gt 0 ] && shift + +cd "$ts" +TSWG_DIR=$top exec go test ./tstest/natlab/vmtest/ --run-vm-tests \ + -run "$run" -v -timeout=30m "$@"