From a82d72ebf5d1e07ec8ed10102b94f04ff09ed601 Mon Sep 17 00:00:00 2001 From: j8takagi Date: Sat, 16 Feb 2019 11:29:28 +0900 Subject: [PATCH] =?utf8?q?valgrind=E3=82=92=E3=80=81cmd=E3=81=8C=E3=82=B7?= =?utf8?q?=E3=82=A7=E3=83=AB=E3=82=B9=E3=82=AF=E3=83=AA=E3=83=97=E3=83=88?= =?utf8?q?=E3=81=A7=E3=82=82C=E5=AE=9F=E8=A1=8C=E3=83=95=E3=82=A1=E3=82=A4?= =?utf8?q?=E3=83=AB=E3=81=A7=E3=82=82=E5=8F=AF=E8=83=BD=E3=81=AA=E3=82=88?= =?utf8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- template/Define.mk | 5 ++++- template/Test.mk | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/template/Define.mk b/template/Define.mk index d4c3b94..f8e6dd9 100644 --- a/template/Define.mk +++ b/template/Define.mk @@ -27,18 +27,21 @@ DEV_NULL := /dev/null DIFF := diff -c ECHO := echo EXPR := expr +FILE := file -b -e ascii FIND := find GREP := grep LINECOUNT := wc -l LN := ln -s MKDIR := mkdir -p MV := mv +PRINTF := printf +REALPATH := realpath SED := sed TEST := test TIME := time TR := tr VALGRIND := valgrind -VALGRINDFLAG := -q --leak-check=full --log-file=valgrind.log +VALGRINDFLAG := -q --leak-check=full --show-leak-kinds=all --log-file=valgrind.log ###################################################################### # テストグループとテストでの共通マクロ diff --git a/template/Test.mk b/template/Test.mk index 13178f6..def57eb 100644 --- a/template/Test.mk +++ b/template/Test.mk @@ -39,11 +39,13 @@ 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によるメモリーチェック結果を、指定されたファイルに出力して表示 # 引数は、テスト名、コマンドファイル、出力ファイル # 用例: $(call valgrind_cmd,file_cmd,file_out) define valgrind_cmd - -$(VALGRIND) $(VALGRINDFLAG) $(strip $(shell tail -1 $(CMD_FILE))) 1>/dev/null 2>&1 + -$(VALGRIND) $(VALGRINDFLAG) $(CMD_VALGRIND) 1>/dev/null 2>&1 endef # テスト実行コマンド。 @@ -127,7 +129,7 @@ reset: all-clean $(CMD_FILE) @$(CAT) $(TEST0_FILE) clean: - @$(RM) $(TEST_RES_FILES) $(TIME_FILE) $(VALGRIND_FILE) + @$(RM) $(TEST_RES_FILES) $(TIME_FILE) $(VALGRIND_FILE) core all-clean: clean @$(RM) $(TEST0_FILE) -- 2.18.0