-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.sh
More file actions
91 lines (69 loc) · 2.01 KB
/
Copy pathscript.sh
File metadata and controls
91 lines (69 loc) · 2.01 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
# Get parameters
while getopts f:i:e:c:t: option
do
case "${option}"
in
f)filename=${OPTARG};;
i)init=${OPTARG};;
e)end=${OPTARG};;
c)color=${OPTARG};;
t)tests=${OPTARG};;
esac
done
#### TESTS
# If the test parameter hasn't been passed, then set the value as "NO"
if [ -z "$tests" ]; then
tests="NO"
fi
# Check the value passed is possible
if [ "${tests^^}" != "YES" ] && [ "${tests^^}" != "NO"]; then
echo "Test argument wrong. Remind the possibilities are \"YES\" and \"NO\". The second one is the default value."
exit 127
fi
# If the test is required, then do it. Otherwise continue.
if [ "${tests^^}" == "YES" ]; then
cd tst/
bash script.sh -f ../dat/bad_network.csv -i A -e F -c NOCOLOR
bash script.sh -f ../dat/no_nodes.csv -i A -e F -c NOCOLOR
bash script.sh -f ../dat/no_links.csv -i A -e F -c NOCOLOR
bash script.sh -f ../dat/network.csv -i A -e F -c ROJO
exit 0
fi
#### CODE
# If the parameter hasn't been passed, then use the default value or stop the program and send message.
if [ -z "$filename" ]; then
filename="dat/network.csv"
fi
if [ -z "$init" ]; then
echo "No initial node passed as argument. Please write it."
exit 127
fi
if [ -z "$end" ]; then
echo "No final node passed as argument. Please write it."
exit 127
fi
if [ -z "$color" ]; then
color="NOCOLOR"
fi
# Print parameters
echo "Filename : $filename"
echo "First node : $init"
echo "Last node : $end"
echo "Color : $color"
# Change the values in the file
sed -i "s%^ this->filename =.*% this->filename = \"${filename}\";%" src/parameters.cpp
sed -i "s%^ this->init =.*% this->init = \"${init^^}\";%" src/parameters.cpp
sed -i "s%^ this->end =.*% this->end = \"${end^^}\";%" src/parameters.cpp
sed -i "s%^ this->color =.*% this->color = \"${color^^}\";%" src/parameters.cpp
# Compilation process
if [ ! -d build ]; then
mkdir build
fi
cd build/
cmake ../ -DMY_COMPILE_NAME=x.code
make
cd ../
# Excution process
time ./build/x.code
rm ./build/x.code