drm/rockchip: Don't change hdmi reference clock rate
[drm/drm-misc.git] / tools / perf / tests / shell / test_uprobe_from_different_cu.sh
blob33387c329f92b6ed59fd6b9eed4a455645ab5f94
1 #!/bin/bash
2 # test perf probe of function from different CU
3 # SPDX-License-Identifier: GPL-2.0
5 set -e
7 # Skip if there's no probe command.
8 if ! perf | grep probe
9 then
10 echo "Skip: probe command isn't present"
11 exit 2
14 # skip if there's no gcc
15 if ! [ -x "$(command -v gcc)" ]; then
16 echo "failed: no gcc compiler"
17 exit 2
20 temp_dir=$(mktemp -d /tmp/perf-uprobe-different-cu-sh.XXXXXXXXXX)
22 cleanup()
24 trap - EXIT TERM INT
25 if [[ "${temp_dir}" =~ ^/tmp/perf-uprobe-different-cu-sh.*$ ]]; then
26 echo "--- Cleaning up ---"
27 perf probe -x ${temp_dir}/testfile -d foo || true
28 rm -f "${temp_dir}/"*
29 rmdir "${temp_dir}"
33 trap_cleanup()
35 cleanup
36 exit 1
39 trap trap_cleanup EXIT TERM INT
41 cat > ${temp_dir}/testfile-foo.h << EOF
42 struct t
44 int *p;
45 int c;
48 extern int foo (int i, struct t *t);
49 EOF
51 cat > ${temp_dir}/testfile-foo.c << EOF
52 #include "testfile-foo.h"
54 int
55 foo (int i, struct t *t)
57 int j, res = 0;
58 for (j = 0; j < i && j < t->c; j++)
59 res += t->p[j];
61 return res;
63 EOF
65 cat > ${temp_dir}/testfile-main.c << EOF
66 #include "testfile-foo.h"
68 static struct t g;
70 int
71 main (int argc, char **argv)
73 int i;
74 int j[argc];
75 g.c = argc;
76 g.p = j;
77 for (i = 0; i < argc; i++)
78 j[i] = (int) argv[i][0];
79 return foo (3, &g);
81 EOF
83 gcc -g -Og -flto -c ${temp_dir}/testfile-foo.c -o ${temp_dir}/testfile-foo.o
84 gcc -g -Og -c ${temp_dir}/testfile-main.c -o ${temp_dir}/testfile-main.o
85 gcc -g -Og -o ${temp_dir}/testfile ${temp_dir}/testfile-foo.o ${temp_dir}/testfile-main.o
87 perf probe -x ${temp_dir}/testfile --funcs foo | grep "foo"
88 perf probe -x ${temp_dir}/testfile foo
90 cleanup