Skip to content

Commit

Permalink
tests: Add support for codesigning command.
Browse files Browse the repository at this point in the history
Allows running the tests out-of-the-box on macOS.
Also delete *.dylib in tests2 dir on "make clean".
One remaining issue on macOS 14.1 is that the
-undefined warning option no longer works,
thus breaking test3 and test1b.
  • Loading branch information
rdoeffinger committed Oct 29, 2023
1 parent 32ac236 commit ece74ce
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ TCCFLAGS = $(TCCFLAGS$(CFG))
TCC_LOCAL = $(TOP)/tcc$(EXESUF)
TCC = $(TCC_LOCAL) $(TCCFLAGS)

ifdef CONFIG_OSX
CODESIGN = codesign -s -
else
CODESIGN = true
endif

CFLAGS_P = $(CFLAGS) -pg -static -DCONFIG_TCC_STATIC -DTCC_PROFILE
LIBS_P = $(LIBS)
LDFLAGS_P = $(LDFLAGS)
Expand Down
6 changes: 5 additions & 1 deletion tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ all test :

hello-exe: ../examples/ex1.c
@echo ------------ $@ ------------
$(TCC) $< -o hello$(EXESUF) && ./hello$(EXESUF) || $(DUMPTCC)
$(TCC) $< -o hello$(EXESUF) && $(CODESIGN) hello$(EXESUF) && ./hello$(EXESUF) || $(DUMPTCC)

hello-run: ../examples/ex1.c
@echo ------------ $@ ------------
Expand Down Expand Up @@ -156,7 +156,9 @@ test4_static: tcctest.c test.ref
dlltest:
@echo ------------ $@ ------------
$(TCC) $(NATIVE_DEFINES) -DLIBTCC_AS_DLL $(TOPSRC)/libtcc.c $(LIBS) -shared -o libtcc2$(DLLSUF)
$(CODESIGN) libtcc2$(DLLSUF)
$(TCC) $(NATIVE_DEFINES) -DONE_SOURCE=0 $(TOPSRC)/tcc.c libtcc2$(DLLSUF) $(LIBS) -Wl,-rpath=. -o tcc2$(EXESUF)
$(CODESIGN) tcc2$(EXESUF)
./tcc2$(EXESUF) $(TCCFLAGS) $(RUN_TCC) -run $(TOPSRC)/examples/ex1.c
ifeq (,$(filter Darwin WIN32,$(TARGETOS)))
@echo ------------ $@ with PIC ------------
Expand Down Expand Up @@ -241,6 +243,7 @@ abitest-cc.exe: abitest.c $(LIBTCC)

abitest-tcc.exe: abitest.c libtcc.c
$(TCC) -o $@ $^ $(NATIVE_DEFINES) $(LIBS)
$(CODESIGN) $@

abitest-% : abitest-%.exe
@echo ------------ $@ ------------
Expand All @@ -253,6 +256,7 @@ endif

vla_test$(EXESUF): vla_test.c
$(TCC) -o $@ $^
$(CODESIGN) $@

vla_test-run: vla_test$(EXESUF)
@echo ------------ $@ ------------
Expand Down
7 changes: 5 additions & 2 deletions tests/tests2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,11 @@ GEN-ALWAYS =
# this test creates two DLLs and an EXE
113_btdll.test: T1 = \
$(TCC) -bt $1 -shared -D DLL=1 -o a1$(DLLSUF) && \
$(CODESIGN) a1$(DLLSUF) && \
$(TCC) -bt $1 -shared -D DLL=2 -o a2$(DLLSUF) && \
$(CODESIGN) a2$(DLLSUF) && \
$(TCC) -bt $1 a1$(DLLSUF) a2$(DLLSUF) -Wl,-rpath=. -o $(basename $@).exe && \
$(CODESIGN) $(basename $@).exe && \
./$(basename $@).exe

114_bound_signal.test: FLAGS += -b
Expand Down Expand Up @@ -136,7 +139,7 @@ all test tests2.all: $(filter-out $(SKIP),$(TESTS))
@$(call T1,$<) $(T3)

T1 = $(TCC) $(FLAGS) $(T2) $(ARGS)
T2 = $(if $(NORUN),$1 -o $(basename $@).exe && ./$(basename $@).exe,-run $1)
T2 = $(if $(NORUN),$1 -o $(basename $@).exe && $(CODESIGN) $(basename $@).exe && ./$(basename $@).exe,-run $1)
T3 = $(FILTER) >$*.output 2>&1 || true \
&& diff -Nbu $(filter %.expect,$^) $*.output \
&& rm -f $*.output $(filter $*.expect,$(GEN-ALWAYS))
Expand Down Expand Up @@ -177,4 +180,4 @@ $(sort $(GEN-ALWAYS) $(UPDATE)) : force
force:

clean :
rm -f fred.txt *.output *.exe *.dll *.so *.def $(GEN-ALWAYS)
rm -f fred.txt *.output *.exe *.dll *.so *.dylib *.def $(GEN-ALWAYS)

0 comments on commit ece74ce

Please sign in to comment.