Skip to content

Commit

Permalink
Avoid cl65 in tests.
Browse files Browse the repository at this point in the history
cl65 creates intermediate files based on the source file name in the source file directory. Calling cl65 in parallel with the same source file causes those intermediate files to get overwritten.

Fixes #1080
  • Loading branch information
oliverschmidt committed Aug 26, 2020
1 parent 4c912a0 commit c658acb
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 71 deletions.
27 changes: 12 additions & 15 deletions test/asm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,22 @@ ifdef CMD_EXE
EXE = .exe
MKDIR = mkdir $(subst /,\,$1)
RMDIR = -rmdir /s /q $(subst /,\,$1)
DEL = del /f $(subst /,\,$1)
else
EXE =
MKDIR = mkdir -p $1
RMDIR = $(RM) -r $1
DEL = $(RM) $1
endif

ifdef QUIET
.SILENT:
endif

CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
CA65 := $(if $(wildcard ../../bin/ca65*),../../bin/ca65,ca65)
LD65 := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65)

WORKDIR = ../../testwrk/asm

DIFF = $(WORKDIR)/isequal$(EXE)
ISEQUAL = $(WORKDIR)/isequal$(EXE)

CC = gcc
CFLAGS = -O2
Expand All @@ -44,34 +43,32 @@ all: $(OPCODE_BINS) $(CPUDETECT_BINS)
$(WORKDIR):
$(call MKDIR,$(WORKDIR))

$(DIFF): ../isequal.c | $(WORKDIR)
$(ISEQUAL): ../isequal.c | $(WORKDIR)
$(CC) $(CFLAGS) -o $@ $<

define OPCODE_template

$(WORKDIR)/$1-opcodes.bin: $1-opcodes.s $(DIFF)
$(WORKDIR)/$1-opcodes.bin: $1-opcodes.s $(ISEQUAL)
$(if $(QUIET),echo asm/$1-opcodes.bin)
$(CL65) --cpu $1 -t none -l $(WORKDIR)/$1-opcodes.lst -o $$@ $$<
$(DIFF) $$@ $1-opcodes.ref
$(CA65) --cpu $1 -t none -l $(WORKDIR)/$1-opcodes.lst -o $(WORKDIR)/$1-opcodes.o $$<
$(LD65) -t none -o $$@ $(WORKDIR)/$1-opcodes.o none.lib
$(ISEQUAL) $$@ $1-opcodes.ref

endef # OPCODE_template

$(foreach cpu,$(OPCODE_CPUS),$(eval $(call OPCODE_template,$(cpu))))

# cpudetect.o is written by multiple rules
.NOTPARALLEL:

define CPUDETECT_template

$(WORKDIR)/$1-cpudetect.bin: cpudetect.s $(DIFF)
$(WORKDIR)/$1-cpudetect.bin: cpudetect.s $(ISEQUAL)
$(if $(QUIET),echo asm/$1-cpudetect.bin)
$(CL65) --cpu $1 -t none -l $(WORKDIR)/$1-cpudetect.lst -o $$@ $$<
$(DIFF) $$@ $1-cpudetect.ref
$(CA65) --cpu $1 -t none -l $(WORKDIR)/$1-cpudetect.lst -o $(WORKDIR)/$1-cpudetect.o $$<
$(LD65) -t none -o $$@ $(WORKDIR)/$1-cpudetect.o none.lib
$(ISEQUAL) $$@ $1-cpudetect.ref

endef # CPUDETECT_template

$(foreach cpu,$(CPUDETECT_CPUS),$(eval $(call CPUDETECT_template,$(cpu))))

clean:
@$(call RMDIR,$(WORKDIR))
@$(call DEL,$(OPCODE_REFS:.ref=.o) cpudetect.o)
11 changes: 4 additions & 7 deletions test/dasm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ ifdef CMD_EXE
EXE = .exe
MKDIR = mkdir $(subst /,\,$1)
RMDIR = -rmdir /s /q $(subst /,\,$1)
DEL = del /f $(subst /,\,$1)
else
EXE =
MKDIR = mkdir -p $1
RMDIR = $(RM) -r $1
DEL = $(RM) $1
endif

