forked from andikleen/simple-pt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tester
executable file
·100 lines (78 loc) · 1.99 KB
/
tester
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
# simple test for simple pt
# needs to be run as root
# tester [sptcmd opts]
# issues:
# may need -k to finish
# some tests may need a quiescent system
set -e
set -x
failed() {
echo FAILED
exit 1
}
trap failed ERR 0
#export LD_LIBRARY_PATH=$(pwd)/../processor-trace/lib
export PATH=$PATH:.
./TEST-FTRACE
PREFIX=stest
EXTRA="-t $1 $2 $3"
STDCMD=loop
CMD=$STDCMD
run() {
sptcmd $EXTRA -o $PREFIX "$@" taskset -c 0 $CMD
$V sptdecode --sideband ${PREFIX}.sideband --pt ${PREFIX}.0 $DARGS > ${PREFIX}.out
}
gcc -o loop loop.c -g
run
grep -q __libc_start_main.*main stest.out
grep -q page_fault stest.out
run -c loop
grep -q __libc_start_main.*main stest.out
grep -q page_fault stest.out
run --disretc --no-user
grep -q page_fault stest.out
run --no-kernel -c loop
grep -q __libc_start_main.*main stest.out
grep -v -q page_fault stest.out
# long trace test to fill the buffer
CMD=BC1s
run --no-kernel -c bc
CMD=$STDCMD
[ "$(stat -c %s stest.0)" -eq $[2048*1024] ]
# retest simple run
run --no-user
grep -q page_fault stest.out
# FIXME: work around libipt bug for now on this test case
if ! ./ptfeature cyc ; then
run --start-addr SyS_prctl --stop-addr SyS_personality
grep -q main stest.out
fi
MAIN=$(nm loop | awk '$3 == "main" { print "0x" $1 } ')
FINI=$(nm loop | awk '$3 == "_fini" { print "0x" $1 } ')
if ./ptfeature filter ; then
run --filter $MAIN,$FINI -c loop
grep -v -q write stest.out
fi
if ./ptfeature stop ; then
run --stop-range $MAIN,$FINI -K -c loop
grep -q __libc_start_main stest.out
grep -v -q -w main stest.out # main is not reached
# XXX check for disabled message later
fi
if ./ptfeature cyc psb mtc ; then
run --cyc 1 --mtc 1 --psb 1
grep -q main stest.out
fi
# simple dwarf resolving test
cp loop loop2
cp loop loop3
cp loop loop4
gcc -I/usr/include/libdwarf -I/usr/local/include/libdwarf -g -o dwarf dwarf.c -DTEST=1 -g -ldwarf -lelf
dwarf loop:$MAIN loop2:$MAIN loop3:$MAIN loop4:$MAIN
rm loop2 loop3 loop4 dwarf
set +x
trap "" ERR 0
echo
echo SUCCEEDED
echo