# Test of foreach statements using "limit EXP".

set test "foreach_limit2"

set ::result_string {Arrays of aggregates:
sorted (by values, decreasing):
agg_array[9]: count:10  sum:174  avg:17  min:1  max:54  variance:216
agg_array[1]: count:9  sum:345  avg:38  min:2  max:120  variance:1209
agg_array[8]: count:8  sum:139  avg:17  min:3  max:48  variance:181
agg_array[2]: count:7  sum:34  avg:4  min:2  max:12  variance:12
agg_array[7]: count:6  sum:133  avg:22  min:7  max:42  variance:245
agg_array[3]: count:5  sum:234  avg:46  min:18  max:108  variance:1240
agg_array[6]: count:4  sum:42  avg:10  min:6  max:12  variance:9
agg_array[5]: count:3  sum:25  avg:8  min:5  max:10  variance:9
agg_array[4]: count:2  sum:16  avg:8  min:8  max:8  variance:0
agg_array[10]: count:1  sum:20  avg:20  min:20  max:20  variance:0

sorted (by values), increasing:
agg_array[10]: count:1  sum:20  avg:20  min:20  max:20  variance:0
agg_array[4]: count:2  sum:16  avg:8  min:8  max:8  variance:0
agg_array[5]: count:3  sum:25  avg:8  min:5  max:10  variance:9
agg_array[6]: count:4  sum:42  avg:10  min:6  max:12  variance:9
agg_array[3]: count:5  sum:234  avg:46  min:18  max:108  variance:1240
agg_array[7]: count:6  sum:133  avg:22  min:7  max:42  variance:245
agg_array[2]: count:7  sum:34  avg:4  min:2  max:12  variance:12
agg_array[8]: count:8  sum:139  avg:17  min:3  max:48  variance:181
agg_array[1]: count:9  sum:345  avg:38  min:2  max:120  variance:1209
agg_array[9]: count:10  sum:174  avg:17  min:1  max:54  variance:216

sorted (by values, decreasing) limit 5:
agg_array[9]: count:10  sum:174  avg:17  min:1  max:54  variance:216
agg_array[1]: count:9  sum:345  avg:38  min:2  max:120  variance:1209
agg_array[8]: count:8  sum:139  avg:17  min:3  max:48  variance:181
agg_array[2]: count:7  sum:34  avg:4  min:2  max:12  variance:12
agg_array[7]: count:6  sum:133  avg:22  min:7  max:42  variance:245
loop had 5 iterations

sorted (by values, increasing) limit 5:
agg_array[10]: count:1  sum:20  avg:20  min:20  max:20  variance:0
agg_array[4]: count:2  sum:16  avg:8  min:8  max:8  variance:0
agg_array[5]: count:3  sum:25  avg:8  min:5  max:10  variance:9
agg_array[6]: count:4  sum:42  avg:10  min:6  max:12  variance:9
agg_array[3]: count:5  sum:234  avg:46  min:18  max:108  variance:1240
loop had 5 iterations

sorted (by keys) limit 5:
agg_array[1]: count:9  sum:345  avg:38  min:2  max:120  variance:1209
agg_array[2]: count:7  sum:34  avg:4  min:2  max:12  variance:12
agg_array[3]: count:5  sum:234  avg:46  min:18  max:108  variance:1240
agg_array[4]: count:2  sum:16  avg:8  min:8  max:8  variance:0
agg_array[5]: count:3  sum:25  avg:8  min:5  max:10  variance:9
loop had 5 iterations

sorted (by values) limit x (3):
agg_array[10]: count:1  sum:20  avg:20  min:20  max:20  variance:0
agg_array[4]: count:2  sum:16  avg:8  min:8  max:8  variance:0
agg_array[5]: count:3  sum:25  avg:8  min:5  max:10  variance:9
loop had 3 iterations

sorted (by values) limit x * 2 (6):
agg_array[10]: count:1  sum:20  avg:20  min:20  max:20  variance:0
agg_array[4]: count:2  sum:16  avg:8  min:8  max:8  variance:0
agg_array[5]: count:3  sum:25  avg:8  min:5  max:10  variance:9
agg_array[6]: count:4  sum:42  avg:10  min:6  max:12  variance:9
agg_array[3]: count:5  sum:234  avg:46  min:18  max:108  variance:1240
agg_array[7]: count:6  sum:133  avg:22  min:7  max:42  variance:245
loop had 6 iterations

sorted (by values) limit ++x:
agg_array[10]: count:1  sum:20  avg:20  min:20  max:20  variance:0
agg_array[4]: count:2  sum:16  avg:8  min:8  max:8  variance:0
agg_array[5]: count:3  sum:25  avg:8  min:5  max:10  variance:9
agg_array[6]: count:4  sum:42  avg:10  min:6  max:12  variance:9
loop had 4 iterations
x ended up as 4

sorted (by values) limit x++:
agg_array[10]: count:1  sum:20  avg:20  min:20  max:20  variance:0
agg_array[4]: count:2  sum:16  avg:8  min:8  max:8  variance:0
agg_array[5]: count:3  sum:25  avg:8  min:5  max:10  variance:9
agg_array[6]: count:4  sum:42  avg:10  min:6  max:12  variance:9
loop had 4 iterations
x ended up as 5

Done.}

foreach runtime [get_runtime_list] {
    if {$runtime != ""} {
	stap_run2 $srcdir/$subdir/$test.stp --runtime=$runtime
    } else {
	stap_run2 $srcdir/$subdir/$test.stp
    }
}
