Add stress test capabilites for make test
This commit is contained in:
parent
2af05238be
commit
d60bdd3771
@ -243,7 +243,15 @@ To build Occlum from the latest source code, do the following steps in an Occlum
|
|||||||
3. Compile and test Occlum
|
3. Compile and test Occlum
|
||||||
```
|
```
|
||||||
make
|
make
|
||||||
|
|
||||||
|
# test musl based binary
|
||||||
make test
|
make test
|
||||||
|
|
||||||
|
# test glibc based binary
|
||||||
|
make test-glibc
|
||||||
|
|
||||||
|
# stress test
|
||||||
|
make test times=100
|
||||||
```
|
```
|
||||||
|
|
||||||
For platforms that don't support SGX
|
For platforms that don't support SGX
|
||||||
|
@ -2,6 +2,9 @@ CUR_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
|||||||
PROJECT_DIR := $(realpath $(CUR_DIR)/../)
|
PROJECT_DIR := $(realpath $(CUR_DIR)/../)
|
||||||
SGX_MODE ?= HW
|
SGX_MODE ?= HW
|
||||||
|
|
||||||
|
# Repeat times for make test. Default to 1
|
||||||
|
STRESS_TEST_TIMES ?= 1
|
||||||
|
|
||||||
C_SRCS := $(wildcard */*.c */*.h)
|
C_SRCS := $(wildcard */*.c */*.h)
|
||||||
CXX_SRCS := $(wildcard */*.cc)
|
CXX_SRCS := $(wildcard */*.cc)
|
||||||
|
|
||||||
@ -67,30 +70,43 @@ postbuild:
|
|||||||
# Test targets
|
# Test targets
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
test-glibc:
|
test:
|
||||||
@OCCLUM_TEST_GLIBC=1 $(MAKE) 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:
|
pretest:
|
||||||
@$(RM) $(PASS_LOG) $(FAIL_LOG)
|
@$(RM) $(PASS_LOG) $(FAIL_LOG)
|
||||||
@cd $(BUILD_DIR)/test && \
|
@cd $(BUILD_DIR)/test && \
|
||||||
$(BUILD_DIR)/bin/occlum start
|
$(BUILD_DIR)/bin/occlum start
|
||||||
|
|
||||||
|
# Restart server if test failed
|
||||||
$(TEST_TARGETS): test-%: %
|
$(TEST_TARGETS): test-%: %
|
||||||
@touch $(PASS_LOG) $(FAIL_LOG)
|
@touch $(PASS_LOG) $(FAIL_LOG)
|
||||||
@$(ECHO) "$(CYAN)RUN TEST => $<$(NO_COLOR)"
|
@for i in $$(seq 1 $(STRESS_TEST_TIMES)); \
|
||||||
@# Restart server if test failed
|
do \
|
||||||
@$(MAKE) --no-print-directory -C $< test ; \
|
$(ECHO) "$(CYAN)RUN TEST => $<$(NO_COLOR)"; \
|
||||||
|
$(MAKE) --no-print-directory -C $< test ; \
|
||||||
if [ $$? -eq 0 ] ; then \
|
if [ $$? -eq 0 ] ; then \
|
||||||
$(ECHO) "$(GREEN)PASS $(NO_COLOR)" ; \
|
$(ECHO) "$(GREEN)PASS $(NO_COLOR)" ; \
|
||||||
$(ECHO) "$< PASS" >> $(PASS_LOG) ; \
|
$(ECHO) "$< PASS $$i" >> $(PASS_LOG) ; \
|
||||||
else \
|
else \
|
||||||
$(ECHO) "$(RED)FAILED$(NO_COLOR)" ; \
|
$(ECHO) "$(RED)FAILED$(NO_COLOR)" ; \
|
||||||
$(ECHO) "$< FAILED" >> $(FAIL_LOG) ; \
|
$(ECHO) "$< FAILED $$i" >> $(FAIL_LOG) ; \
|
||||||
cd $(BUILD_DIR)/test && \
|
cd $(BUILD_DIR)/test && \
|
||||||
$(BUILD_DIR)/bin/occlum start ; \
|
$(BUILD_DIR)/bin/occlum start ; \
|
||||||
fi ;
|
cd -; \
|
||||||
|
fi ; \
|
||||||
|
done
|
||||||
|
|
||||||
posttest:
|
posttest:
|
||||||
@cd $(BUILD_DIR)/test && \
|
@cd $(BUILD_DIR)/test && \
|
||||||
@ -100,6 +116,9 @@ posttest:
|
|||||||
$(ECHO) "\nTotal:" ; \
|
$(ECHO) "\nTotal:" ; \
|
||||||
$(ECHO) "$(GREEN)PASS: $$PASS_NUM $(RED)FAILED: $$FAIL_NUM $(NO_COLOR)" ; \
|
$(ECHO) "$(GREEN)PASS: $$PASS_NUM $(RED)FAILED: $$FAIL_NUM $(NO_COLOR)" ; \
|
||||||
if [ $$FAIL_NUM -ne 0 ] ; then \
|
if [ $$FAIL_NUM -ne 0 ] ; then \
|
||||||
|
$(ECHO) "\nFAILED TESTS:$(RED)" ; \
|
||||||
|
cat $(FAIL_LOG); \
|
||||||
|
$(ECHO) "$(NO_COLOR)====================="; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi ;
|
fi ;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user