Added diamond test package

This commit is contained in:
Claudio Maggioni 2019-09-25 08:42:00 +02:00
parent ffd992d549
commit 20b7254c19
11 changed files with 2303 additions and 0 deletions

54
diamond/Makefile Normal file
View File

@ -0,0 +1,54 @@
CFLAGS=-Wall -g
# CC=$(CXX)
SHELL=/bin/bash
PROGRAM=diamond
TIMEOUT=8
TESTS_DIR=tests
TESTS_SH:=$(wildcard $(TESTS_DIR)/*.sh)
TESTS:=$(patsubst $(TESTS_DIR)/%.sh, %, $(TESTS_SH))
.PHONY: all
all: compile-program check
.PHONY: compile-program
compile-program: $(PROGRAM)
.PHONY: check
check: compile-program $(TESTS_SH)
@exec 2> /dev/null; \
for t in $(TESTS); do \
echo -n "Running test $$t..." ; \
/bin/sh "$(TESTS_DIR)/$$t.sh" $(dir $(PROGRAM))$(PROGRAM) > "$$t.out" 2>&1 & \
prog_pid=$$!; \
( sleep $(TIMEOUT); kill $$prog_pid > /dev/null 2>&1 ) & \
killer_pid=$$!; \
wait $$prog_pid; \
res=$$?; \
if test $$res -gt 128; \
then \
echo KILLED; \
rm -f "$$t.out" ;\
else \
kill $$killer_pid > /dev/null 2>&1 ;\
wait $$killer_pid; \
if cmp -s "$$t.out" "$(TESTS_DIR)/$$t.expected"; \
then \
echo "PASSED" ;\
rm -f "$$t.out" ;\
else \
echo "FAILED" ;\
diff "$$t.out" "$(TESTS_DIR)/$$t.expected";\
fi; \
fi; \
done
.PHONY: clean
clean:
rm -f $(PROGRAM) tests/*.out

View File

3
diamond/tests/test0.sh Normal file
View File

@ -0,0 +1,3 @@
#!/bin/sh
exec "$1" 0

View File

@ -0,0 +1 @@
#

3
diamond/tests/test1.sh Normal file
View File

@ -0,0 +1,3 @@
#!/bin/sh
exec "$1" 1

View File

@ -0,0 +1,3 @@
#
###
#

3
diamond/tests/test2.sh Normal file
View File

@ -0,0 +1,3 @@
#!/bin/sh
exec "$1" 2

View File

@ -0,0 +1,11 @@
#
###
#####
#######
#########
###########
#########
#######
#####
###
#

3
diamond/tests/test3.sh Normal file
View File

@ -0,0 +1,3 @@
#!/bin/sh
exec "$1" 6

2217
diamond/tests/test4.expected Normal file

File diff suppressed because it is too large Load Diff

5
diamond/tests/test4.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/sh
"$1" 10
"$1" 100
"$1" 1000