Skip to content

Commit

Permalink
GH-25 Fix SEE FNEGATE; add test to SEE all words. Tweak error
Browse files Browse the repository at this point in the history
output to use stdout which allows errors to follow more closely
to the their temporal location.
  • Loading branch information
SirWumpus committed Sep 3, 2024
1 parent 9470ca9 commit d00e59c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ post4$E : config.h post4.h hooks.c post4.c
post4.i : config.h post4.h post4.c
${CC} -E ${CFLAGS} -DTEST -DP4_BUILT="\"${BUILT}\"" post4.c >$*.i

test : post4$E
test tests: post4$E
cd ../test && ${MAKE} $@

valgrind: post4$E
Expand Down
5 changes: 4 additions & 1 deletion src/post4.c
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ p4Create(P4_Options *opts)
return NULL;
}

#define STDERR stderr
#define STDERR stdout

#ifdef P4_TRACE
static void
Expand Down Expand Up @@ -2725,6 +2725,9 @@ _seext: word = P4_POP(ctx->ds).xt;
} else if (strncmp(x.w->name.string, "_slit", STRLEN("_slit")) == 0) {
(void) printf("S\" %s\" ", (char *) &w.p[2]);
w.u += P4_CELL + P4_CELL_ALIGN(w.p[1].u + 1);
} else if (strncmp(x.w->name.string, "flit", STRLEN("flit")) == 0) {
/* Test: SEE FNEGATE */
(void) printf("%.*lF ", (int) ctx->precision, (*++w.p).f);
} else {
(void) printf("%.*s ", (int) x.w->name.length, x.w->name.string);
if (x.w->code == &&_branch || x.w->code == &&_branchz
Expand Down
13 changes: 12 additions & 1 deletion test/makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ build: title post4$E

clean : title
-rm -f *.o *.obj *.i *.map *.tds *.TR2 *.stackdump core *.core core.* *.log
-rm -f a.out$E post4$E
-rm -f a.out$E see.out post4$E

distclean: clean
-rm -f config.h config.h.in makefile
Expand All @@ -60,12 +60,23 @@ title :
@echo '***************************************************************'
@echo

tests: test test_quit see_all

test : ${POST4}
POST4_PATH=../src ${POST4} ./units.p4

test_quit : ${POST4}
@echo Testing QUIT...
! printf "' QUIT CATCH \n ABORT" | ${POST4} -c ${WORDS}
! printf "' QUIT CATCH \n -1 THROW" | ${POST4} -c ${WORDS}
! printf "' QUIT CATCH \n -123 THROW" | ${POST4} -c ${WORDS}
printf 'S" 0 THROW" '\'' EVALUATE CATCH' | ${POST4} -c ${WORDS}
printf 'S" -1 THROW" '\'' EVALUATE CATCH' | ${POST4} -c ${WORDS}
printf ": tw_keep_ds [: 123 QUIT ;] CATCH 456 . THROW ;\n tw_keep_ds \n . CR" | ${POST4} -c ${WORDS}

# Test SEE against all words to check if any result in some failure like SEGFAULT.
see_all: ${POST4}
echo WORDS | ${POST4} -c ${WORDS} \
| sed 's/[[:space:][:cntrl:]]*$$//; s/[^[:space:][:cntrl:]]*/SEE &/g'\
| ${POST4} -c ${WORDS} >see.out 2>&1
@echo "-OK-"

0 comments on commit d00e59c

Please sign in to comment.