Skip to content

Commit

Permalink
Enable pretty output for test suite
Browse files Browse the repository at this point in the history
Detailed testing procedure is only activated when VERBOSE equals to 1.
  • Loading branch information
jserv committed Aug 12, 2018
1 parent 50a0986 commit ce7846c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
41 changes: 24 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,23 @@ $(BIN)-native: $(BIN).c
-ldl

check: $(EXEC) $(TEST_OBJ)
$(VECHO) "[ C to IR ]\n"
$(Q)./$(BIN)-native -s tests/arginc.c | diff tests/arginc.list -
$(VECHO) "[ JIT ]\n"
$(Q)$(ARM_EXEC) ./$(BIN) tests/hello.c
$(VECHO) "[ compiled ]\n"
$(VECHO) "[ C to IR translation ]"
$(Q)./$(BIN)-native -s tests/arginc.c | diff tests/arginc.list - \
&& $(call pass)
$(VECHO) "[ JIT compilation + execution ]"
$(Q)if [ "$(shell $(ARM_EXEC) ./$(BIN) tests/hello.c)" = "hello, world" ]; then \
$(call pass); \
fi
$(VECHO) "[ ELF generation ]"
$(Q)$(ARM_EXEC) ./$(BIN) -o $(OBJ_DIR)/hello tests/hello.c
$(Q)$(ARM_EXEC) $(OBJ_DIR)/hello
$(VECHO) "[ nested ]\n"
$(Q)$(ARM_EXEC) ./$(BIN) $(BIN).c tests/hello.c
$(VECHO) "[ Compatibility with GCC ]\n"
$(Q)if [ "$(shell $(ARM_EXEC) $(OBJ_DIR)/hello)" = "hello, world" ]; then \
$(call pass); \
fi
$(VECHO) "[ nested/self compilation ]"
$(Q)if [ "$(shell $(ARM_EXEC) ./$(BIN) $(BIN).c tests/hello.c)" = "hello, world" ]; then \
$(call pass); \
fi
$(VECHO) "[ Compatibility with GCC/Arm ]\n"
$(Q)python runtest.py || echo

$(OBJ_DIR)/$(BIN): $(BIN)
Expand All @@ -40,14 +47,14 @@ $(OBJ_DIR)/$(BIN): $(BIN)

SHELL_HACK := $(shell mkdir -p $(OBJ_DIR))
$(TEST_DIR)/%.o: $(TEST_DIR)/%.c $(BIN) $(OBJ_DIR)/$(BIN)
$(VECHO) "[*** verify $< <JIT>********]\n"
$(Q)$(ARM_EXEC) ./$(BIN) $< 2
$(VECHO) "[*** verify $< <ELF>********]\n"
$(Q)$(ARM_EXEC) ./$(BIN) -o $(OBJ_DIR)/$(notdir $(basename $<)) $<
$(Q)$(ARM_EXEC) $(OBJ_DIR)/$(notdir $(basename $<)) 2
$(VECHO) "[*** verify $< <ELF-self>***]\n"
$(Q)$(ARM_EXEC) ./$(OBJ_DIR)/$(BIN) $< 2
$(VECHO) "$(PASS_COLOR)$< pass$(NO_COLOR)\n"
$(VECHO) "[*** verify $< <JIT> *******]\n"
$(Q)$(ARM_EXEC) ./$(BIN) $< 2 $(REDIR)
$(VECHO) "[*** verify $< <ELF> *******]\n"
$(Q)$(ARM_EXEC) ./$(BIN) -o $(OBJ_DIR)/$(notdir $(basename $<)) $< $(REDIR)
$(Q)$(ARM_EXEC) $(OBJ_DIR)/$(notdir $(basename $<)) 2 $(REDIR)
$(VECHO) "[*** verify $< <ELF-self> **]\n"
$(Q)$(ARM_EXEC) ./$(OBJ_DIR)/$(BIN) $< 2 $(REDIR)
$(Q)$(call pass,$<)

clean:
$(RM) $(EXEC) $(OBJ_DIR)/* \
Expand Down
3 changes: 3 additions & 0 deletions mk/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ endif
ifeq ("$(VERBOSE)","1")
Q :=
VECHO = @true
REDIR =
else
Q := @
VECHO = @$(PRINTF)
REDIR = >/dev/null
endif

# Test suite
PASS_COLOR = \e[32;01m
NO_COLOR = \e[0m

pass = $(PRINTF) "$(PASS_COLOR)$1 Passed$(NO_COLOR)\n"

0 comments on commit ce7846c

Please sign in to comment.