test_intel_pt.sh 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. #!/bin/sh
  2. # Miscellaneous Intel PT testing
  3. # SPDX-License-Identifier: GPL-2.0
  4. set -e
  5. # Skip if no Intel PT
  6. perf list | grep -q 'intel_pt//' || exit 2
  7. shelldir=$(dirname "$0")
  8. # shellcheck source=lib/waiting.sh
  9. . "${shelldir}"/lib/waiting.sh
  10. skip_cnt=0
  11. ok_cnt=0
  12. err_cnt=0
  13. temp_dir=$(mktemp -d /tmp/perf-test-intel-pt-sh.XXXXXXXXXX)
  14. tmpfile="${temp_dir}/tmp-perf.data"
  15. perfdatafile="${temp_dir}/test-perf.data"
  16. outfile="${temp_dir}/test-out.txt"
  17. errfile="${temp_dir}/test-err.txt"
  18. workload="${temp_dir}/workload"
  19. awkscript="${temp_dir}/awkscript"
  20. jitdump_workload="${temp_dir}/jitdump_workload"
  21. maxbrstack="${temp_dir}/maxbrstack.py"
  22. cleanup()
  23. {
  24. trap - EXIT TERM INT
  25. sane=$(echo "${temp_dir}" | cut -b 1-26)
  26. if [ "${sane}" = "/tmp/perf-test-intel-pt-sh" ] ; then
  27. echo "--- Cleaning up ---"
  28. rm -f "${temp_dir}/"*
  29. rmdir "${temp_dir}"
  30. fi
  31. }
  32. trap_cleanup()
  33. {
  34. cleanup
  35. exit 1
  36. }
  37. trap trap_cleanup EXIT TERM INT
  38. # perf record for testing without decoding
  39. perf_record_no_decode()
  40. {
  41. # Options to speed up recording: no post-processing, no build-id cache update,
  42. # and no BPF events.
  43. perf record -B -N --no-bpf-event "$@"
  44. }
  45. # perf record for testing should not need BPF events
  46. perf_record_no_bpf()
  47. {
  48. # Options for no BPF events
  49. perf record --no-bpf-event "$@"
  50. }
  51. have_workload=false
  52. cat << _end_of_file_ | /usr/bin/cc -o "${workload}" -xc - -pthread && have_workload=true
  53. #include <time.h>
  54. #include <pthread.h>
  55. void work(void) {
  56. struct timespec tm = {
  57. .tv_nsec = 1000000,
  58. };
  59. int i;
  60. /* Run for about 30 seconds */
  61. for (i = 0; i < 30000; i++)
  62. nanosleep(&tm, NULL);
  63. }
  64. void *threadfunc(void *arg) {
  65. work();
  66. return NULL;
  67. }
  68. int main(void) {
  69. pthread_t th;
  70. pthread_create(&th, NULL, threadfunc, NULL);
  71. work();
  72. pthread_join(th, NULL);
  73. return 0;
  74. }
  75. _end_of_file_
  76. can_cpu_wide()
  77. {
  78. echo "Checking for CPU-wide recording on CPU $1"
  79. if ! perf_record_no_decode -o "${tmpfile}" -e dummy:u -C "$1" true >/dev/null 2>&1 ; then
  80. echo "No so skipping"
  81. return 2
  82. fi
  83. echo OK
  84. return 0
  85. }
  86. test_system_wide_side_band()
  87. {
  88. echo "--- Test system-wide sideband ---"
  89. # Need CPU 0 and CPU 1
  90. can_cpu_wide 0 || return $?
  91. can_cpu_wide 1 || return $?
  92. # Record on CPU 0 a task running on CPU 1
  93. perf_record_no_decode -o "${perfdatafile}" -e intel_pt//u -C 0 -- taskset --cpu-list 1 uname
  94. # Should get MMAP events from CPU 1 because they can be needed to decode
  95. mmap_cnt=$(perf script -i "${perfdatafile}" --no-itrace --show-mmap-events -C 1 2>/dev/null | grep -c MMAP)
  96. if [ "${mmap_cnt}" -gt 0 ] ; then
  97. echo OK
  98. return 0
  99. fi
  100. echo "Failed to record MMAP events on CPU 1 when tracing CPU 0"
  101. return 1
  102. }
  103. can_kernel()
  104. {
  105. if [ -z "${can_kernel_trace}" ] ; then
  106. can_kernel_trace=0
  107. perf_record_no_decode -o "${tmpfile}" -e dummy:k true >/dev/null 2>&1 && can_kernel_trace=1
  108. fi
  109. if [ ${can_kernel_trace} -eq 0 ] ; then
  110. echo "SKIP: no kernel tracing"
  111. return 2
  112. fi
  113. return 0
  114. }
  115. test_per_thread()
  116. {
  117. k="$1"
  118. desc="$2"
  119. echo "--- Test per-thread ${desc}recording ---"
  120. if ! $have_workload ; then
  121. echo "No workload, so skipping"
  122. return 2
  123. fi
  124. if [ "${k}" = "k" ] ; then
  125. can_kernel || return 2
  126. fi
  127. cat <<- "_end_of_file_" > "${awkscript}"
  128. BEGIN {
  129. s = "[ ]*"
  130. u = s"[0-9]+"s
  131. d = s"[0-9-]+"s
  132. x = s"[0-9a-fA-FxX]+"s
  133. mmapping = "idx"u": mmapping fd"u
  134. set_output = "idx"u": set output fd"u"->"u
  135. perf_event_open = "sys_perf_event_open: pid"d"cpu"d"group_fd"d"flags"x"="u
  136. }
  137. /perf record opening and mmapping events/ {
  138. if (!done)
  139. active = 1
  140. }
  141. /perf record done opening and mmapping events/ {
  142. active = 0
  143. done = 1
  144. }
  145. $0 ~ perf_event_open && active {
  146. match($0, perf_event_open)
  147. $0 = substr($0, RSTART, RLENGTH)
  148. pid = $3
  149. cpu = $5
  150. fd = $11
  151. print "pid " pid " cpu " cpu " fd " fd " : " $0
  152. fd_array[fd] = fd
  153. pid_array[fd] = pid
  154. cpu_array[fd] = cpu
  155. }
  156. $0 ~ mmapping && active {
  157. match($0, mmapping)
  158. $0 = substr($0, RSTART, RLENGTH)
  159. fd = $5
  160. print "fd " fd " : " $0
  161. if (fd in fd_array) {
  162. mmap_array[fd] = 1
  163. } else {
  164. print "Unknown fd " fd
  165. exit 1
  166. }
  167. }
  168. $0 ~ set_output && active {
  169. match($0, set_output)
  170. $0 = substr($0, RSTART, RLENGTH)
  171. fd = $6
  172. fd_to = $8
  173. print "fd " fd " fd_to " fd_to " : " $0
  174. if (fd in fd_array) {
  175. if (fd_to in fd_array) {
  176. set_output_array[fd] = fd_to
  177. } else {
  178. print "Unknown fd " fd_to
  179. exit 1
  180. }
  181. } else {
  182. print "Unknown fd " fd
  183. exit 1
  184. }
  185. }
  186. END {
  187. print "Checking " length(fd_array) " fds"
  188. for (fd in fd_array) {
  189. if (fd in mmap_array) {
  190. pid = pid_array[fd]
  191. if (pid != -1) {
  192. if (pid in pids) {
  193. print "More than 1 mmap for PID " pid
  194. exit 1
  195. }
  196. pids[pid] = 1
  197. }
  198. cpu = cpu_array[fd]
  199. if (cpu != -1) {
  200. if (cpu in cpus) {
  201. print "More than 1 mmap for CPU " cpu
  202. exit 1
  203. }
  204. cpus[cpu] = 1
  205. }
  206. } else if (!(fd in set_output_array)) {
  207. print "No mmap for fd " fd
  208. exit 1
  209. }
  210. }
  211. n = length(pids)
  212. if (n != thread_cnt) {
  213. print "Expected " thread_cnt " per-thread mmaps - found " n
  214. exit 1
  215. }
  216. }
  217. _end_of_file_
  218. $workload &
  219. w1=$!
  220. $workload &
  221. w2=$!
  222. echo "Workload PIDs are $w1 and $w2"
  223. wait_for_threads ${w1} 2
  224. wait_for_threads ${w2} 2
  225. perf_record_no_decode -o "${perfdatafile}" -e intel_pt//u"${k}" -vvv --per-thread -p "${w1},${w2}" 2>"${errfile}" >"${outfile}" &
  226. ppid=$!
  227. echo "perf PID is $ppid"
  228. wait_for_perf_to_start ${ppid} "${errfile}" || return 1
  229. kill ${w1}
  230. wait_for_process_to_exit ${w1} || return 1
  231. is_running ${ppid} || return 1
  232. kill ${w2}
  233. wait_for_process_to_exit ${w2} || return 1
  234. wait_for_process_to_exit ${ppid} || return 1
  235. awk -v thread_cnt=4 -f "${awkscript}" "${errfile}" || return 1
  236. echo OK
  237. return 0
  238. }
  239. test_jitdump()
  240. {
  241. echo "--- Test tracing self-modifying code that uses jitdump ---"
  242. script_path=$(realpath "$0")
  243. script_dir=$(dirname "$script_path")
  244. jitdump_incl_dir="${script_dir}/../../util"
  245. jitdump_h="${jitdump_incl_dir}/jitdump.h"
  246. if [ ! -e "${jitdump_h}" ] ; then
  247. echo "SKIP: Include file jitdump.h not found"
  248. return 2
  249. fi
  250. if [ -z "${have_jitdump_workload}" ] ; then
  251. have_jitdump_workload=false
  252. # Create a workload that uses self-modifying code and generates its own jitdump file
  253. cat <<- "_end_of_file_" | /usr/bin/cc -o "${jitdump_workload}" -I "${jitdump_incl_dir}" -xc - -pthread && have_jitdump_workload=true
  254. #define _GNU_SOURCE
  255. #include <sys/mman.h>
  256. #include <sys/types.h>
  257. #include <stddef.h>
  258. #include <stdio.h>
  259. #include <stdint.h>
  260. #include <unistd.h>
  261. #include <string.h>
  262. #include "jitdump.h"
  263. #define CHK_BYTE 0x5a
  264. static inline uint64_t rdtsc(void)
  265. {
  266. unsigned int low, high;
  267. asm volatile("rdtsc" : "=a" (low), "=d" (high));
  268. return low | ((uint64_t)high) << 32;
  269. }
  270. static FILE *open_jitdump(void)
  271. {
  272. struct jitheader header = {
  273. .magic = JITHEADER_MAGIC,
  274. .version = JITHEADER_VERSION,
  275. .total_size = sizeof(header),
  276. .pid = getpid(),
  277. .timestamp = rdtsc(),
  278. .flags = JITDUMP_FLAGS_ARCH_TIMESTAMP,
  279. };
  280. char filename[256];
  281. FILE *f;
  282. void *m;
  283. snprintf(filename, sizeof(filename), "jit-%d.dump", getpid());
  284. f = fopen(filename, "w+");
  285. if (!f)
  286. goto err;
  287. /* Create an MMAP event for the jitdump file. That is how perf tool finds it. */
  288. m = mmap(0, 4096, PROT_READ | PROT_EXEC, MAP_PRIVATE, fileno(f), 0);
  289. if (m == MAP_FAILED)
  290. goto err_close;
  291. munmap(m, 4096);
  292. if (fwrite(&header,sizeof(header),1,f) != 1)
  293. goto err_close;
  294. return f;
  295. err_close:
  296. fclose(f);
  297. err:
  298. return NULL;
  299. }
  300. static int write_jitdump(FILE *f, void *addr, const uint8_t *dat, size_t sz, uint64_t *idx)
  301. {
  302. struct jr_code_load rec = {
  303. .p.id = JIT_CODE_LOAD,
  304. .p.total_size = sizeof(rec) + sz,
  305. .p.timestamp = rdtsc(),
  306. .pid = getpid(),
  307. .tid = gettid(),
  308. .vma = (unsigned long)addr,
  309. .code_addr = (unsigned long)addr,
  310. .code_size = sz,
  311. .code_index = ++*idx,
  312. };
  313. if (fwrite(&rec,sizeof(rec),1,f) != 1 ||
  314. fwrite(dat, sz, 1, f) != 1)
  315. return -1;
  316. return 0;
  317. }
  318. static void close_jitdump(FILE *f)
  319. {
  320. fclose(f);
  321. }
  322. int main()
  323. {
  324. /* Get a memory page to store executable code */
  325. void *addr = mmap(0, 4096, PROT_WRITE | PROT_EXEC, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
  326. /* Code to execute: mov CHK_BYTE, %eax ; ret */
  327. uint8_t dat[] = {0xb8, CHK_BYTE, 0x00, 0x00, 0x00, 0xc3};
  328. FILE *f = open_jitdump();
  329. uint64_t idx = 0;
  330. int ret = 1;
  331. if (!f)
  332. return 1;
  333. /* Copy executable code to executable memory page */
  334. memcpy(addr, dat, sizeof(dat));
  335. /* Record it in the jitdump file */
  336. if (write_jitdump(f, addr, dat, sizeof(dat), &idx))
  337. goto out_close;
  338. /* Call it */
  339. ret = ((int (*)(void))addr)() - CHK_BYTE;
  340. out_close:
  341. close_jitdump(f);
  342. return ret;
  343. }
  344. _end_of_file_
  345. fi
  346. if ! $have_jitdump_workload ; then
  347. echo "SKIP: No jitdump workload"
  348. return 2
  349. fi
  350. # Change to temp_dir so jitdump collateral files go there
  351. cd "${temp_dir}"
  352. perf_record_no_bpf -o "${tmpfile}" -e intel_pt//u "${jitdump_workload}"
  353. perf inject -i "${tmpfile}" -o "${perfdatafile}" --jit
  354. decode_br_cnt=$(perf script -i "${perfdatafile}" --itrace=b | wc -l)
  355. # Note that overflow and lost errors are suppressed for the error count
  356. decode_err_cnt=$(perf script -i "${perfdatafile}" --itrace=e-o-l | grep -ci error)
  357. cd -
  358. # Should be thousands of branches
  359. if [ "${decode_br_cnt}" -lt 1000 ] ; then
  360. echo "Decode failed, only ${decode_br_cnt} branches"
  361. return 1
  362. fi
  363. # Should be no errors
  364. if [ "${decode_err_cnt}" -ne 0 ] ; then
  365. echo "Decode failed, ${decode_err_cnt} errors"
  366. perf script -i "${perfdatafile}" --itrace=e-o-l --show-mmap-events | cat
  367. return 1
  368. fi
  369. echo OK
  370. return 0
  371. }
  372. test_packet_filter()
  373. {
  374. echo "--- Test with MTC and TSC disabled ---"
  375. # Disable MTC and TSC
  376. perf_record_no_decode -o "${perfdatafile}" -e intel_pt/mtc=0,tsc=0/u uname
  377. # Should not get MTC packet
  378. mtc_cnt=$(perf script -i "${perfdatafile}" -D 2>/dev/null | grep -c "MTC 0x")
  379. if [ "${mtc_cnt}" -ne 0 ] ; then
  380. echo "Failed to filter with mtc=0"
  381. return 1
  382. fi
  383. # Should not get TSC package
  384. tsc_cnt=$(perf script -i "${perfdatafile}" -D 2>/dev/null | grep -c "TSC 0x")
  385. if [ "${tsc_cnt}" -ne 0 ] ; then
  386. echo "Failed to filter with tsc=0"
  387. return 1
  388. fi
  389. echo OK
  390. return 0
  391. }
  392. test_disable_branch()
  393. {
  394. echo "--- Test with branches disabled ---"
  395. # Disable branch
  396. perf_record_no_decode -o "${perfdatafile}" -e intel_pt/branch=0/u uname
  397. # Should not get branch related packets
  398. tnt_cnt=$(perf script -i "${perfdatafile}" -D 2>/dev/null | grep -c "TNT 0x")
  399. tip_cnt=$(perf script -i "${perfdatafile}" -D 2>/dev/null | grep -c "TIP 0x")
  400. fup_cnt=$(perf script -i "${perfdatafile}" -D 2>/dev/null | grep -c "FUP 0x")
  401. if [ "${tnt_cnt}" -ne 0 ] || [ "${tip_cnt}" -ne 0 ] || [ "${fup_cnt}" -ne 0 ] ; then
  402. echo "Failed to disable branches"
  403. return 1
  404. fi
  405. echo OK
  406. return 0
  407. }
  408. test_time_cyc()
  409. {
  410. echo "--- Test with/without CYC ---"
  411. # Check if CYC is supported
  412. cyc=$(cat /sys/bus/event_source/devices/intel_pt/caps/psb_cyc)
  413. if [ "${cyc}" != "1" ] ; then
  414. echo "SKIP: CYC is not supported"
  415. return 2
  416. fi
  417. # Enable CYC
  418. perf_record_no_decode -o "${perfdatafile}" -e intel_pt/cyc/u uname
  419. # should get CYC packets
  420. cyc_cnt=$(perf script -i "${perfdatafile}" -D 2>/dev/null | grep -c "CYC 0x")
  421. if [ "${cyc_cnt}" = "0" ] ; then
  422. echo "Failed to get CYC packet"
  423. return 1
  424. fi
  425. # Without CYC
  426. perf_record_no_decode -o "${perfdatafile}" -e intel_pt//u uname
  427. # Should not get CYC packets
  428. cyc_cnt=$(perf script -i "${perfdatafile}" -D 2>/dev/null | grep -c "CYC 0x")
  429. if [ "${cyc_cnt}" -gt 0 ] ; then
  430. echo "Still get CYC packet without cyc"
  431. return 1
  432. fi
  433. echo OK
  434. return 0
  435. }
  436. test_sample()
  437. {
  438. echo "--- Test recording with sample mode ---"
  439. # Check if recording with sample mode is working
  440. if ! perf_record_no_decode -o "${perfdatafile}" --aux-sample=8192 -e '{intel_pt//u,branch-misses:u}' uname ; then
  441. echo "perf record failed with --aux-sample"
  442. return 1
  443. fi
  444. # Check with event with PMU name
  445. if perf_record_no_decode -o "${perfdatafile}" -e br_misp_retired.all_branches:u uname ; then
  446. if ! perf_record_no_decode -o "${perfdatafile}" -e '{intel_pt//,br_misp_retired.all_branches/aux-sample-size=8192/}:u' uname ; then
  447. echo "perf record failed with --aux-sample-size"
  448. return 1
  449. fi
  450. fi
  451. echo OK
  452. return 0
  453. }
  454. test_kernel_trace()
  455. {
  456. echo "--- Test with kernel trace ---"
  457. # Check if recording with kernel trace is working
  458. can_kernel || return 2
  459. if ! perf_record_no_decode -o "${perfdatafile}" -e intel_pt//k -m1,128 uname ; then
  460. echo "perf record failed with intel_pt//k"
  461. return 1
  462. fi
  463. echo OK
  464. return 0
  465. }
  466. test_virtual_lbr()
  467. {
  468. echo "--- Test virtual LBR ---"
  469. # Check if python script is supported
  470. libpython=$(perf version --build-options | grep python | grep -cv OFF)
  471. if [ "${libpython}" != "1" ] ; then
  472. echo "SKIP: python scripting is not supported"
  473. return 2
  474. fi
  475. # Python script to determine the maximum size of branch stacks
  476. cat << "_end_of_file_" > "${maxbrstack}"
  477. from __future__ import print_function
  478. bmax = 0
  479. def process_event(param_dict):
  480. if "brstack" in param_dict:
  481. brstack = param_dict["brstack"]
  482. n = len(brstack)
  483. global bmax
  484. if n > bmax:
  485. bmax = n
  486. def trace_end():
  487. print("max brstack", bmax)
  488. _end_of_file_
  489. # Check if virtual lbr is working
  490. perf_record_no_bpf -o "${perfdatafile}" --aux-sample -e '{intel_pt//,cycles}:u' uname
  491. times_val=$(perf script -i "${perfdatafile}" --itrace=L -s "${maxbrstack}" 2>/dev/null | grep "max brstack " | cut -d " " -f 3)
  492. case "${times_val}" in
  493. [0-9]*) ;;
  494. *) times_val=0;;
  495. esac
  496. if [ "${times_val}" -lt 2 ] ; then
  497. echo "Failed with virtual lbr"
  498. return 1
  499. fi
  500. echo OK
  501. return 0
  502. }
  503. test_power_event()
  504. {
  505. echo "--- Test power events ---"
  506. # Check if power events are supported
  507. power_event=$(cat /sys/bus/event_source/devices/intel_pt/caps/power_event_trace)
  508. if [ "${power_event}" != "1" ] ; then
  509. echo "SKIP: power_event_trace is not supported"
  510. return 2
  511. fi
  512. if ! perf_record_no_decode -o "${perfdatafile}" -a -e intel_pt/pwr_evt/u uname ; then
  513. echo "perf record failed with pwr_evt"
  514. return 1
  515. fi
  516. echo OK
  517. return 0
  518. }
  519. test_no_tnt()
  520. {
  521. echo "--- Test with TNT packets disabled ---"
  522. # Check if TNT disable is supported
  523. notnt=$(cat /sys/bus/event_source/devices/intel_pt/caps/tnt_disable)
  524. if [ "${notnt}" != "1" ] ; then
  525. echo "SKIP: tnt_disable is not supported"
  526. return 2
  527. fi
  528. perf_record_no_decode -o "${perfdatafile}" -e intel_pt/notnt/u uname
  529. # Should be no TNT packets
  530. tnt_cnt=$(perf script -i "${perfdatafile}" -D | grep -c TNT)
  531. if [ "${tnt_cnt}" -ne 0 ] ; then
  532. echo "TNT packets still there after notnt"
  533. return 1
  534. fi
  535. echo OK
  536. return 0
  537. }
  538. test_event_trace()
  539. {
  540. echo "--- Test with event_trace ---"
  541. # Check if event_trace is supported
  542. event_trace=$(cat /sys/bus/event_source/devices/intel_pt/caps/event_trace)
  543. if [ "${event_trace}" != 1 ] ; then
  544. echo "SKIP: event_trace is not supported"
  545. return 2
  546. fi
  547. if ! perf_record_no_decode -o "${perfdatafile}" -e intel_pt/event/u uname ; then
  548. echo "perf record failed with event trace"
  549. return 1
  550. fi
  551. echo OK
  552. return 0
  553. }
  554. test_pipe()
  555. {
  556. echo "--- Test with pipe mode ---"
  557. # Check if it works with pipe
  558. if ! perf_record_no_bpf -o- -e intel_pt//u uname | perf report -q -i- --itrace=i10000 ; then
  559. echo "perf record + report failed with pipe mode"
  560. return 1
  561. fi
  562. if ! perf_record_no_bpf -o- -e intel_pt//u uname | perf inject -b > /dev/null ; then
  563. echo "perf record + inject failed with pipe mode"
  564. return 1
  565. fi
  566. echo OK
  567. return 0
  568. }
  569. count_result()
  570. {
  571. if [ "$1" -eq 2 ] ; then
  572. skip_cnt=$((skip_cnt + 1))
  573. return
  574. fi
  575. if [ "$1" -eq 0 ] ; then
  576. ok_cnt=$((ok_cnt + 1))
  577. return
  578. fi
  579. err_cnt=$((err_cnt + 1))
  580. }
  581. ret=0
  582. test_system_wide_side_band || ret=$? ; count_result $ret ; ret=0
  583. test_per_thread "" "" || ret=$? ; count_result $ret ; ret=0
  584. test_per_thread "k" "(incl. kernel) " || ret=$? ; count_result $ret ; ret=0
  585. test_jitdump || ret=$? ; count_result $ret ; ret=0
  586. test_packet_filter || ret=$? ; count_result $ret ; ret=0
  587. test_disable_branch || ret=$? ; count_result $ret ; ret=0
  588. test_time_cyc || ret=$? ; count_result $ret ; ret=0
  589. test_sample || ret=$? ; count_result $ret ; ret=0
  590. test_kernel_trace || ret=$? ; count_result $ret ; ret=0
  591. test_virtual_lbr || ret=$? ; count_result $ret ; ret=0
  592. test_power_event || ret=$? ; count_result $ret ; ret=0
  593. test_no_tnt || ret=$? ; count_result $ret ; ret=0
  594. test_event_trace || ret=$? ; count_result $ret ; ret=0
  595. test_pipe || ret=$? ; count_result $ret ; ret=0
  596. cleanup
  597. echo "--- Done ---"
  598. if [ ${err_cnt} -gt 0 ] ; then
  599. exit 1
  600. fi
  601. if [ ${ok_cnt} -gt 0 ] ; then
  602. exit 0
  603. fi
  604. exit 2