Skip to content

Commit c74ee58

Browse files
committed
Add Makefile target to run sysbox-libs unit tests.
Run it with "make test-sysbox-libs". Signed-off-by: Cesar Talledo <[email protected]>
1 parent 202e0c5 commit c74ee58

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

Makefile

+24-5
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@
1111
install uninstall \
1212
test \
1313
test-sysbox test-sysbox-ci test-sysbox-systemd test-sysbox-installer \
14-
test-runc test-fs test-mgr \
14+
test-runc test-fs test-mgr test-sysbox-libs \
1515
test-shell test-shell-debug test-shell-systemd test-shell-systemd-debug test-shell-installer test-shell-installer-debug \
1616
test-img test-img-systemd test-cleanup \
17-
test-sysbox-local test-sysbox-local-installer test-sysbox-local-ci test-fs-local test-mgr-local \
18-
test-sind test-sind-local test-sind-shell \
17+
test-sysbox-local test-sysbox-local-installer test-sysbox-local-ci test-fs-local test-mgr-local test-sysbox-libs-local \
1918
lint lint-local lint-sysbox-local lint-tests-local shfmt \
2019
sysbox-runc-recvtty \
21-
listRuncPkgs listFsPkgs listMgrPkgs \
20+
listRuncPkgs listFsPkgs listMgrPkgs listSysboxLibsPkgs \
2221
clean
2322

2423
export SHELL=bash
@@ -341,7 +340,7 @@ DOCKER_STOP := docker stop -t0 sysbox-test
341340
##@ Testing targets
342341

343342
test: ## Run all sysbox test suites
344-
test: test-fs test-mgr test-runc test-sysbox test-sysbox-systemd
343+
test: test-fs test-mgr test-runc test-sysbox-libs test-sysbox test-sysbox-systemd
345344

346345
test-sysbox: ## Run sysbox integration tests
347346
test-sysbox: test-prereq test-img
@@ -393,6 +392,13 @@ test-mgr: test-prereq test-img
393392
@printf "\n** Running sysbox-mgr unit tests **\n\n"
394393
$(DOCKER_RUN) /bin/bash -c "make --no-print-directory test-mgr-local"
395394

395+
test-sysbox-libs: test-prereq sysbox
396+
@printf "\n** Running sysbox-libs unit tests **\n\n"
397+
$(TEST_DIR)/scr/testContainerPre $(TEST_VOL1) $(TEST_VOL2) $(TEST_VOL3)
398+
$(DOCKER_RUN) /bin/bash -c "export PHY_EGRESS_IFACE_MTU=$(EGRESS_IFACE_MTU) && \
399+
testContainerInit && \
400+
make --no-print-directory test-sysbox-libs-local"
401+
396402
test-shell: ## Get a shell in the test container (useful for debug)
397403
test-shell: test-prereq test-img
398404
$(TEST_DIR)/scr/testContainerPre $(TEST_VOL1) $(TEST_VOL2) $(TEST_VOL3)
@@ -507,6 +513,13 @@ test-mgr-local: sysbox-ipc
507513
sleep 2
508514
cd $(SYSMGR_DIR) && go test -buildvcs=false -timeout 3m -v $(mgrPkgs)
509515

516+
test-sysbox-libs-local:
517+
@for dir in $(sysboxLibsPkgDirs); do \
518+
pushd $$dir > /dev/null; \
519+
go test ./... || break; \
520+
popd > /dev/null; \
521+
done
522+
510523
##@ Code Hygiene targets
511524

512525
lint: ## Runs lint checker on sysbox source code and tests
@@ -552,6 +565,9 @@ listFsPkgs:
552565
listMgrPkgs:
553566
@echo $(mgrPkgs)
554567

568+
listSysboxLibsPkgs:
569+
@echo $(sysboxLibsPkgs)
570+
555571
#
556572
# cleanup targets
557573
#
@@ -592,3 +608,6 @@ fsPkgs = $(if $(__fsPkgs),,$(eval __fsPkgs := $$(_fsPkgs)))$(__fsPkgs)
592608

593609
_mgrPkgs = $(shell cd $(SYSMGR_DIR) && go list -buildvcs=false ./... | grep -v vendor)
594610
mgrPkgs = $(if $(__mgrPkgs),,$(eval __mgrPkgs := $$(_mgrPkgs)))$(__mgrPkgs)
611+
612+
sysboxLibsPkgDirs := $(shell find $(SYSLIBS_DIR) -type f -name "go.mod" -exec dirname {} \;)
613+
sysboxLibsPkgs := $(foreach dir,$(sysboxLibsPkgDirs),$(shell cd $(dir); go list ./...; cd ..))

0 commit comments

Comments
 (0)