test: Fix and clean up dynamic library setup

Signed-off-by: Jacques de Laval <jacques@de-laval.se>
This commit is contained in:
Jacques de Laval committed 2021-02-20 11:05:41 +01:00
1 parent c80a755dc6
commit e72fd5a271
1 file changed
+9 -15
+9 -15
View File
@@ -11,6 +11,7 @@ BBURL ?= https://www.busybox.net/downloads/binaries/$(BBVER)-defconfig-multiarch
testroot = test_root testroot = test_root
testroot_bin = $(testroot)/bin testroot_bin = $(testroot)/bin
binaries = $(testroot_bin)/cat \ binaries = $(testroot_bin)/cat \
$(testroot_bin)/cp \
$(testroot_bin)/date \ $(testroot_bin)/date \
$(testroot_bin)/echo \ $(testroot_bin)/echo \
$(testroot_bin)/kill \ $(testroot_bin)/kill \
@@ -30,13 +31,13 @@ binaries = $(testroot_bin)/cat \
dirs = $(testroot)/bin \ dirs = $(testroot)/bin \
$(testroot)/dev \ $(testroot)/dev \
$(testroot)/etc \ $(testroot)/etc \
$(testroot)/lib \
$(testroot)/lib64 \
$(testroot)/proc \ $(testroot)/proc \
$(testroot)/sbin \ $(testroot)/sbin \
$(testroot)/sys \ $(testroot)/sys \
$(testroot)/tmp \ $(testroot)/tmp
$(testroot)/usr/lib
_libs_src = $(shell ldd $(FINITBIN) | grep -Eo '/[^ ]+')
libs = $(foreach path,$(_libs_src),$(testroot)$(path))
all: check all: check
@@ -62,19 +63,12 @@ $(binaries): $(testroot_bin)/$(BBBIN)
$(testroot_bin)/chrootsetup.sh: chrootsetup.sh $(testroot_bin)/chrootsetup.sh: chrootsetup.sh
cp $< $@ cp $< $@
libs_src = $(shell ldd $(FINITBIN) | grep -v lib64 | grep '=>' | cut -d' ' -f3) $(testroot)/sbin/finit: $(FINITBIN) $(libs)
libs = $(foreach path,$(libs_src),$(testroot)/usr/lib/$(shell basename $(path)))
libs64_src = $(shell ldd $(FINITBIN) | grep lib64 | grep '=>' | cut -d' ' -f3)
libs64 = $(foreach path,$(libs64_src),$(testroot)/lib64/$(shell basename $(path)))
$(testroot)/sbin/finit: $(FINITBIN) $(libs) $(libs64)
cp $< $@ cp $< $@
$(libs): $@ $(libs):
cp $(shell ldd $(FINITBIN) | cut -d' ' -f3 | grep $(notdir $@)) $@ mkdir -p $(dir $@)
cp $(shell echo $@ | sed s/^$(testroot)//) $@
$(libs64): $@
cp $(shell ldd $(FINITBIN) | cut -d' ' -f3 | grep $(notdir $@)) $@
check: $(binaries) $(testroot_bin)/chrootsetup.sh $(dirs) $(testroot)/sbin/finit check: $(binaries) $(testroot_bin)/chrootsetup.sh $(dirs) $(testroot)/sbin/finit
./runtest.sh test_start_stop_service/test.sh ./runtest.sh test_start_stop_service/test.sh