pz12

This is a task for our favourite professor
git clone git://git.stellar-nexus.ru/pz12
Log | Files | Refs | Submodules

commit 1a67807b18a9a053dccd6749df832afc5decc1b6
parent b33419b59334a277578cce2ad7d7ed09aa0db984
Author: Plat <plat@stellar-nexus.ru>
Date:   Thu, 27 Nov 2025 20:49:55 +0000

Massive revamps to testing logic

Diffstat:
MMakefile | 40++++++++++++++++++++++------------------
Mmake_tests.sh | 14+++++++-------
Mtest.sh | 15++++++++++++---
Atest1/clean.sh | 4++++
Atest1/full1 | 1+
Atest2/clean.sh | 4++++
6 files changed, 50 insertions(+), 28 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,5 +1,5 @@ -CC = true cc -CXX = true cxx +CC = cc #already uses the correct flags +CXX = g++ -static -O3 -flto -march=native STUDENTS =\ anazarova \ @@ -51,18 +51,17 @@ all: ${STUDENTS} ${STUDENTS}: @echo "=== Processing student: $@ ===" @test -d "$@" || \ - echo "No such directory" + exit 0; \ test -f "$@"/Makefile && \ - echo Found Makefile && \ - ${MAKE} -C "$@" || true - ls *.c >/dev/null 2>&1 && COMP="${CC}" || COMP="${CXX}"; \ + echo Found Makefile && (\ + ${MAKE} -C "$@" || true) || \ + (ls $@/*.c >/dev/null && COMP="${CC}" || COMP="${CXX}"; \ echo "No Makefile, compiling with $$COMP"; \ for BIN in ${BIN1} ${BIN2}; do \ echo "Compiling $$BIN"; \ - $$COMP "$@"/$${BIN}* -o "$@/$$BIN"; \ - file -f "$@/$$BIN" && strip "$@/$$BIN"; \ - done; - ) + $$COMP "$@"/$${BIN}* -o "$@/$$BIN" || true; \ + test -x "$@/$$BIN" && strip "$@/$$BIN" || true; \ + done;) test: enough ${BIN1} ${BIN2} @@ -73,21 +72,26 @@ ${BIN1}: @echo "=== Testing $@ ===" @echo "=== Testing $@ ===" >> test1_results @for s in ${STUDENTS}; do \ - echo "$$s:"; \ - echo "$$s:" >> test1_results; \ + echo -n "$$s: "; \ + echo -n "$$s: " >> test1_results; \ program="$$(ls -l $$s | grep x | grep " $@" | cut -d\ -f 9)"; \ - ./test.sh "./$$s/$$program" >> test1_results || true; \ - done; \ + ./test1.sh "./$$s/$$program" >> test1_results || true; \ done; ${BIN2}: @echo "=== Testing $@ ===" @echo "=== Testing $@ ===" >> test2_results @for s in ${STUDENTS}; do \ - echo "$$s:"; \ - echo "$$s:" >> test2_results; \ + echo -n "$$s: "; \ + echo -n "$$s: " >> test2_results; \ program="$$(ls -l $$s | grep x | grep " $@" | cut -d\ -f 9)"; \ - ./test.sh "./$$s/$$program" >> test2_results || true; \ + ./test2.sh "./$$s/$$program" >> test2_results || true; \ done; -.PHONY: all ${STUDENTS} ${BIN1} ${BIN2} +clean: + rm -rf test enough test1_results test2_results + cd test1 && ./clean.sh + cd test2 && ./clean.sh +#you should totally add restoring students' dirs here too + +.PHONY: all ${STUDENTS} test ${BIN1} ${BIN2} clean diff --git a/make_tests.sh b/make_tests.sh @@ -1,12 +1,12 @@ #!/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 +for i in $(seq 1 $1); do + testnumber1=$(($(ls -l test1/input* | wc -l) + 1)) + testnumber2=$(($(ls -l test2/input* | wc -l) + 1)) + head -80 /dev/urandom | od -An -w2 -tu2 | sed 's/ //g' | sed 's/*/10/g' > test1/input$testnumber1 + head -80 /dev/urandom | od -An -w2 -tu2 | sed 's/ //g' | sed 's/*/10/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 + printf "$((($(wc -l test1/input$testnumber1 | cut -d\ -f 1) - 1) / 2))\n$(cat test1/input$testnumber1)" | sponge test1/input$testnumber1 + printf "$(wc -l test2/input$testnumber2 | cut -d\ -f 1)\n$(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 diff --git a/test.sh b/test.sh @@ -1,18 +1,27 @@ #!/bin/sh +#This is a dumpster fire - I wish I could use rc for this dir="$(echo "$0" | cut -c 3- | cut -d. -f1)" prog="$1" total=0 -tests=$(("$(ls -l "$dir" | wc -l)" - 1)) #GNU ls outputs an extra line +tests="$(ls -l "$dir"/input* | wc -l)" +out="expected" for i in $(seq 1 $(($tests - 1))); do + echo "$prog" | grep -q full && test $i -eq 1 && continue + echo "$prog" | grep -q full && #Full would take too long to compute big amounts of. Use 30 + output="$(printf "30\n$(tail +2 "test1/input${i}" | tail -63)" | "$prog")" || 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)" - echo "$1" | grep -q greed || ( #greed may have wrong output - ignore it - diff -q <(echo "$rest") "${dir}/expected${i}" || (echo -1 && exit 1)) + if $(echo "$prog" | grep -q full); then + printf "30\n$(tail +2 "${dir}/input${i}" | tail -63)" | ./gavrilov/bell | tail +2 > test1/full${i} + out="full" + fi + echo "$prog" | grep -q greed || #greed may have wrong output - ignore it + diff -q <(echo "$rest") "${dir}/${out}${i}" || (echo -${i} && exit 1) done echo "$total" diff --git a/test1/clean.sh b/test1/clean.sh @@ -0,0 +1,4 @@ +#!/bin/sh +for i in $(seq 2 100); do + rm -f input$i expected$i full$i +done diff --git a/test1/full1 b/test1/full1 @@ -0,0 +1 @@ +0 1 diff --git a/test2/clean.sh b/test2/clean.sh @@ -0,0 +1,4 @@ +#!/bin/sh +for i in $(seq 2 100); do + rm -f input$i expected$i full$i +done