Skip to content

Commit

Permalink
tooling: Do not build vtd plugin by default
Browse files Browse the repository at this point in the history
This also allows us to run smoketests in the Docker container,
since we no longer require VTD to be available to run the
smoketests.
  • Loading branch information
cassava committed Feb 3, 2021
1 parent 0613af1 commit 1cc63c2
Show file tree
Hide file tree
Showing 11 changed files with 1,815 additions and 292 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ doxygen:
doxygen Doxyfile

smoketest:
# Call this target with WITH_VTD=1 to include VTD binding tests.
$(call print_header, "Running smoke tests...")
@${CLOE_LAUNCH} clean -P conanfile.py
@\time -f "\nTotal smoketest time (real) = %e sec" bats tests
Expand Down
10 changes: 5 additions & 5 deletions Makefile.all
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ CONAN_OPTIONS :=
WITH_ENGINE := 1

## WITH_VTD
## Usage: make WITH_VTD=0 <targets>
## Default: 1
## Usage: make WITH_VTD=1 <targets>
## Default: 0
##
WITH_VTD := 1
WITH_VTD := 0

## BUILD_TESTS
## Usage: make BUILD_TESTS=0 package
Expand Down Expand Up @@ -139,9 +139,9 @@ ALL_PKGS := $(filter-out engine, ${ALL_PKGS})
CONAN_OPTIONS += -o cloe:with_engine=False
endif

ifeq (${WITH_VTD},0)
ifeq (${WITH_VTD},1)
ALL_PKGS := $(filter-out plugins/vtd, ${ALL_PKGS})
CONAN_OPTIONS += -o cloe:with_vtd=False
CONAN_OPTIONS += -o cloe:with_vtd=True
endif

ifeq (${BUILD_TESTS},0)
Expand Down
36 changes: 20 additions & 16 deletions Makefile.setup
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,39 @@ APT_ARGS := --no-install-recommends -y
PACMAN := $(shell command -v pacman 2>/dev/null)
PACMAN_ARGS := --noconfirm --needed

PIPX := $(shell command -v pipx 2>/dev/null)
PIPX_INSTALL_ARGS :=

PIP := $(or \
$(shell command -v pipx 2>/dev/null), \
$(shell command -v pip3 2>/dev/null), \
$(shell command -v pip 2>/dev/null) \
)
ifndef PIPX
ifeq (${VIRTUAL_ENV}, )
PIP_INSTALL_ARGS := --user --upgrade
else
PIP_INSTALL_ARGS := ${PIPX_INSTALL_ARGS}
PIP_INSTALL_ARGS := --upgrade
endif

PIPX := $(shell command -v pipx 2>/dev/null)
PIPX_INSTALL_ARGS :=
ifndef PIPX
PIPX := ${PIP}
PIPX_INSTALL_ARGS := ${PIP_INSTALL_ARGS}
endif

.PHONY: help
.DEFAULT: help
.SILENT: help
help::
echo "Available setup targets:"
echo " setup to perform Git repository setup"
echo " install-system-deps to install build (and development) system requirements"
echo " install-python-deps to install build (and development) Python requirements"
echo " setup to perform Git repository setup"
echo " install-system-deps to install build (and development) system requirements"
echo " install-python-deps to install Python runtime requirements with ${PIP}"
echo " install-python-tools to install Python development tools with ${PIPX}"
echo

.PHONY: setup
setup:
git config --local core.hooksPath .git-hooks/

.PHONY: install-system-deps install-ubuntu-deps install-archlinux-deps install-python-deps
.PHONY: install-system-deps install-ubuntu-deps install-archlinux-deps install-python-deps install-python-tools
install-system-deps::

# Ubuntu ----------------------------------------------------------------------
Expand Down Expand Up @@ -112,19 +116,20 @@ endif

# Python ----------------------------------------------------------------------
ifdef PIP
install-deps:: install-python-deps
install-deps:: install-python-deps install-python-tools
endif

install-python-deps::
command -v ${PIP} >/dev/null 2>&1
${PIP} install ${PIP_INSTALL_ARGS} \
click \
conan \
libtmux \
toml \
;

