pve: build test stub of Proxmox::Lib::PVE for tests

this replaces the libdirs() sub with one containing:
- ../target (for when run from build/pve-rs)
- ../../target (for when run from toplevel/pve-rs

This way we can run 'make check' both from within `pve-rs`
as well as from the package building process.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2022-11-15 13:35:23 +01:00
parent 08eba82025
commit 13e3d8b87e
2 changed files with 17 additions and 2 deletions

View File

@ -20,11 +20,18 @@ PM_DIR := PVE
ifeq ($(BUILD_MODE), release)
CARGO_BUILD_ARGS += --release
TARGET_DIR=release
else
TARGET_DIR=debug
endif
all: PVE Proxmox/Lib/PVE.pm
ifneq ($(BUILD_MODE), skip)
cargo build $(CARGO_BUILD_ARGS)
mkdir -p test/Proxmox/Lib
sed -r -e \
's@^sub libdirs.*$$@sub libdirs { return ("../target/$(TARGET_DIR)", "../../target/$(TARGET_DIR)"); }@' \
Proxmox/Lib/PVE.pm >test/Proxmox/Lib/PVE.pm
endif
PVE: ../scripts/genpackage.pl
@ -38,6 +45,9 @@ Proxmox/Lib/PVE.pm: ../Proxmox/Lib/template.pm
mkdir -p Proxmox/Lib
$(call package_template,PVE,pve_rs,../)
check: all
$(MAKE) -C test test
# always re-create this dir
# but also copy the local target/ and PVE/ dirs as a build-cache
.PHONY: build

View File

@ -1,4 +1,9 @@
.PHONY: test
test:
test: Proxmox/Lib/PVE.pm
@echo "-- running pve-rs tests --"
./resource_scheduling.pl
perl -I. -I.. -I../.. ./resource_scheduling.pl
# The test stub, we don't know where to look for the library from in here!
Proxmox/Lib/PVE.pm:
@echo "run 'make' in the pve-rs/ dir first"
@exit 1