forked from intel/lkp-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenv.sh
executable file
·110 lines (94 loc) · 1.76 KB
/
env.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/sh
[ -n "$lib_env_load_once" ] && return
lib_env_load_once=1
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lkp/benchmarks/lib
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/lkp/benchmarks/lib/pkgconfig:/lkp/benchmarks/share/pkgconfig
if command -v command >/dev/null 2>&1; then
has_cmd()
{
command -v "$1" >/dev/null
}
cmd_path()
{
command -v "$1"
}
else
has_cmd()
{
type "$1" >/dev/null 2>&1
}
cmd_path()
{
has_cmd "$1" && which "$1"
}
fi
# gawk has a known bug
# awk: fatal error: internal error: segfault
if has_cmd mawk; then
__mawk_cmd=$(cmd_path mawk)
awk()
{
$__mawk_cmd "$@"
}
fi
nproc()
{
if has_cmd 'nproc'; then
/usr/bin/nproc
elif has_cmd 'getconf'; then
getconf '_NPROCESSORS_CONF'
else
grep -c '^processor' /proc/cpuinfo
fi
}
role()
{
# $node_roles will be determined at job schedule time and
# set accordingly in each scheduled job
local __my_roles=" $node_roles "
[ "${__my_roles#* $1 }" != "$__my_roles" ]
}
is_virt()
{
[ -n "$VM_VIRTFS" ] && return 0
if [ -n "$model" ]; then
# running inside LKP job
[ -n "$nr_vm" ]
elif has_cmd 'virt-what'; then
# run as root
[ -n "$(virt-what)" ]
else
grep -q -w hypervisor /proc/cpuinfo
fi
}
set_perf_path()
{
if [ -x "$1" ]; then
perf="$1"
else
perf=$(cmd_path perf) || {
. $LKP_SRC/lib/debug.sh
die "Can not find perf command"
}
fi
}
disable_nmi_watchdog()
{
# Disable NMI watchdog to free up one perf counter
test -e /proc/sys/kernel/nmi_watchdog &&
echo 0 > /proc/sys/kernel/nmi_watchdog
}
need_run_on_vmm()
{
# lkp qemu will set LKP_LOCAL_RUN=1
[ "$LKP_LOCAL_RUN" = 1 ] && return 1
echo "$testcase" | grep -q "^kvm:"
}
is_aliyunos()
{
[ -f /etc/redhat-release ] && grep -qw "Aliyun Linux" /etc/redhat-release
}
is_docker()
{
[ -f /.dockerenv ]
}