Skip to content

Commit 31c989a

Browse files
committed
couple of fixes to prof-accept to automate profiling with valgrind from make target
1 parent fd55666 commit 31c989a

3 files changed

Lines changed: 24 additions & 8 deletions

File tree

src/tests/multi-server/scripts/profiling/start_valgrind_profiling.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
# To be run inside the profiling container
44

5+
# Clear any stale marker from a previous run
6+
rm -f /etc/prof-results/.profiling_complete
7+
58
# Load proto_load config to get packet settings
69
source /etc/freeradius/proto_load_config.env
710

@@ -30,14 +33,20 @@ until grep -q "Ready to process requests" /tmp/fr.log; do
3033
sleep 0.1
3134
done
3235

33-
FR_PID=$(pgrep -f "freeradius -f")
34-
35-
# Enable instrumentation at packet processing start
36-
callgrind_control --instr=on ${FR_PID}
36+
# Enable instrumentation. callgrind_control auto-detects the running callgrind
37+
# instance and prints "PID <n>: freeradius ..." — capture that to get the PID
38+
# we need later for the graceful shutdown signal.
39+
CTRL_OUT=$(callgrind_control --instr=on)
40+
printf '%s\n' "$CTRL_OUT"
41+
FR_PID=$(printf '%s\n' "$CTRL_OUT" | grep -oP 'PID \K\d+(?=: freeradius)' | head -1)
42+
echo "Freeradius PID: ${FR_PID}"
3743

3844
# Wait for approximate send duration
3945
sleep ${SEND_DURATION}
4046

4147
# Graceful shutdown (equivalent to Ctrl+C)
4248
kill -SIGINT ${FR_PID}
4349
wait
50+
51+
# Signal that valgrind has finished writing all profiling data
52+
touch /etc/prof-results/.profiling_complete

src/tests/multi-server/tests/prof-accept/short.ci.test.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ loadgen:
1313
repeat: "no"
1414

1515
# Test framework
16-
test_timeout: 80
17-
test_verify_timeout: 70
16+
test_timeout: 165
17+
test_state1_verify_timeout: 130
18+
test_state2_verify_timeout: 5

src/tests/multi-server/tests/prof-accept/template.yml.j2

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,14 @@ states:
4848
source /etc/freeradius/start_valgrind_profiling.sh
4949

5050
detach: true
51+
- execute_command:
52+
command: |
53+
# Block until valgrind finishes writing all profiling data.
54+
# start_valgrind_profiling.sh touches this file after `wait` returns.
55+
until [ -f /etc/prof-results/.profiling_complete ]; do sleep 5; done
56+
rm -f /etc/prof-results/.profiling_complete
5157
verify:
52-
timeout: {{ test_verify_timeout }}
58+
timeout: {{ test_state1_verify_timeout }}
5359
trigger_mode: unordered
5460
state_2:
5561
description: >
@@ -63,5 +69,5 @@ states:
6369
#cd /etc/prof-results
6470
#callgrind_annotate $(find . -name "callgrind.out.*" -size +0c | sort) > callgrind_report.txt
6571
verify:
66-
timeout: 5
72+
timeout: {{ test_state2_verify_timeout }}
6773
trigger_mode: unordered

0 commit comments

Comments
 (0)