btrfs-progs: preload libbtrfs for libbtrfs-test

The libbtrfs-test simulated build happens outside of the source
repository, but sometimes the system library is used instead of the repo
one. When -rpath does not work, force the correct library by LD_PRELOAD.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2019-10-24 02:02:07 +02:00
parent c15c559f54
commit 075f147cef
1 changed files with 2 additions and 1 deletions

View File

@ -624,9 +624,10 @@ library-test: library-test.c libbtrfs.so
@echo " [TEST PREP] $@"$(eval TMPD=$(shell mktemp -d))
$(Q)mkdir -p $(TMPD)/include/btrfs && \
cp $(libbtrfs_headers) $(TMPD)/include/btrfs && \
cp libbtrfs.so.0.1 $(TMPD) && \
cd $(TMPD) && $(CC) -I$(TMPD)/include -o $@ $(addprefix $(ABSTOPDIR)/,$^) -Wl,-rpath=$(ABSTOPDIR) -lbtrfs
@echo " [TEST RUN] $@"
$(Q)cd $(TMPD) && ./$@
$(Q)cd $(TMPD) && LD_PRELOAD=libbtrfs.so.0.1 ./$@
@echo " [TEST CLEAN] $@"
$(Q)$(RM) -rf -- $(TMPD)