Last active
August 19, 2018 17:14
-
-
Save senapk/e1c21b297ff3ab48a5d199197d93d42b to your computer and use it in GitHub Desktop.
Makefile para rodar testes e gerar vlp.cases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Para o run passe o nome do comando executável e o nome da pasta que contem os testes | |
# Ex: O nome do executavel é 'calculadora' e a pasta que contem os testes no formato .in .sol é 'testes' | |
# make run cmd=calculadora folder=testes | |
# Para gerar o vpl a usando os testes da pasta 'testes' faça | |
# make vpl folder=testes | |
# Se o modelo dos arquivos de entrada e saída forem in1, out1, in2, out2, você deve usar os comandos | |
# make run2 cmd=executavel folder=testes | |
# make vpl2 folder=testes | |
# se tiver varias pastas de teste do tipo test1, test2, test3, etc você pode usar o * | |
# make vpl2 folder=test* | |
CFLAGS= -Wall -std=c99 | |
CPPFLAGS= -Wall -std=c++11 | |
run: | |
@ for in_file in $${folder}/*.in ;\ | |
do \ | |
out_file=$${in_file%.in}.sol ;\ | |
user_file=$${in_file%.in}.user ;\ | |
./$${cmd} <$$in_file >$$user_file ;\ | |
DIFF="$$(diff -B -Z -w -q $$out_file $$user_file)" ;\ | |
RES=$$? ;\ | |
if [ "$$RES" -eq 0 ]; then \ | |
echo "$$in_file : DONE" ;\ | |
else \ | |
echo "$$in_file : FAIL" ;\ | |
echo "---------ENTRADA--------" && cat $$in_file ;\ | |
echo "----SAIDA DO PROGRAMA---" && cat $$user_file ;\ | |
echo "------SAIDA ESPERADA----" && cat $$out_file ;\ | |
fi ;\ | |
echo '@@@@@@@@@@@@@@@@@@@@@@@@@@' ;\ | |
done | |
run2: | |
@ for in_file in $${folder}/in* ;\ | |
do \ | |
out_file=$${folder}/out$${in_file#*in} ;\ | |
user_file=$${folder}/user$${in_file#*in} ;\ | |
./$${cmd} <$$in_file >$$user_file ;\ | |
DIFF="$$(diff -B -Z -w -q $$out_file $$user_file)" ;\ | |
RES=$$? ;\ | |
if [ "$$RES" -eq 0 ]; then \ | |
echo "$$in_file : DONE" ;\ | |
else \ | |
echo "$$in_file : FAIL" ;\ | |
echo "---------ENTRADA--------" && cat $$in_file ;\ | |
echo "----SAIDA DO PROGRAMA---" && cat $$user_file ;\ | |
echo "------SAIDA ESPERADA----" && cat $$out_file ;\ | |
fi ;\ | |
echo '@@@@@@@@@@@@@@@@@@@@@@@@@@' ;\ | |
done | |
vpl: | |
@ cont=1 ;\ | |
for in_file in $${folder}/*.in ;\ | |
do \ | |
out_file=$${in_file%.in}.sol ;\ | |
printf "case=%d\n" "$$cont" ;\ | |
printf "input=" ;\ | |
printf "$$(cat $$in_file)\n" ;\ | |
printf "output=\"" ;\ | |
printf "$$(cat $$out_file)" ;\ | |
printf "\"\n" ;\ | |
printf "grade reduction = 100%%\n\n" ;\ | |
((cont++)) ;\ | |
done | |
vpl2: | |
@ cont=1 ;\ | |
for in_file in $${folder}/in* ;\ | |
do \ | |
out_file=$${folder}/out$${in_file#*in} ;\ | |
printf "case=%d\n" "$$cont" ;\ | |
printf "input=" ;\ | |
printf "$$(cat $$in_file)\n" ;\ | |
printf "output=\"" ;\ | |
printf "$$(cat $$out_file)" ;\ | |
printf "\"\n" ;\ | |
printf "grade reduction = 100%%\n\n" ;\ | |
((cont++)) ;\ | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment