Merge pull request #751 from nathanross/busybox-approach-2

Add busybox test functionality
This commit is contained in:
Heather 2015-12-21 08:08:08 +04:00
commit ec3490b5b2
3 changed files with 61 additions and 6 deletions

View file

@ -24,6 +24,10 @@ BASEDIR ?= $(shell pwd)
BUILDDIR := $(BASEDIR)/target/${PROFILE}/
PKG_BUILDDIR := $(BUILDDIR)/deps/
BUSYBOX_ROOT := $(BASEDIR)/tmp/
BUSYBOX_VER := 1.24.1
BUSYBOX_SRC:=$(BUSYBOX_ROOT)/busybox-$(BUSYBOX_VER)/
# Possible programs
PROGS := \
base64 \
@ -160,6 +164,11 @@ TEST ?= $(TEST_PROGS)
TESTS := \
$(sort $(filter $(TEST),$(filter-out $(DONT_TEST),$(TEST_PROGS))))
BUSYTEST ?= $(PROGS)
BUSYTESTS := \
$(sort $(filter $(BUSYTEST),$(filter-out $(DONT_BUSYTEST),$(PROGS))))
define BUILD_EXE
build_exe_$(1):
${CARGO} build ${CARGOFLAGS} ${PROFILE_CMD} -p $(1)
@ -170,6 +179,11 @@ test_integration_$(1): build_exe_$(1)
${CARGO} test ${CARGOFLAGS} --test $(1) --features $(1) --no-default-features
endef
define TEST_BUSYBOX
test_busybox_$(1): build_exe_$(1)
(cd $(BUSYBOX_SRC)/testsuite && bindir=$(BUILDDIR) ./runtest $(RUNTEST_ARGS) $(1) )
endef
# Output names
EXES := \
$(sort $(filter $(BUILD),$(filter-out $(DONT_BUILD),$(PROGS))))
@ -210,9 +224,35 @@ build-uutils: $(addprefix build_exe_,$(EXES))
build: build-uutils
$(foreach test,$(TESTS),$(eval $(call TEST_INTEGRATION,$(test))))
$(foreach test,$(PROGS),$(eval $(call TEST_BUSYBOX,$(test))))
test: $(addprefix test_integration_,$(TESTS))
busybox-src:
if [ ! -e $(BUSYBOX_SRC) ]; then \
mkdir -p $(BUSYBOX_ROOT); \
wget http://busybox.net/downloads/busybox-$(BUSYBOX_VER).tar.bz2 -P $(BUSYBOX_ROOT); \
tar -C $(BUSYBOX_ROOT) -xf $(BUSYBOX_ROOT)/busybox-$(BUSYBOX_VER).tar.bz2; \
fi; \
ensure-builddir:
mkdir -p $(BUILDDIR)
# Test under the busybox testsuite
$(BUILDDIR)/busybox: busybox-src ensure-builddir
echo '#!/bin/bash\n$(PKG_BUILDDIR)./$$1 $${@:2}' > $@; \
chmod +x $@;
# This is a busybox-specific config file their test suite wants to parse.
$(BUILDDIR)/.config: $(BASEDIR)/.busybox-config ensure-builddir
cp $< $@
ifeq ($(BUSYTESTS),)
busytest:
else
busytest: $(BUILDDIR)/busybox $(BUILDDIR)/.config $(addprefix test_busybox_,$(BUSYTESTS))
endif
clean:
$(RM) -rf $(BUILDDIR)

View file

@ -110,6 +110,26 @@ To test only a few of the available utilities:
make TEST='UTILITY_1 UTILITY_2' test
```
Run busybox tests
-----------------
This testing functionality is only available on *nix operating systems
To run busybox's tests for all utilities for which busybox has tests
```
make busytest
```
To run busybox's tests for a few of the available utilities
```
make BUSYTEST='UTILITY_1 UTILITY_2' busytest
```
To pass an argument like "-v" to the busybox test runtime
```
make BUSYTEST='UTILITY_1 UTILITY_2' RUNTEST_ARGS='-v' busytest
```
Contribute
----------

View file

@ -49,12 +49,7 @@ fn main() {
None => (),
}
if binary_as_util.ends_with("uutils") || binary_as_util.starts_with("uutils") ||
binary_as_util.ends_with("busybox") || binary_as_util.starts_with("busybox") {
// uutils can be called as either "uutils", "busybox"
// "uutils-suffix" or "busybox-suffix". Not sure
// what busybox uses the -suffix pattern for.
} else {
if !(binary_as_util.ends_with("uutils") || binary_as_util.starts_with("uutils")) {
println!("{}: applet not found", binary_as_util);
std::process::exit(1);
}