mirror of
https://github.com/troglobit/finit.git
synced 2026-11-08 16:11:10 +00:00
test: Clean up Makefile
Signed-off-by: Jacques de Laval <jacques@de-laval.se>
This commit is contained in:
1 parent
5a4cb74493
commit
c80a755dc6
1 file changed
+25
-23
+25
-23
@@ -1,9 +1,12 @@
|
|||||||
|
.PHONY: clean check test-check
|
||||||
|
|
||||||
ARCH ?= x86_64
|
ARCH ?= x86_64
|
||||||
|
|
||||||
finit_bin = ../src/finit
|
FINITBIN ?= ../src/finit
|
||||||
|
|
||||||
busybox_ver = 1.31.0
|
BBVER ?= 1.31.0
|
||||||
busybox_bin = busybox-$(ARCH)
|
BBBIN = busybox-$(ARCH)
|
||||||
|
BBURL ?= https://www.busybox.net/downloads/binaries/$(BBVER)-defconfig-multiarch-musl/$(BBBIN)
|
||||||
|
|
||||||
testroot = test_root
|
testroot = test_root
|
||||||
testroot_bin = $(testroot)/bin
|
testroot_bin = $(testroot)/bin
|
||||||
@@ -35,51 +38,50 @@ dirs = $(testroot)/bin \
|
|||||||
$(testroot)/tmp \
|
$(testroot)/tmp \
|
||||||
$(testroot)/usr/lib
|
$(testroot)/usr/lib
|
||||||
|
|
||||||
|
all: check
|
||||||
|
|
||||||
$(dirs):
|
$(dirs):
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
|
|
||||||
$(busybox_bin):
|
$(BBBIN):
|
||||||
wget 'https://www.busybox.net/downloads/binaries/$(busybox_ver)-defconfig-multiarch-musl/$(busybox_bin)'
|
wget -O $@ $(BBURL)
|
||||||
md5sum -c $(busybox_bin).md5
|
md5sum -c $@.md5
|
||||||
|
|
||||||
$(testroot):
|
$(testroot):
|
||||||
mkdir $(testroot)
|
mkdir $(testroot)
|
||||||
|
|
||||||
$(testroot_bin)/$(busybox_bin): $(busybox_bin)
|
$(testroot_bin)/$(BBBIN): $(BBBIN)
|
||||||
mkdir -p $(testroot_bin)
|
mkdir -p $(testroot_bin)
|
||||||
cp $(busybox_bin) $(testroot_bin)/
|
cp $(BBBIN) $(testroot_bin)/
|
||||||
chmod +x $(testroot_bin)/$(busybox_bin)
|
chmod +x $(testroot_bin)/$(BBBIN)
|
||||||
|
|
||||||
$(binaries): $(testroot_bin)/$(busybox_bin)
|
$(binaries): $(testroot_bin)/$(BBBIN)
|
||||||
cd $(testroot_bin); \
|
cd $(testroot_bin); \
|
||||||
ln -s $(busybox_bin) $(notdir $@)
|
ln -s $(BBBIN) $(notdir $@)
|
||||||
|
|
||||||
$(testroot_bin)/chrootsetup.sh: chrootsetup.sh
|
$(testroot_bin)/chrootsetup.sh: chrootsetup.sh
|
||||||
cp $< $@
|
cp $< $@
|
||||||
|
|
||||||
libs_src = $(shell ldd $(finit_bin) | grep -v lib64 | grep '=>' | cut -d' ' -f3)
|
libs_src = $(shell ldd $(FINITBIN) | grep -v lib64 | grep '=>' | cut -d' ' -f3)
|
||||||
libs = $(foreach path,$(libs_src),$(testroot)/usr/lib/$(shell basename $(path)))
|
libs = $(foreach path,$(libs_src),$(testroot)/usr/lib/$(shell basename $(path)))
|
||||||
libs64_src = $(shell ldd $(finit_bin) | grep lib64 | grep '=>' | cut -d' ' -f3)
|
libs64_src = $(shell ldd $(FINITBIN) | grep lib64 | grep '=>' | cut -d' ' -f3)
|
||||||
libs64 = $(foreach path,$(libs64_src),$(testroot)/lib64/$(shell basename $(path)))
|
libs64 = $(foreach path,$(libs64_src),$(testroot)/lib64/$(shell basename $(path)))
|
||||||
|
|
||||||
$(testroot)/sbin/finit: $(finit_bin) $(libs) $(libs64)
|
$(testroot)/sbin/finit: $(FINITBIN) $(libs) $(libs64)
|
||||||
cp $< $@
|
cp $< $@
|
||||||
|
|
||||||
.PHONY: test
|
|
||||||
test: $(binaries) $(testroot_bin)/chrootsetup.sh $(dirs) $(testroot)/sbin/finit
|
|
||||||
./runtest.sh test_start_stop_service/test.sh
|
|
||||||
|
|
||||||
$(libs): $@
|
$(libs): $@
|
||||||
cp $(shell ldd $(finit_bin) | cut -d' ' -f3 | grep $(notdir $@)) $@
|
cp $(shell ldd $(FINITBIN) | cut -d' ' -f3 | grep $(notdir $@)) $@
|
||||||
|
|
||||||
$(libs64): $@
|
$(libs64): $@
|
||||||
cp $(shell ldd $(finit_bin) | cut -d' ' -f3 | grep $(notdir $@)) $@
|
cp $(shell ldd $(FINITBIN) | cut -d' ' -f3 | grep $(notdir $@)) $@
|
||||||
|
|
||||||
|
check: $(binaries) $(testroot_bin)/chrootsetup.sh $(dirs) $(testroot)/sbin/finit
|
||||||
|
./runtest.sh test_start_stop_service/test.sh
|
||||||
|
|
||||||
.PHONY: test-check
|
|
||||||
test-check:
|
test-check:
|
||||||
shellcheck $(shell find . -name '*.sh')
|
shellcheck $(shell find . -name '*.sh')
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(testroot)
|
rm -rf $(testroot)
|
||||||
rm -f $(busybox_bin)
|
rm -f $(BBBIN)
|
||||||
Reference in new issue
Block a user