From: j8takagi Date: Wed, 26 Jan 2011 13:39:40 +0000 (+0900) Subject: セルフテストを修正し、テンプレートもセルフテストに合わせて変更 X-Git-Tag: 0.2p3~16 X-Git-Url: https://j8takagi.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2c3d175e3cab882c137c5c53cc1dbe648405827;p=autotest_mk.git セルフテストを修正し、テンプレートもセルフテストに合わせて変更 テスト結果でカレントディレクトリを出力する場合は、「$PWD」に置換 --- diff --git a/selftest/unittest/Define_group.mk b/selftest/unittest/Define_group.mk deleted file mode 120000 index aa8100a..0000000 --- a/selftest/unittest/Define_group.mk +++ /dev/null @@ -1 +0,0 @@ -../../template/Define_group.mk \ No newline at end of file diff --git a/selftest/unittest/Define_test.mk b/selftest/unittest/Define_test.mk deleted file mode 120000 index d1df03e..0000000 --- a/selftest/unittest/Define_test.mk +++ /dev/null @@ -1 +0,0 @@ -../../template/Define_test.mk \ No newline at end of file diff --git a/selftest/unittest/chk_file_ext/0.txt b/selftest/unittest/chk_file_ext/0.txt index 260671d..2bffdac 100644 --- a/selftest/unittest/chk_file_ext/0.txt +++ b/selftest/unittest/chk_file_ext/0.txt @@ -1,5 +1,5 @@ b: not exist b/b.txt: not exist -Makefile:14: *** a exists in /home/kazubito/2010_12/autotest.mk/selftest/unittest/chk_file_ext. 中止. -Makefile:18: *** a/a.txt exists in /home/kazubito/2010_12/autotest.mk/selftest/unittest/chk_file_ext. 中止. +Makefile:13: *** a exists in $PWD. Stop. +Makefile:17: *** a/a.txt exists in $PWD. Stop. diff --git a/selftest/unittest/chk_file_ext/Makefile b/selftest/unittest/chk_file_ext/Makefile index bf2e4c6..3a58e4b 100644 --- a/selftest/unittest/chk_file_ext/Makefile +++ b/selftest/unittest/chk_file_ext/Makefile @@ -1,5 +1,4 @@ include ../Define.mk -include ../Define_test.mk include ../Test.mk .PHONY: utest utest_err1 utest_err2 diff --git a/selftest/unittest/chk_var_null/0.txt b/selftest/unittest/chk_var_null/0.txt index 389f8d0..758a890 100644 --- a/selftest/unittest/chk_var_null/0.txt +++ b/selftest/unittest/chk_var_null/0.txt @@ -1,5 +1,5 @@ VAR_0: 0 VAR_1: 1 VAR_NULL: -Makefile:18: *** NULL argument. 中止. +Makefile:17: *** NULL argument. Stop. diff --git a/selftest/unittest/chk_var_null/Makefile b/selftest/unittest/chk_var_null/Makefile index 793d9cc..178f406 100644 --- a/selftest/unittest/chk_var_null/Makefile +++ b/selftest/unittest/chk_var_null/Makefile @@ -1,5 +1,4 @@ include ../Define.mk -include ../Define_test.mk include ../Test.mk .PHONY: utest utest_err diff --git a/selftest/unittest/create_dir/0.txt b/selftest/unittest/create_dir/0.txt index 468bd1a..78f649a 100644 --- a/selftest/unittest/create_dir/0.txt +++ b/selftest/unittest/create_dir/0.txt @@ -1,4 +1,4 @@ atest -Makefile:15: *** NULL argument. 中止. -Makefile:12: *** atest exists in /home/kazubito/2010_12/autotest.mk/selftest/unittest/create_dir. 中止. +Makefile:13: *** NULL argument. Stop. +Makefile:10: *** atest exists in $PWD. Stop. diff --git a/selftest/unittest/create_dir/Makefile b/selftest/unittest/create_dir/Makefile index b75fceb..71cef8b 100644 --- a/selftest/unittest/create_dir/Makefile +++ b/selftest/unittest/create_dir/Makefile @@ -1,7 +1,5 @@ include ../Define.mk -include ../Define_test.mk include ../Test.mk -include ../Define_group.mk .PHONY: utest utest_err clean_utest diff --git a/selftest/unittest/create_dir/report_detail.txt b/selftest/unittest/create_dir/report_detail.txt deleted file mode 100644 index a6803aa..0000000 --- a/selftest/unittest/create_dir/report_detail.txt +++ /dev/null @@ -1,13 +0,0 @@ -引数として指定したディレクトリーを作成 -引数が指定されない場合は、エラー終了 -ディレクトリーが既存の場合は、エラー終了 -create_dir: Test Success 2010-11-28 19:06:19 -make -s clean_utest -make -s utest 2>&1 && ls | grep atest -make -s utest_err 2>&1 && ls | grep atest -make -s utest 2>&1 && ls | grep atest -echo -atest -Makefile:15: *** NULL argument. 中止. -Makefile:12: *** atest exists in /home/kazubito/2010_11/autotest.mk/selftest/unittest/create_dir. 中止. - diff --git a/selftest/unittest/create_makefile/0.txt b/selftest/unittest/create_makefile/0.txt index 39531db..617c0d5 100644 --- a/selftest/unittest/create_makefile/0.txt +++ b/selftest/unittest/create_makefile/0.txt @@ -1,4 +1,3 @@ include ../Define.mk -include ../Define_test.mk include ../Test.mk diff --git a/selftest/unittest/create_makefile/Makefile b/selftest/unittest/create_makefile/Makefile index 5a21ced..5d60877 100644 --- a/selftest/unittest/create_makefile/Makefile +++ b/selftest/unittest/create_makefile/Makefile @@ -1,11 +1,8 @@ include ../Define.mk -include ../Define_test.mk include ../Test.mk -include ../Define_group.mk - override TEST_RES_FILES := $(TEST_RES_FILES) 0.mk utest: echo $(TEST_INCLUDE_FILES) - $(call create_makefile,0.mk,$(TEST_MAKEFILES)) + $(call create_makefile,0.mk,$(MAKEFILES)) diff --git a/selftest/unittest/desc_log/Makefile b/selftest/unittest/desc_log/Makefile index 7a135fa..d19867d 100644 --- a/selftest/unittest/desc_log/Makefile +++ b/selftest/unittest/desc_log/Makefile @@ -1,5 +1,4 @@ include ../Define.mk -include ../Define_test.mk include ../Test.mk utest: diff --git a/selftest/unittest/exec_cmd/Makefile b/selftest/unittest/exec_cmd/Makefile index 9f5d044..b58df7d 100644 --- a/selftest/unittest/exec_cmd/Makefile +++ b/selftest/unittest/exec_cmd/Makefile @@ -1,5 +1,4 @@ include ../Define.mk -include ../Define_test.mk include ../Test.mk .PHONY: utest clean_utest diff --git a/selftest/unittest/makefiles_abs/0.txt b/selftest/unittest/makefiles_abs/0.txt index b50a9f6..e5980d0 100644 --- a/selftest/unittest/makefiles_abs/0.txt +++ b/selftest/unittest/makefiles_abs/0.txt @@ -1 +1 @@ -/home/kazubito/2010_12/autotest.mk/selftest/unittest/makefiles_abs/Define.mk /home/kazubito/2010_12/autotest.mk/selftest/unittest/makefiles_abs/Define_group.mk /home/kazubito/2010_12/autotest.mk/selftest/unittest/makefiles_abs/Define_test.mk /home/kazubito/2010_12/autotest.mk/selftest/unittest/makefiles_abs/Test.mk +$PWD/Define.mk $PWD/Test.mk diff --git a/selftest/unittest/makefiles_abs/Makefile b/selftest/unittest/makefiles_abs/Makefile index 4c5d509..fe01b66 100644 --- a/selftest/unittest/makefiles_abs/Makefile +++ b/selftest/unittest/makefiles_abs/Makefile @@ -1,5 +1,4 @@ include ../Define.mk -include ../Define_test.mk include ../Test.mk utest: diff --git a/selftest/unittest/report_file/0.txt b/selftest/unittest/report_file/0.txt index 2188dc6..123d6aa 100644 --- a/selftest/unittest/report_file/0.txt +++ b/selftest/unittest/report_file/0.txt @@ -1,7 +1,6 @@ == Makefile == ---------------------------------------------------------------------- include ../Define.mk -include ../Define_test.mk include ../Test.mk .PHONY: utest utest_err1 utest_err2 clean_utest @@ -21,5 +20,5 @@ clean_utest: $(RM) detail.log ---------------------------------------------------------------------- -Makefile:13: *** NULL argument. 中止. +Makefile:12: *** NULL argument. Stop. cat: detail.log: No such file or directory diff --git a/selftest/unittest/report_file/Makefile b/selftest/unittest/report_file/Makefile index c8fd0be..3fcdbf7 100644 --- a/selftest/unittest/report_file/Makefile +++ b/selftest/unittest/report_file/Makefile @@ -1,5 +1,4 @@ include ../Define.mk -include ../Define_test.mk include ../Test.mk .PHONY: utest utest_err1 utest_err2 clean_utest diff --git a/selftest/unittest/report_files/0.txt b/selftest/unittest/report_files/0.txt index f9f3adb..d027691 100644 --- a/selftest/unittest/report_files/0.txt +++ b/selftest/unittest/report_files/0.txt @@ -7,7 +7,6 @@ make -s utest && cat detail.log == Makefile == ---------------------------------------------------------------------- include ../Define.mk -include ../Define_test.mk include ../Test.mk .PHONY: utest utest_err1 utest_err2 clean_utest diff --git a/selftest/unittest/report_files/Makefile b/selftest/unittest/report_files/Makefile index 26be367..2d033c5 100644 --- a/selftest/unittest/report_files/Makefile +++ b/selftest/unittest/report_files/Makefile @@ -1,5 +1,4 @@ include ../Define.mk -include ../Define_test.mk include ../Test.mk .PHONY: utest utest_err1 utest_err2 clean_utest diff --git a/selftest/unittest/test_res_files/0.txt b/selftest/unittest/test_res_files/0.txt index d3d4f8b..1ab55db 100644 --- a/selftest/unittest/test_res_files/0.txt +++ b/selftest/unittest/test_res_files/0.txt @@ -1,2 +1,2 @@ -1.txt diff.txt err.txt test.log detail.log time.log +1.txt diff.log err.log summary.log detail.log time.log diff --git a/selftest/unittest/test_res_files/Makefile b/selftest/unittest/test_res_files/Makefile index bc2192f..a4ff5c8 100644 --- a/selftest/unittest/test_res_files/Makefile +++ b/selftest/unittest/test_res_files/Makefile @@ -1,5 +1,4 @@ include ../Define.mk -include ../Define_test.mk include ../Test.mk .PHONY: utest diff --git a/template/Define.mk b/template/Define.mk index e4695d4..ff5b4b0 100644 --- a/template/Define.mk +++ b/template/Define.mk @@ -47,6 +47,8 @@ EXPR ?= expr LN ?= ln -s +SED ?= sed + ###################################################################### # テストグループとテストでの共通マクロ ###################################################################### @@ -63,6 +65,41 @@ define chk_file_ext $(if $(wildcard $1),$(error $1 exists in $(CURRDIR))) endef +# 指定したディレクトリーを作成 +# 引数は、ディレクトリー名 +# 用例: $(call create_dir,name) +define create_dir + $(call chk_var_null,$1) + $(call chk_file_ext,$1) + $(MKDIR) $1 +endef + +# テストディレクトリーのMakefileを作成 +# 引数は、Makefile名、依存ファイル群 +# 用例: $(call create_makefile,file,list_include_file) +define create_makefile + $(RM) $1 + $(foreach infile,$2,$(ECHO) "include ../$(infile)" >>$1; ) + $(if $(filter $(SRC),c),$(call puts_cmd_c,$1)) +endef + +# C言語の関数をテストするための設定を、指定されたファイルに出力 +# 引数は、ファイル名 +# 用例: $(call puts_cmd_c,file) +define puts_cmd_c + $(ECHO) >>$1 + $(ECHO) "CC := gcc" >>$1 + $(ECHO) "CFLAGS := -Wall" >>$1 + $(ECHO) >>$1 + $(ECHO) ".INTERMEDIATE:" "$$""(CMD_FILE)" >>$1 + $(ECHO) >>$1 + $(ECHO) "CMDSRC_FILE := cmd.c" >>$1 + $(ECHO) "TESTTARGET_FILES := # Set test target files" >>$1 + $(ECHO) >>$1 + $(ECHO) "$$""(CMD_FILE):" "$$""(CMDSRC_FILE)" "$$""(TESTTARGET_FILES)" >>$1 + $(ECHO) " ""$$""(CC)" "$$""(CFLAGS)" "-o" "$$""@" "$$""^" >>$1 +endef + ###################################################################### # テストグループのディレクトリー ###################################################################### diff --git a/template/Group.mk b/template/Group.mk index c686b5e..01d5a27 100644 --- a/template/Group.mk +++ b/template/Group.mk @@ -46,41 +46,6 @@ TEST_LOG_FILES := $(foreach test,$(TESTS),$(test)/$(LOG_FILE)) # テストグループのマクロ ###################################################################### -# 指定したディレクトリーを作成 -# 引数は、ディレクトリー名 -# 用例: $(call create_dir,name) -define create_dir - $(call chk_var_null,$1) - $(call chk_file_ext,$1) - $(MKDIR) $1 -endef - -# テストディレクトリーのMakefileを作成 -# 引数は、Makefile名、依存ファイル群 -# 用例: $(call create_makefile,file,list_include_file) -define create_makefile - $(RM) $1 - $(foreach infile,$2,$(ECHO) "include ../$(infile)" >>$1; ) - $(if $(filter $(SRC),c),$(call puts_cmd_c,$1)) -endef - -# C言語の関数をテストするための設定を、指定されたファイルに出力 -# 引数は、ファイル名 -# 用例: $(call puts_cmd_c,file) -define puts_cmd_c - $(ECHO) >>$1 - $(ECHO) "CC := gcc" >>$1 - $(ECHO) "CFLAGS := -Wall" >>$1 - $(ECHO) >>$1 - $(ECHO) ".INTERMEDIATE:" "$$""(CMD_FILE)" >>$1 - $(ECHO) >>$1 - $(ECHO) "CMDSRC_FILE := cmd.c" >>$1 - $(ECHO) "TESTTARGET_FILES := # Set test target files" >>$1 - $(ECHO) >>$1 - $(ECHO) "$$""(CMD_FILE):" "$$""(CMDSRC_FILE)" "$$""(TESTTARGET_FILES)" >>$1 - $(ECHO) " ""$$""(CC)" "$$""(CFLAGS)" "-o" "$$""@" "$$""^" >>$1 -endef - # テストごとのファイルをグループファイルに出力 # 引数は、テストのリスト、グループファイル、テストファイル # 用例: $(call group_log,files_test_log,file_group_log) diff --git a/template/Test.mk b/template/Test.mk index 8db269a..11d4065 100644 --- a/template/Test.mk +++ b/template/Test.mk @@ -49,6 +49,7 @@ define exec_cmd if test ! -x $1; then $(CHMOD) u+x $1; fi ./$1 >>$2 2>$3 if test -s $3; then $(CAT) $3 >>$2; fi + $(SED) -i '' -e "s%$(CURRDIR)%\$$PWD%g" $2 $(call rm_null,$3) endef