comet2コマンド実行時のリセット位置を変更
[YACASL2.git] / test / unit / TEST.mk
1 # テストのテンプレート
2 # make         : CMDで設定されたコマンドを実行した出力結果を1.txtに出力し、0.txtと比較し、レポート
3 # make check   : ↓
4 # make prepare : CMDで設定されたコマンドを実行した出力結果を0.txt(テストの想定結果)に出力
5 # make clean   : 「make」で生成されたファイルをクリア
6 # make cleanall: 「make」と「make clean」で生成されたファイルをクリア
7 ERRFILE = err.txt
8 UNITNAME = `pwd | xargs basename`
9
10 SRCDIR = ../../../src
11 INCLUDE = ../../../include
12 CC = gcc
13 CFLAGS = -g -Wall -I $(INCLUDE)
14 COMMONSRC = $(SRCDIR)/word.c $(SRCDIR)/struct.c $(SRCDIR)/hash.c $(SRCDIR)/cmd.c $(SRCDIR)/cerr.c
15 ASSRC = $(SRCDIR)/assemble.c $(SRCDIR)/token.c $(SRCDIR)/label.c $(SRCDIR)/macro.c
16 EXECSRC = $(SRCDIR)/exec.c $(SRCDIR)/dump.c
17
18 ifeq "$(UCLASS)" "AS"
19   SRC = $(COMMONSRC) $(ASSRC)
20 endif
21 ifeq "$(UCLASS)" "EXEC"
22   SRC = $(COMMONSRC) $(EXECSRC)
23 endif
24 ifeq "$(UCLASS)" "COMMON"
25   SRC = $(COMMONSRC)
26 endif
27
28 .PHPNY: check prepare clean cleanall
29 check: clean report.txt
30 prepare: cleanall 0.txt
31 clean:
32         @rm -f a.out 1.txt diff.txt report.txt
33 cleanall: clean
34         @rm -f 0.txt
35 a.out: $(SRC) $(TESTSRCFILE)
36         @gcc $(CFLAGS) $(SRC) $(TESTSRCFILE)
37 0.txt 1.txt: a.out
38         @./a.out >$@ 2>&1
39 diff.txt: 1.txt
40         @-diff -c 0.txt 1.txt >$@ 2>&1
41 report.txt: diff.txt
42         @echo -n "$(UNITNAME): Test " >$@; \
43      if test ! -s $^; then echo -n "Success " >>$@; rm -f $^; else echo -n "Failure " >>$@; fi; \
44      echo `date +"%F %T"` >>$@