ifndef WITHOUT_DEV_DEPS
install-python-deps::
command -v ${PIP} >/dev/null 2>&1
install-python-tools::
command -v ${PIPX} >/dev/null 2>&1
for pkg in \
black \
mypy \
Expand All @@ -134,6 +139,5 @@ install-python-deps::
yq \
; \
do \
${PIP} install ${PIP_INSTALL_ARGS} $${pkg}; \
${PIPX} install ${PIPX_INSTALL_ARGS} $${pkg}; \
done
endif
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Cloe(ConanFile):
default_options = {
"test": True,
"pedantic": True,
"with_vtd": True,
"with_vtd": False,
"with_engine": True,
}
generators = "cmake"
Expand Down
6 changes: 4 additions & 2 deletions dist/docker/Dockerfile.archlinux
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RUN pacman -Syu --noconfirm --needed make && \

RUN pip3 install --upgrade pip && \
make -f /cloe/Makefile.setup \
WITHOUT_DEV_DEPS=yes PIP_INSTALL_ARGS="" \
PIP_INSTALL_ARGS="" \
install-python-deps

# Install and Setup Conan
Expand All @@ -33,8 +33,10 @@ RUN conan profile new --detect default && \
# Build and Install Cloe
WORKDIR /cloe
COPY . /cloe
RUN make export-vtd export && \
RUN make export-vendor export && \
make WITH_VTD=0 package-all && \
export LC_ALL=C.UTF-8 LANG=C.UTF-8 && \
make WITH_VTD=0 smoketest && \
make WITH_VTD=0 INSTALL_DIR="/deploy" deploy && \
conan remove \* -b -f

Expand Down
5 changes: 4 additions & 1 deletion dist/docker/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RUN apt-get update && \

RUN pip3 install --upgrade pip && \
make -f /cloe/Makefile.setup \
WITHOUT_DEV_DEPS=yes PIP_INSTALL_ARGS="" \
PIP_INSTALL_ARGS="" \
install-python-deps

# Install and Setup Conan
Expand Down Expand Up @@ -58,6 +58,9 @@ RUN \
# You can specify more than one package here, see the Makefile for more
# information on the WITH_*, PACKAGES, NOBUILD_PKGS, and BUILD_PKGS variables.
make WITH_VTD=0 package-all && \
# Run smoketests.
export LC_ALL=C.UTF-8 LANG=C.UTF-8 && \
make WITH_VTD=0 smoketest && \
# Deploy all the Cloe packages to INSTALL_DIR, which is /usr/local by
# default. This will also populate BUILD_DIR, so that should be removed
# afterwards to prevent this image from getting too big.
Expand Down
14 changes: 14 additions & 0 deletions tests/setup_bats.bash
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ cloe_engine() {
for var in ${CLOE_OVERRIDE_ENV[@]}; do
cloe_launch_args+=(--override-env=${var})
done
if [[ "${WITH_VTD}" -eq "1" ]]; then
cloe_launch_args+=(-o)
cloe_launch_args+=("with_vtd=True")
fi
for var in ${CLOE_LAUNCH_ARGS[@]}; do
cloe_launch_args+=(${var})
done

local user_args=()
while [[ $# -ne 0 ]]; do
Expand Down Expand Up @@ -75,6 +82,13 @@ cloe_shell() {
for var in ${CLOE_OVERRIDE_ENV[@]}; do
cloe_launch_args+=(--override-env=${var})
done
if [[ "${WITH_VTD}" -eq "1" ]]; then
cloe_launch_args+=(-o)
cloe_launch_args+=("with_vtd=True")
fi
for var in ${CLOE_LAUNCH_ARGS[@]}; do
cloe_launch_args+=(${var})
done

local user_args=("$@")

Expand Down
11 changes: 10 additions & 1 deletion tests/test_engine.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@

load setup_bats

test_vtd_plugin_exists() {
# VTD_ROOT is only available in the shell.
cloe_shell -c 'test -d "${VTD_ROOT}"'
}

@test "Expect schema equality : test_engine_json_schema.json" {
if ! type diff &>/dev/null; then
skip "required program diff not present"
fi

diff <(cloe_engine usage -j 2>/dev/null) test_engine_json_schema.json
if test_vtd_plugin_exists; then
diff <(cloe_engine usage -j 2>/dev/null) test_engine_json_schema_with_vtd.json
else
diff <(cloe_engine usage -j 2>/dev/null) test_engine_json_schema.json
fi
}

@test "Expect check success : test_engine_smoketest.json" {
Expand Down
Loading

0 comments on commit 1cc63c2

Please sign in to comment.