ifdef QUIET
Expand All @@ -25,7 +23,7 @@ DA65 := $(if $(wildcard ../../bin/da65*),../../bin/da65,da65)

WORKDIR = ../../testwrk/dasm

DIFF = $(WORKDIR)/isequal$(EXE)
ISEQUAL = $(WORKDIR)/isequal$(EXE)

CC = gcc
CFLAGS = -O2
Expand All @@ -44,7 +42,7 @@ all: $(BINS)
$(WORKDIR):
$(call MKDIR,$(WORKDIR))

$(DIFF): ../isequal.c | $(WORKDIR)
$(ISEQUAL): ../isequal.c | $(WORKDIR)
$(CC) $(CFLAGS) -o $@ $<

define DISASS_template
Expand All @@ -55,15 +53,14 @@ $(WORKDIR)/$1-disass.bin: $1-disass.s | $(WORKDIR)
$(WORKDIR)/$1-reass.s: $(WORKDIR)/$1-disass.bin
$(DA65) --cpu $1 $(START) -o $$@ $$<

$(WORKDIR)/$1-reass.bin: $(WORKDIR)/$1-reass.s $(DIFF)
$(WORKDIR)/$1-reass.bin: $(WORKDIR)/$1-reass.s $(ISEQUAL)
$(if $(QUIET),echo dasm/$1-reass.bin)
$(CL65) --cpu $1 -t none $(START) -o $$@ $$<
$(DIFF) $$@ $(WORKDIR)/$1-disass.bin
$(ISEQUAL) $$@ $(WORKDIR)/$1-disass.bin

endef # DISASS_template

$(foreach cpu,$(CPUS),$(eval $(call DISASS_template,$(cpu))))

clean:
@$(call RMDIR,$(WORKDIR))
@$(call DEL,$(SOURCES:.s=.o))
48 changes: 23 additions & 25 deletions test/misc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ ifdef CMD_EXE
NULLDEV = nul:
MKDIR = mkdir $(subst /,\,$1)
RMDIR = -rmdir /s /q $(subst /,\,$1)
DEL = del /f $(subst /,\,$1)
else
S = /
NOT = !
EXE =
NULLDEV = /dev/null
MKDIR = mkdir -p $1
RMDIR = $(RM) -r $1
DEL = $(RM) $1
endif

ifdef QUIET
Expand All @@ -30,14 +28,16 @@ endif

SIM65FLAGS = -x 200000000

CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65)
CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65)
CA65 := $(if $(wildcard ../../bin/ca65*),..$S..$Sbin$Sca65,ca65)
LD65 := $(if $(wildcard ../../bin/ld65*),..$S..$Sbin$Sld65,ld65)
SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)

WORKDIR = ..$S..$Stestwrk$Smisc

OPTIONS = g O Os Osi Osir Osr Oi Oir Or

DIFF = $(WORKDIR)$Sisequal$(EXE)
ISEQUAL = $(WORKDIR)$Sisequal$(EXE)

CC = gcc
CFLAGS = -O2
Expand All @@ -50,15 +50,10 @@ TESTS += $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).65c02.

all: $(TESTS)

# The same input file is processed with different cl65 args,
# but cl65 uses the input file name to make the temp file name,
# and they stomp each other.
.NOTPARALLEL:

$(WORKDIR):
$(call MKDIR,$(WORKDIR))

$(DIFF): ../isequal.c | $(WORKDIR)
$(ISEQUAL): ../isequal.c | $(WORKDIR)
$(CC) $(CFLAGS) -o $@ $<

define PRG_template
Expand All @@ -67,61 +62,65 @@ define PRG_template
$(WORKDIR)/bug250.$1.$2.prg: bug250.c | $(WORKDIR)
@echo "FIXME: " $$@ "currently does not compile."
$(if $(QUIET),echo misc/bug250.$1.$2.prg)
$(NOT) $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
$(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)

# should compile, but gives an error
$(WORKDIR)/bug760.$1.$2.prg: bug760.c | $(WORKDIR)
@echo "FIXME: " $$@ "currently does not compile."
$(if $(QUIET),echo misc/bug760.$1.$2.prg)
$(NOT) $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
$(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)

