aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/tests2/42_function_pointer.c6
-rw-r--r--tests/tests2/Makefile11
2 files changed, 15 insertions, 2 deletions
diff --git a/tests/tests2/42_function_pointer.c b/tests/tests2/42_function_pointer.c
index 49c331b..697bd79 100644
--- a/tests/tests2/42_function_pointer.c
+++ b/tests/tests2/42_function_pointer.c
@@ -8,9 +8,13 @@ int fred(int p)
int (*f)(int) = &fred;
+/* To test what this is supposed to test the destination function
+ (fprint here) must not be called directly anywhere in the test. */
+int (*fprintfptr)(FILE *, const char *, ...) = &fprintf;
+
int main()
{
- printf("%d\n", (*f)(24));
+ fprintfptr(stdout, "%d\n", (*f)(24));
return 0;
}
diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile
index 2434215..166fb2a 100644
--- a/tests/tests2/Makefile
+++ b/tests/tests2/Makefile
@@ -34,6 +34,10 @@ ARGS =
31_args.test : ARGS = arg1 arg2 arg3 arg4 arg5
46_grep.test : ARGS = '[^* ]*[:a:d: ]+\:\*-/: $$' $(SRC)/46_grep.c
+# And some tests don't test the right thing with -run
+NORUN =
+42_function_pointer.test : NORUN = true
+
# Some tests might need different flags
76_dollars_in_identifiers.test : TCCFLAGS += -fdollars-in-identifiers
@@ -49,7 +53,12 @@ all test: $(filter-out $(SKIP),$(TESTS))
%.test: %.c %.expect
@echo Test: $*...
# test -run
- @$(TCC) -run $< $(ARGS) $(FILTER) >$*.output 2>&1 || true
+ @if test -z "$(NORUN)"; then \
+ $(TCC) -run $< $(ARGS) $(FILTER) >$*.output 2>&1 || true; \
+ else \
+ $(TCC) $< -o ./$*.exe $(FILTER) 2>&1 && \
+ ./$*.exe $(ARGS) >$*.output 2>&1 || true; \
+ fi
@diff -Nbu $(SRC)/$*.expect $*.output && rm -f $*.output
# automatically generate .expect files with gcc: