From a26bbbf201bfaf289e3a40f471074f85112c034a Mon Sep 17 00:00:00 2001 From: j8takagi Date: Wed, 27 Apr 2011 00:20:14 +0900 Subject: [PATCH] =?utf8?q?=E3=83=A6=E3=83=8B=E3=83=83=E3=83=88=E3=83=86?= =?utf8?q?=E3=82=B9=E3=83=88=E3=81=AE=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- test/unit/getcmdcode/0.txt | 74 +++++++++++++++++------------------ test/unit/getcmdcode/Makefile | 2 +- test/unit/getcmdcode/cmd.c | 1 + test/unit/getcmdtype/0.txt | 40 ------------------- test/unit/getcmdtype/Makefile | 15 ------- test/unit/getcmdtype/cmd.c | 32 --------------- test/unit/getgr/Makefile | 2 +- test/unit/linetok/0.txt | 26 ++++++------ test/unit/linetok/Makefile | 11 ++++-- test/unit/linetok/cmd.c | 5 ++- test/unit/opdtok/Makefile | 2 +- 11 files changed, 63 insertions(+), 147 deletions(-) delete mode 100644 test/unit/getcmdtype/0.txt delete mode 100644 test/unit/getcmdtype/Makefile delete mode 100644 test/unit/getcmdtype/cmd.c diff --git a/test/unit/getcmdcode/0.txt b/test/unit/getcmdcode/0.txt index b62ac55..a09a453 100644 --- a/test/unit/getcmdcode/0.txt +++ b/test/unit/getcmdcode/0.txt @@ -1,41 +1,41 @@ LD:000 ---> #FFFF LD:066 ---> #FFFF -NOEX:020 ---> #FFFF +NOEX:002 ---> #FFFF NOP:000 ---> #0000 -LD:011 ---> #1000 -ST:010 ---> #1100 -LAD:010 ---> #1200 -LD:020 ---> #1400 -ADDA:011 ---> #2000 -SUBA:011 ---> #2100 -ADDL:011 ---> #2200 -SUBL:011 ---> #2300 -ADDA:020 ---> #2400 -SUBA:020 ---> #2500 -ADDL:020 ---> #2600 -SUBL:020 ---> #2700 -AND:011 ---> #3000 -OR:011 ---> #3100 -XOR:011 ---> #3200 -AND:020 ---> #3400 -OR:020 ---> #3500 -XOR:020 ---> #3600 -CPA:011 ---> #4000 -CPL:011 ---> #4100 -CPA:020 ---> #4400 -CPL:020 ---> #4500 -SLA:010 ---> #5000 -SRA:010 ---> #5100 -SLL:010 ---> #5200 -SRL:010 ---> #5300 -JMI:030 ---> #6100 -JNZ:030 ---> #6200 -JZE:030 ---> #6300 -JUMP:030 ---> #6400 -JPL:030 ---> #6500 -JOV:030 ---> #6600 -PUSH:030 ---> #7000 -POP:040 ---> #7100 -CALL:030 ---> #8000 -SVC:030 ---> #F000 +LD:001 ---> #1000 +ST:001 ---> #1100 +LAD:001 ---> #1200 +LD:002 ---> #1400 +ADDA:001 ---> #2000 +SUBA:001 ---> #2100 +ADDL:001 ---> #2200 +SUBL:001 ---> #2300 +ADDA:002 ---> #2400 +SUBA:002 ---> #2500 +ADDL:002 ---> #2600 +SUBL:002 ---> #2700 +AND:001 ---> #3000 +OR:001 ---> #3100 +XOR:001 ---> #3200 +AND:002 ---> #3400 +OR:002 ---> #3500 +XOR:002 ---> #3600 +CPA:001 ---> #4000 +CPL:001 ---> #4100 +CPA:002 ---> #4400 +CPL:002 ---> #4500 +SLA:001 ---> #5000 +SRA:001 ---> #5100 +SLL:001 ---> #5200 +SRL:001 ---> #5300 +JMI:003 ---> #6100 +JNZ:003 ---> #6200 +JZE:003 ---> #6300 +JUMP:003 ---> #6400 +JPL:003 ---> #6500 +JOV:003 ---> #6600 +PUSH:003 ---> #7000 +POP:004 ---> #7100 +CALL:003 ---> #8000 +SVC:003 ---> #F000 RET:000 ---> #8100 diff --git a/test/unit/getcmdcode/Makefile b/test/unit/getcmdcode/Makefile index c60bfe7..42ae4fb 100644 --- a/test/unit/getcmdcode/Makefile +++ b/test/unit/getcmdcode/Makefile @@ -9,7 +9,7 @@ CFLAGS := -Wall CMDSRC_FILE := cmd.c TARGETDIR := ../../../src INCLUDEDIR := ../../../include -TESTTARGET_FILES := $(TARGETDIR)/hash.c $(TARGETDIR)/cmd.c $(TARGETDIR)/cmem.c $(TARGETDIR)/cerr.c # Set test target files +TESTTARGET_FILES := $(TARGETDIR)/hash.c $(TARGETDIR)/cmd.c $(TARGETDIR)/exec.c $(TARGETDIR)/struct.c $(TARGETDIR)/dump.c $(TARGETDIR)/word.c $(TARGETDIR)/cmem.c $(TARGETDIR)/cerr.c # Set test target files $(CMD_FILE): $(CMDSRC_FILE) $(TESTTARGET_FILES) $(CC) $(CFLAGS) -I $(INCLUDEDIR) -o $@ $^ diff --git a/test/unit/getcmdcode/cmd.c b/test/unit/getcmdcode/cmd.c index 5cf5efc..c1d33ff 100644 --- a/test/unit/getcmdcode/cmd.c +++ b/test/unit/getcmdcode/cmd.c @@ -1,6 +1,7 @@ #include #include "struct.h" #include "cerr.h" +#include "exec.h" int main(){ int i; diff --git a/test/unit/getcmdtype/0.txt b/test/unit/getcmdtype/0.txt deleted file mode 100644 index b904ae0..0000000 --- a/test/unit/getcmdtype/0.txt +++ /dev/null @@ -1,40 +0,0 @@ -#FFFF ---> 077 -#0001 ---> 077 -#0000 ---> 000 -#1000 ---> 011 -#1100 ---> 010 -#1200 ---> 010 -#1400 ---> 020 -#2000 ---> 011 -#2100 ---> 011 -#2200 ---> 011 -#2300 ---> 011 -#2400 ---> 020 -#2500 ---> 020 -#2600 ---> 020 -#2700 ---> 020 -#3000 ---> 011 -#3100 ---> 011 -#3200 ---> 011 -#3400 ---> 020 -#3500 ---> 020 -#3600 ---> 020 -#4000 ---> 011 -#4100 ---> 011 -#4400 ---> 020 -#4500 ---> 020 -#5000 ---> 010 -#5100 ---> 010 -#5200 ---> 010 -#5300 ---> 010 -#6100 ---> 030 -#6200 ---> 030 -#6300 ---> 030 -#6400 ---> 030 -#6500 ---> 030 -#6600 ---> 030 -#7000 ---> 030 -#7100 ---> 040 -#8000 ---> 030 -#F000 ---> 030 -#8100 ---> 000 diff --git a/test/unit/getcmdtype/Makefile b/test/unit/getcmdtype/Makefile deleted file mode 100644 index ffbaa13..0000000 --- a/test/unit/getcmdtype/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -include ../Define.mk -include ../Test.mk - -CC := gcc -CFLAGS := -Wall - -.INTERMEDIATE: $(CMD_FILE) - -CMDSRC_FILE := cmd.c -TARGETDIR := ../../../src -INCLUDEDIR := ../../../include -TESTTARGET_FILES := $(TARGETDIR)/hash.c $(TARGETDIR)/cmem.c $(TARGETDIR)/cerr.c $(TARGETDIR)/cmd.c # Set test target files - -$(CMD_FILE): $(CMDSRC_FILE) $(TESTTARGET_FILES) - $(CC) $(CFLAGS) -I $(INCLUDEDIR) -o $@ $^ diff --git a/test/unit/getcmdtype/cmd.c b/test/unit/getcmdtype/cmd.c deleted file mode 100644 index a4f2856..0000000 --- a/test/unit/getcmdtype/cmd.c +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include "struct.h" -#include "cerr.h" - -int main(){ - int i; - CMDTYPE type; - WORD codelist[] = { - 0xFFFF, 0x0001, - 0x0, 0x1000, 0x1100, 0x1200, 0x1400, - 0x2000, 0x2100, 0x2200, 0x2300, 0x2400, - 0x2500, 0x2600, 0x2700, 0x3000, 0x3100, - 0x3200, 0x3400, 0x3500, 0x3600, 0x4000, - 0x4100, 0x4400, 0x4500, 0x5000, 0x5100, - 0x5200, 0x5300, 0x6100, 0x6200, 0x6300, - 0x6400, 0x6500, 0x6600, 0x7000, 0x7100, - 0x8000, 0xF000, 0x8100, - }; - - cerr = malloc_chk(sizeof(CERR), "cerr"); /* エラーの初期化 */ - create_code_type(); - for(i = 0; i < ARRAYSIZE(codelist); i++) { - type = getcmdtype(codelist[i]); - printf("#%04X ---> 0%02o\n", codelist[i], type); - if(cerr->num != 0) { - printf("\t%s", cerr->msg); - freecerr(); - } - } - free_code_type(); - return 0; -} diff --git a/test/unit/getgr/Makefile b/test/unit/getgr/Makefile index 04c59d6..09a9d15 100644 --- a/test/unit/getgr/Makefile +++ b/test/unit/getgr/Makefile @@ -9,7 +9,7 @@ CFLAGS := -Wall CMDSRC_FILE := cmd.c TARGETDIR := ../../../src INCLUDEDIR := ../../../include -TESTTARGET_FILES := $(TARGETDIR)/hash.c $(TARGETDIR)/cmem.c $(TARGETDIR)/cerr.c $(TARGETDIR)/cmd.c $(TARGETDIR)/assemble.c $(TARGETDIR)/word.c $(TARGETDIR)/label.c $(TARGETDIR)/struct.c $(TARGETDIR)/token.c # Set test target files +TESTTARGET_FILES := $(TARGETDIR)/hash.c $(TARGETDIR)/cmem.c $(TARGETDIR)/cerr.c $(TARGETDIR)/cmd.c $(TARGETDIR)/assemble.c $(TARGETDIR)/word.c $(TARGETDIR)/label.c $(TARGETDIR)/struct.c $(TARGETDIR)/token.c $(TARGETDIR)/exec.c $(TARGETDIR)/dump.c # Set test target files $(CMD_FILE): $(CMDSRC_FILE) $(TESTTARGET_FILES) $(CC) $(CFLAGS) -I $(INCLUDEDIR) -o $@ $^ diff --git a/test/unit/linetok/0.txt b/test/unit/linetok/0.txt index 40c7fb3..db379b0 100644 --- a/test/unit/linetok/0.txt +++ b/test/unit/linetok/0.txt @@ -1,56 +1,52 @@ -0: IOTEST START -cl->label: IOTEST -cl->cmd: START -cl->opdc: 0 - -1: OUT OBUF1,OLEN1 +0: OUT OBUF1,OLEN1 cl->cmd: OUT cl->opdc: 2 cl->opdv[0]: OBUF1 cl->opdv[1]: OLEN1 -2: OUT OBUF2,OLEN2 ;comment +1: OUT OBUF2,OLEN2 ;comment cl->cmd: OUT cl->opdc: 2 cl->opdv[0]: OBUF2 cl->opdv[1]: OLEN2 -3: OUT OBUF1,OLEN1 +2: OUT OBUF1,OLEN1 cl->cmd: OUT cl->opdc: 2 cl->opdv[0]: OBUF1 cl->opdv[1]: OLEN1 -4: OUT OBUF1,OLEN1 +3: OUT OBUF1,OLEN1 cl->cmd: OUT cl->opdc: 2 cl->opdv[0]: OBUF1 cl->opdv[1]: OLEN1 -5: OUT OBUF2,OLEN2 +4: OUT OBUF2,OLEN2 cl->cmd: OUT cl->opdc: 2 cl->opdv[0]: OBUF2 cl->opdv[1]: OLEN2 -6: OUT OBUF1, OLEN1 +5: OUT OBUF1, OLEN1 cl->cmd: OUT cl->opdc: 1 cl->opdv[0]: OBUF1 error - 121: cannot get operand token -7: BEGIN LD GR1, A +6: BEGIN LD GR1, A cl->label: BEGIN cl->cmd: LD cl->opdc: 1 cl->opdv[0]: GR1 error - 121: cannot get operand token -8: +7: +cl is NULL + +8: ;comment cl is NULL - error - 121: cannot get operand token 9: ;comment cl is NULL - error - 121: cannot get operand token diff --git a/test/unit/linetok/Makefile b/test/unit/linetok/Makefile index 4606383..167af4f 100644 --- a/test/unit/linetok/Makefile +++ b/test/unit/linetok/Makefile @@ -4,13 +4,18 @@ include ../Test.mk CC := gcc CFLAGS := -g -Wall -.INTERMEDIATE: $(CMD_FILE) +# .INTERMEDIATE: $(CMD_FILE) CMDSRC_FILE := cmd.c TARGETDIR := ../../../src INCLUDEDIR := ../../../include -TESTTARGET_FILES := $(TARGETDIR)/cmem.c $(TARGETDIR)/cerr.c $(TARGETDIR)/cmd.c $(TARGETDIR)/word.c $(TARGETDIR)/struct.c $(TARGETDIR)/token.c $(TARGETDIR)/hash.c # Set test target files +TESTTARGET_FILES := $(TARGETDIR)/cmem.c $(TARGETDIR)/cerr.c $(TARGETDIR)/cmd.c $(TARGETDIR)/word.c $(TARGETDIR)/struct.c $(TARGETDIR)/token.c $(TARGETDIR)/hash.c $(TARGETDIR)/exec.c $(TARGETDIR)/dump.c # Set test target files $(CMD_FILE): $(CMDSRC_FILE) $(TESTTARGET_FILES) $(CC) $(CFLAGS) -I $(INCLUDEDIR) -o $@ $^ - @rm -rf cmd.dSYM + +clean_cmd: + @rm -rf cmd.dSYM cmd + +clean: clean_cmd + diff --git a/test/unit/linetok/cmd.c b/test/unit/linetok/cmd.c index 854f565..d858c62 100644 --- a/test/unit/linetok/cmd.c +++ b/test/unit/linetok/cmd.c @@ -7,7 +7,7 @@ int main(){ int i, j; char *testline[] = { - "IOTEST START\n", + /* "IOTEST START\n", */ " OUT OBUF1,OLEN1\n", " OUT OBUF2,OLEN2 ;comment\n", " OUT OBUF1,OLEN1 \n", @@ -16,13 +16,14 @@ int main(){ " OUT OBUF1, OLEN1 \n", "BEGIN LD GR1, A\n", "\n", + ";comment\n", " ;comment\n" }; CMDLINE *testcl = malloc(sizeof(CMDLINE)); - cerr_init(); /* エラーの初期化 */ addcerrlist_tok(); for(i = 0; i < sizeof testline /sizeof testline[0]; i++) { + cerr_init(); /* エラーの初期化 */ printf("%d: %s", i, testline[i]); testcl = linetok(testline[i]); if(testcl == NULL) { diff --git a/test/unit/opdtok/Makefile b/test/unit/opdtok/Makefile index 04c59d6..445aabc 100644 --- a/test/unit/opdtok/Makefile +++ b/test/unit/opdtok/Makefile @@ -9,7 +9,7 @@ CFLAGS := -Wall CMDSRC_FILE := cmd.c TARGETDIR := ../../../src INCLUDEDIR := ../../../include -TESTTARGET_FILES := $(TARGETDIR)/hash.c $(TARGETDIR)/cmem.c $(TARGETDIR)/cerr.c $(TARGETDIR)/cmd.c $(TARGETDIR)/assemble.c $(TARGETDIR)/word.c $(TARGETDIR)/label.c $(TARGETDIR)/struct.c $(TARGETDIR)/token.c # Set test target files +TESTTARGET_FILES := $(TARGETDIR)/hash.c $(TARGETDIR)/cmem.c $(TARGETDIR)/cerr.c $(TARGETDIR)/cmd.c $(TARGETDIR)/assemble.c $(TARGETDIR)/word.c $(TARGETDIR)/label.c $(TARGETDIR)/struct.c $(TARGETDIR)/token.c $(TARGETDIR)/exec.c $(TARGETDIR)/dump.c # Set test target files $(CMD_FILE): $(CMDSRC_FILE) $(TESTTARGET_FILES) $(CC) $(CFLAGS) -I $(INCLUDEDIR) -o $@ $^ -- 2.18.0