xref: /linux/tools/perf/tests/shell/record.sh (revision f6d181fde135e5757c5c94409f510cf42874308b)
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3# perf record tests
4
5set -e
6
7shelldir=$(dirname "$0")
8. "${shelldir}"/lib/perf_record.sh
9
10
11. "${shelldir}"/lib/waiting.sh
12
13. "${shelldir}"/lib/perf_has_symbol.sh
14
15testsym="test_loop"
16testsym2="brstack"
17
18skip_test_missing_symbol ${testsym}
19skip_test_missing_symbol ${testsym2}
20
21err=0
22perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
23script_output=$(mktemp /tmp/__perf_test.perf.data.XXXXX.script)
24testprog="perf test -w thloop"
25cpu_pmu_dir="/sys/bus/event_source/devices/cpu*"
26br_cntr_file="/caps/branch_counter_nr"
27br_cntr_output="branch stack counters"
28br_cntr_script_output="br_cntr: A"
29
30default_fd_limit=$(ulimit -Sn)
31# With option --threads=cpu the number of open file descriptors should be
32# equal to sum of:    nmb_cpus * nmb_events (2+dummy),
33#                     nmb_threads for perf.data.n (equal to nmb_cpus) and
34#                     2*nmb_cpus of pipes = 4*nmb_cpus (each pipe has 2 ends)
35# All together it needs 8*nmb_cpus file descriptors plus some are also used
36# outside of testing, thus raising the limit to 16*nmb_cpus
37min_fd_limit=$(($(getconf _NPROCESSORS_ONLN) * 16))
38
39cleanup() {
40  rm -rf "${perfdata}"
41  rm -rf "${perfdata}".old
42  rm -f "${script_output}"
43  perf_record_cleanup
44
45  trap - EXIT TERM INT
46}
47
48trap_cleanup() {
49  echo "Unexpected signal in ${FUNCNAME[1]}"
50  cleanup
51  exit 1
52}
53trap trap_cleanup EXIT TERM INT
54
55check_per_thread() {
56  perf report -i "${perfdata}" -q | grep -q "${testsym}"
57}
58
59test_per_thread() {
60  echo "Basic --per-thread mode test"
61  local ret=0
62  perf_record_with_retry "${perfdata}" "check_per_thread" "perf test -w thloop" \
63    --per-thread || ret=$?
64  if [ $ret -eq 2 ]; then
65    echo "Per-thread record [Skipped event not supported]"
66    return
67  elif [ $ret -eq 1 ]; then
68    echo "Per-thread record [Failed record or missing output]"
69    err=1
70    return
71  fi
72
73  # run the test program in background (for 30 seconds)
74  ${testprog} 30 &
75  TESTPID=$!
76
77  rm -f "${perfdata}"
78
79  wait_for_threads ${TESTPID} 2
80  perf record -p "${TESTPID}" --per-thread -o "${perfdata}" sleep 1 2> /dev/null
81  kill ${TESTPID}
82
83  if [ ! -e "${perfdata}" ]
84  then
85    echo "Per-thread record [Failed record -p]"
86    err=1
87    return
88  fi
89  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
90  then
91    echo "Per-thread record [Failed -p missing output]"
92    err=1
93    return
94  fi
95
96  echo "Basic --per-thread mode test [Success]"
97}
98
99check_register_capture() {
100  perf script -F ip,sym,iregs -i "${perfdata}" 2>/dev/null | grep -q "DI:"
101}
102
103test_register_capture() {
104  echo "Register capture test"
105  if ! perf list pmu | grep -q 'br_inst_retired.near_call'
106  then
107    echo "Register capture test [Skipped missing event]"
108    return
109  fi
110  if ! perf record --intr-regs=\? 2>&1 | grep -q 'available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15'
111  then
112    echo "Register capture test [Skipped missing registers]"
113    return
114  fi
115
116  local ret=0
117  perf_record_with_retry "${perfdata}" "check_register_capture" "perf test -w thloop" \
118    --intr-regs=di,r8,dx,cx -e br_inst_retired.near_call -c 1000 --per-thread || ret=$?
119
120  if [ $ret -ne 0 ]; then
121    echo "Register capture test [Failed missing output]"
122    err=1
123    return
124  fi
125  echo "Register capture test [Success]"
126}
127
128check_system_wide() {
129  perf report -i "${perfdata}" -q | grep -q "${testsym}"
130}
131
132check_ext_reg_capture() {
133  local script_field="$1"
134  local ext_reg="$2"
135
136  perf script -F ip,sym,"${script_field}" -i "${perfdata}" 2>/dev/null | \
137  grep -q -i "${ext_reg}:"
138}
139
140get_x86_extended_regs() {
141  local advertised_ext_regs="$1"
142  local ext_regs=""
143
144  if echo "${advertised_ext_regs}" | grep -q -i R16
145  then
146    ext_regs="${ext_regs} R16"
147  fi
148  if echo "${advertised_ext_regs}" | grep -q -i R31
149  then
150    ext_regs="${ext_regs} R31"
151  fi
152  if echo "${advertised_ext_regs}" | grep -q -i SSP
153  then
154    ext_regs="${ext_regs} SSP"
155  fi
156
157  echo "${ext_regs}" | xargs
158}
159
160validate_extd_regs_sampling() {
161  local regs_opt="$1"
162  local extd_regs="$2"
163  local script_field="$3"
164  local ret=0
165  local reg
166
167  for reg in ${extd_regs}
168  do
169    perf_record_with_retry "${perfdata}" \
170      "check_ext_reg_capture ${script_field} ${reg}" "perf test -w thloop" \
171      -e br_inst_retired.near_call ${regs_opt}=${reg} -c 1000 \
172      --per-thread || ret=$?
173
174    if [ $ret -ne 0 ]
175    then
176      echo "Extended register capture test [Failed record ${regs_opt}=${reg}]"
177      return 1
178    fi
179  done
180
181  return 0
182}
183
184test_extd_register_capture() {
185  local arch
186  local intr_regs
187  local user_regs
188  local intr_ext_regs
189  local user_ext_regs
190  local tested=0
191
192  echo "Extended register capture test"
193  if ! perf list pmu | grep -q 'br_inst_retired.near_call'
194  then
195    echo "Extended register capture test [Skipped missing event]"
196    return
197  fi
198
199  intr_regs=$(perf record --intr-regs=\? 2>&1 || true)
200  user_regs=$(perf record --user-regs=\? 2>&1 || true)
201
202  intr_ext_regs=""
203  user_ext_regs=""
204
205  arch=$(uname -m)
206  case ${arch} in
207  x86_64|i386)
208    intr_ext_regs=$(get_x86_extended_regs "${intr_regs}")
209    user_ext_regs=$(get_x86_extended_regs "${user_regs}")
210    ;;
211  *)
212    echo "Extended register capture test [Skipped non-x86 platform]"
213    return
214    ;;
215  esac
216
217  if [ -z "${intr_ext_regs}" ]
218  then
219    echo "Extended register capture test [Skipped missing intr extended registers]"
220  elif ! validate_extd_regs_sampling "--intr-regs" "${intr_ext_regs}" "iregs"
221  then
222    echo "Extended register capture test [Failed intr extended register sampling]"
223    err=1
224    return
225  else
226    tested=1
227  fi
228
229  if [ -z "${user_ext_regs}" ]
230  then
231    echo "Extended register capture test [Skipped missing user extended registers]"
232  elif ! validate_extd_regs_sampling "--user-regs" "${user_ext_regs}" "uregs"
233  then
234    echo "Extended register capture test [Failed user extended register sampling]"
235    err=1
236    return
237  else
238    tested=1
239  fi
240
241  if [ ${tested} -eq 0 ]
242  then
243    echo "Extended register capture test [Skipped missing extended registers]"
244    return
245  fi
246
247  echo "Extended register capture test [Success]"
248}
249
250extract_x86_advertised_simd_classes() {
251  local regs_output="$1"
252
253  echo "${regs_output}" \
254    | grep -oE '(ZMM|YMM|XMM|OPMASK)[0-9]+-[0-9]+' \
255    | sed -E 's/[0-9]+-[0-9]+$//' \
256    | tr '[:upper:]' '[:lower:]' \
257    | sort -u
258}
259
260ordered_x86_simd_classes() {
261  local advertised_classes="$1"
262  local simd_classes=""
263
264  if echo "${advertised_classes}" | grep -qw zmm
265  then
266    simd_classes="${simd_classes} zmm"
267  fi
268  if echo "${advertised_classes}" | grep -qw ymm
269  then
270    simd_classes="${simd_classes} ymm"
271  fi
272  if echo "${advertised_classes}" | grep -qw xmm
273  then
274    simd_classes="${simd_classes} xmm"
275  fi
276  if echo "${advertised_classes}" | grep -qw opmask
277  then
278    simd_classes="${simd_classes} opmask"
279  fi
280
281  echo "${simd_classes}" | xargs
282}
283
284check_simd_reg_capture() {
285  local script_field="$1"
286  local simd_reg="$2"
287
288  perf script -F ip,sym,"${script_field}" -i "${perfdata}" 2>/dev/null | \
289  grep -q -i "${simd_reg}\["
290}
291
292validate_simd_regs_sampling() {
293  local regs_opt="$1"
294  local simd_classes="$2"
295  local script_field="$3"
296  local simd_class
297  local ret=0
298
299  for simd_class in ${simd_classes}
300  do
301    perf_record_with_retry "${perfdata}" \
302      "check_simd_reg_capture ${script_field} ${simd_class}" "perf test -w thloop" \
303      -e br_inst_retired.near_call ${regs_opt}=${simd_class} -c 1000 \
304      --per-thread || ret=$?
305
306    if [ $ret -ne 0 ]
307    then
308      echo "SIMD register capture test [Failed record ${regs_opt}=${simd_class}]"
309      return 1
310    fi
311  done
312
313  return 0
314}
315
316test_simd_register_capture() {
317  local arch
318  local intr_regs
319  local user_regs
320  local simd_classes
321  local user_simd_classes
322  local advertised_intr_classes
323  local advertised_user_classes
324  local tested=0
325
326  echo "SIMD register capture test"
327  if ! perf list pmu | grep -q 'br_inst_retired.near_call'
328  then
329    echo "SIMD register capture test [Skipped missing event]"
330    return
331  fi
332
333  intr_regs=$(perf record --intr-regs=\? 2>&1 || true)
334  user_regs=$(perf record --user-regs=\? 2>&1 || true)
335
336  simd_classes=""
337  user_simd_classes=""
338
339  arch=$(uname -m)
340  case ${arch} in
341  x86_64|i386)
342    advertised_intr_classes=$(extract_x86_advertised_simd_classes "${intr_regs}")
343    advertised_user_classes=$(extract_x86_advertised_simd_classes "${user_regs}")
344
345    simd_classes=$(ordered_x86_simd_classes "${advertised_intr_classes}")
346    user_simd_classes=$(ordered_x86_simd_classes "${advertised_user_classes}")
347    ;;
348  *)
349    echo "SIMD register capture test [Skipped non-x86 platform]"
350    return
351    ;;
352  esac
353
354  if [ -z "${simd_classes}" ]
355  then
356    echo "SIMD register capture test [Skipped missing intr SIMD registers]"
357  elif ! validate_simd_regs_sampling "--intr-regs" "${simd_classes}" "iregs"
358  then
359    echo "SIMD register capture test [Failed intr SIMD register sampling]"
360    err=1
361    return
362  else
363    tested=1
364  fi
365
366  if [ -z "${user_simd_classes}" ]
367  then
368    echo "SIMD register capture test [Skipped missing user SIMD registers]"
369  elif ! validate_simd_regs_sampling "--user-regs" "${user_simd_classes}" "uregs"
370  then
371    echo "SIMD register capture test [Failed user SIMD register sampling]"
372    err=1
373    return
374  else
375    tested=1
376  fi
377
378  if [ ${tested} -eq 0 ]
379  then
380    echo "SIMD register capture test [Skipped missing SIMD registers]"
381    return
382  fi
383
384  echo "SIMD register capture test [Success]"
385}
386
387test_system_wide() {
388  echo "Basic --system-wide mode test"
389  local ret=0
390  perf_record_with_retry "${perfdata}" "check_system_wide" "perf test -w thloop" \
391    -aB --synth=no -e cpu-clock || ret=$?
392  if [ $ret -eq 2 ]; then
393    echo "System-wide record [Skipped not supported]"
394    return
395  elif [ $ret -eq 1 ]; then
396    echo "System-wide record [Failed missing output]"
397    err=1
398    return
399  fi
400
401  ret=0
402  perf_record_with_retry "${perfdata}" "check_system_wide" "perf test -w thloop" \
403    -aB --synth=no -e cpu-clock,cs --threads=cpu || ret=$?
404  if [ $ret -ne 0 ]; then
405    echo "System-wide record [Failed record --threads option or missing output]"
406    err=1
407    return
408  fi
409  echo "Basic --system-wide mode test [Success]"
410}
411
412check_workload() {
413  perf report -i "${perfdata}" -q | grep -q "${testsym}"
414}
415
416test_workload() {
417  echo "Basic target workload test"
418  local ret=0
419  perf_record_with_retry "${perfdata}" "check_workload" "perf test -w thloop" || ret=$?
420  if [ $ret -ne 0 ]; then
421    echo "Workload record [Failed record or missing output]"
422    err=1
423    return
424  fi
425
426  ret=0
427  perf_record_with_retry "${perfdata}" "check_workload" "perf test -w thloop" \
428    -e cpu-clock,cs --threads=package || ret=$?
429  if [ $ret -ne 0 ]; then
430    echo "Workload record [Failed record --threads option or missing output]"
431    err=1
432    return
433  fi
434  echo "Basic target workload test [Success]"
435}
436
437check_branch_counter() {
438  perf report -i "${perfdata}" -D -q 2>/dev/null | grep -q "$br_cntr_output" && \
439  perf script -i "${perfdata}" -F +brstackinsn,+brcntr 2>/dev/null | \
440    grep -q "$br_cntr_script_output"
441}
442
443test_branch_counter() {
444  echo "Branch counter test"
445  # Check if the branch counter feature is supported
446  for dir in $cpu_pmu_dir
447  do
448    if [ ! -e "$dir$br_cntr_file" ]
449    then
450      echo "branch counter feature not supported on all core PMUs ($dir) [Skipped]"
451      return
452    fi
453  done
454  local ret=0
455  perf_record_with_retry "${perfdata}" "check_branch_counter" "perf test -w thloop" \
456    -e "{branches:p,instructions}" -j any,counter || ret=$?
457  if [ $ret -ne 0 ]; then
458    echo "Branch counter test [Failed record or missing output]"
459    err=1
460    return
461  fi
462  echo "Branch counter test [Success]"
463}
464
465check_cgroup() {
466  perf report -i "${perfdata}" -D 2>/dev/null | grep -q "CGROUP" && \
467  perf script -i "${perfdata}" -F cgroup 2>/dev/null | grep -q -v "unknown"
468}
469
470test_cgroup() {
471  echo "Cgroup sampling test"
472  local ret=0
473  perf_record_with_retry "${perfdata}" "check_cgroup" "perf test -w thloop" \
474    -aB --synth=cgroup --all-cgroups -e cpu-clock || ret=$?
475  if [ $ret -eq 2 ]; then
476    echo "Cgroup sampling [Skipped not supported]"
477    return
478  elif [ $ret -eq 1 ]; then
479    echo "Cgroup sampling [Failed missing output]"
480    err=1
481    return
482  fi
483  echo "Cgroup sampling test [Success]"
484}
485
486check_uid() {
487  perf report -i "${perfdata}" -q | grep -q "${testsym}"
488}
489
490test_uid() {
491  echo "Uid sampling test"
492  local ret=0
493  perf_record_with_retry "${perfdata}" "check_uid" "perf test -w thloop" \
494    -aB --synth=no --uid "$(id -u)" -e cpu-clock || ret=$?
495  if [ $ret -eq 2 ]; then
496    local logfile="${PERF_RECORD_LOGS[${#PERF_RECORD_LOGS[@]}-1]}"
497    if grep -q -E "libbpf.*EPERM|Access to performance monitoring" "$logfile" || \
498       grep -q -E "Permission denied|Failure to open any events" "$logfile"
499    then
500      echo "Uid sampling [Skipped permissions]"
501      return
502    else
503      echo "Uid sampling [Failed to record]"
504      err=1
505      return
506    fi
507  elif [ $ret -eq 1 ]; then
508    echo "Uid sampling [Failed missing output]"
509    err=1
510    return
511  fi
512  echo "Uid sampling test [Success]"
513}
514
515test_leader_sampling() {
516  echo "Basic leader sampling test"
517  events="{cycles,cycles}:Su"
518  [ "$(uname -m)" = "s390x" ] && {
519    [ ! -d /sys/devices/cpum_sf ] && {
520      echo "No CPUMF [Skipped record]"
521      return
522    }
523    events="{cpum_sf/SF_CYCLES_BASIC/,cycles}:Su"
524    perf record -o "${perfdata}" -e "$events" -- perf test -w brstack 2> /dev/null
525    # Perf grouping might be unsupported, depends on version.
526    [ "$?" -ne 0 ] && {
527      echo "Grouping not support [Skipped record]"
528      return
529    }
530  }
531  if ! perf record -o "${perfdata}" -e "$events" -- \
532    perf test -w brstack 2> /dev/null
533  then
534    echo "Leader sampling [Failed record]"
535    err=1
536    return
537  fi
538  perf script -i "${perfdata}" -F period,ip,sym | grep brstack > $script_output
539  # Check if the two instruction counts are equal in each record.
540  # However, the throttling code doesn't consider event grouping. During throttling, only the
541  # leader is stopped, causing the slave's counts significantly higher. To temporarily solve this,
542  # let's set the tolerance rate to 80%.
543  # TODO: Revert the code for tolerance once the throttling mechanism is fixed.
544  index=0
545  valid_counts=0
546  invalid_counts=0
547  tolerance_rate=0.8
548  while IFS= read -r line
549  do
550    cycles=$(echo $line | awk '{ print $1 }')
551    if [ $(($index%2)) -ne 0 ]
552    then
553      if (( $(bc <<< "scale=4; r = ${cycles} / ${prev_cycles}; r >= 0.99 && r <= 1.01") ))
554      then
555        valid_counts=$(($valid_counts+1))
556      else
557        invalid_counts=$(($invalid_counts+1))
558      fi
559    fi
560    index=$(($index+1))
561    prev_cycles=$cycles
562  done < "${script_output}"
563  total_counts=$(bc <<< "$invalid_counts+$valid_counts")
564  if (( $(bc <<< "$total_counts <= 0") ))
565  then
566    echo "Leader sampling [No sample generated]"
567    err=1
568    return
569  fi
570  isok=$(bc <<< "scale=2; if (($invalid_counts/$total_counts) < (1-$tolerance_rate)) { 0 } else { 1 };")
571  if [ $isok -eq 1 ]
572  then
573     echo "Leader sampling [Failed inconsistent cycles count]"
574     err=1
575  else
576    echo "Basic leader sampling test [Success]"
577  fi
578}
579
580test_topdown_leader_sampling() {
581  echo "Topdown leader sampling test"
582  if ! perf stat -e "{slots,topdown-retiring}" true 2> /dev/null
583  then
584    echo "Topdown leader sampling [Skipped event parsing failed]"
585    return
586  fi
587  if ! perf record -o "${perfdata}" -e "{instructions,slots,topdown-retiring}:S" true 2> /dev/null
588  then
589    echo "Topdown leader sampling [Failed topdown events not reordered correctly]"
590    err=1
591    return
592  fi
593  echo "Topdown leader sampling test [Success]"
594}
595
596test_precise_max() {
597  local -i skipped=0
598
599  echo "precise_max attribute test"
600  # Just to make sure event cycles is supported for sampling
601  if perf record -o "${perfdata}" -e "cycles" true 2> /dev/null
602  then
603    if ! perf record -o "${perfdata}" -e "cycles:P" true 2> /dev/null
604    then
605      echo "precise_max attribute [Failed cycles:P event]"
606      err=1
607      return
608    fi
609  else
610    echo "precise_max attribute [Skipped no cycles:P event]"
611    ((skipped+=1))
612  fi
613  # On s390 event instructions is not supported for perf record
614  if perf record -o "${perfdata}" -e "instructions" true 2> /dev/null
615  then
616    # On AMD, cycles and instructions events are treated differently
617    if ! perf record -o "${perfdata}" -e "instructions:P" true 2> /dev/null
618    then
619      echo "precise_max attribute [Failed instructions:P event]"
620      err=1
621      return
622    fi
623  else
624    echo "precise_max attribute [Skipped no instructions:P event]"
625    ((skipped+=1))
626  fi
627  if [ $skipped -eq 2 ]
628  then
629    echo "precise_max attribute [Skipped no hardware events]"
630  else
631    echo "precise_max attribute test [Success]"
632  fi
633}
634
635test_callgraph() {
636  echo "Callgraph test"
637
638  case $(uname -m)
639  in s390x)
640       cmd_flags="--call-graph dwarf -e cpu-clock";;
641     *)
642       cmd_flags="-g";;
643  esac
644
645  if ! perf record -o "${perfdata}" $cmd_flags perf test -w brstack
646  then
647    echo "Callgraph test [Failed missing output]"
648    err=1
649    return
650  fi
651
652  if ! perf report -i "${perfdata}" 2>&1 | grep "${testsym2}"
653  then
654    echo "Callgraph test [Failed missing symbol]"
655    err=1
656    return
657  fi
658
659  echo "Callgraph test [Success]"
660}
661
662test_acr_sampling() {
663  events="{instructions/period=40000,acr_mask=0x2/u,cycles/period=20000,acr_mask=0x3/u}"
664  pebs_events="{instructions/period=40000,acr_mask=0x2/pu,cycles/period=20000,acr_mask=0x3/u}"
665  echo "Auto counter reload (ACR) sampling test"
666  if ! perf record -o "${perfdata}" -e "${events}" ${testprog} 2> /dev/null
667  then
668    echo "Auto counter reload sampling [Skipped not supported]"
669    return
670  fi
671  if ! perf script -i "${perfdata}" -F event | grep -q "instructions"
672  then
673    echo "Auto counter reload sampling [Failed missing instructions event]"
674    err=1
675    return
676  fi
677  if perf script -i "${perfdata}" -F event | grep -q "cycles"
678  then
679    echo "Auto counter reload sampling [Failed cycles event shouldn't be sampled]"
680    err=1
681    return
682  fi
683  if ! perf record -o "${perfdata}" -e "${pebs_events}" ${testprog} 2> /dev/null
684  then
685    echo "Auto counter reload PEBS sampling [Skipped not supported]"
686    echo "Auto counter reload sampling [Success]"
687    return
688  fi
689  if ! perf script -i "${perfdata}" -F event | grep -q "instructions"
690  then
691    echo "Auto counter reload PEBS sampling [Failed missing instructions event]"
692    err=1
693    return
694  fi
695  if perf script -i "${perfdata}" -F event | grep -q "cycles"
696  then
697    echo "Auto counter reload PEBS sampling [Failed cycles event shouldn't be sampled]"
698    err=1
699    return
700  fi
701  echo "Auto counter reload sampling [Success]"
702}
703
704test_ratio_to_prev() {
705  echo "ratio-to-prev test"
706  if ! perf record -o /dev/null -e "{instructions, cycles/period=100000,ratio-to-prev=0.5/}" \
707     true 2> /dev/null
708  then
709    echo "ratio-to-prev [Skipped not supported]"
710    return
711  fi
712  if ! perf record -o /dev/null -e "instructions, cycles/period=100000,ratio-to-prev=0.5/" \
713     true |& grep -q 'Invalid use of ratio-to-prev term without preceding element in group'
714  then
715    echo "ratio-to-prev test [Failed elements must be in same group]"
716    err=1
717    return
718  fi
719  if ! perf record -o /dev/null -e "{instructions,dummy,cycles/period=100000,ratio-to-prev=0.5/}" \
720     true |& grep -q 'must have same PMU'
721  then
722    echo "ratio-to-prev test [Failed elements must have same PMU]"
723    err=1
724    return
725  fi
726  if ! perf record -o /dev/null -e "{instructions,cycles/ratio-to-prev=0.5/}" \
727     true |& grep -q 'Event period term or count (-c) must be set when using ratio-to-prev term.'
728  then
729    echo "ratio-to-prev test [Failed period must be set]"
730    err=1
731    return
732  fi
733  if ! perf record -o /dev/null -e "{cycles/ratio-to-prev=0.5/}" \
734     true |& grep -q 'Invalid use of ratio-to-prev term without preceding element in group'
735  then
736    echo "ratio-to-prev test [Failed need 2+ events]"
737    err=1
738    return
739  fi
740  echo "Basic ratio-to-prev record test [Success]"
741}
742
743# raise the limit of file descriptors to minimum
744if [[ $default_fd_limit -lt $min_fd_limit ]]; then
745       ulimit -Sn $min_fd_limit
746fi
747
748test_per_thread
749test_register_capture
750test_extd_register_capture
751test_simd_register_capture
752test_system_wide
753test_workload
754test_branch_counter
755test_cgroup
756test_uid
757test_leader_sampling
758test_topdown_leader_sampling
759test_precise_max
760test_callgraph
761test_acr_sampling
762test_ratio_to_prev
763
764# restore the default value
765ulimit -Sn $default_fd_limit
766
767cleanup
768exit $err
769