-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.sh
executable file
·66 lines (56 loc) · 2.11 KB
/
common.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
#!/bin/bash
# Todo: Replace the ips here
BOARD_IP="[email protected]"
MIRALIS_IP="[email protected]"
PROTECT_PAYLOAD_IP="[email protected]"
OFFLOAD_IP="[email protected]"
function create_folder_if_not_exists() {
local folder="$1"
if [ ! -d "$folder" ]; then
echo "Folder '$folder' does not exist. Creating..."
mkdir "$folder"
fi
}
function RemoteExec() {
sshpass -p 'starfive' ssh -oStrictHostKeyChecking=no -p 22 "$1" "cd miralis-benchmark;$2";
}
function setup() {
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <arg1>"
echo "Error: Please provide the benchmark type as argument, options are [board|miralis|protect]"
exit 1
fi
# We only allow three kind of benchmark types
if ! [[ "$1" == "board" || "$1" == "miralis" || "$1" == "protect" || "$1" == "offload" ]]; then
echo "Error: Invalid argument. Allowed values are 'board', 'miralis', 'offload' or 'protect'."
exit 1
fi
echo "Benchmark type: $1"
# Determine ADDRESS based on VALUE
if [[ "$1" == "board" ]]; then
ADDRESS=$BOARD_IP
elif [[ "$1" == "miralis" ]]; then
ADDRESS=$MIRALIS_IP
elif [[ "$1" == "protect" ]]; then
ADDRESS=$PROTECT_PAYLOAD_IP
elif [[ "$1" == "offload" ]]; then
ADDRESS=$OFFLOAD_IP
else
echo "Unknown value: $VALUE"
exit 1
fi
create_folder_if_not_exists "results"
create_folder_if_not_exists "results/stats"
}
function clear_stats_entries() {
echo "" > "results/stats/$1_core_1.txt"
echo "" > "results/stats/$1_core_2.txt"
echo "" > "results/stats/$1_core_3.txt"
echo "" > "results/stats/$1_core_4.txt"
}
function add_miralis_stat_entry() {
RemoteExec $ADDRESS "taskset 1 cat /proc/miralis && dmesg | tail -n 1" >> "results/stats/$1_core_1.txt"
RemoteExec $ADDRESS "taskset 2 cat /proc/miralis && dmesg | tail -n 1" >> "results/stats/$1_core_2.txt"
RemoteExec $ADDRESS "taskset 3 cat /proc/miralis && dmesg | tail -n 1" >> "results/stats/$1_core_3.txt"
RemoteExec $ADDRESS "taskset 4 cat /proc/miralis && dmesg | tail -n 1" >> "results/stats/$1_core_4.txt"
}