core tests

This commit is contained in:
corey 2023-11-12 05:57:05 -06:00
parent abb904e5f5
commit d03c21ba38
4 changed files with 17 additions and 13 deletions

2
.gitignore vendored
View File

@ -2,6 +2,6 @@
/par
/libpar.a
/listing
/tests/bin/*
/version.h
/completion/par
/tests/*/bin*

View File

@ -7,6 +7,7 @@ NASMFLAGS= -Fdwarf -felf64
OBJS= str.o tok.o vec.o lex.o pnode.o reg.o mem.o state.o err.o x86_64.o run.o ir.o gen.o
LIB= libpar.a
TESTS_x86_64= $(notdir $(basename $(shell find tests/x86_64/ -name '*.par')))
TESTS_CORE= $(notdir $(basename $(shell find tests/core/ -name '*.c')))
PAR= ./par
VALGRIND= valgrind --leak-check=full --log-file=$(@D)/valgrind.$*
@ -21,17 +22,20 @@ version.h:
./update_ver.sh
par: version.h main.o libpar.a
$(CC) $(filter-out %.h, $^) -o $@ $(LDFLAGS)
tests: par $(addprefix tests/bin/, $(TESTS_x86_64)) tests/bin FORCE
./tests/dotests.sh tests
tests: par tests/x86_64/bin $(addprefix tests/x86_64/bin/, $(TESTS_x86_64)) FORCE
@./tests/dotests.sh tests
tests_core: $(LIB) tests/core/bin $(addprefix tests/core/bin/, $(TESTS_CORE)) FORCE
#
# IMPLICIT RULES
#
%.o: %.c %.h
$(CC) $< -c $(CFLAGS)
tests/bin:
@mkdir tests/bin
tests/bin/%.asm: tests/x86_64/%.par par
tests/x86_64/bin tests/core/bin:
@mkdir $@
tests/core/bin/%: tests/core/%.c $(LIB)
$(CC) $< -o $@ $(CFLAGS) $(LDFLAGS) $(LIB) -I.
tests/x86_64/bin/%.asm: tests/x86_64/%.par par
$(VALGRIND) $(PAR) -m x86_64 -o $@ $<
%.asm: %.par par
$(PAR) $<
@ -62,4 +66,4 @@ install_shell_completion: par completion/par
mkdir -p /usr/share/bash-completion/completions
install -m 644 completion/par /usr/share/bash-completion/completions/
clean:
$(RM) a.out *.o $(OBJS) par libpar.a $(addprefix tests/bin/, *.asm *.o $(TESTS_x86_64)) listing version.h completion/par
$(RM) a.out *.o $(OBJS) par libpar.a $(addprefix tests/x86_64/bin/, *.asm *.o $(TESTS_x86_64)) tests/core/bin/* tests/x86_64/bin/* listing version.h completion/par

View File

@ -51,7 +51,7 @@ main()
[ $# -gt 0 ] && cd $1
for x in $(find x86_64/ -name '*.par'); do
export TEST_ARCH=x86_64
test_program "bin/$(basename --suffix .par $x)" "$x"
test_program "x86_64/bin/$(basename --suffix .par $x)" "$x"
done
for x in $(find run/ -name '*.par'); do
export TEST_ARCH=run

View File

@ -39,11 +39,11 @@ void gen_x86_64(Gen*gen,const PNode*pn,FILE*file)
{
if(vec_at(&pn->tokens,1,const Tok*)->type!=LOPERATOR||(strcmp(vec_at(&pn->tokens,1,const Tok*)->str.buffer,"=")))
err_log("%u: expected either ';' or '='",vec_at(&pn->tokens,1,const Tok*)->line);
Var var={
.value.i32=0,
.name=vec_at(&pn->tokens,0,const Tok*)->str.buffer,
.type=I32,
};
/* Var var={ */
/* .value.i32=0, */
/* .name=vec_at(&pn->tokens,0,const Tok*)->str.buffer, */
/* .type=I32, */
/* }; */
/* vec_push(&gen->var_desc,&var); */
}
else if(pn->tokens.size==0)