Skip to content
Snippets Groups Projects
Commit bea36442 authored by Baruta Daniel Mihail's avatar Baruta Daniel Mihail
Browse files

General improvements

parent 4bb42f74
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,8 @@ cd "$(dirname "$0")" || exit 1
EXECUTABLE="../src/perfect"
TIMEOUT_DURATION=10
SCORE=0
TOTAL_SCORE=0
test_err()
{
......@@ -52,7 +54,6 @@ test_edge()
return $?
}
setup()
{
pushd ../src > /dev/null || exit 1
......@@ -68,31 +69,42 @@ cleanup()
}
test_fun_array=( \
test_err "Name 1" 5 \
test_single "Name 2" 5 \
test_multiple "Name 3" 5 \
test_edge "Name 4" 5 \
test_err "Name 1" 25 \
test_single "Name 2" 25 \
test_multiple "Name 3" 25 \
test_edge "Name 4" 25 \
)
test_all()
run_test()
{
local score=0
test_index="$1"
test_func_index=$((test_index * 3))
description=${test_fun_array[$((test_func_index + 1))]}
points=${test_fun_array[$((test_func_index + 2))]}
TOTAL_SCORE=$((TOTAL_SCORE + points))
echo -ne "Testing\t\t$description\t"
if ${test_fun_array["$test_func_index"]} ; then
SCORE=$((SCORE + points))
echo "$points/$points"
else
echo "0/$points"
fi
}
test_all()
{
for i in $(seq 0 "$((${#test_fun_array[@]} / 3 - 1))") ; do
test_index=$((i * 3))
description=${test_fun_array[$((test_index + 1))]}
points=${test_fun_array[$((test_index + 2))]}
echo -e "Testing\t\t$description"
if ${test_fun_array["$test_index"]} ; then
score=$((score + points))
fi
run_test "$i"
done
echo -e "\nTotal: $score"
echo -e "\nTotal: $SCORE/$TOTAL_SCORE"
}
setup
test_all
if [ -z "$1" ] ; then
test_all
else
run_test "$1"
fi
cleanup
......@@ -18,11 +18,11 @@ DEFAULT_REGISTRY='registry.gitlab.cs.pub.ro'
#=============================================================================
LOG_INFO() {
echo -e "[$(date +%F_%T)] [INFO] $1"
echo -e "[$(date +%FT%T)] [INFO] $1"
}
LOG_FATAL() {
echo -e "[$(date +%F_%T)] [${RED}FATAL${NC}] $1"
echo -e "[$(date +%FT%T)] [${RED}FATAL${NC}] $1"
exit 1
}
......@@ -63,9 +63,10 @@ print_help() {
echo " --full_image_name <full_image_name> - the full name of the image (default: registry.gitlab.cs.pub.ro/<current_directory_name>:latest)"
echo " --use_executable <executable> - command to run inside the container (default: /bin/bash)"
echo ""
echo "local.sh checker [--remove_image] [argumets_for_checker]"
echo "local.sh checker [--remove_image] [--use_existing_image <image_name>] [argumets_for_checker]"
echo ""
echo " --remove_image - remove the checker's docker image after the run"
echo " --use_existing_image - user image_name instead of building the image from current directory"
echo " argumets_for_checker - list of space separated arguments to be passed to the checker"
echo ""
}
......@@ -232,7 +233,7 @@ checker_main() {
LOG_INFO "Running checker..."
docker run --rm \
--mount type=bind,source="$tmpdir",target=/build \
"$image_name" /bin/bash /build/checker/checker.sh "${script_args[@]}"
"$image_name" /bin/bash -c "rm -rf /usr/local/bin/bash; /build/checker/checker.sh \"${script_args[@]}\"" # remove bash middleware script
if [ -n "$remove_image" ] ; then
LOG_INFO "Cleaning up..."
......
File deleted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment