mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
Merge pull request #751 from nathanross/busybox-approach-2
Add busybox test functionality
This commit is contained in:
commit
ec3490b5b2
3 changed files with 61 additions and 6 deletions
40
Makefile
40
Makefile
|
@ -24,6 +24,10 @@ BASEDIR ?= $(shell pwd)
|
||||||
BUILDDIR := $(BASEDIR)/target/${PROFILE}/
|
BUILDDIR := $(BASEDIR)/target/${PROFILE}/
|
||||||
PKG_BUILDDIR := $(BUILDDIR)/deps/
|
PKG_BUILDDIR := $(BUILDDIR)/deps/
|
||||||
|
|
||||||
|
BUSYBOX_ROOT := $(BASEDIR)/tmp/
|
||||||
|
BUSYBOX_VER := 1.24.1
|
||||||
|
BUSYBOX_SRC:=$(BUSYBOX_ROOT)/busybox-$(BUSYBOX_VER)/
|
||||||
|
|
||||||
# Possible programs
|
# Possible programs
|
||||||
PROGS := \
|
PROGS := \
|
||||||
base64 \
|
base64 \
|
||||||
|
@ -160,6 +164,11 @@ TEST ?= $(TEST_PROGS)
|
||||||
TESTS := \
|
TESTS := \
|
||||||
$(sort $(filter $(TEST),$(filter-out $(DONT_TEST),$(TEST_PROGS))))
|
$(sort $(filter $(TEST),$(filter-out $(DONT_TEST),$(TEST_PROGS))))
|
||||||
|
|
||||||
|
BUSYTEST ?= $(PROGS)
|
||||||
|
BUSYTESTS := \
|
||||||
|
$(sort $(filter $(BUSYTEST),$(filter-out $(DONT_BUSYTEST),$(PROGS))))
|
||||||
|
|
||||||
|
|
||||||
define BUILD_EXE
|
define BUILD_EXE
|
||||||
build_exe_$(1):
|
build_exe_$(1):
|
||||||
${CARGO} build ${CARGOFLAGS} ${PROFILE_CMD} -p $(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
|
${CARGO} test ${CARGOFLAGS} --test $(1) --features $(1) --no-default-features
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
define TEST_BUSYBOX
|
||||||
|
test_busybox_$(1): build_exe_$(1)
|
||||||
|
(cd $(BUSYBOX_SRC)/testsuite && bindir=$(BUILDDIR) ./runtest $(RUNTEST_ARGS) $(1) )
|
||||||
|
endef
|
||||||
|
|
||||||
# Output names
|
# Output names
|
||||||
EXES := \
|
EXES := \
|
||||||
$(sort $(filter $(BUILD),$(filter-out $(DONT_BUILD),$(PROGS))))
|
$(sort $(filter $(BUILD),$(filter-out $(DONT_BUILD),$(PROGS))))
|
||||||
|
@ -210,9 +224,35 @@ build-uutils: $(addprefix build_exe_,$(EXES))
|
||||||
build: build-uutils
|
build: build-uutils
|
||||||
|
|
||||||
$(foreach test,$(TESTS),$(eval $(call TEST_INTEGRATION,$(test))))
|
$(foreach test,$(TESTS),$(eval $(call TEST_INTEGRATION,$(test))))
|
||||||
|
$(foreach test,$(PROGS),$(eval $(call TEST_BUSYBOX,$(test))))
|
||||||
|
|
||||||
test: $(addprefix test_integration_,$(TESTS))
|
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:
|
clean:
|
||||||
$(RM) -rf $(BUILDDIR)
|
$(RM) -rf $(BUILDDIR)
|
||||||
|
|
||||||
|
|
20
README.md
20
README.md
|
@ -110,6 +110,26 @@ To test only a few of the available utilities:
|
||||||
make TEST='UTILITY_1 UTILITY_2' test
|
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
|
Contribute
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
|
|
@ -49,12 +49,7 @@ fn main() {
|
||||||
None => (),
|
None => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
if binary_as_util.ends_with("uutils") || binary_as_util.starts_with("uutils") ||
|
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 {
|
|
||||||
println!("{}: applet not found", binary_as_util);
|
println!("{}: applet not found", binary_as_util);
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue