-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrapper.sh
70 lines (53 loc) · 1.18 KB
/
wrapper.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#! /usr/bin/env bash
set -o errexit
set -o nounset
function log_info()
{
log_ "info" "$@"
}
function log_error()
{
log_ "error" "$@"
}
function log_()
{
local type=$1
local message=$2
local date_str=; date_str=$(date +'%Y-%m-%d %H:%M:%S')
echo "[${type}] [${date_str}] ${message}"
}
function main()
{
log_info "Stage #1 Compiling..."
local build_dir=build
local src=src
rm -rf ${build_dir}
mkdir ${build_dir}
cp ${src}/Makefile ./${build_dir}
cp ${src}/{*.c} ./${build_dir}
if ! make --directory=${build_dir} debug ; then
log_error "Failed to compile."
return 1
fi
local test_dir=tests
local executable=os_lab1
local test_genrator=generator
if [ $# == 1 ] && [ $1 == -gen ] ; then
rm -rf ${test_dir}
mkdir ${test_dir}
cp run.sh ./${test_dir}
log_info "Stage #2 Test generating..."
if ! python3 ${test_genrator}.py ${test_dir} ; then
log_error "Failed to generate tests."
return 1
fi
else
log_info "Stage #2 Test generating skipped (-gen to generate)"
fi
log_info "Stage #3 Checking..."
if ! ./${test_dir}/run.sh ; then
log_error "Failed to run test"
return 1
fi
}
main $@