# should compile, but gives an error
$(WORKDIR)/bug1209-ind-goto-rev.$1.$2.prg: bug1209-ind-goto-rev.c | $(WORKDIR)
@echo "FIXME: " $$@ "currently does not compile."
$(if $(QUIET),echo misc/bug1209-ind-goto-rev.$1.$2.prg)
$(NOT) $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
$(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)

# should compile, but gives an error
$(WORKDIR)/bug1209-ind-goto-rev-2.$1.$2.prg: bug1209-ind-goto-rev-2.c | $(WORKDIR)
@echo "FIXME: " $$@ "currently does not compile."
$(if $(QUIET),echo misc/bug1209-ind-goto-rev-2.$1.$2.prg)
$(NOT) $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
$(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)

# should compile, but gives an error
$(WORKDIR)/bug1209-ind-goto-rev-3.$1.$2.prg: bug1209-ind-goto-rev-3.c | $(WORKDIR)
@echo "FIXME: " $$@ "currently does not compile."
$(if $(QUIET),echo misc/bug1209-ind-goto-rev-3.$1.$2.prg)
$(NOT) $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
$(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)

# should compile, but gives an error
$(WORKDIR)/pptest2.$1.$2.prg: pptest2.c | $(WORKDIR)
@echo "FIXME: " $$@ "currently does not compile."
$(if $(QUIET),echo misc/pptest2.$1.$2.prg)
$(NOT) $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
$(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)

