From 505fe196a5c5e8edeaa2ca898dd7074e116622ad Mon Sep 17 00:00:00 2001 From: Robert Ulmer Date: Thu, 28 Nov 2024 20:41:37 +0100 Subject: [PATCH] Add create_io_test.sh to easyliy create tests --- buildscripts/create_io_test.sh | 36 ++++++++++++++++++++++++++++++++++ buildscripts/criterion.sh | 2 +- compile_commands.json | 1 - 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100755 buildscripts/create_io_test.sh delete mode 120000 compile_commands.json diff --git a/buildscripts/create_io_test.sh b/buildscripts/create_io_test.sh new file mode 100755 index 0000000..99d8038 --- /dev/null +++ b/buildscripts/create_io_test.sh @@ -0,0 +1,36 @@ +#!/bin/env bash + +cd $(dirname $0)/.. + +program_file=$1 ; shift +test_number=$(printf "%02d" $1) ; shift + +printf "Creating test number %s for program %s\n" ${test_number} ${program_file} + +if ! [ -x ${program_file} ]; then + program_file=./build/${program_file}; +fi + +if ! [ -x ${program_file} ]; then + echo program file not executeable 1>&2 + exit 1 +fi + +if [ ${test_number} -lt 0 ] || [ ${test_number} -gt 99 ]; then + echo invalid test number 1>&2 + exit 2 +fi + +test_dir=./tests/io_tests/$(basename ${program_file})/ + +[ -d ${test_dir} ] || mkdir -p ${test_dir} + +in_file=${test_dir}${test_number}.in +out_file=${test_dir}${test_number}.out +err_file=${test_dir}${test_number}.err + +rm -f ${in_file} +rm -f ${out_file} +rm -f ${err_file} + +tee ${in_file} | stdbuf -o0 ${program_file} 2> ${err_file} | tee ${out_file} diff --git a/buildscripts/criterion.sh b/buildscripts/criterion.sh index a3bfc18..f846ed7 100755 --- a/buildscripts/criterion.sh +++ b/buildscripts/criterion.sh @@ -8,7 +8,7 @@ cmake --build . --target $(basename ${criterion_target}) out_file="./$(dirname ${criterion_target})/Testing/$(basename ${criterion_target}).out" -timeout 10 ./${criterion_target} > ${out_file} 2>&1 || { +timeout 10 ./${criterion_target} --verbose > ${out_file} 2>&1 || { tail -n 10 ${out_file} rm -f ${out_file} exit 2 diff --git a/compile_commands.json b/compile_commands.json deleted file mode 120000 index 878ba91..0000000 --- a/compile_commands.json +++ /dev/null @@ -1 +0,0 @@ -/home/robert/Unison/Development/templates/cmake_template/out/Debug/compile_commands.json \ No newline at end of file