Add stress test capabilites for make test

This commit is contained in:
Hui, Chunyang 2021-10-14 09:47:03 +00:00 committed by Zongmin.Gu
parent 2af05238be
commit d60bdd3771
2 changed files with 37 additions and 10 deletions

@ -243,7 +243,15 @@ To build Occlum from the latest source code, do the following steps in an Occlum
3. Compile and test Occlum
```
make
# test musl based binary
make test
# test glibc based binary
make test-glibc
# stress test
make test times=100
```
For platforms that don't support SGX

@ -2,6 +2,9 @@ CUR_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
PROJECT_DIR := $(realpath $(CUR_DIR)/../)
SGX_MODE ?= HW
# Repeat times for make test. Default to 1
STRESS_TEST_TIMES ?= 1
C_SRCS := $(wildcard */*.c */*.h)
CXX_SRCS := $(wildcard */*.cc)
@ -67,30 +70,43 @@ postbuild:
# Test targets
#############################################################################
test-glibc:
@OCCLUM_TEST_GLIBC=1 $(MAKE) test
test:
@$(MAKE) test-common
test: build pretest $(TEST_TARGETS) posttest
test-glibc:
@OCCLUM_TEST_GLIBC=1 $(MAKE) test-common
test-common:
@if [ -n "$(times)" ] && [ "$(times)" -eq "$(times)" ] 2>/dev/null; then \
export STRESS_TEST_TIMES=$(times); \
fi ; \
$(MAKE) test-internal
test-internal: build pretest $(TEST_TARGETS) posttest
pretest:
@$(RM) $(PASS_LOG) $(FAIL_LOG)
@cd $(BUILD_DIR)/test && \
$(BUILD_DIR)/bin/occlum start
# Restart server if test failed
$(TEST_TARGETS): test-%: %
@touch $(PASS_LOG) $(FAIL_LOG)
@$(ECHO) "$(CYAN)RUN TEST => $<$(NO_COLOR)"
@# Restart server if test failed
@$(MAKE) --no-print-directory -C $< test ; \
@for i in $$(seq 1 $(STRESS_TEST_TIMES)); \
do \
$(ECHO) "$(CYAN)RUN TEST => $<$(NO_COLOR)"; \
$(MAKE) --no-print-directory -C $< test ; \
if [ $$? -eq 0 ] ; then \
$(ECHO) "$(GREEN)PASS$(NO_COLOR)" ; \
$(ECHO) "$< PASS" >> $(PASS_LOG) ; \
$(ECHO) "$(GREEN)PASS $(NO_COLOR)" ; \
$(ECHO) "$< PASS $$i" >> $(PASS_LOG) ; \
else \
$(ECHO) "$(RED)FAILED$(NO_COLOR)" ; \
$(ECHO) "$< FAILED" >> $(FAIL_LOG) ; \
$(ECHO) "$< FAILED $$i" >> $(FAIL_LOG) ; \
cd $(BUILD_DIR)/test && \
$(BUILD_DIR)/bin/occlum start ; \
fi ;
cd -; \
fi ; \
done
posttest:
@cd $(BUILD_DIR)/test && \
@ -100,6 +116,9 @@ posttest:
$(ECHO) "\nTotal:" ; \
$(ECHO) "$(GREEN)PASS: $$PASS_NUM $(RED)FAILED: $$FAIL_NUM $(NO_COLOR)" ; \
if [ $$FAIL_NUM -ne 0 ] ; then \
$(ECHO) "\nFAILED TESTS:$(RED)" ; \
cat $(FAIL_LOG); \
$(ECHO) "$(NO_COLOR)====================="; \
exit 1; \
fi ;