summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.base/optim_arridx.exp
blob: c33952a6bb15aee6acdf2abdb7ef7c75ecc6ff5b (plain)
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
98
99
# test integer limits. Set and print variables and print constants.

set test "optim_arridx"
set ::result_string {# globals
arr1:long [long, long]
arr2:long [long]
arr3:long [long]
elide_idx1:long
elide_global_a:long
elide_global_b:long
# functions
exit:unknown ()
%{ /* unprivileged */
    atomic_set (&session_state, STAP_SESSION_STOPPING);
    _stp_exit ();
%}
fna:long (a:long)
return a
fnb:long (a:long, b:long)
return (a) + (b)
# probes
begin /* <- begin */
  # locals
  idx2:long
  j:long
  k:long
  b:long
  m:long
  aa:long
  bb:long
  cc:long
  dd:long
  ee:long
{
(arr2[(elide_idx1) = (1)]) = (10)
(arr2[(idx2) = (2)]) = (20)
(arr2[3]) = (30)
(arr2[(j) = (4)]) = (40)
(arr1[fna((k) = (0)), k]) = (1)
(arr1[(b) = (1), b]) = (2)
(arr1[2, 2]) = (3)
(arr3[0]) = (4)
(m) = (1)
for (2; (m) <= (10); (m)++) (arr2[m]) = ((m) * (10))
printf("%d %d %d %d\\n", arr1[0, 0], arr2[0], idx2, j)
(aa) = (fna(1))
(bb) = (fnb((cc) = (1), (elide_global_a) = (2)))
for (1; (bb) < (10); (bb)++) (cc) += (bb)
for ((dd) = (1); (dd) < (10); 1) (dd) += (1)
if ((elide_global_b) = (1)) (ee) = (1)

(cc) = ((dd) = (5))
(cc) = ((4) + ((cc) = (1)))
printf("%d %d %d %d %d\\n", aa, bb, cc, dd, ee)
exit()
}
end /* <- end */
  # locals
  idx0:long
{
foreach ([idx0] in arr3-) printf("arr3[%#d]=%#x\\n", idx0, arr3[idx0])
}
end /* <- end */
{
printf("elide_idx1=%#x\\n", elide_idx1)
}
end /* <- end */
{
printf("elide_global_a=%#x\\n", elide_global_a)
}
end /* <- end */
{
printf("elide_global_b=%#x\\n", elide_global_b)
}
}

proc optim_arridx_run { TEST_NAME args } {
    # zap the srcdir prefix
    set test_file_name $TEST_NAME
    set TEST_NAME [regsub {.*/testsuite/} $TEST_NAME ""]
    
    set cmd [concat stap $args $test_file_name]
    catch {eval exec $cmd} res

    set n 0
    set expected [split $::result_string "\n"]
    foreach line [split $res "\n"] {
	if {![string equal $line [lindex $expected $n]]} {
	    fail "$TEST_NAME"
	    send_log "line [expr $n + 1]: expected \"[lindex $expected $n]\"\n"
	    send_log "Got \"$line\"\n"
	    return
	}
	incr n
    }
    pass "$TEST_NAME"
}

optim_arridx_run $srcdir/$subdir/$test.stp -p2 -v 2>/dev/null