forked from Pithikos/C-Thread-Pool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
funcs.sh
executable file
·52 lines (40 loc) · 1004 Bytes
/
funcs.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
#! /bin/bash
#
# This file should be included by other shell scripts that
# want to use any of the functions
#
function assure_installed_valgrind {
valgrind --version &> /dev/null
if (( $? != 0 )); then
msg="Valgrind seems to not be installed."
err "$msg" "$msg"
fi
}
function needle { #needle #haystack
python -c "import re; print(re.search(r'$1', '$2').group(0))"
if (( $? != 0 )); then
msg="Python script error"
err "$msg" "$msg"
fi
}
function extract_num { #needle with number #haystack
string=$(needle "$1" "$2")
needle "[0-9]*" "$string"
if (( $? != 0 )); then
msg="Python script error"
err "$msg" "$msg"
fi
}
function time_exec { #command ..
realsecs=$(/usr/bin/time -f '%e' "$@" 2>&1 > /dev/null)
echo "$realsecs"
}
function err { #string #log
echo "------------------- ERROR ------------------------"
echo "$1"
echo "$2" >> error.log
exit 1
}
function compile { #cfilepath
gcc $COMPILATION_FLAGS "$1" ../thpool.c -D THPOOL_DEBUG -pthread -o test
}