commit b33419b59334a277578cce2ad7d7ed09aa0db984
parent 87f99a25e53a5c0c037d7a060150d98f9fbeaa11
Author: Plat <plat@stellar-nexus.ru>
Date: Thu, 27 Nov 2025 00:03:24 +0000
Viable testing launch
Diffstat:
7 files changed, 60 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
@@ -64,4 +64,30 @@ ${STUDENTS}:
done;
)
-.PHONY: all ${STUDENTS}
+test: enough ${BIN1} ${BIN2}
+
+enough:
+ ./make_tests.sh 30
+
+${BIN1}:
+ @echo "=== Testing $@ ==="
+ @echo "=== Testing $@ ===" >> test1_results
+ @for s in ${STUDENTS}; do \
+ echo "$$s:"; \
+ echo "$$s:" >> test1_results; \
+ program="$$(ls -l $$s | grep x | grep " $@" | cut -d\ -f 9)"; \
+ ./test.sh "./$$s/$$program" >> test1_results || true; \
+ done; \
+ done;
+
+${BIN2}:
+ @echo "=== Testing $@ ==="
+ @echo "=== Testing $@ ===" >> test2_results
+ @for s in ${STUDENTS}; do \
+ echo "$$s:"; \
+ echo "$$s:" >> test2_results; \
+ program="$$(ls -l $$s | grep x | grep " $@" | cut -d\ -f 9)"; \
+ ./test.sh "./$$s/$$program" >> test2_results || true; \
+ done;
+
+.PHONY: all ${STUDENTS} ${BIN1} ${BIN2}
diff --git a/make_tests.sh b/make_tests.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+for i in $(seq $1); do
+ testnumber1=$(wc -l test1) #GNU ls outputs an extra line
+ testnumber2=$(wc -l test2) #GNU ls outputs an extra line
+ head -80 /dev/urandom | od -An -w2 -tu2 | sed 's/ //g'> test1/input$testnumber1
+ head -80 /dev/urandom | od -An -w2 -tu2 | sed 's/ //g'> test2/input$testnumber2
+
+ printf "$(($(wc -l test1/input$testnumber1) - 1))$(cat test1/input$testnumber1)" | sponge test1/input$testnumber1
+ printf "$(($(wc -l test2/input$testnumber1) - 0))$(cat test2/input$testnumber2)" | sponge test2/input$testnumber2
+
+ ./gavrilov/bell < test1/input$testnumber1 | tail +2 > test1/expected$testnumber1
+ ./gavrilov/shell < test2/input$testnumber2 | tail +2 > test2/expected$testnumber2
+done
+
+touch enough
diff --git a/test.sh b/test.sh
@@ -6,12 +6,13 @@ total=0
tests=$(("$(ls -l "$dir" | wc -l)" - 1)) #GNU ls outputs an extra line
for i in $(seq 1 $(($tests - 1))); do
- output = "$("$prog" < "${dir}/input${i}")"
+ output="$("$prog" < "${dir}/input${i}")"
first_line="$(echo "$output" | head -n 1)"
rest="$(echo "$output" | tail -n +2)"
total="$(echo "$total" + "$first_line" | bc -l)"
- diff -q <(echo "$rest") "${dir}/expected${i}" || (echo -1 && exit 1)
+ echo "$1" | grep -q greed || ( #greed may have wrong output - ignore it
+ diff -q <(echo "$rest") "${dir}/expected${i}" || (echo -1 && exit 1))
done
echo "$total"
diff --git a/test1/expected1 b/test1/expected1
@@ -0,0 +1 @@
+0 1
diff --git a/test1/input1 b/test1/input1
@@ -0,0 +1,3 @@
+5 3
+1 2 3 4 5
+5 4 3 2 1
diff --git a/test2/expected1 b/test2/expected1
@@ -0,0 +1,5 @@
+1
+2
+3
+4
+5
diff --git a/test2/input1 b/test2/input1
@@ -0,0 +1,6 @@
+5
+5
+4
+3
+2
+1