xref: /illumos-gate/usr/src/cmd/dtrace/test/tst/common/aggs/tst.signedkeyspos.d (revision dd72704bd9e794056c558153663c739e2012d721)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * ASSERTION:
29  * 	Signed integer keys print and sort as expected using the
30  * 	aggsortkeypos and aggsortrev options
31  *
32  * SECTION: Aggregations, Printing Aggregations
33  *
34  * NOTES: DTrace sorts integer keys as unsigned values, yet prints 32-
35  * and 64-bit integers as signed values. Since the Java DTrace API is
36  * expected to emulate this behavior, this test was added to ensure that
37  * the behavior is preserved.
38  */
39 
40 #pragma D option quiet
41 #pragma D option aggsortkey
42 #pragma D option aggsortkeypos=1
43 #pragma D option aggsortrev
44 
45 BEGIN
46 {
47 	@i8["cat", (char)-2] = sum(-2);
48 	@i8["dog", (char)-2] = sum(-22);
49 	@i8["mouse", (char)-2] = sum(-222);
50 	@i8["cat", (char)-1] = sum(-1);
51 	@i8["dog", (char)-1] = sum(-11);
52 	@i8["mouse", (char)-1] = sum(-111);
53 	@i8["cat", (char)0] = sum(0);
54 	@i8["dog", (char)0] = sum(10);
55 	@i8["mouse", (char)0] = sum(100);
56 	@i8["cat", (char)1] = sum(1);
57 	@i8["dog", (char)1] = sum(11);
58 	@i8["mouse", (char)1] = sum(111);
59 	@i8["cat", (char)2] = sum(2);
60 	@i8["dog", (char)2] = sum(22);
61 	@i8["mouse", (char)2] = sum(222);
62 
63 	@i16["mouse", (short)-2] = sum(-2);
64 	@i16["dog", (short)-2] = sum(-22);
65 	@i16["cat", (short)-2] = sum(-222);
66 	@i16["mouse", (short)-1] = sum(-1);
67 	@i16["dog", (short)-1] = sum(-11);
68 	@i16["cat", (short)-1] = sum(-111);
69 	@i16["mouse", (short)0] = sum(0);
70 	@i16["dog", (short)0] = sum(10);
71 	@i16["cat", (short)0] = sum(100);
72 	@i16["mouse", (short)1] = sum(1);
73 	@i16["dog", (short)1] = sum(11);
74 	@i16["cat", (short)1] = sum(111);
75 	@i16["mouse", (short)2] = sum(2);
76 	@i16["dog", (short)2] = sum(22);
77 	@i16["cat", (short)2] = sum(222);
78 
79 	@i32["mouse", -2] = sum(-2);
80 	@i32["bear", -2] = sum(-22);
81 	@i32["cat", -2] = sum(-222);
82 	@i32["mouse", -1] = sum(-1);
83 	@i32["bear", -1] = sum(-11);
84 	@i32["cat", -1] = sum(-111);
85 	@i32["mouse", 0] = sum(0);
86 	@i32["bear", 0] = sum(10);
87 	@i32["cat", 0] = sum(100);
88 	@i32["mouse", 1] = sum(1);
89 	@i32["bear", 1] = sum(11);
90 	@i32["cat", 1] = sum(111);
91 	@i32["mouse", 2] = sum(2);
92 	@i32["bear", 2] = sum(22);
93 	@i32["cat", 2] = sum(222);
94 
95 	@i64["cat", (long long)-2] = sum(-2);
96 	@i64["bear", (long long)-2] = sum(-22);
97 	@i64["dog", (long long)-2] = sum(-222);
98 	@i64["cat", (long long)-1] = sum(-1);
99 	@i64["bear", (long long)-1] = sum(-11);
100 	@i64["dog", (long long)-1] = sum(-111);
101 	@i64["cat", (long long)0] = sum(0);
102 	@i64["bear", (long long)0] = sum(10);
103 	@i64["dog", (long long)0] = sum(100);
104 	@i64["cat", (long long)1] = sum(1);
105 	@i64["bear", (long long)1] = sum(11);
106 	@i64["dog", (long long)1] = sum(111);
107 	@i64["cat", (long long)2] = sum(2);
108 	@i64["bear", (long long)2] = sum(22);
109 	@i64["dog", (long long)2] = sum(222);
110 
111 	exit(0);
112 }
113