/
phoronix-test-suite
executable file
·373 lines (350 loc) · 10.5 KB
/
phoronix-test-suite
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
#!/bin/sh
#
# Phoronix Test Suite
# URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/
# Copyright (C) 2008 - 2021, Phoronix Media
# Copyright (C) 2008 - 2021, Michael Larabel
# phoronix-test-suite: The Phoronix Test Suite is an extensible open-source testing / benchmarking platform
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
if which sed >/dev/null 2>&1 ;
then
# Remove the current dir from PATH if present, as it causes infinitely resursive shell scripts.
PATH="`echo $PATH | sed -e s/:[\.]:/:/g -e s/:[\.]// -e s/[\.]://`"
fi
# Full path to root directory of the actual Phoronix Test Suite code
if [ -d /Applications ] && [ -d /usr/share/phoronix-test-suite/ ]
then
# macOS has problems with the readlink code
export PTS_DIR="/usr/share/phoronix-test-suite/"
elif [ -d /Applications ]
then
# macOS has problems with the readlink code
export PTS_DIR=`pwd`
else
export PTS_DIR=$(readlink -f `dirname $0`)
fi
#export PTS_DIR=`pwd`
export PTS_MODE="CLIENT"
if which realpath >/dev/null 2>&1 ;
then
export PTS_LAUNCHER=`realpath $0`
else
export PTS_LAUNCHER="$PTS_DIR/phoronix-test-suite"
fi
if [ $PTS_DIR != "`pwd`" ]
then
cd $PTS_DIR
fi
# Run any start-up hooks, such as to pre-seed environment variables or other non-default behaviors / customizations
if [ -d pts-core/hooks/startup ]
then
for file in pts-core/hooks/startup/*.sh
do
./$file
done
fi
# Determine PHP binary location
if [ ! "X$PHP_BIN" = "X" ] && [ -x $PHP_BIN ]
then
export PHP_BIN=$PHP_BIN
elif [ -x /usr/bin/php8 ] || [ -x /usr/local/bin/php8 ] || [ -x /usr/pkg/bin/php8 ]
then
export PHP_BIN="php8"
elif [ -x /usr/bin/php7 ] || [ -x /usr/local/bin/php7 ] || [ -x /usr/pkg/bin/php7 ]
then
export PHP_BIN="php7"
elif [ -x /usr/bin/php ] || [ -x /usr/pkg/bin/php ]
then
export PHP_BIN="php"
elif [ -x /usr/php7/bin/php ]
then
export PHP_BIN="/usr/php7/bin/php"
elif [ -x /usr/php8/bin/php ]
then
export PHP_BIN="/usr/php8/bin/php"
elif [ -x /usr/php/bin/php ]
then
export PHP_BIN="/usr/php/bin/php"
elif [ -x /usr/local/bin/php ]
then
export PHP_BIN="/usr/local/bin/php"
elif [ -x /usr/local/bin/php-7.0 ]
then
export PHP_BIN="/usr/local/bin/php-7.0"
elif [ -x /usr/local/bin/php-7.1 ]
then
export PHP_BIN="/usr/local/bin/php-7.1"
elif [ -x /usr/local/bin/php-7.2 ]
then
export PHP_BIN="/usr/local/bin/php-7.2"
elif [ -x /usr/local/bin/php-7.3 ]
then
export PHP_BIN="/usr/local/bin/php-7.3"
elif [ -x /usr/local/bin/php-7.4 ]
then
export PHP_BIN="/usr/local/bin/php-7.4"
elif [ -x /usr/local/bin/php-8.0 ]
then
export PHP_BIN="/usr/local/bin/php-8.0"
elif [ -x /usr/local/bin/php-8.1 ]
then
export PHP_BIN="/usr/local/bin/php-8.1"
elif [ -x /usr/local/bin/php-8.2 ]
then
export PHP_BIN="/usr/local/bin/php-8.2"
elif [ -x /opt/bin/php ]
then
export PHP_BIN="/opt/bin/php"
elif [ -x /usr/pkg/libexec/cgi-bin/php ]
then
export PHP_BIN="/usr/pkg/libexec/cgi-bin/php"
elif which php >/dev/null 2>&1 ;
then
export PHP_BIN="php"
elif which php7 >/dev/null 2>&1 ;
then
export PHP_BIN="php7"
elif which php8 >/dev/null 2>&1 ;
then
export PHP_BIN="php8"
elif [ -x /usr/php5/bin/php ]
then
export PHP_BIN="/usr/php5/bin/php"
elif [ -x /usr/bin/php5 ] || [ -x /usr/local/bin/php5 ] || [ -x /usr/pkg/bin/php5 ]
then
export PHP_BIN="php5"
elif which php8 >/dev/null 2>&1 ;
then
export PHP_BIN="php8"
elif which php7 >/dev/null 2>&1 ;
then
export PHP_BIN="php7"
elif which php5 >/dev/null 2>&1 ;
then
export PHP_BIN="php5"
elif which php-cli >/dev/null 2>&1 ;
then
export PHP_BIN="php-cli"
else
export PHP_BIN=""
fi
# Make sure PHP is installed
if [ "X$PHP_BIN" = "X" ]
then
cat <<'EOT'
PHP must be installed for the Phoronix Test Suite
The PHP command-line package is commonly called php-cli, php7-cli, php8-cli, or php.
For more information, see the included documentation or online via:
https://github.com/phoronix-test-suite/phoronix-test-suite/tree/master/documentation
EOT
if [ -x /usr/bin/zypper ]
then
# SUSE / OpenSUSE
echo "The command to likely run for your operating system is: "
echo "# zypper install php8 php8-zip php8-openssl"
echo " "
elif [ -x /usr/bin/apt-get ]
then
# Debian / Ubuntu Based Systems
echo "The command to likely run for your operating system is: "
echo "# apt-get install php-cli php-xml"
echo " "
elif [ -x /usr/bin/dnf ]
then
# Modern Fedora
echo "The command to likely run for your operating system is: "
echo "# dnf install php-cli php-xml php-json"
echo " "
elif [ -x /usr/bin/yum ]
then
# Red Hat / Fedora / etc
echo "The command to likely run for your operating system is: "
echo "# yum install php-cli php-xml php-json"
echo " "
elif [ -x /usr/bin/pkg_radd ]
then
# BSD
echo "The command to likely run for your operating system is: "
echo "# pkg_radd php7 php7-json php7-zip php7-dom"
echo " "
elif [ -x /usr/bin/pacman ]
then
# Arch Linux
echo "The command to likely run for your operating system is: "
echo "# pacman -S php"
echo " "
elif [ -x /usr/local/sbin/pkg ] || [ -x /usr/sbin/pkg ]
then
# DragonFlyBSD and others
echo "The command to likely run for your operating system is: "
echo "# pkg install php82 php82-dom php82-zip php82-simplexml"
echo " "
elif [ -x /usr/bin/swupd ]
then
# Clear Linux
echo "The command to likely run for your operating system is: "
echo "# swupd bundle-add os-testsuite-phoronix"
echo " "
elif [ -x /usr/pkg/bin/pkgin ]
then
# NetBSD
echo "The command to likely run for your operating system is: "
echo "# pkgin php php-zip"
echo " "
elif [ -x /usr/sbin/pkg_add ]
then
# OpenBSD
echo "The command to likely run for your operating system is: "
echo "# pkg_add php php-zip"
echo " "
elif [ -x /usr/sbin/equo ]
then
# Sabayon
echo "The command to likely run for your operating system is: "
echo "# equo install dev-lang/php"
echo " "
elif [ -x /usr/bin/xbps-install ] || [ -x /usr/sbin/xbps-install ]
then
# Void Linux
echo "The command to likely run for your operating system is: "
echo "# xbps-install -Sy php unzip"
echo " "
elif [ -x /usr/sbin/netpkg ]
then
# Zenwalk
echo "The command to likely run for your operating system is: "
echo "# netpkg php"
echo " "
elif [ -x /usr/sbin/slackpkg ]
then
# Slackware
echo "The command to likely run for your operating system is: "
echo "# slackpkg install php"
echo " "
elif [ -x /sbin/apk ]
then
# Alpine Linux
echo "The command to likely run for your operating system is: "
echo "# apk add php7 php7-dom php7-zip php7-json php7-simplexml"
echo " "
elif [ -x /usr/bin/urpmi ]
then
# OpenMandriva Linux
echo "The command to likely run for your operating system is: "
echo "# urpmi php-cli"
echo " "
elif [ -x /usr/bin/eopkg ]
then
# Solus Linux
echo "The command to likely run for your operating system is: "
echo "# eopkg install php"
echo " "
elif [ -x /usr/sbin/mport ]
then
# MidnightBSD
echo "The command to likely run for your operating system is: "
echo "# mport install php74 php74-dom php74-zip php74-json php74-simplexml php74-openssl"
echo " "
elif [ -x /bin/opkg ]
then
# Linux Embedded Development Environment
echo "The command to likely run for your operating system is: "
echo "# opkg install php7-cli php7-mod-dom php7-mod-zip php7-mod-json php7-mod-simplexml"
echo " "
elif [ -x /usr/bin/equo ]
then
# Sabayon
echo "The command to likely run for your operating system is: "
echo "# equo install php"
echo " "
elif [ -x /usr/bin/emerge ]
then
# Gentoo
echo "The command to likely run for your operating system is: "
echo "# emerge dev-lang/php"
echo " "
elif [ -x /usr/local/bin/brew ]
then
# macOS Homebrew
echo "The command to likely run for your operating system is: "
echo "$ brew install php"
echo " "
fi
exit 1
fi
if [ ! -f pts-core/phoronix-test-suite.php ] && [ -f `dirname $0`/pts-core/phoronix-test-suite.php ]
then
cd `dirname $0`
fi
# Ensure the user is in the correct directory
if [ ! -f pts-core/phoronix-test-suite.php ]
then
cat <<'EOT'
To run the Phoronix Test Suite locally you must first change directories to phoronix-test-suite/
or install the program using the install-sh script.
For support visit:
https://www.phoronix-test-suite.com/
https://github.com/phoronix-test-suite/phoronix-test-suite
EOT
exit
fi
# Command-specific conditions
case "$1" in
"test-module" | "debug-module" | "webui")
export PTS_IGNORE_MODULES=1
;;
"debug-self-test")
export PTS_IGNORE_MODULES=1
export PTS_SILENT_MODE=1
;;
"enterprise-setup")
export PTS_SILENT_MODE=1
;;
esac
export PTS_EXT_LAUNCH_SCRIPT_DIR=`mktemp -d 2>/dev/null || mktemp -d -t ptstmp`
PTS_PREPEND_LAUNCH=""
# check for options to inhibit screensaver short of using the toggle_screensaver module's toggling
#if which kde-inhibit >/dev/null 2>&1
#then
# # https://invent.kde.org/plasma/kde-cli-tools/-/merge_requests/2
# Currently breaks input in some configurations, etc
# PTS_PREPEND_LAUNCH='kde-inhibit --power --screenSaver'
# export PTS_SCREENSAVER_PM_ALREADY_INHIBITED=1 # Setting to 1 will make toggle_screensaver PTS module disable
#elif which systemd-inhibit >/dev/null 2>&1
#then
# Disable by default again due to https://github.com/phoronix-test-suite/phoronix-test-suite/pull/491#issuecomment-762899039
# PTS_PREPEND_LAUNCH='systemd-inhibit --what=idle:sleep --who="Phoronix Test Suite" --why="Phoronix Test Suite benchmarking" '
# export PTS_SCREENSAVER_PM_ALREADY_INHIBITED=1 # Setting to 1 will make toggle_screensaver PTS module disable
#fi
# Run The Phoronix Test Suite
PTS_EXIT_STATUS=8
while [ $PTS_EXIT_STATUS -eq 8 ]; do
PTS_LAUNCH_ARGS="$@"
sh -c "$PTS_PREPEND_LAUNCH $PHP_BIN $PTS_DIR/pts-core/phoronix-test-suite.php $PTS_LAUNCH_ARGS"
PTS_EXIT_STATUS=$?
done
if [ -f $PTS_EXT_LAUNCH_SCRIPT_DIR/web-server-launcher ]
then
chmod +x $PTS_EXT_LAUNCH_SCRIPT_DIR/web-server-launcher
exec $PTS_EXT_LAUNCH_SCRIPT_DIR/web-server-launcher
rm -f $PTS_EXT_LAUNCH_SCRIPT_DIR/web-server-launcher
elif [ -f $PTS_EXT_LAUNCH_SCRIPT_DIR/phoromatic-server-launcher ]
then
chmod +x $PTS_EXT_LAUNCH_SCRIPT_DIR/phoromatic-server-launcher
exec $PTS_EXT_LAUNCH_SCRIPT_DIR/phoromatic-server-launcher
rm -f $PTS_EXT_LAUNCH_SCRIPT_DIR/phoromatic-server-launcher
fi
# rm -rf $PTS_EXT_LAUNCH_SCRIPT_DIR