xref: /titanic_50/usr/src/cmd/dtrace/test/tst/common/aggs/tst.signedkeys.d (revision 23b5c241225a8ade2b6b9f06ebb891ee459e3b02)
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 #pragma	ident	"%Z%%M%	%I%	%E% SMI"
28 
29 
30 /*
31  * ASSERTION:
32  * 	Signed integer keys print and sort as expected.
33  *
34  * SECTION: Aggregations, Printing Aggregations
35  *
36  * NOTES: DTrace sorts integer keys as unsigned values, yet prints 32-
37  * and 64-bit integers as signed values. Since the Java DTrace API is
38  * expected to emulate this behavior, this test was added to ensure that
39  * the behavior is preserved. Consistency with trace() output is also
40  * tested.
41  */
42 
43 #pragma D option quiet
44 #pragma D option aggsortkey
45 
46 BEGIN
47 {
48 	trace((char)-2);
49 	trace("\n");
50 	trace((char)-1);
51 	trace("\n");
52 	trace((char)0);
53 	trace("\n");
54 	trace((char)1);
55 	trace("\n");
56 	trace((char)2);
57 	trace("\n");
58 	trace("\n");
59 
60 	trace((short)-2);
61 	trace("\n");
62 	trace((short)-1);
63 	trace("\n");
64 	trace((short)0);
65 	trace("\n");
66 	trace((short)1);
67 	trace("\n");
68 	trace((short)2);
69 	trace("\n");
70 	trace("\n");
71 
72 	trace(-2);
73 	trace("\n");
74 	trace(-1);
75 	trace("\n");
76 	trace(0);
77 	trace("\n");
78 	trace(1);
79 	trace("\n");
80 	trace(2);
81 	trace("\n");
82 	trace("\n");
83 
84 	trace((long long)-2);
85 	trace("\n");
86 	trace((long long)-1);
87 	trace("\n");
88 	trace((long long)0);
89 	trace("\n");
90 	trace((long long)1);
91 	trace("\n");
92 	trace((long long)2);
93 	trace("\n");
94 
95 	@i8[(char)-2] = sum(-2);
96 	@i8[(char)-1] = sum(-1);
97 	@i8[(char)0] = sum(0);
98 	@i8[(char)1] = sum(1);
99 	@i8[(char)2] = sum(2);
100 
101 	@i16[(short)-2] = sum(-2);
102 	@i16[(short)-1] = sum(-1);
103 	@i16[(short)0] = sum(0);
104 	@i16[(short)1] = sum(1);
105 	@i16[(short)2] = sum(2);
106 
107 	@i32[-2] = sum(-2);
108 	@i32[-1] = sum(-1);
109 	@i32[0] = sum(0);
110 	@i32[1] = sum(1);
111 	@i32[2] = sum(2);
112 
113 	@i64[(long long)-2] = sum(-2);
114 	@i64[(long long)-1] = sum(-1);
115 	@i64[(long long)0] = sum(0);
116 	@i64[(long long)1] = sum(1);
117 	@i64[(long long)2] = sum(2);
118 
119 	exit(0);
120 }
121