From a0d7910e91429150c698c4c54faa7239c706cca9 Mon Sep 17 00:00:00 2001 From: Nathan Ross Date: Sun, 20 Dec 2015 19:48:26 -0500 Subject: [PATCH 1/3] add back busybox test support --- Makefile | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Makefile b/Makefile index 0db41b849..7a73dc201 100644 --- a/Makefile +++ b/Makefile @@ -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) From 73cfb04d1107e95f9c2f9d06b58acab1243c0f7f Mon Sep 17 00:00:00 2001 From: Nathan Ross Date: Sun, 20 Dec 2015 19:48:52 -0500 Subject: [PATCH 2/3] add busybox test instructions to README.md --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 71b110aa1..2675aa74d 100644 --- a/README.md +++ b/README.md @@ -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 ---------- From 5ee7b5b8fcb1cc074412f681479465734391d561 Mon Sep 17 00:00:00 2001 From: Nathan Ross Date: Sun, 20 Dec 2015 20:55:16 -0500 Subject: [PATCH 3/3] rm recognition of "busybox" bin name in uutils.rs --- src/uutils/uutils.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/uutils/uutils.rs b/src/uutils/uutils.rs index 28d7c650d..de335b6f2 100644 --- a/src/uutils/uutils.rs +++ b/src/uutils/uutils.rs @@ -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); }