# should compile, but then hangs in an endless loop
$(WORKDIR)/endless.$1.$2.prg: endless.c | $(WORKDIR)
$(if $(QUIET),echo misc/endless.$1.$2.prg)
$(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
$(CC65) -t sim$2 -$1 -o $$(@:.prg=.s) $$< $(NULLERR)
$(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
$(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
$(NOT) $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) $(NULLERR)

# these need reference data that can't be generated by a host-compiled program,
# in a useful way
$(WORKDIR)/limits.$1.$2.prg: limits.c $(DIFF) | $(WORKDIR)
$(WORKDIR)/limits.$1.$2.prg: limits.c $(ISEQUAL) | $(WORKDIR)
$(if $(QUIET),echo misc/limits.$1.$2.prg)
$(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
$(CC65) -t sim$2 -$1 -o $$(@:.prg=.s) $$< $(NULLERR)
$(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
$(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
$(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/limits.$1.$2.out
$(DIFF) $(WORKDIR)/limits.$1.$2.out limits.ref
$(ISEQUAL) $(WORKDIR)/limits.$1.$2.out limits.ref

$(WORKDIR)/goto.$1.$2.prg: goto.c $(DIFF) | $(WORKDIR)
$(WORKDIR)/goto.$1.$2.prg: goto.c $(ISEQUAL) | $(WORKDIR)
$(if $(QUIET),echo misc/goto.$1.$2.prg)
$(CL65) -t sim$2 -$1 -o $$@ $$< 2>$(WORKDIR)/goto.$1.$2.out
$(DIFF) $(WORKDIR)/goto.$1.$2.out goto.ref
$(CC65) -t sim$2 -$1 -o $$@ $$< 2>$(WORKDIR)/goto.$1.$2.out
$(ISEQUAL) $(WORKDIR)/goto.$1.$2.out goto.ref

# the rest are tests that fail currently for one reason or another
$(WORKDIR)/sitest.$1.$2.prg: sitest.c | $(WORKDIR)
@echo "FIXME: " $$@ "currently does not compile."
$(NOT) $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
$(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
# $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT)

endef # PRG_template
Expand All @@ -131,4 +130,3 @@ $(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02)))

clean:
@$(call RMDIR,$(WORKDIR))
@$(call DEL,$(SOURCES:.c=.o))
19 changes: 10 additions & 9 deletions test/ref/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ ifdef CMD_EXE
NULLDEV = nul:
MKDIR = mkdir $(subst /,\,$1)
RMDIR = -rmdir /s /q $(subst /,\,$1)
DEL = del /f $(subst /,\,$1)
else
S = /
EXE =
NULLDEV = /dev/null
MKDIR = mkdir -p $1
RMDIR = $(RM) -r $1
DEL = $(RM) $1
endif

ifdef QUIET
Expand All @@ -28,14 +26,16 @@ endif

SIM65FLAGS = -x 200000000

CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65)
CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65)
CA65 := $(if $(wildcard ../../bin/ca65*),..$S..$Sbin$Sca65,ca65)
LD65 := $(if $(wildcard ../../bin/ld65*),..$S..$Sbin$Sld65,ld65)
SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)

WORKDIR = ..$S..$Stestwrk$Sref

OPTIONS = g O Os Osi Osir Osr Oi Oir Or

DIFF = $(WORKDIR)$Sisequal$(EXE)
ISEQUAL = $(WORKDIR)$Sisequal$(EXE)

CC = gcc
CFLAGS = -O2 -Wall -W -Wextra -funsigned-char -fwrapv -fno-strict-overflow
Expand All @@ -57,7 +57,7 @@ $(WORKDIR)/%.ref: %.c | $(WORKDIR)
$(CC) $(CFLAGS) -o $(WORKDIR)/$*.host $< $(NULLERR)
$(WORKDIR)$S$*.host > $@

$(DIFF): ../isequal.c | $(WORKDIR)
$(ISEQUAL): ../isequal.c | $(WORKDIR)
$(CC) $(CFLAGS) -o $@ $<

# "yaccdbg.c" includes "yacc.c".
Expand All @@ -68,11 +68,13 @@ $(WORKDIR)/yaccdbg.%.prg: yacc.c

define PRG_template

$(WORKDIR)/%.$1.$2.prg: %.c $(WORKDIR)/%.ref $(DIFF)
$(WORKDIR)/%.$1.$2.prg: %.c $(WORKDIR)/%.ref $(ISEQUAL)
$(if $(QUIET),echo ref/$$*.$1.$2.prg)
$(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< $(NULLERR)
$(CC65) -t sim$2 $$(CC65FLAGS) -$1 -o $$(@:.prg=.s) $$< $(NULLERR)
$(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
$(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
$(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/$$*.$1.$2.out
$(DIFF) $(WORKDIR)/$$*.$1.$2.out $(WORKDIR)/$$*.ref
$(ISEQUAL) $(WORKDIR)/$$*.$1.$2.out $(WORKDIR)/$$*.ref

endef # PRG_template

Expand All @@ -81,4 +83,3 @@ $(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02)))

clean:
@$(call RMDIR,$(WORKDIR))
@$(call DEL,$(SOURCES:.c=.o))
11 changes: 6 additions & 5 deletions test/todo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ ifdef CMD_EXE
NULLDEV = nul:
MKDIR = mkdir $(subst /,\,$1)
RMDIR = -rmdir /s /q $(subst /,\,$1)
DEL = del /f $(subst /,\,$1)
else
S = /
NOT = !
NULLDEV = /dev/null
MKDIR = mkdir -p $1
RMDIR = $(RM) -r $1
DEL = $(RM) $1
endif

ifdef QUIET
Expand All @@ -28,7 +26,9 @@ endif

SIM65FLAGS = -x 200000000

CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65)
CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65)
CA65 := $(if $(wildcard ../../bin/ca65*),..$S..$Sbin$Sca65,ca65)
LD65 := $(if $(wildcard ../../bin/ld65*),..$S..$Sbin$Sld65,ld65)
SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)

WORKDIR = ../../testwrk/val
Expand All @@ -50,7 +50,9 @@ define PRG_template

$(WORKDIR)/%.$1.$2.prg: %.c | $(WORKDIR)
$(if $(QUIET),echo val/$$*.$1.$2.prg)
$(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< $(NULLERR)
$(CC65) -t sim$2 $$(CC65FLAGS) -$1 -o $$(@:.prg=.s) $$< $(NULLERR)
$(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
$(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
$(NOT) $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT)

endef # PRG_template
Expand All @@ -60,4 +62,3 @@ $(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02)))

clean:
@$(call RMDIR,$(WORKDIR))
@$(call DEL,$(SOURCES:.c=.o))

0 comments on commit c658acb

Please sign in to comment.