Skip to content

Commit db7b260

Browse files
committed
Tests: Swap usages of pidof for pgrep --full
Some implementations of pidof (such as the one from procps-ng) seem immune to changing a process' name using prctl() and overwriting argv[0]. Using preg --full works around this problem. In time, we should ensure every deamon publishes a PID file which can be reliably used by the tests. Signed-off-by: Jérémie Galarneau <[email protected]>
1 parent 91d98ef commit db7b260

4 files changed

+19
-19
lines changed

tests/stress/test_multi_sessions_per_uid_10app

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function enable_channel_per_uid()
4343

4444
function check_sessiond()
4545
{
46-
if [ -z "$(pidof lt-lttng-sessiond)" ]; then
46+
if [ -z "$(pgrep --full lt-lttng-sessiond)" ]; then
4747
local str_date=$(date +%H%M%S-%d%m%Y)
4848

4949
diag "!!!The session daemon died unexpectedly!!!"
@@ -65,7 +65,7 @@ function start_sessiond()
6565
BAIL_OUT "*** Kernel too old for session daemon tests ***"
6666
fi
6767

68-
if [ -z $(pidof lt-$SESSIOND_BIN) ]; then
68+
if [ -z $(pgrep --full lt-$SESSIOND_BIN) ]; then
6969
# We have to start it like this so the ulimit -c is used by this
7070
# process. Also, we collect any error message printed out.
7171
$TESTDIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --quiet --background --consumerd32-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" >$LOG_FILE 2>&1

tests/stress/test_multi_sessions_per_uid_5app_streaming

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function lttng_create_session_uri
5151

5252
function check_sessiond()
5353
{
54-
if [ -z "$(pidof lt-lttng-sessiond)" ]; then
54+
if [ -z "$(pgrep --full lt-lttng-sessiond)" ]; then
5555
local str_date=$(date +%H%M%S-%d%m%Y)
5656

5757
diag "!!!The session daemon died unexpectedly!!!"
@@ -65,7 +65,7 @@ function check_sessiond()
6565

6666
function check_relayd()
6767
{
68-
if [ -z "$(pidof lt-lttng-relayd)" ]; then
68+
if [ -z "$(pgrep --full lt-lttng-relayd)" ]; then
6969
local str_date=$(date +%H%M%S-%d%m%Y)
7070

7171
diag "!!!The relay daemon died unexpectedly!!!"
@@ -87,7 +87,7 @@ function start_sessiond()
8787
BAIL_OUT "*** Kernel too old for session daemon tests ***"
8888
fi
8989

90-
if [ -z $(pidof lt-$SESSIOND_BIN) ]; then
90+
if [ -z $(pgrep --full lt-$SESSIOND_BIN) ]; then
9191
# We have to start it like this so the ulimit -c is used by this
9292
# process. Also, we collect any error message printed out.
9393
$TESTDIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --quiet --background --consumerd32-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" >$LOG_FILE_SESSIOND 2>&1
@@ -101,7 +101,7 @@ function start_relayd
101101
local opt=$1
102102
local RELAYD_BIN="lttng-relayd"
103103

104-
if [ -z $(pidof lt-$RELAYD_BIN) ]; then
104+
if [ -z $(pgrep --full lt-$RELAYD_BIN) ]; then
105105
$TESTDIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >$LOG_FILE_RELAYD 2>&1 &
106106
ok $? "Start lttng-relayd (opt: \"$opt\")"
107107
fi

tests/stress/test_multi_sessions_per_uid_5app_streaming_kill_relayd

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function lttng_create_session_uri
5252

5353
function check_sessiond()
5454
{
55-
if [ -z "$(pidof lt-lttng-sessiond)" ]; then
55+
if [ -z "$(pgrep --full lt-lttng-sessiond)" ]; then
5656
local str_date=$(date +%H%M%S-%d%m%Y)
5757

5858
diag "!!!The session daemon died unexpectedly!!!"
@@ -74,7 +74,7 @@ function start_sessiond()
7474
BAIL_OUT "*** Kernel too old for session daemon tests ***"
7575
fi
7676

77-
if [ -z $(pidof lt-$SESSIOND_BIN) ]; then
77+
if [ -z $(pgrep --full lt-$SESSIOND_BIN) ]; then
7878
# We have to start it like this so the ulimit -c is used by this
7979
# process. Also, we collect any error message printed out.
8080
#$TESTDIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --quiet --background --consumerd32-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" >$LOG_FILE_SESSIOND 2>&1
@@ -90,15 +90,15 @@ function start_relayd
9090
local opt=$1
9191
local RELAYD_BIN="lttng-relayd"
9292

93-
if [ -z $(pidof lt-$RELAYD_BIN) ]; then
93+
if [ -z $(pgrep --full lt-$RELAYD_BIN) ]; then
9494
$TESTDIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >$LOG_FILE_RELAYD 2>&1 &
9595
ok $? "Start lttng-relayd (opt: \"$opt\")"
9696
fi
9797
}
9898

9999
function check_relayd()
100100
{
101-
if [ -z "$(pidof lt-lttng-relayd)" ]; then
101+
if [ -z "$(pgrep --full lt-lttng-relayd)" ]; then
102102
local str_date=$(date +%H%M%S-%d%m%Y)
103103

104104
#diag "Relay daemon died. Starting it again"

tests/utils/utils.sh

+9-9
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ function start_lttng_relayd_opt()
269269

270270
DIR=$(readlink -f $TESTDIR)
271271

272-
if [ -z $(pidof lt-$RELAYD_BIN) ]; then
272+
if [ -z $(pgrep --full lt-$RELAYD_BIN) ]; then
273273
$DIR/../src/bin/lttng-relayd/$RELAYD_BIN -b $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
274274
#$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
275275
if [ $? -eq 1 ]; then
@@ -301,7 +301,7 @@ function stop_lttng_relayd_opt()
301301
{
302302
local withtap=$1
303303

304-
PID_RELAYD=`pidof lt-$RELAYD_BIN`
304+
PID_RELAYD=`pgrep --full lt-$RELAYD_BIN`
305305

306306
if [ $withtap -eq "1" ]; then
307307
diag "Killing lttng-relayd (pid: $PID_RELAYD)"
@@ -317,7 +317,7 @@ function stop_lttng_relayd_opt()
317317
else
318318
out=1
319319
while [ -n "$out" ]; do
320-
out=$(pidof lt-$RELAYD_BIN)
320+
out=$(pgrep --full lt-$RELAYD_BIN)
321321
sleep 0.5
322322
done
323323
if [ $withtap -eq "1" ]; then
@@ -359,7 +359,7 @@ function start_lttng_sessiond_opt()
359359
: ${LTTNG_SESSION_CONFIG_XSD_PATH=${DIR}/../src/common/config/}
360360
export LTTNG_SESSION_CONFIG_XSD_PATH
361361

362-
if [ -z $(pidof lt-$SESSIOND_BIN) ]; then
362+
if [ -z $(pgrep --full lt-$SESSIOND_BIN) ]; then
363363
# Have a load path ?
364364
if [ -n "$load_path" ]; then
365365
$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --load "$1" --background --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
@@ -395,7 +395,7 @@ function stop_lttng_sessiond_opt()
395395
return
396396
fi
397397

398-
PID_SESSIOND=`pidof lt-$SESSIOND_BIN`
398+
PID_SESSIOND=`pgrep --full lt-$SESSIOND_BIN`
399399

400400
if [ -n "$2" ]; then
401401
kill_opt="$kill_opt -s $signal"
@@ -410,12 +410,12 @@ function stop_lttng_sessiond_opt()
410410
else
411411
out=1
412412
while [ -n "$out" ]; do
413-
out=$(pidof lt-$SESSIOND_BIN)
413+
out=$(pgrep --full lt-$SESSIOND_BIN)
414414
sleep 0.5
415415
done
416416
out=1
417417
while [ -n "$out" ]; do
418-
out=$(pidof $CONSUMERD_BIN)
418+
out=$(pgrep --full $CONSUMERD_BIN)
419419
sleep 0.5
420420
done
421421
if [ $withtap -eq "1" ]; then
@@ -440,7 +440,7 @@ function stop_lttng_consumerd_opt()
440440
local signal=$2
441441
local kill_opt=""
442442

443-
PID_CONSUMERD=`pidof $CONSUMERD_BIN`
443+
PID_CONSUMERD=`pgrep --full $CONSUMERD_BIN`
444444

445445
if [ -n "$2" ]; then
446446
kill_opt="$kill_opt -s $signal"
@@ -461,7 +461,7 @@ function stop_lttng_consumerd_opt()
461461
else
462462
out=1
463463
while [ $out -ne 0 ]; do
464-
pid=$(pidof $CONSUMERD_BIN)
464+
pid=$(pgrep --full $CONSUMERD_BIN)
465465

466466
# If consumerds are still present check their status.
467467
# A zombie status qualifies the consumerd as *killed*

0 commit comments

Comments
 (0)