default: tests.log

include ../../src/config.inc

# SHARD restricts the long-running symex-driven-lazy-loading run to a single
# shard "<index>/<count>" (see test.pl --shard); the parent Makefile sets it to
# spread this profile across parallel workers. An empty SHARD runs the whole
# profile. Each shard writes a distinct log so concurrent shards do not clobber
# one another.
SHARD =
symex_driven_log = symex-driven-loading$(if $(SHARD),-$(firstword $(subst /, ,$(SHARD))))
# With BDD_GUARDS the bdd-expected-timeout tests are additionally excluded
# (preserving the historic behaviour of this Makefile).
ifeq ($(filter %DBDD_GUARDS, $(CXXFLAGS)),)
symex_driven_extra_exclude =
else
symex_driven_extra_exclude = -X bdd-expected-timeout
endif
symex_driven_opts = -X symex-driven-lazy-loading-expected-failure $(symex_driven_extra_exclude) $(if $(SHARD),--shard $(SHARD)) -s $(symex_driven_log)

.PHONY: test test-normal test-symex-driven-lazy-loading
test: test-normal test-symex-driven-lazy-loading

test-normal:
	@../$(CPROVER_DIR)/regression/test.pl -e -p -c "../../../src/jbmc/jbmc --validate-goto-model --validate-ssa-equation"

test-symex-driven-lazy-loading:
	@../$(CPROVER_DIR)/regression/test.pl -e -p -c "../../../src/jbmc/jbmc --validate-goto-model --validate-ssa-equation --symex-driven-lazy-loading" $(symex_driven_opts)

tests.log: ../$(CPROVER_DIR)/regression/test.pl
	@../$(CPROVER_DIR)/regression/test.pl -e -p -c "../../../src/jbmc/jbmc --validate-goto-model --validate-ssa-equation"
	@../$(CPROVER_DIR)/regression/test.pl -e -p -c "../../../src/jbmc/jbmc --validate-goto-model --validate-ssa-equation --symex-driven-lazy-loading" -X symex-driven-lazy-loading-expected-failure $(symex_driven_extra_exclude) -s symex-driven-loading

show:
	@for dir in *; do \
		if [ -d "$$dir" ]; then \
			vim -o "$$dir/*.java" "$$dir/*.out"; \
		fi; \
	done;

clean:
	find -name '*.out' -execdir $(RM) '{}' \;
	find -name '*.gb' -execdir $(RM) '{}' \;
	$(RM) tests.log tests-symex-driven-loading*.log

%.class: %.java ../../src/org.cprover.jar
	javac -g -cp ../../src/org.cprover.jar:. $<

nondet_java_files := $(shell find . -name "Nondet*.java")
nondet_class_files := $(patsubst %.java, %.class, $(nondet_java_files))

.PHONY: nondet-class-files
nondet-class-files: $(nondet_class_files)

.PHONY: clean-nondet-class-files
clean-nondet-class-files:
	-rm $(nondet_class_files)
