forked from gkatsikas/snf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·63 lines (50 loc) · 1.61 KB
/
run.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
#!/bin/bash
##============================================================================
## Name: run.sh
## Author: Georgios Katsikas ([email protected])
## Description: Runs SNF with or without the GNU debugger (gdb).
##============================================================================
if [[ -z $SNF_HOME ]]; then
printf "Need to set env. variable SNF_HOME\n"
exit 1
fi
source $SNF_HOME/scripts/commons.sh
program=$0
# Argument 1: Path to the SNF executable
executable=$1
# Argument 2: Input property file
input_property_file=$2
# Argument 3: Debug flag for gdb [Optional]
debug_mode=$3
usage()
{
printf "Usage: %s <executable> <input_property_file> [OPTIONAL -d]\n" $program
exit $ERROR
}
main()
{
# Check if the SNF executable exists
file_exists $executable && : || usage
executable=$(get_abs_path $executable)
printf "SNF Executable: %s\n" $executable
# Check if the input property file exists
file_exists $input_property_file && : || usage
input_property_file=$(get_abs_path $input_property_file)
printf "SNF Input: %s\n" $input_property_file
# Debug option is given
[[ $debug_mode == "-d" ]] && debug_mode="true" || debug_mode="false"
printf " Debug Mode: %s\n" $debug_mode
cd $SNF_HOME
### Execution through GDB (Press r (run) and then q (quit))
if [[ $debug_mode == "true" ]]; then
printf "Execution through GDB: Press r to run and then q to quit\n"
gdb --args $executable -p $input_property_file -v
### Normal execution
else
$executable -p $input_property_file -v
fi
cd - > /dev/null
exit $SUCCESS
}
# Check input arguments
[[ ($# != 2) && ($# != 3) ]] && usage || main