From: j8takagi <j8takagi@nifty.com> Date: Thu, 21 Feb 2019 15:18:57 +0000 (+0900) Subject: make valgrindで、CMD_VALGRINDファイルがあればそのコマンドを実行 X-Git-Tag: 0.2p17 X-Git-Url: https://j8takagi.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;p=autotest_mk.git make valgrindで、CMD_VALGRINDファイルがあればそのコマンドを実行 --- diff --git a/VERSION b/VERSION index 1e8eced..3742f5d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2p16 +0.2p17 diff --git a/template/Define.mk b/template/Define.mk index 48f103d..74f4c33 100644 --- a/template/Define.mk +++ b/template/Define.mk @@ -41,7 +41,9 @@ TEST := test TIME := time TR := tr VALGRIND := valgrind -VALGRINDFLAG := -q --leak-check=full --show-leak-kinds=all --log-file=valgrind.log +VALGRIND_LOGFILE := _valgrind.log +VALGRINDFLAG := -q --leak-check=full --show-leak-kinds=all --log-file=$(VALGRIND_LOGFILE) +VALGRIND_CMDLOGFILE := valgrind.log ###################################################################### # ãã¹ãã°ã«ã¼ãã¨ãã¹ãã§ã®å ±éãã¯ã @@ -68,6 +70,7 @@ define create_dir $(MKDIR) $1 endef + # ãã¡ã¤ã«1ãããã¡ã¤ã«2ã¸ã®ç¸å¯¾ãã¹ # å¼æ°ã¯ããã¡ã¤ã«å1ããã¡ã¤ã«å2 # ç¨ä¾: $(call rel_to,file1,file2) @@ -130,6 +133,9 @@ GROUP_MAKEFILE_REL = $(call rel_to,$(GROUPDIR),$(GROUP_MAKEFILE)) # ãã¹ãã³ãã³ããã¡ã¤ã« CMD_FILE := cmd +# valgrindãã¹ãã³ãã³ããã¡ã¤ã« +VALGRIND_CMD_FILE := cmd_valgrind + # ãã¹ã説æãã¡ã¤ã« DESC_FILE := desc.txt diff --git a/template/Test.mk b/template/Test.mk index def57eb..e8a3135 100644 --- a/template/Test.mk +++ b/template/Test.mk @@ -39,16 +39,16 @@ define time_cmd ($(TIME) ./$1 1>$(DEV_NULL) 2>$(DEV_NULL)) 2>&1 | $(GREP) '^real' >$2 endef -CMD_VALGRIND = $(strip $(shell if test "`$(FILE) $(CMD_FILE)`" = "data"; then cat $(CMD_FILE); else $(PRINTF) "./$(CMD_FILE)"; fi)) +VALGRIND_CMD = $(strip $(shell if test -s $(VALGRIND_CMD_FILE); then $(CAT) $(VALGRIND_CMD_FILE); elif test "`$(FILE) $(CMD_FILE)`" = "data"; then $(CAT) $(CMD_FILE); else $(PRINTF) "./$(CMD_FILE)"; fi)) # valgrindã«ããã¡ã¢ãªã¼ãã§ãã¯çµæããæå®ããããã¡ã¤ã«ã«åºåãã¦è¡¨ç¤º # å¼æ°ã¯ããã¹ãåãã³ãã³ããã¡ã¤ã«ãåºåãã¡ã¤ã« # ç¨ä¾: $(call valgrind_cmd,file_cmd,file_out) define valgrind_cmd - -$(VALGRIND) $(VALGRINDFLAG) $(CMD_VALGRIND) 1>/dev/null 2>&1 + -$(VALGRIND) $(VALGRINDFLAG) $(VALGRIND_CMD) 1>/dev/null 2>&1 endef -# ãã¹ãå®è¡ã³ãã³ãã +# ãã¹ãå®è¡ã³ãã³ã # ã³ãã³ããã¡ã¤ã«ãå®è¡ããæ¨æºåºåãæå®ããããã¡ã¤ã«ã«ä¿åã # ã¨ã©ã¼çºçæã¯ãã¨ã©ã¼åºåãåºåãã¡ã¤ã«ã¨ã¨ã©ã¼ãã¡ã¤ã«ã«ä¿åã # å¼æ°ã¯ãã³ãã³ããã¡ã¤ã«ãåºåãã¡ã¤ã«ãã¨ã©ã¼ãã¡ã¤ã« @@ -129,7 +129,7 @@ reset: all-clean $(CMD_FILE) @$(CAT) $(TEST0_FILE) clean: - @$(RM) $(TEST_RES_FILES) $(TIME_FILE) $(VALGRIND_FILE) core + @$(RM) $(TEST_RES_FILES) $(TIME_FILE) $(VALGRIND_LOGFILE) $(VALGRIND_CMDLOGFILE) core all-clean: clean @$(RM) $(TEST0_FILE) @@ -140,11 +140,14 @@ time: time-clean $(TIME_FILE) time-clean: @$(RM) $(TIME_FILE) -valgrind: valgrind-clean $(VALGRIND_FILE) - if test -s $(VALGRIND_FILE); then $(ECHO) $(CURDIR) && $(CAT) $(VALGRIND_FILE); else $(RM) $(VALGRIND_FILE); fi +valgrind: valgrind-clean $(VALGRIND_LOGFILE) $(VALGRIND_CMDLOGFILE) + if test -s $(VALGRIND_LOGFILE); then $(ECHO) $(CURDIR) && $(CAT) $(VALGRIND_LOGFILE); else $(RM) $(VALGRIND_LOGFILE); fi + +$(VALGRIND_CMDLOGFILE): $(VALGRIND_LOGFILE) + @$(PRINTF) "$(VALGRIND) $(VALGRINDFLAG) $(VALGRIND_CMD)\n" | $(CAT) - $(VALGRIND_LOGFILE) >$(VALGRIND_CMDLOGFILE) valgrind-clean: - @$(RM) $(VALGRIND_FILE) + @$(RM) $(VALGRIND_LOGFILE) $(TEST1_FILE): $(CMD_FILE) @-$(call exec_cmd,$^,$@,$(ERR_FILE)) @@ -161,5 +164,5 @@ $(DETAIL_FILE): $(LOG_FILE) $(TIME_FILE): $(CMD_FILE) @$(call time_cmd,$^,$@) -$(VALGRIND_FILE): $(CMD_FILE) +$(VALGRIND_LOGFILE): $(CMD_FILE) $(call valgrind_cmd,$^,$@)