Skip to content

Commit c54e2f8

Browse files
captain5050namhyung
authored andcommitted
perf tests record: Add basic uid filtering test
Based on the system-wide test with changes around how failure is handled as BPF permissions are a bigger issue than perf event paranoia. Signed-off-by: Ian Rogers <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent 1151208 commit c54e2f8

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tools/perf/tests/shell/record.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,31 @@ test_cgroup() {
231231
echo "Cgroup sampling test [Success]"
232232
}
233233

234+
test_uid() {
235+
echo "Uid sampling test"
236+
if ! perf record -aB --synth=no --uid "$(id -u)" -o "${perfdata}" ${testprog} \
237+
> "${script_output}" 2>&1
238+
then
239+
if grep -q "libbpf.*EPERM" "${script_output}"
240+
then
241+
echo "Uid sampling [Skipped permissions]"
242+
return
243+
else
244+
echo "Uid sampling [Failed to record]"
245+
err=1
246+
# cat "${script_output}"
247+
return
248+
fi
249+
fi
250+
if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
251+
then
252+
echo "Uid sampling [Failed missing output]"
253+
err=1
254+
return
255+
fi
256+
echo "Uid sampling test [Success]"
257+
}
258+
234259
test_leader_sampling() {
235260
echo "Basic leader sampling test"
236261
if ! perf record -o "${perfdata}" -e "{cycles,cycles}:Su" -- \
@@ -345,6 +370,7 @@ test_system_wide
345370
test_workload
346371
test_branch_counter
347372
test_cgroup
373+
test_uid
348374
test_leader_sampling
349375
test_topdown_leader_sampling
350376
test_precise_max

0 commit comments

Comments
 (0)