diff --git a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 new file mode 100644 index 000000000000..e20ed9fe6ba8 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 @@ -0,0 +1,670 @@ +'\" te +.\" CDDL HEADER START +.\" +.\" The contents of this file are subject to the terms of the +.\" Common Development and Distribution License (the "License"). +.\" You may not use this file except in compliance with the License. +.\" +.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +.\" or http://www.opensolaris.org/os/licensing. +.\" See the License for the specific language governing permissions +.\" and limitations under the License. +.\" +.\" When distributing Covered Code, include this CDDL HEADER in each +.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE. +.\" If applicable, add the following below this CDDL HEADER, with the +.\" fields enclosed by brackets "[]" replaced with your own identifying +.\" information: Portions Copyright [yyyy] [name of copyright owner] +.\" +.\" CDDL HEADER END +.\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved. +.TH dtrace 1M "5 Sep 2006" "SunOS 5.11" "System Administration Commands" +.SH NAME +dtrace \- DTrace dynamic tracing compiler and tracing utility +.SH SYNOPSIS +.LP +.nf +\fBdtrace\fR [\fB-32\fR | \fB-64\fR] [\fB-aACeFGHhlqSvVwZ\fR] [\fB-b\fR \fIbufsz\fR] [\fB-c\fR \fIcmd\fR] + [\fB-D\fR \fIname\fR [\fI=value\fR]] [\fB-I\fR \fIpath\fR] [\fB-L\fR \fIpath\fR] [\fB-o\fR \fIoutput\fR] + [\fB-s\fR \fIscript\fR] [\fB-U\fR \fIname\fR] [\fB-x\fR \fIarg\fR [\fI=val\fR]] + [\fB-X\fR a | c | s | t] [\fB-p\fR \fIpid\fR] + [\fB-P\fR \fIprovider\fR [[\fIpredicate\fR] \fIaction\fR]] + [\fB-m\fR [\fIprovider:\fR] \fImodule\fR [[\fIpredicate\fR] \fIaction\fR]] + [\fB-f\fR [[\fIprovider:\fR] \fImodule:\fR] \fIfunction\fR [[\fIpredicate\fR] \fIaction\fR]] + [\fB-n\fR [[[\fIprovider:\fR] \fImodule:\fR] \fIfunction:\fR] \fIname\fR [[\fIpredicate\fR] \fIaction\fR]] + [\fB-i\fR \fIprobe-id\fR [[\fIpredicate\fR] \fIaction\fR]] +.fi + +.SH DESCRIPTION +.sp +.LP +DTrace is a comprehensive dynamic tracing framework for the Solaris Operating System. DTrace provides a powerful infrastructure that permits administrators, developers, and service personnel to concisely answer arbitrary questions about the behavior of the operating system and user programs. +.sp +.LP +The \fISolaris Dynamic Tracing Guide\fR describes how to use DTrace to observe, debug, and tune system behavior. Refer to this book for a detailed description of DTrace features, including the bundled DTrace observability +tools, instrumentation providers, and the D programming language. +.sp +.LP +The \fBdtrace\fR command provides a generic interface to the essential services provided by the DTrace facility, including: +.RS +4 +.TP +.ie t \(bu +.el o +Options that list the set of probes and providers currently published by DTrace +.RE +.RS +4 +.TP +.ie t \(bu +.el o +Options that enable probes directly using any of the probe description specifiers (provider, module, function, name) +.RE +.RS +4 +.TP +.ie t \(bu +.el o +Options that run the D compiler and compile one or more D program files or programs written directly on the command line +.RE +.RS +4 +.TP +.ie t \(bu +.el o +Options that generate anonymous tracing programs +.RE +.RS +4 +.TP +.ie t \(bu +.el o +Options that generate program stability reports +.RE +.RS +4 +.TP +.ie t \(bu +.el o +Options that modify DTrace tracing and buffering behavior and enable additional D compiler features +.RE +.sp +.LP +You can use \fBdtrace\fR to create D scripts by using it in a \fB#!\fR declaration to create an interpreter file. You can also use \fBdtrace\fR to attempt to compile D programs and determine their properties without actually enabling tracing using the \fB-e\fR option. See \fBOPTIONS\fR. See the \fISolaris Dynamic Tracing Guide\fR for detailed examples of how to use the \fBdtrace\fR utility to perform these tasks. +.SH OPTIONS +.sp +.LP +The arguments accepted by the \fB-P\fR, \fB-m\fR, \fB-f\fR, \fB-n\fR, and \fB-i\fR options can include an optional D language \fIpredicate\fR enclosed in slashes \fB//\fR and optional D language \fIaction\fR statement list enclosed in braces \fB{}\fR. D program code specified on the command line must be appropriately quoted to avoid intepretation of meta-characters by the shell. +.sp +.LP +The following options are supported: +.sp +.ne 2 +.mk +.na +\fB\fB-32\fR | \fB-64\fR\fR +.ad +.sp .6 +.RS 4n +The D compiler produces programs using the native data model of the operating system kernel. You can use the \fBisainfo\fR \fB-b\fR command to determine the current operating system data model. If the \fB-32\fR option is specified, \fBdtrace\fR forces +the D compiler to compile a D program using the 32-bit data model. If the \fB-64\fR option is specified, \fBdtrace\fR forces the D compiler to compile a D program using the 64-bit data model. These options are typically not required as \fBdtrace\fR selects the +native data model as the default. The data model affects the sizes of integer types and other language properties. D programs compiled for either data model can be executed on both 32-bit and 64-bit kernels. The \fB-32\fR and \fB-64\fR options also determine the ELF file format +(ELF32 or ELF64) produced by the \fB-G\fR option. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-a\fR\fR +.ad +.sp .6 +.RS 4n +Claim anonymous tracing state and display the traced data. You can combine the \fB-a\fR option with the \fB-e\fR option to force \fBdtrace\fR to exit immediately after consuming the anonymous tracing state rather than continuing to wait for new +data. See the \fISolaris Dynamic Tracing Guide\fR for more information about anonymous tracing. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-A\fR\fR +.ad +.sp .6 +.RS 4n +Generate \fBdriver.conf\fR(4) directives for anonymous tracing. This option constructs a set of \fBdtrace\fR(7D) configuration file directives to enable the specified probes for anonymous tracing and then exits. By default, \fBdtrace\fR attempts to store the directives to the file \fB/kernel/drv/dtrace.conf\fR. You can modify this behavior if you use the \fB-o\fR option to specify an alternate output file. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-b\fR \fIbufsz\fR\fR +.ad +.sp .6 +.RS 4n +Set principal trace buffer size (\fIbufsz\fR). The trace buffer size can include any of the size suffixes \fBk\fR, \fBm\fR, \fBg\fR, or \fBt\fR. If the buffer space cannot be allocated, \fBdtrace\fR attempts +to reduce the buffer size or exit depending on the setting of the \fBbufresize\fR property. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-c\fR \fIcmd\fR\fR +.ad +.sp .6 +.RS 4n +Run the specified command \fIcmd\fR and exit upon its completion. If more than one \fB-c\fR option is present on the command line, \fBdtrace\fR exits when all commands have exited, reporting the exit status for each child process as it +terminates. The process-ID of the first command is made available to any D programs specified on the command line or using the \fB-s\fR option through the \fB$target\fR macro variable. Refer to the \fISolaris Dynamic Tracing Guide\fR for more information +on macro variables. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-C\fR\fR +.ad +.sp .6 +.RS 4n +Run the C preprocessor \fBcpp\fR(1) over D programs before compiling them. You can pass options to the C preprocessor using the \fB-D\fR, \fB-U\fR, \fB-I\fR, and \fB-H\fR options. You can select the degree of C standard conformance if you use the \fB-X\fR option. For a description of the set of tokens defined by the D compiler when invoking the C preprocessor, see \fB-X\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-D\fR \fIname\fR \fB[=\fR\fIvalue\fR\fB]\fR\fR +.ad +.sp .6 +.RS 4n +Define \fIname\fR when invoking \fBcpp\fR(1) (enabled using the \fB-C\fR option). If you specify the equals sign (\fB=\fR) +and additional \fIvalue\fR, the name is assigned the corresponding value. This option passes the \fB-D\fR option to each \fBcpp\fR invocation. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-e\fR\fR +.ad +.sp .6 +.RS 4n +Exit after compiling any requests and consuming anonymous tracing state (\fB-a\fR option) but prior to enabling any probes. You can combine this option with the \fB-a\fR option to print anonymous tracing data and exit. You can also combine this option with D +compiler options. This combination verifies that the programs compile without actually executing them and enabling the corresponding instrumentation. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-f\fR\fB[[\fR\fIprovider\fR\fB:]\fR\fImodule\fR\fB:]\fR\fIfunction\fR\fB[[\fR\fIpredicate\fR\fB]\fR\fIaction\fR\fB]]\fR\fR +.ad +.sp .6 +.RS 4n +Specify function name to trace or list (\fB-l\fR option). The corresponding argument can include any of the probe description forms \fIprovider:module:function\fR, \fImodule:function\fR, or \fIfunction\fR. +Unspecified probe description fields are left blank and match any probes regardless of the values in those fields. If no qualifiers other than \fIfunction\fR are specified in the description, all probes with the corresponding \fIfunction\fR are matched. +The \fB-f\fR argument can be suffixed with an optional D probe clause. You can specify more than one \fB-f\fR option on the command line at a time. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-F\fR\fR +.ad +.sp .6 +.RS 4n +Coalesce trace output by identifying function entry and return. Function entry probe reports are indented and their output is prefixed with \fB->\fR. Function return probe reports are unindented and their output is prefixed with \fB<-\fR\&. System call +entry probe reports are indented and their output is prefixed with \fB=>\fR. System call return probe reports are unindented and their output is prefixed with \fB<=\fR\&. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-G\fR\fR +.ad +.sp .6 +.RS 4n +Generate an ELF file containing an embedded DTrace program. The DTrace probes specified in the program are saved inside of a relocatable ELF object which can be linked into another program. If the \fB-o\fR option is present, the ELF file is saved using the pathname specified +as the argument for this operand. If the \fB-o\fR option is not present and the DTrace program is contained with a file whose name is \fB\fIfilename\fR.d\fR, then the ELF file is saved using the name \fB\fIfilename\fR.o\fR. +Otherwise the ELF file is saved using the name \fBd.out\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-H\fR\fR +.ad +.sp .6 +.RS 4n +Print the pathnames of included files when invoking \fBcpp\fR(1) (enabled using the \fB-C\fR option). This option passes the \fB-H\fR option +to each \fBcpp\fR invocation, causing it to display the list of pathnames, one for each line, to \fBstderr\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-h\fR\fR +.ad +.sp .6 +.RS 4n +Generate a header file containing macros that correspond to probes in the specified provider definitions. This option should be used to generate a header file that is included by other source files for later use with the \fB-G\fR option. If the \fB-o\fR option +is present, the header file is saved using the pathname specified as the argument for that option. If the \fB-o\fR option is not present and the DTrace program is contained with a file whose name is \fIfilename\fR\fB\&.d\fR, then the header file is saved +using the name \fIfilename\fR\fB\&.h\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-i\fR \fIprobe-id\fR\fB[[\fR\fIpredicate\fR] \fIaction\fR\fB]\fR\fR +.ad +.sp .6 +.RS 4n +Specify probe identifier (\fIprobe-id\fR) to trace or list (\fB-l\fR option). You can specify probe IDs using decimal integers as shown by \fBdtrace\fR \fB-l\fR. The \fB-i\fR argument can be suffixed with an optional +D probe clause. You can specify more than one \fB-i\fR option at a time. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-I\fR \fIpath\fR\fR +.ad +.sp .6 +.RS 4n +Add the specified directory \fIpath\fR to the search path for \fB#include\fR files when invoking \fBcpp\fR(1) (enabled +using the \fB-C\fR option). This option passes the \fB-I\fR option to each \fBcpp\fR invocation. The specified \fIpath\fR is inserted into the search path ahead of the default directory list. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-L\fR \fIpath\fR\fR +.ad +.sp .6 +.RS 4n +Add the specified directory \fIpath\fR to the search path for DTrace libraries. DTrace libraries are used to contain common definitions that can be used when writing D programs. The specified \fIpath\fR is added after the default library +search path. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-l\fR\fR +.ad +.sp .6 +.RS 4n +List probes instead of enabling them. If the \fB-l\fR option is specified, \fBdtrace\fR produces a report of the probes matching the descriptions given using the \fB-P\fR, \fB-m\fR, \fB-f\fR, \fB-n\fR, \fB-i\fR, +and \fB-s\fR options. If none of these options are specified, this option lists all probes. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-m\fR [[\fIprovider:\fR] \fImodule:\fR [[\fIpredicate\fR] \fIaction\fR]]\fR +.ad +.sp .6 +.RS 4n +Specify module name to trace or list (\fB-l\fR option). The corresponding argument can include any of the probe description forms \fIprovider:module\fR or \fImodule\fR. Unspecified probe description fields are left blank and match +any probes regardless of the values in those fields. If no qualifiers other than \fImodule\fR are specified in the description, all probes with a corresponding \fImodule\fR are matched. The \fB-m\fR argument can be suffixed with an optional D +probe clause. More than one \fB-m\fR option can be specified on the command line at a time. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-n\fR [[[\fIprovider:\fR] \fImodule:\fR] \fIfunction:\fR] \fIname\fR [[\fIpredicate\fR] \fIaction\fR]\fR +.ad +.sp .6 +.RS 4n +Specify probe name to trace or list (\fB-l\fR option). The corresponding argument can include any of the probe description forms \fIprovider:module:function:name\fR, \fImodule:function:name\fR, \fIfunction:name\fR, +or \fIname\fR. Unspecified probe description fields are left blank and match any probes regardless of the values in those fields. If no qualifiers other than \fIname\fR are specified in the description, all probes with a corresponding \fIname\fR are +matched. The \fB-n\fR argument can be suffixed with an optional D probe clause. More than one \fB-n\fR option can be specified on the command line at a time. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-o\fR \fIoutput\fR\fR +.ad +.sp .6 +.RS 4n +Specify the \fIoutput\fR file for the \fB-A\fR , \fB-G\fR, and \fB-l\fR options, or for the traced data itself. If the \fB-A\fR option is present and \fB-o\fR is not present, the default output file is \fB/kernel/drv/dtrace.conf\fR. If the \fB-G\fR option is present and the \fB-s\fR option's argument is of the form \fB\fIfilename\fR.d\fR and \fB-o\fR is not present, the default output file is \fB\fIfilename\fR.o\fR. +Otherwise the default output file is \fBd.out\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-p\fR \fIpid\fR\fR +.ad +.sp .6 +.RS 4n +Grab the specified process-ID \fIpid\fR, cache its symbol tables, and exit upon its completion. If more than one \fB-p\fR option is present on the command line, \fBdtrace\fR exits when all commands have exited, reporting the exit status +for each process as it terminates. The first process-ID is made available to any D programs specified on the command line or using the \fB-s\fR option through the \fB$target\fR macro variable. Refer to the \fISolaris Dynamic Tracing Guide\fR for +more information on macro variables. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-P\fR \fIprovider\fR \fB[[\fR\fIpredicate\fR\fB]\fR \fIaction\fR]\fR +.ad +.sp .6 +.RS 4n +Specify provider name to trace or list (\fB-l\fR option). The remaining probe description fields module, function, and name are left blank and match any probes regardless of the values in those fields. The \fB-P\fR argument can be suffixed with an optional D +probe clause. You can specify more than one \fB-P\fR option on the command line at a time. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-q\fR\fR +.ad +.sp .6 +.RS 4n +Set quiet mode. \fBdtrace\fR suppresses messages such as the number of probes matched by the specified options and D programs and does not print column headers, the CPU ID, the probe ID, or insert newlines into the output. Only data traced and formatted by D program +statements such as \fBtrace()\fR and \fBprintf()\fR is displayed to \fBstdout\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-s\fR\fR +.ad +.sp .6 +.RS 4n +Compile the specified D program source file. If the \fB-e\fR option is present, the program is compiled but instrumentation is not enabled. If the \fB-l\fR option is present, the program is compiled and the set of probes matched by it is listed, but instrumentation +is not enabled. If none of \fB-e\fR, \fB-l\fR, \fB-G\fR, or \fB-A\fR are present, the instrumentation specified by the D program is enabled and tracing begins. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-S\fR\fR +.ad +.sp .6 +.RS 4n +Show D compiler intermediate code. The D compiler produces a report of the intermediate code generated for each D program to \fBstderr\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-U\fR \fIname\fR\fR +.ad +.sp .6 +.RS 4n +Undefine the specified \fIname\fR when invoking \fBcpp\fR(1) (enabled using the \fB-C\fR option). This option passes the \fB-U\fR option to each \fBcpp\fR invocation. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-v\fR\fR +.ad +.sp .6 +.RS 4n +Set verbose mode. If the \fB-v\fR option is specified, \fBdtrace\fR produces a program stability report showing the minimum interface stability and dependency level for the specified D programs. DTrace stability levels are explained in further detail in the \fISolaris Dynamic Tracing Guide\fR. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-V\fR\fR +.ad +.sp .6 +.RS 4n +Report the highest D programming interface version supported by \fBdtrace\fR. The version information is printed to \fBstdout\fR and the \fBdtrace\fR command exits. Refer to the \fISolaris Dynamic Tracing Guide\fR for +more information about DTrace versioning features. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-w\fR\fR +.ad +.sp .6 +.RS 4n +Permit destructive actions in D programs specified using the \fB-s\fR, \fB-P\fR, \fB-m\fR, \fB-f\fR, \fB-n\fR, or \fB-i\fR options. If the \fB-w\fR option is not specified, \fBdtrace\fR does not +permit the compilation or enabling of a D program that contains destructive actions. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-x\fR \fIarg\fR [\fI=val\fR]\fR +.ad +.sp .6 +.RS 4n +Enable or modify a DTrace runtime option or D compiler option. The list of options is found in the \fISolaris Dynamic Tracing Guide\fR. Boolean options are enabled by specifying their name. Options with values are set by separating the option name and +value with an equals sign (\fB=\fR). +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-X\fR \fBa | c | s | t\fR\fR +.ad +.sp .6 +.RS 4n +Specify the degree of conformance to the ISO C standard that should be selected when invoking \fBcpp\fR(1) (enabled using the \fB-C\fR option). +The \fB-X\fR option argument affects the value and presence of the \fB__STDC__\fR macro depending upon the value of the argument letter. +.sp +The \fB-X\fR option supports the following arguments: +.sp +.ne 2 +.mk +.na +\fB\fBa\fR\fR +.ad +.RS 5n +.rt +Default. ISO C plus K&R compatibility extensions, with semantic changes required by ISO C. This is the default mode if \fB-X\fR is not specified. The predefined macro \fB__STDC__\fR has a value of 0 when \fBcpp\fR is invoked in conjunction +with the \fB-Xa\fR option. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBc\fR\fR +.ad +.RS 5n +.rt +Conformance. Strictly conformant ISO C, without K&R C compatibility extensions. The predefined macro \fB__STDC__\fR has a value of 1 when \fBcpp\fR is invoked in conjunction with the \fB-Xc\fR option. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBs\fR\fR +.ad +.RS 5n +.rt +K&R C only. The macro \fB__STDC__\fR is not defined when \fBcpp\fR is invoked in conjunction with the \fB-Xs\fR option. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBt\fR\fR +.ad +.RS 5n +.rt +Transition. ISO C plus K&R C compatibility extensions, without semantic changes required by ISO C. The predefined macro \fB__STDC__\fR has a value of 0 when \fBcpp\fR is invoked in conjunction with the \fB-Xt\fR option. +.RE + +As the \fB-X\fR option only affects how the D compiler invokes the C preprocessor, the \fB-Xa\fR and \fB-Xt\fR options are equivalent from the perspective of D and both are provided only to ease re-use of settings from a C build environment. +.sp +Regardless of the \fB-X\fR mode, the following additional C preprocessor definitions are always specified and valid in all modes: +.RS +4 +.TP +.ie t \(bu +.el o +\fB__sun\fR +.RE +.RS +4 +.TP +.ie t \(bu +.el o +\fB__unix\fR +.RE +.RS +4 +.TP +.ie t \(bu +.el o +\fB__SVR4\fR +.RE +.RS +4 +.TP +.ie t \(bu +.el o +\fB__sparc\fR (on SPARC systems only) +.RE +.RS +4 +.TP +.ie t \(bu +.el o +\fB__sparcv9\fR (on SPARC systems only when 64-bit programs are compiled) +.RE +.RS +4 +.TP +.ie t \(bu +.el o +\fB__i386\fR (on x86 systems only when 32-bit programs are compiled) +.RE +.RS +4 +.TP +.ie t \(bu +.el o +\fB__amd64\fR (on x86 systems only when 64-bit programs are compiled) +.RE +.RS +4 +.TP +.ie t \(bu +.el o +\fB__\fI`uname -s`\fR_\fI`uname -r`\fR\fR (for example, \fB__SunOS_5_10\fR) +.RE +.RS +4 +.TP +.ie t \(bu +.el o +\fB__SUNW_D=1\fR +.RE +.RS +4 +.TP +.ie t \(bu +.el o +\fB__SUNW_D_VERSION=0x\fIMMmmmuuu\fR\fR +.sp +Where \fIMM\fR is the major release value in hexadecimal, \fImmm\fR is the minor release value in hexadecimal, and \fIuuu\fR is the +micro release value in hexadecimal. Refer to the \fISolaris Dynamic Tracing Guide\fR for more information about DTrace versioning. +.RE +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB-Z\fR\fR +.ad +.sp .6 +.RS 4n +Permit probe descriptions that match zero probes. If the \fB-Z\fR option is not specified, \fBdtrace\fR reports an error and exits if any probe descriptions specified in D program files (\fB-s\fR option) or on the command line (\fB-P\fR, \fB-m\fR, \fB-f\fR, \fB-n\fR, or \fB-i\fR options) contain descriptions that do not match any known probes. +.RE + +.SH OPERANDS +.sp +.LP +You can specify zero or more additional arguments on the \fBdtrace\fR command line to define a set of macro variables (\fB$1\fR, \fB$2\fR, and so forth). The additional arguments can be used in D programs specified using the \fB-s\fR option +or on the command line. The use of macro variables is described further in the \fISolaris Dynamic Tracing Guide\fR. +.SH EXIT STATUS +.sp +.LP +The following exit values are returned: +.sp +.ne 2 +.mk +.na +\fB0\fR +.ad +.RS 5n +.rt +Successful completion. +.sp +For D program requests, an exit status of \fB0\fR indicates that programs were successfully compiled, probes were successfully enabled, or anonymous state was successfully retrieved. \fBdtrace\fR returns \fB0\fR even if the specified tracing requests +encountered errors or drops. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB1\fR\fR +.ad +.RS 5n +.rt +An error occurred. +.sp +For D program requests, an exit status of \fB1\fR indicates that program compilation failed or that the specified request could not be satisfied. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fB2\fR\fR +.ad +.RS 5n +.rt +Invalid command line options or arguments were specified. +.RE + +.SH ATTRIBUTES +.sp +.LP +See \fBattributes\fR(5) for descriptions of the following attributes: +.sp + +.sp +.TS +tab() box; +cw(2.75i) |cw(2.75i) +lw(2.75i) |lw(2.75i) +. +ATTRIBUTE TYPEATTRIBUTE VALUE +_ +AvailabilitySUNWdtrc +_ +Interface StabilitySee below. +.TE + +.sp +.LP +The command-line syntax is Committed. The human-readable output is Uncommitted. +.SH SEE ALSO +.sp +.LP +\fBcpp\fR(1), \fBisainfo\fR(1), \fBlibdtrace\fR(3LIB), \fBdriver.conf\fR(4), \fBattributes\fR(5), \fBdtrace\fR(7D) +.sp +.LP +\fISolaris Dynamic Tracing Guide\fR diff --git a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c new file mode 100644 index 000000000000..f909e229b5f2 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c @@ -0,0 +1,1898 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(sun) +#include +#endif +#include +#if defined(sun) +#include +#endif + +typedef struct dtrace_cmd { + void (*dc_func)(struct dtrace_cmd *); /* function to compile arg */ + dtrace_probespec_t dc_spec; /* probe specifier context */ + char *dc_arg; /* argument from main argv */ + const char *dc_name; /* name for error messages */ + const char *dc_desc; /* desc for error messages */ + dtrace_prog_t *dc_prog; /* program compiled from arg */ + char dc_ofile[PATH_MAX]; /* derived output file name */ +} dtrace_cmd_t; + +#define DMODE_VERS 0 /* display version information and exit (-V) */ +#define DMODE_EXEC 1 /* compile program for enabling (-a/e/E) */ +#define DMODE_ANON 2 /* compile program for anonymous tracing (-A) */ +#define DMODE_LINK 3 /* compile program for linking with ELF (-G) */ +#define DMODE_LIST 4 /* compile program and list probes (-l) */ +#define DMODE_HEADER 5 /* compile program for headergen (-h) */ + +#define E_SUCCESS 0 +#define E_ERROR 1 +#define E_USAGE 2 + +static const char DTRACE_OPTSTR[] = + "3:6:aAb:Bc:CD:ef:FGhHi:I:lL:m:n:o:p:P:qs:SU:vVwx:X:Z"; + +static char **g_argv; +static int g_argc; +static char **g_objv; +static int g_objc; +static dtrace_cmd_t *g_cmdv; +static int g_cmdc; +static struct ps_prochandle **g_psv; +static int g_psc; +static int g_pslive; +static char *g_pname; +static int g_quiet; +static int g_flowindent; +static int g_intr; +static int g_impatient; +static int g_newline; +static int g_total; +static int g_cflags; +static int g_oflags; +static int g_verbose; +static int g_exec = 1; +static int g_mode = DMODE_EXEC; +static int g_status = E_SUCCESS; +static int g_grabanon = 0; +static const char *g_ofile = NULL; +static FILE *g_ofp; +static dtrace_hdl_t *g_dtp; +#if defined(sun) +static char *g_etcfile = "/etc/system"; +static const char *g_etcbegin = "* vvvv Added by DTrace"; +static const char *g_etcend = "* ^^^^ Added by DTrace"; + +static const char *g_etc[] = { +"*", +"* The following forceload directives were added by dtrace(1M) to allow for", +"* tracing during boot. If these directives are removed, the system will", +"* continue to function, but tracing will not occur during boot as desired.", +"* To remove these directives (and this block comment) automatically, run", +"* \"dtrace -A\" without additional arguments. See the \"Anonymous Tracing\"", +"* chapter of the Solaris Dynamic Tracing Guide for details.", +"*", +NULL }; +#endif + +static int +usage(FILE *fp) +{ + static const char predact[] = "[[ predicate ] action ]"; + + (void) fprintf(fp, "Usage: %s [-32|-64] [-aACeFGhHlqSvVwZ] " + "[-b bufsz] [-c cmd] [-D name[=def]]\n\t[-I path] [-L path] " + "[-o output] [-p pid] [-s script] [-U name]\n\t" + "[-x opt[=val]] [-X a|c|s|t]\n\n" + "\t[-P provider %s]\n" + "\t[-m [ provider: ] module %s]\n" + "\t[-f [[ provider: ] module: ] func %s]\n" + "\t[-n [[[ provider: ] module: ] func: ] name %s]\n" + "\t[-i probe-id %s] [ args ... ]\n\n", g_pname, + predact, predact, predact, predact, predact); + + (void) fprintf(fp, "\tpredicate -> '/' D-expression '/'\n"); + (void) fprintf(fp, "\t action -> '{' D-statements '}'\n"); + + (void) fprintf(fp, "\n" + "\t-32 generate 32-bit D programs and ELF files\n" + "\t-64 generate 64-bit D programs and ELF files\n\n" + "\t-a claim anonymous tracing state\n" + "\t-A generate driver.conf(4) directives for anonymous tracing\n" + "\t-b set trace buffer size\n" + "\t-c run specified command and exit upon its completion\n" + "\t-C run cpp(1) preprocessor on script files\n" + "\t-D define symbol when invoking preprocessor\n" + "\t-e exit after compiling request but prior to enabling probes\n" + "\t-f enable or list probes matching the specified function name\n" + "\t-F coalesce trace output by function\n" + "\t-G generate an ELF file containing embedded dtrace program\n" + "\t-h generate a header file with definitions for static probes\n" + "\t-H print included files when invoking preprocessor\n" + "\t-i enable or list probes matching the specified probe id\n" + "\t-I add include directory to preprocessor search path\n" + "\t-l list probes matching specified criteria\n" + "\t-L add library directory to library search path\n" + "\t-m enable or list probes matching the specified module name\n" + "\t-n enable or list probes matching the specified probe name\n" + "\t-o set output file\n" + "\t-p grab specified process-ID and cache its symbol tables\n" + "\t-P enable or list probes matching the specified provider name\n" + "\t-q set quiet mode (only output explicitly traced data)\n" + "\t-s enable or list probes according to the specified D script\n" + "\t-S print D compiler intermediate code\n" + "\t-U undefine symbol when invoking preprocessor\n" + "\t-v set verbose mode (report stability attributes, arguments)\n" + "\t-V report DTrace API version\n" + "\t-w permit destructive actions\n" + "\t-x enable or modify compiler and tracing options\n" + "\t-X specify ISO C conformance settings for preprocessor\n" + "\t-Z permit probe descriptions that match zero probes\n"); + + return (E_USAGE); +} + +static void +verror(const char *fmt, va_list ap) +{ + int error = errno; + + (void) fprintf(stderr, "%s: ", g_pname); + (void) vfprintf(stderr, fmt, ap); + + if (fmt[strlen(fmt) - 1] != '\n') + (void) fprintf(stderr, ": %s\n", strerror(error)); +} + +/*PRINTFLIKE1*/ +static void +fatal(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + verror(fmt, ap); + va_end(ap); + + exit(E_ERROR); +} + +/*PRINTFLIKE1*/ +static void +dfatal(const char *fmt, ...) +{ +#if !defined(sun) && defined(NEED_ERRLOC) + char *p_errfile = NULL; + int errline = 0; +#endif + va_list ap; + + va_start(ap, fmt); + + (void) fprintf(stderr, "%s: ", g_pname); + if (fmt != NULL) + (void) vfprintf(stderr, fmt, ap); + + va_end(ap); + + if (fmt != NULL && fmt[strlen(fmt) - 1] != '\n') { + (void) fprintf(stderr, ": %s\n", + dtrace_errmsg(g_dtp, dtrace_errno(g_dtp))); + } else if (fmt == NULL) { + (void) fprintf(stderr, "%s\n", + dtrace_errmsg(g_dtp, dtrace_errno(g_dtp))); + } +#if !defined(sun) && defined(NEED_ERRLOC) + dt_get_errloc(g_dtp, &p_errfile, &errline); + if (p_errfile != NULL) + printf("File '%s', line %d\n", p_errfile, errline); +#endif + + /* + * Close the DTrace handle to ensure that any controlled processes are + * correctly restored and continued. + */ + dtrace_close(g_dtp); + + exit(E_ERROR); +} + +/*PRINTFLIKE1*/ +static void +error(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + verror(fmt, ap); + va_end(ap); +} + +/*PRINTFLIKE1*/ +static void +notice(const char *fmt, ...) +{ + va_list ap; + + if (g_quiet) + return; /* -q or quiet pragma suppresses notice()s */ + + va_start(ap, fmt); + verror(fmt, ap); + va_end(ap); +} + +/*PRINTFLIKE1*/ +static void +oprintf(const char *fmt, ...) +{ + va_list ap; + int n; + + if (g_ofp == NULL) + return; + + va_start(ap, fmt); + n = vfprintf(g_ofp, fmt, ap); + va_end(ap); + + if (n < 0) { + if (errno != EINTR) { + fatal("failed to write to %s", + g_ofile ? g_ofile : ""); + } + clearerr(g_ofp); + } +} + +static char ** +make_argv(char *s) +{ + const char *ws = "\f\n\r\t\v "; + char **argv = malloc(sizeof (char *) * (strlen(s) / 2 + 1)); + int argc = 0; + char *p = s; + + if (argv == NULL) + return (NULL); + + for (p = strtok(s, ws); p != NULL; p = strtok(NULL, ws)) + argv[argc++] = p; + + if (argc == 0) + argv[argc++] = s; + + argv[argc] = NULL; + return (argv); +} + +static void +dof_prune(const char *fname) +{ + struct stat sbuf; + size_t sz, i, j, mark, len; + char *buf; + int msg = 0, fd; + + if ((fd = open(fname, O_RDONLY)) == -1) { + /* + * This is okay only if the file doesn't exist at all. + */ + if (errno != ENOENT) + fatal("failed to open %s", fname); + return; + } + + if (fstat(fd, &sbuf) == -1) + fatal("failed to fstat %s", fname); + + if ((buf = malloc((sz = sbuf.st_size) + 1)) == NULL) + fatal("failed to allocate memory for %s", fname); + + if (read(fd, buf, sz) != sz) + fatal("failed to read %s", fname); + + buf[sz] = '\0'; + (void) close(fd); + + if ((fd = open(fname, O_WRONLY | O_TRUNC)) == -1) + fatal("failed to open %s for writing", fname); + + len = strlen("dof-data-"); + + for (mark = 0, i = 0; i < sz; i++) { + if (strncmp(&buf[i], "dof-data-", len) != 0) + continue; + + /* + * This is only a match if it's in the 0th column. + */ + if (i != 0 && buf[i - 1] != '\n') + continue; + + if (msg++ == 0) { + error("cleaned up old anonymous " + "enabling in %s\n", fname); + } + + /* + * We have a match. First write out our data up until now. + */ + if (i != mark) { + if (write(fd, &buf[mark], i - mark) != i - mark) + fatal("failed to write to %s", fname); + } + + /* + * Now scan forward until we scan past a newline. + */ + for (j = i; j < sz && buf[j] != '\n'; j++) + continue; + + /* + * Reset our mark. + */ + if ((mark = j + 1) >= sz) + break; + + i = j; + } + + if (mark < sz) { + if (write(fd, &buf[mark], sz - mark) != sz - mark) + fatal("failed to write to %s", fname); + } + + (void) close(fd); + free(buf); +} + +#if defined(sun) +static void +etcsystem_prune(void) +{ + struct stat sbuf; + size_t sz; + char *buf, *start, *end; + int fd; + char *fname = g_etcfile, *tmpname; + + if ((fd = open(fname, O_RDONLY)) == -1) + fatal("failed to open %s", fname); + + if (fstat(fd, &sbuf) == -1) + fatal("failed to fstat %s", fname); + + if ((buf = malloc((sz = sbuf.st_size) + 1)) == NULL) + fatal("failed to allocate memory for %s", fname); + + if (read(fd, buf, sz) != sz) + fatal("failed to read %s", fname); + + buf[sz] = '\0'; + (void) close(fd); + + if ((start = strstr(buf, g_etcbegin)) == NULL) + goto out; + + if (strlen(buf) != sz) { + fatal("embedded nul byte in %s; manual repair of %s " + "required\n", fname, fname); + } + + if (strstr(start + 1, g_etcbegin) != NULL) { + fatal("multiple start sentinels in %s; manual repair of %s " + "required\n", fname, fname); + } + + if ((end = strstr(buf, g_etcend)) == NULL) { + fatal("missing end sentinel in %s; manual repair of %s " + "required\n", fname, fname); + } + + if (start > end) { + fatal("end sentinel preceeds start sentinel in %s; manual " + "repair of %s required\n", fname, fname); + } + + end += strlen(g_etcend) + 1; + bcopy(end, start, strlen(end) + 1); + + tmpname = alloca(sz = strlen(fname) + 80); + (void) snprintf(tmpname, sz, "%s.dtrace.%d", fname, getpid()); + + if ((fd = open(tmpname, + O_WRONLY | O_CREAT | O_EXCL, sbuf.st_mode)) == -1) + fatal("failed to create %s", tmpname); + + if (write(fd, buf, strlen(buf)) < strlen(buf)) { + (void) unlink(tmpname); + fatal("failed to write to %s", tmpname); + } + + (void) close(fd); + + if (chown(tmpname, sbuf.st_uid, sbuf.st_gid) != 0) { + (void) unlink(tmpname); + fatal("failed to chown(2) %s to uid %d, gid %d", tmpname, + (int)sbuf.st_uid, (int)sbuf.st_gid); + } + + if (rename(tmpname, fname) == -1) + fatal("rename of %s to %s failed", tmpname, fname); + + error("cleaned up forceload directives in %s\n", fname); +out: + free(buf); +} + +static void +etcsystem_add(void) +{ + const char *mods[20]; + int nmods, line; + + if ((g_ofp = fopen(g_ofile = g_etcfile, "a")) == NULL) + fatal("failed to open output file '%s'", g_ofile); + + oprintf("%s\n", g_etcbegin); + + for (line = 0; g_etc[line] != NULL; line++) + oprintf("%s\n", g_etc[line]); + + nmods = dtrace_provider_modules(g_dtp, mods, + sizeof (mods) / sizeof (char *) - 1); + + if (nmods >= sizeof (mods) / sizeof (char *)) + fatal("unexpectedly large number of modules!"); + + mods[nmods++] = "dtrace"; + + for (line = 0; line < nmods; line++) + oprintf("forceload: drv/%s\n", mods[line]); + + oprintf("%s\n", g_etcend); + + if (fclose(g_ofp) == EOF) + fatal("failed to close output file '%s'", g_ofile); + + error("added forceload directives to %s\n", g_ofile); +} +#endif + +static void +print_probe_info(const dtrace_probeinfo_t *p) +{ + char buf[BUFSIZ]; + int i; + + oprintf("\n\tProbe Description Attributes\n"); + + oprintf("\t\tIdentifier Names: %s\n", + dtrace_stability_name(p->dtp_attr.dtat_name)); + oprintf("\t\tData Semantics: %s\n", + dtrace_stability_name(p->dtp_attr.dtat_data)); + oprintf("\t\tDependency Class: %s\n", + dtrace_class_name(p->dtp_attr.dtat_class)); + + oprintf("\n\tArgument Attributes\n"); + + oprintf("\t\tIdentifier Names: %s\n", + dtrace_stability_name(p->dtp_arga.dtat_name)); + oprintf("\t\tData Semantics: %s\n", + dtrace_stability_name(p->dtp_arga.dtat_data)); + oprintf("\t\tDependency Class: %s\n", + dtrace_class_name(p->dtp_arga.dtat_class)); + + oprintf("\n\tArgument Types\n"); + + for (i = 0; i < p->dtp_argc; i++) { + if (ctf_type_name(p->dtp_argv[i].dtt_ctfp, + p->dtp_argv[i].dtt_type, buf, sizeof (buf)) == NULL) + (void) strlcpy(buf, "(unknown)", sizeof (buf)); + oprintf("\t\targs[%d]: %s\n", i, buf); + } + + if (p->dtp_argc == 0) + oprintf("\t\tNone\n"); + + oprintf("\n"); +} + +/*ARGSUSED*/ +static int +info_stmt(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, + dtrace_stmtdesc_t *stp, dtrace_ecbdesc_t **last) +{ + dtrace_ecbdesc_t *edp = stp->dtsd_ecbdesc; + dtrace_probedesc_t *pdp = &edp->dted_probe; + dtrace_probeinfo_t p; + + if (edp == *last) + return (0); + + oprintf("\n%s:%s:%s:%s\n", + pdp->dtpd_provider, pdp->dtpd_mod, pdp->dtpd_func, pdp->dtpd_name); + + if (dtrace_probe_info(dtp, pdp, &p) == 0) + print_probe_info(&p); + + *last = edp; + return (0); +} + +/* + * Execute the specified program by enabling the corresponding instrumentation. + * If -e has been specified, we get the program info but do not enable it. If + * -v has been specified, we print a stability report for the program. + */ +static void +exec_prog(const dtrace_cmd_t *dcp) +{ + dtrace_ecbdesc_t *last = NULL; + dtrace_proginfo_t dpi; + + if (!g_exec) { + dtrace_program_info(g_dtp, dcp->dc_prog, &dpi); + } else if (dtrace_program_exec(g_dtp, dcp->dc_prog, &dpi) == -1) { + dfatal("failed to enable '%s'", dcp->dc_name); + } else { + notice("%s '%s' matched %u probe%s\n", + dcp->dc_desc, dcp->dc_name, + dpi.dpi_matches, dpi.dpi_matches == 1 ? "" : "s"); + } + + if (g_verbose) { + oprintf("\nStability attributes for %s %s:\n", + dcp->dc_desc, dcp->dc_name); + + oprintf("\n\tMinimum Probe Description Attributes\n"); + oprintf("\t\tIdentifier Names: %s\n", + dtrace_stability_name(dpi.dpi_descattr.dtat_name)); + oprintf("\t\tData Semantics: %s\n", + dtrace_stability_name(dpi.dpi_descattr.dtat_data)); + oprintf("\t\tDependency Class: %s\n", + dtrace_class_name(dpi.dpi_descattr.dtat_class)); + + oprintf("\n\tMinimum Statement Attributes\n"); + + oprintf("\t\tIdentifier Names: %s\n", + dtrace_stability_name(dpi.dpi_stmtattr.dtat_name)); + oprintf("\t\tData Semantics: %s\n", + dtrace_stability_name(dpi.dpi_stmtattr.dtat_data)); + oprintf("\t\tDependency Class: %s\n", + dtrace_class_name(dpi.dpi_stmtattr.dtat_class)); + + if (!g_exec) { + (void) dtrace_stmt_iter(g_dtp, dcp->dc_prog, + (dtrace_stmt_f *)info_stmt, &last); + } else + oprintf("\n"); + } + + g_total += dpi.dpi_matches; +} + +/* + * Print out the specified DOF buffer as a set of ASCII bytes appropriate for + * storing in a driver.conf(4) file associated with the dtrace driver. + */ +static void +anon_prog(const dtrace_cmd_t *dcp, dof_hdr_t *dof, int n) +{ + const uchar_t *p, *q; + + if (dof == NULL) + dfatal("failed to create DOF image for '%s'", dcp->dc_name); + + p = (uchar_t *)dof; + q = p + dof->dofh_loadsz; + +#if defined(sun) + oprintf("dof-data-%d=0x%x", n, *p++); + + while (p < q) + oprintf(",0x%x", *p++); + + oprintf(";\n"); +#else + /* + * On FreeBSD, the DOF data is handled as a kernel environment (kenv) + * string. We use two hex characters per DOF byte. + */ + oprintf("dof-data-%d=%02x", n, *p++); + + while (p < q) + oprintf("%02x", *p++); + + oprintf("\n"); +#endif + + dtrace_dof_destroy(g_dtp, dof); +} + +/* + * Link the specified D program in DOF form into an ELF file for use in either + * helpers, userland provider definitions, or both. If -o was specified, that + * path is used as the output file name. If -o wasn't specified and the input + * program is from a script whose name is %.d, use basename(%.o) as the output + * file name. Otherwise we use "d.out" as the default output file name. + */ +static void +link_prog(dtrace_cmd_t *dcp) +{ + char *p; + + if (g_cmdc == 1 && g_ofile != NULL) { + (void) strlcpy(dcp->dc_ofile, g_ofile, sizeof (dcp->dc_ofile)); + } else if ((p = strrchr(dcp->dc_arg, '.')) != NULL && + strcmp(p, ".d") == 0) { + p[0] = '\0'; /* strip .d suffix */ + (void) snprintf(dcp->dc_ofile, sizeof (dcp->dc_ofile), + "%s.o", basename(dcp->dc_arg)); + } else { + (void) snprintf(dcp->dc_ofile, sizeof (dcp->dc_ofile), + g_cmdc > 1 ? "%s.%d" : "%s", "d.out", (int)(dcp - g_cmdv)); + } + + if (dtrace_program_link(g_dtp, dcp->dc_prog, DTRACE_D_PROBES, + dcp->dc_ofile, g_objc, g_objv) != 0) + dfatal("failed to link %s %s", dcp->dc_desc, dcp->dc_name); +} + +/*ARGSUSED*/ +static int +list_probe(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp, void *arg) +{ + dtrace_probeinfo_t p; + + oprintf("%5d %10s %17s %33s %s\n", pdp->dtpd_id, + pdp->dtpd_provider, pdp->dtpd_mod, pdp->dtpd_func, pdp->dtpd_name); + + if (g_verbose && dtrace_probe_info(dtp, pdp, &p) == 0) + print_probe_info(&p); + + return (0); +} + +/*ARGSUSED*/ +static int +list_stmt(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, + dtrace_stmtdesc_t *stp, dtrace_ecbdesc_t **last) +{ + dtrace_ecbdesc_t *edp = stp->dtsd_ecbdesc; + + if (edp == *last) + return (0); + + if (dtrace_probe_iter(g_dtp, &edp->dted_probe, list_probe, NULL) != 0) { + error("failed to match %s:%s:%s:%s: %s\n", + edp->dted_probe.dtpd_provider, edp->dted_probe.dtpd_mod, + edp->dted_probe.dtpd_func, edp->dted_probe.dtpd_name, + dtrace_errmsg(dtp, dtrace_errno(dtp))); + } + + *last = edp; + return (0); +} + +/* + * List the probes corresponding to the specified program by iterating over + * each statement and then matching probes to the statement probe descriptions. + */ +static void +list_prog(const dtrace_cmd_t *dcp) +{ + dtrace_ecbdesc_t *last = NULL; + + (void) dtrace_stmt_iter(g_dtp, dcp->dc_prog, + (dtrace_stmt_f *)list_stmt, &last); +} + +static void +compile_file(dtrace_cmd_t *dcp) +{ + char *arg0; + FILE *fp; + + if ((fp = fopen(dcp->dc_arg, "r")) == NULL) + fatal("failed to open %s", dcp->dc_arg); + + arg0 = g_argv[0]; + g_argv[0] = dcp->dc_arg; + + if ((dcp->dc_prog = dtrace_program_fcompile(g_dtp, fp, + g_cflags, g_argc, g_argv)) == NULL) + dfatal("failed to compile script %s", dcp->dc_arg); + + g_argv[0] = arg0; + (void) fclose(fp); + + dcp->dc_desc = "script"; + dcp->dc_name = dcp->dc_arg; +} + +static void +compile_str(dtrace_cmd_t *dcp) +{ + char *p; + + if ((dcp->dc_prog = dtrace_program_strcompile(g_dtp, dcp->dc_arg, + dcp->dc_spec, g_cflags | DTRACE_C_PSPEC, g_argc, g_argv)) == NULL) + dfatal("invalid probe specifier %s", dcp->dc_arg); + + if ((p = strpbrk(dcp->dc_arg, "{/;")) != NULL) + *p = '\0'; /* crop name for reporting */ + + dcp->dc_desc = "description"; + dcp->dc_name = dcp->dc_arg; +} + +/*ARGSUSED*/ +static void +prochandler(struct ps_prochandle *P, const char *msg, void *arg) +{ +fatal("DOODAD in function %s, file %s, line %d\n",__FUNCTION__,__FILE__,__LINE__); +#ifdef DOODAD + const psinfo_t *prp = Ppsinfo(P); + int pid = Pstatus(P)->pr_pid; + char name[SIG2STR_MAX]; + + if (msg != NULL) { + notice("pid %d: %s\n", pid, msg); + return; + } + + switch (Pstate(P)) { + case PS_UNDEAD: + /* + * Ideally we would like to always report pr_wstat here, but it + * isn't possible given current /proc semantics. If we grabbed + * the process, Ppsinfo() will either fail or return a zeroed + * psinfo_t depending on how far the parent is in reaping it. + * When /proc provides a stable pr_wstat in the status file, + * this code can be improved by examining this new pr_wstat. + */ + if (prp != NULL && WIFSIGNALED(prp->pr_wstat)) { + notice("pid %d terminated by %s\n", pid, + proc_signame(WTERMSIG(prp->pr_wstat), + name, sizeof (name))); + } else if (prp != NULL && WEXITSTATUS(prp->pr_wstat) != 0) { + notice("pid %d exited with status %d\n", + pid, WEXITSTATUS(prp->pr_wstat)); + } else { + notice("pid %d has exited\n", pid); + } + g_pslive--; + break; + + case PS_LOST: + notice("pid %d exec'd a set-id or unobservable program\n", pid); + g_pslive--; + break; + } +#endif +} + +/*ARGSUSED*/ +static int +errhandler(const dtrace_errdata_t *data, void *arg) +{ + error(data->dteda_msg); + return (DTRACE_HANDLE_OK); +} + +/*ARGSUSED*/ +static int +drophandler(const dtrace_dropdata_t *data, void *arg) +{ + error(data->dtdda_msg); + return (DTRACE_HANDLE_OK); +} + +/*ARGSUSED*/ +static int +setopthandler(const dtrace_setoptdata_t *data, void *arg) +{ + if (strcmp(data->dtsda_option, "quiet") == 0) + g_quiet = data->dtsda_newval != DTRACEOPT_UNSET; + + if (strcmp(data->dtsda_option, "flowindent") == 0) + g_flowindent = data->dtsda_newval != DTRACEOPT_UNSET; + + return (DTRACE_HANDLE_OK); +} + +#define BUFDUMPHDR(hdr) \ + (void) printf("%s: %s%s\n", g_pname, hdr, strlen(hdr) > 0 ? ":" : ""); + +#define BUFDUMPSTR(ptr, field) \ + (void) printf("%s: %20s => ", g_pname, #field); \ + if ((ptr)->field != NULL) { \ + const char *c = (ptr)->field; \ + (void) printf("\""); \ + do { \ + if (*c == '\n') { \ + (void) printf("\\n"); \ + continue; \ + } \ + \ + (void) printf("%c", *c); \ + } while (*c++ != '\0'); \ + (void) printf("\"\n"); \ + } else { \ + (void) printf("\n"); \ + } + +#define BUFDUMPASSTR(ptr, field, str) \ + (void) printf("%s: %20s => %s\n", g_pname, #field, str); + +#define BUFDUMP(ptr, field) \ + (void) printf("%s: %20s => %lld\n", g_pname, #field, \ + (long long)(ptr)->field); + +#define BUFDUMPPTR(ptr, field) \ + (void) printf("%s: %20s => %s\n", g_pname, #field, \ + (ptr)->field != NULL ? "" : ""); + +/*ARGSUSED*/ +static int +bufhandler(const dtrace_bufdata_t *bufdata, void *arg) +{ + const dtrace_aggdata_t *agg = bufdata->dtbda_aggdata; + const dtrace_recdesc_t *rec = bufdata->dtbda_recdesc; + const dtrace_probedesc_t *pd; + uint32_t flags = bufdata->dtbda_flags; + char buf[512], *c = buf, *end = c + sizeof (buf); + int i, printed; + + struct { + const char *name; + uint32_t value; + } flagnames[] = { + { "AGGVAL", DTRACE_BUFDATA_AGGVAL }, + { "AGGKEY", DTRACE_BUFDATA_AGGKEY }, + { "AGGFORMAT", DTRACE_BUFDATA_AGGFORMAT }, + { "AGGLAST", DTRACE_BUFDATA_AGGLAST }, + { "???", UINT32_MAX }, + { NULL } + }; + + if (bufdata->dtbda_probe != NULL) { + pd = bufdata->dtbda_probe->dtpda_pdesc; + } else if (agg != NULL) { + pd = agg->dtada_pdesc; + } else { + pd = NULL; + } + + BUFDUMPHDR(">>> Called buffer handler"); + BUFDUMPHDR(""); + + BUFDUMPHDR(" dtrace_bufdata"); + BUFDUMPSTR(bufdata, dtbda_buffered); + BUFDUMPPTR(bufdata, dtbda_probe); + BUFDUMPPTR(bufdata, dtbda_aggdata); + BUFDUMPPTR(bufdata, dtbda_recdesc); + + (void) snprintf(c, end - c, "0x%x ", bufdata->dtbda_flags); + c += strlen(c); + + for (i = 0, printed = 0; flagnames[i].name != NULL; i++) { + if (!(flags & flagnames[i].value)) + continue; + + (void) snprintf(c, end - c, + "%s%s", printed++ ? " | " : "(", flagnames[i].name); + c += strlen(c); + flags &= ~flagnames[i].value; + } + + if (printed) + (void) snprintf(c, end - c, ")"); + + BUFDUMPASSTR(bufdata, dtbda_flags, buf); + BUFDUMPHDR(""); + + if (pd != NULL) { + BUFDUMPHDR(" dtrace_probedesc"); + BUFDUMPSTR(pd, dtpd_provider); + BUFDUMPSTR(pd, dtpd_mod); + BUFDUMPSTR(pd, dtpd_func); + BUFDUMPSTR(pd, dtpd_name); + BUFDUMPHDR(""); + } + + if (rec != NULL) { + BUFDUMPHDR(" dtrace_recdesc"); + BUFDUMP(rec, dtrd_action); + BUFDUMP(rec, dtrd_size); + + if (agg != NULL) { + uint8_t *data; + int lim = rec->dtrd_size; + + (void) sprintf(buf, "%d (data: ", rec->dtrd_offset); + c = buf + strlen(buf); + + if (lim > sizeof (uint64_t)) + lim = sizeof (uint64_t); + + data = (uint8_t *)agg->dtada_data + rec->dtrd_offset; + + for (i = 0; i < lim; i++) { + (void) snprintf(c, end - c, "%s%02x", + i == 0 ? "" : " ", *data++); + c += strlen(c); + } + + (void) snprintf(c, end - c, + "%s)", lim < rec->dtrd_size ? " ..." : ""); + BUFDUMPASSTR(rec, dtrd_offset, buf); + } else { + BUFDUMP(rec, dtrd_offset); + } + + BUFDUMPHDR(""); + } + + if (agg != NULL) { + dtrace_aggdesc_t *desc = agg->dtada_desc; + + BUFDUMPHDR(" dtrace_aggdesc"); + BUFDUMPSTR(desc, dtagd_name); + BUFDUMP(desc, dtagd_varid); + BUFDUMP(desc, dtagd_id); + BUFDUMP(desc, dtagd_nrecs); + BUFDUMPHDR(""); + } + + return (DTRACE_HANDLE_OK); +} + +/*ARGSUSED*/ +static int +chewrec(const dtrace_probedata_t *data, const dtrace_recdesc_t *rec, void *arg) +{ + dtrace_actkind_t act; + uintptr_t addr; + + if (rec == NULL) { + /* + * We have processed the final record; output the newline if + * we're not in quiet mode. + */ + if (!g_quiet) + oprintf("\n"); + + return (DTRACE_CONSUME_NEXT); + } + + act = rec->dtrd_action; + addr = (uintptr_t)data->dtpda_data; + + if (act == DTRACEACT_EXIT) { + g_status = *((uint32_t *)addr); + return (DTRACE_CONSUME_NEXT); + } + + return (DTRACE_CONSUME_THIS); +} + +/*ARGSUSED*/ +static int +chew(const dtrace_probedata_t *data, void *arg) +{ + dtrace_probedesc_t *pd = data->dtpda_pdesc; + processorid_t cpu = data->dtpda_cpu; + static int heading; + + if (g_impatient) { + g_newline = 0; + return (DTRACE_CONSUME_ABORT); + } + + if (heading == 0) { + if (!g_flowindent) { + if (!g_quiet) { + oprintf("%3s %6s %32s\n", + "CPU", "ID", "FUNCTION:NAME"); + } + } else { + oprintf("%3s %-41s\n", "CPU", "FUNCTION"); + } + heading = 1; + } + + if (!g_flowindent) { + if (!g_quiet) { + char name[DTRACE_FUNCNAMELEN + DTRACE_NAMELEN + 2]; + + (void) snprintf(name, sizeof (name), "%s:%s", + pd->dtpd_func, pd->dtpd_name); + + oprintf("%3d %6d %32s ", cpu, pd->dtpd_id, name); + } + } else { + int indent = data->dtpda_indent; + char *name; + size_t len; + + if (data->dtpda_flow == DTRACEFLOW_NONE) { + len = indent + DTRACE_FUNCNAMELEN + DTRACE_NAMELEN + 5; + name = alloca(len); + (void) snprintf(name, len, "%*s%s%s:%s", indent, "", + data->dtpda_prefix, pd->dtpd_func, + pd->dtpd_name); + } else { + len = indent + DTRACE_FUNCNAMELEN + 5; + name = alloca(len); + (void) snprintf(name, len, "%*s%s%s", indent, "", + data->dtpda_prefix, pd->dtpd_func); + } + + oprintf("%3d %-41s ", cpu, name); + } + + return (DTRACE_CONSUME_THIS); +} + +static void +go(void) +{ + int i; + + struct { + char *name; + char *optname; + dtrace_optval_t val; + } bufs[] = { + { "buffer size", "bufsize" }, + { "aggregation size", "aggsize" }, + { "speculation size", "specsize" }, + { "dynamic variable size", "dynvarsize" }, + { NULL } + }, rates[] = { + { "cleaning rate", "cleanrate" }, + { "status rate", "statusrate" }, + { NULL } + }; + + for (i = 0; bufs[i].name != NULL; i++) { + if (dtrace_getopt(g_dtp, bufs[i].optname, &bufs[i].val) == -1) + fatal("couldn't get option %s", bufs[i].optname); + } + + for (i = 0; rates[i].name != NULL; i++) { + if (dtrace_getopt(g_dtp, rates[i].optname, &rates[i].val) == -1) + fatal("couldn't get option %s", rates[i].optname); + } + + if (dtrace_go(g_dtp) == -1) + dfatal("could not enable tracing"); + + for (i = 0; bufs[i].name != NULL; i++) { + dtrace_optval_t j = 0, mul = 10; + dtrace_optval_t nsize; + + if (bufs[i].val == DTRACEOPT_UNSET) + continue; + + (void) dtrace_getopt(g_dtp, bufs[i].optname, &nsize); + + if (nsize == DTRACEOPT_UNSET || nsize == 0) + continue; + + if (nsize >= bufs[i].val - sizeof (uint64_t)) + continue; + + for (; (INT64_C(1) << mul) <= nsize; j++, mul += 10) + continue; + + if (!(nsize & ((INT64_C(1) << (mul - 10)) - 1))) { + error("%s lowered to %lld%c\n", bufs[i].name, + (long long)nsize >> (mul - 10), " kmgtpe"[j]); + } else { + error("%s lowered to %lld bytes\n", bufs[i].name, + (long long)nsize); + } + } + + for (i = 0; rates[i].name != NULL; i++) { + dtrace_optval_t nval; + char *dir; + + if (rates[i].val == DTRACEOPT_UNSET) + continue; + + (void) dtrace_getopt(g_dtp, rates[i].optname, &nval); + + if (nval == DTRACEOPT_UNSET || nval == 0) + continue; + + if (rates[i].val == nval) + continue; + + dir = nval > rates[i].val ? "reduced" : "increased"; + + if (nval <= NANOSEC && (NANOSEC % nval) == 0) { + error("%s %s to %lld hz\n", rates[i].name, dir, + (long long)NANOSEC / (long long)nval); + continue; + } + + if ((nval % NANOSEC) == 0) { + error("%s %s to once every %lld seconds\n", + rates[i].name, dir, + (long long)nval / (long long)NANOSEC); + continue; + } + + error("%s %s to once every %lld nanoseconds\n", + rates[i].name, dir, (long long)nval); + } +} + +/*ARGSUSED*/ +static void +intr(int signo) +{ + if (!g_intr) + g_newline = 1; + + if (g_intr++) + g_impatient = 1; +} + +int +main(int argc, char *argv[]) +{ + dtrace_bufdesc_t buf; + struct sigaction act, oact; + dtrace_status_t status[2]; + dtrace_optval_t opt; + dtrace_cmd_t *dcp; + + g_ofp = stdout; + int done = 0, mode = 0; + int err, i, c; + char *p, **v; + struct ps_prochandle *P; + pid_t pid; + + g_pname = basename(argv[0]); + + if (argc == 1) + return (usage(stderr)); + + if ((g_argv = malloc(sizeof (char *) * argc)) == NULL || + (g_cmdv = malloc(sizeof (dtrace_cmd_t) * argc)) == NULL || + (g_psv = malloc(sizeof (struct ps_prochandle *) * argc)) == NULL) + fatal("failed to allocate memory for arguments"); + + g_argv[g_argc++] = argv[0]; /* propagate argv[0] to D as $0/$$0 */ + argv[0] = g_pname; /* rewrite argv[0] for getopt errors */ + + bzero(status, sizeof (status)); + bzero(&buf, sizeof (buf)); + + /* + * Make an initial pass through argv[] processing any arguments that + * affect our behavior mode (g_mode) and flags used for dtrace_open(). + * We also accumulate arguments that are not affiliated with getopt + * options into g_argv[], and abort if any invalid options are found. + */ + for (optind = 1; optind < argc; optind++) { + while ((c = getopt(argc, argv, DTRACE_OPTSTR)) != -1) { + switch (c) { + case '3': + if (strcmp(optarg, "2") != 0) { + (void) fprintf(stderr, + "%s: illegal option -- 3%s\n", + argv[0], optarg); + return (usage(stderr)); + } + g_oflags &= ~DTRACE_O_LP64; + g_oflags |= DTRACE_O_ILP32; + break; + + case '6': + if (strcmp(optarg, "4") != 0) { + (void) fprintf(stderr, + "%s: illegal option -- 6%s\n", + argv[0], optarg); + return (usage(stderr)); + } + g_oflags &= ~DTRACE_O_ILP32; + g_oflags |= DTRACE_O_LP64; + break; + + case 'a': + g_grabanon++; /* also checked in pass 2 below */ + break; + + case 'A': + g_mode = DMODE_ANON; + g_exec = 0; + mode++; + break; + + case 'e': + g_exec = 0; + done = 1; + break; + + case 'h': + g_mode = DMODE_HEADER; + g_oflags |= DTRACE_O_NODEV; + g_cflags |= DTRACE_C_ZDEFS; /* -h implies -Z */ + g_exec = 0; + mode++; + break; + + case 'G': + g_mode = DMODE_LINK; + g_oflags |= DTRACE_O_NODEV; + g_cflags |= DTRACE_C_ZDEFS; /* -G implies -Z */ + g_exec = 0; + mode++; + break; + + case 'l': + g_mode = DMODE_LIST; + g_cflags |= DTRACE_C_ZDEFS; /* -l implies -Z */ + mode++; + break; + + case 'V': + g_mode = DMODE_VERS; + mode++; + break; + + default: + if (strchr(DTRACE_OPTSTR, c) == NULL) + return (usage(stderr)); + } + } + + if (optind < argc) + g_argv[g_argc++] = argv[optind]; + } + + if (mode > 1) { + (void) fprintf(stderr, "%s: only one of the [-AGhlV] options " + "can be specified at a time\n", g_pname); + return (E_USAGE); + } + + if (g_mode == DMODE_VERS) + return (printf("%s: %s\n", g_pname, _dtrace_version) <= 0); + + /* + * If we're in linker mode and the data model hasn't been specified, + * we try to guess the appropriate setting by examining the object + * files. We ignore certain errors since we'll catch them later when + * we actually process the object files. + */ + if (g_mode == DMODE_LINK && + (g_oflags & (DTRACE_O_ILP32 | DTRACE_O_LP64)) == 0 && + elf_version(EV_CURRENT) != EV_NONE) { + int fd; + Elf *elf; + GElf_Ehdr ehdr; + + for (i = 1; i < g_argc; i++) { + if ((fd = open64(g_argv[i], O_RDONLY)) == -1) + break; + + if ((elf = elf_begin(fd, ELF_C_READ, NULL)) == NULL) { + (void) close(fd); + break; + } + + if (elf_kind(elf) != ELF_K_ELF || + gelf_getehdr(elf, &ehdr) == NULL) { + (void) close(fd); + (void) elf_end(elf); + break; + } + + (void) close(fd); + (void) elf_end(elf); + + if (ehdr.e_ident[EI_CLASS] == ELFCLASS64) { + if (g_oflags & DTRACE_O_ILP32) { + fatal("can't mix 32-bit and 64-bit " + "object files\n"); + } + g_oflags |= DTRACE_O_LP64; + } else if (ehdr.e_ident[EI_CLASS] == ELFCLASS32) { + if (g_oflags & DTRACE_O_LP64) { + fatal("can't mix 32-bit and 64-bit " + "object files\n"); + } + g_oflags |= DTRACE_O_ILP32; + } else { + break; + } + } + } + + /* + * Open libdtrace. If we are not actually going to be enabling any + * instrumentation attempt to reopen libdtrace using DTRACE_O_NODEV. + */ + while ((g_dtp = dtrace_open(DTRACE_VERSION, g_oflags, &err)) == NULL) { + if (!(g_oflags & DTRACE_O_NODEV) && !g_exec && !g_grabanon) { + g_oflags |= DTRACE_O_NODEV; + continue; + } + + fatal("failed to initialize dtrace: %s\n", + dtrace_errmsg(NULL, err)); + } + +#if defined(__i386__) + /* XXX The 32-bit seems to need more buffer space by default -sson */ + (void) dtrace_setopt(g_dtp, "bufsize", "12m"); + (void) dtrace_setopt(g_dtp, "aggsize", "12m"); +#else + (void) dtrace_setopt(g_dtp, "bufsize", "4m"); + (void) dtrace_setopt(g_dtp, "aggsize", "4m"); +#endif + + /* + * If -G is specified, enable -xlink=dynamic and -xunodefs to permit + * references to undefined symbols to remain as unresolved relocations. + * If -A is specified, enable -xlink=primary to permit static linking + * only to kernel symbols that are defined in a primary kernel module. + */ + if (g_mode == DMODE_LINK) { + (void) dtrace_setopt(g_dtp, "linkmode", "dynamic"); + (void) dtrace_setopt(g_dtp, "unodefs", NULL); + + /* + * Use the remaining arguments as the list of object files + * when in linker mode. + */ + g_objc = g_argc - 1; + g_objv = g_argv + 1; + + /* + * We still use g_argv[0], the name of the executable. + */ + g_argc = 1; + } else if (g_mode == DMODE_ANON) + (void) dtrace_setopt(g_dtp, "linkmode", "primary"); + + /* + * Now that we have libdtrace open, make a second pass through argv[] + * to perform any dtrace_setopt() calls and change any compiler flags. + * We also accumulate any program specifications into our g_cmdv[] at + * this time; these will compiled as part of the fourth processing pass. + */ + for (optind = 1; optind < argc; optind++) { + while ((c = getopt(argc, argv, DTRACE_OPTSTR)) != -1) { + switch (c) { + case 'a': + if (dtrace_setopt(g_dtp, "grabanon", 0) != 0) + dfatal("failed to set -a"); + break; + + case 'b': + if (dtrace_setopt(g_dtp, + "bufsize", optarg) != 0) + dfatal("failed to set -b %s", optarg); + break; + + case 'B': + g_ofp = NULL; + break; + + case 'C': + g_cflags |= DTRACE_C_CPP; + break; + + case 'D': + if (dtrace_setopt(g_dtp, "define", optarg) != 0) + dfatal("failed to set -D %s", optarg); + break; + + case 'f': + dcp = &g_cmdv[g_cmdc++]; + dcp->dc_func = compile_str; + dcp->dc_spec = DTRACE_PROBESPEC_FUNC; + dcp->dc_arg = optarg; + break; + + case 'F': + if (dtrace_setopt(g_dtp, "flowindent", 0) != 0) + dfatal("failed to set -F"); + break; + + case 'H': + if (dtrace_setopt(g_dtp, "cpphdrs", 0) != 0) + dfatal("failed to set -H"); + break; + + case 'i': + dcp = &g_cmdv[g_cmdc++]; + dcp->dc_func = compile_str; + dcp->dc_spec = DTRACE_PROBESPEC_NAME; + dcp->dc_arg = optarg; + break; + + case 'I': + if (dtrace_setopt(g_dtp, "incdir", optarg) != 0) + dfatal("failed to set -I %s", optarg); + break; + + case 'L': + if (dtrace_setopt(g_dtp, "libdir", optarg) != 0) + dfatal("failed to set -L %s", optarg); + break; + + case 'm': + dcp = &g_cmdv[g_cmdc++]; + dcp->dc_func = compile_str; + dcp->dc_spec = DTRACE_PROBESPEC_MOD; + dcp->dc_arg = optarg; + break; + + case 'n': + dcp = &g_cmdv[g_cmdc++]; + dcp->dc_func = compile_str; + dcp->dc_spec = DTRACE_PROBESPEC_NAME; + dcp->dc_arg = optarg; + break; + + case 'P': + dcp = &g_cmdv[g_cmdc++]; + dcp->dc_func = compile_str; + dcp->dc_spec = DTRACE_PROBESPEC_PROVIDER; + dcp->dc_arg = optarg; + break; + + case 'q': + if (dtrace_setopt(g_dtp, "quiet", 0) != 0) + dfatal("failed to set -q"); + break; + + case 'o': + g_ofile = optarg; + break; + + case 's': + dcp = &g_cmdv[g_cmdc++]; + dcp->dc_func = compile_file; + dcp->dc_spec = DTRACE_PROBESPEC_NONE; + dcp->dc_arg = optarg; + break; + + case 'S': + g_cflags |= DTRACE_C_DIFV; + break; + + case 'U': + if (dtrace_setopt(g_dtp, "undef", optarg) != 0) + dfatal("failed to set -U %s", optarg); + break; + + case 'v': + g_verbose++; + break; + + case 'w': + if (dtrace_setopt(g_dtp, "destructive", 0) != 0) + dfatal("failed to set -w"); + break; + + case 'x': + if ((p = strchr(optarg, '=')) != NULL) + *p++ = '\0'; + + if (dtrace_setopt(g_dtp, optarg, p) != 0) + dfatal("failed to set -x %s", optarg); + break; + + case 'X': + if (dtrace_setopt(g_dtp, "stdc", optarg) != 0) + dfatal("failed to set -X %s", optarg); + break; + + case 'Z': + g_cflags |= DTRACE_C_ZDEFS; + break; + + default: + if (strchr(DTRACE_OPTSTR, c) == NULL) + return (usage(stderr)); + } + } + } + + if (g_ofp == NULL && g_mode != DMODE_EXEC) { + (void) fprintf(stderr, "%s: -B not valid in combination" + " with [-AGl] options\n", g_pname); + return (E_USAGE); + } + + if (g_ofp == NULL && g_ofile != NULL) { + (void) fprintf(stderr, "%s: -B not valid in combination" + " with -o option\n", g_pname); + return (E_USAGE); + } + + /* + * In our third pass we handle any command-line options related to + * grabbing or creating victim processes. The behavior of these calls + * may been affected by any library options set by the second pass. + */ + for (optind = 1; optind < argc; optind++) { + while ((c = getopt(argc, argv, DTRACE_OPTSTR)) != -1) { + switch (c) { + case 'c': + if ((v = make_argv(optarg)) == NULL) + fatal("failed to allocate memory"); + + P = dtrace_proc_create(g_dtp, v[0], v); + if (P == NULL) + dfatal(NULL); /* dtrace_errmsg() only */ + + g_psv[g_psc++] = P; + free(v); + break; + + case 'p': + errno = 0; + pid = strtol(optarg, &p, 10); + + if (errno != 0 || p == optarg || p[0] != '\0') + fatal("invalid pid: %s\n", optarg); + + P = dtrace_proc_grab(g_dtp, pid, 0); + if (P == NULL) + dfatal(NULL); /* dtrace_errmsg() only */ + + g_psv[g_psc++] = P; + break; + } + } + } + + /* + * In our fourth pass we finish g_cmdv[] by calling dc_func to convert + * each string or file specification into a compiled program structure. + */ + for (i = 0; i < g_cmdc; i++) + g_cmdv[i].dc_func(&g_cmdv[i]); + + if (g_mode != DMODE_LIST) { + if (dtrace_handle_err(g_dtp, &errhandler, NULL) == -1) + dfatal("failed to establish error handler"); + + if (dtrace_handle_drop(g_dtp, &drophandler, NULL) == -1) + dfatal("failed to establish drop handler"); + + if (dtrace_handle_proc(g_dtp, &prochandler, NULL) == -1) + dfatal("failed to establish proc handler"); + + if (dtrace_handle_setopt(g_dtp, &setopthandler, NULL) == -1) + dfatal("failed to establish setopt handler"); + + if (g_ofp == NULL && + dtrace_handle_buffered(g_dtp, &bufhandler, NULL) == -1) + dfatal("failed to establish buffered handler"); + } + + (void) dtrace_getopt(g_dtp, "flowindent", &opt); + g_flowindent = opt != DTRACEOPT_UNSET; + + (void) dtrace_getopt(g_dtp, "grabanon", &opt); + g_grabanon = opt != DTRACEOPT_UNSET; + + (void) dtrace_getopt(g_dtp, "quiet", &opt); + g_quiet = opt != DTRACEOPT_UNSET; + + /* + * Now make a fifth and final pass over the options that have been + * turned into programs and saved in g_cmdv[], performing any mode- + * specific processing. If g_mode is DMODE_EXEC, we will break out + * of the switch() and continue on to the data processing loop. For + * other modes, we will exit dtrace once mode-specific work is done. + */ + switch (g_mode) { + case DMODE_EXEC: + if (g_ofile != NULL && (g_ofp = fopen(g_ofile, "a")) == NULL) + fatal("failed to open output file '%s'", g_ofile); + + for (i = 0; i < g_cmdc; i++) + exec_prog(&g_cmdv[i]); + + if (done && !g_grabanon) { + dtrace_close(g_dtp); + return (g_status); + } + break; + + case DMODE_ANON: + if (g_ofile == NULL) +#if defined(sun) + g_ofile = "/kernel/drv/dtrace.conf"; +#else + /* + * On FreeBSD, anonymous DOF data is written to + * the DTrace DOF file that the boot loader will + * read if booting with the DTrace option. + */ + g_ofile = "/boot/dtrace.dof"; +#endif + + dof_prune(g_ofile); /* strip out any old DOF directives */ +#if defined(sun) + etcsystem_prune(); /* string out any forceload directives */ +#endif + + if (g_cmdc == 0) { + dtrace_close(g_dtp); + return (g_status); + } + + if ((g_ofp = fopen(g_ofile, "a")) == NULL) + fatal("failed to open output file '%s'", g_ofile); + + for (i = 0; i < g_cmdc; i++) { + anon_prog(&g_cmdv[i], + dtrace_dof_create(g_dtp, g_cmdv[i].dc_prog, 0), i); + } + + /* + * Dump out the DOF corresponding to the error handler and the + * current options as the final DOF property in the .conf file. + */ + anon_prog(NULL, dtrace_geterr_dof(g_dtp), i++); + anon_prog(NULL, dtrace_getopt_dof(g_dtp), i++); + + if (fclose(g_ofp) == EOF) + fatal("failed to close output file '%s'", g_ofile); + + /* + * These messages would use notice() rather than error(), but + * we don't want them suppressed when -A is run on a D program + * that itself contains a #pragma D option quiet. + */ + error("saved anonymous enabling in %s\n", g_ofile); +#if defined(sun) + etcsystem_add(); + error("run update_drv(1M) or reboot to enable changes\n"); +#endif + + dtrace_close(g_dtp); + return (g_status); + + case DMODE_LINK: + if (g_cmdc == 0) { + (void) fprintf(stderr, "%s: -G requires one or more " + "scripts or enabling options\n", g_pname); + dtrace_close(g_dtp); + return (E_USAGE); + } + + for (i = 0; i < g_cmdc; i++) + link_prog(&g_cmdv[i]); + + if (g_cmdc > 1 && g_ofile != NULL) { + char **objv = alloca(g_cmdc * sizeof (char *)); + + for (i = 0; i < g_cmdc; i++) + objv[i] = g_cmdv[i].dc_ofile; + + if (dtrace_program_link(g_dtp, NULL, DTRACE_D_PROBES, + g_ofile, g_cmdc, objv) != 0) + dfatal(NULL); /* dtrace_errmsg() only */ + } + + dtrace_close(g_dtp); + return (g_status); + + case DMODE_LIST: + if (g_ofile != NULL && (g_ofp = fopen(g_ofile, "a")) == NULL) + fatal("failed to open output file '%s'", g_ofile); + + oprintf("%5s %10s %17s %33s %s\n", + "ID", "PROVIDER", "MODULE", "FUNCTION", "NAME"); + + for (i = 0; i < g_cmdc; i++) + list_prog(&g_cmdv[i]); + + if (g_cmdc == 0) + (void) dtrace_probe_iter(g_dtp, NULL, list_probe, NULL); + + dtrace_close(g_dtp); + return (g_status); + + case DMODE_HEADER: + if (g_cmdc == 0) { + (void) fprintf(stderr, "%s: -h requires one or more " + "scripts or enabling options\n", g_pname); + dtrace_close(g_dtp); + return (E_USAGE); + } + + if (g_ofile == NULL) { + char *p; + + if (g_cmdc > 1) { + (void) fprintf(stderr, "%s: -h requires an " + "output file if multiple scripts are " + "specified\n", g_pname); + dtrace_close(g_dtp); + return (E_USAGE); + } + + if ((p = strrchr(g_cmdv[0].dc_arg, '.')) == NULL || + strcmp(p, ".d") != 0) { + (void) fprintf(stderr, "%s: -h requires an " + "output file if no scripts are " + "specified\n", g_pname); + dtrace_close(g_dtp); + return (E_USAGE); + } + + p[0] = '\0'; /* strip .d suffix */ + g_ofile = p = g_cmdv[0].dc_ofile; + (void) snprintf(p, sizeof (g_cmdv[0].dc_ofile), + "%s.h", basename(g_cmdv[0].dc_arg)); + } + + if ((g_ofp = fopen(g_ofile, "w")) == NULL) + fatal("failed to open header file '%s'", g_ofile); + + oprintf("/*\n * Generated by dtrace(1M).\n */\n\n"); + + if (dtrace_program_header(g_dtp, g_ofp, g_ofile) != 0 || + fclose(g_ofp) == EOF) + dfatal("failed to create header file %s", g_ofile); + + dtrace_close(g_dtp); + return (g_status); + } + + /* + * If -a and -Z were not specified and no probes have been matched, no + * probe criteria was specified on the command line and we abort. + */ + if (g_total == 0 && !g_grabanon && !(g_cflags & DTRACE_C_ZDEFS)) + dfatal("no probes %s\n", g_cmdc ? "matched" : "specified"); + + /* + * Start tracing. Once we dtrace_go(), reload any options that affect + * our globals in case consuming anonymous state has changed them. + */ + go(); + + (void) dtrace_getopt(g_dtp, "flowindent", &opt); + g_flowindent = opt != DTRACEOPT_UNSET; + + (void) dtrace_getopt(g_dtp, "grabanon", &opt); + g_grabanon = opt != DTRACEOPT_UNSET; + + (void) dtrace_getopt(g_dtp, "quiet", &opt); + g_quiet = opt != DTRACEOPT_UNSET; + + (void) dtrace_getopt(g_dtp, "destructive", &opt); + if (opt != DTRACEOPT_UNSET) + notice("allowing destructive actions\n"); + + (void) sigemptyset(&act.sa_mask); + act.sa_flags = 0; + act.sa_handler = intr; + + if (sigaction(SIGINT, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN) + (void) sigaction(SIGINT, &act, NULL); + + if (sigaction(SIGTERM, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN) + (void) sigaction(SIGTERM, &act, NULL); + +#if !defined(sun) + if (sigaction(SIGUSR1, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN) + (void) sigaction(SIGUSR1, &act, NULL); +#endif + + /* + * Now that tracing is active and we are ready to consume trace data, + * continue any grabbed or created processes, setting them running + * using the /proc control mechanism inside of libdtrace. + */ + for (i = 0; i < g_psc; i++) + dtrace_proc_continue(g_dtp, g_psv[i]); + + g_pslive = g_psc; /* count for prochandler() */ + + do { + if (!g_intr && !done) + dtrace_sleep(g_dtp); + + if (g_newline) { + /* + * Output a newline just to make the output look + * slightly cleaner. Note that we do this even in + * "quiet" mode... + */ + oprintf("\n"); + g_newline = 0; + } + + if (done || g_intr || (g_psc != 0 && g_pslive == 0)) { + done = 1; + if (dtrace_stop(g_dtp) == -1) + dfatal("couldn't stop tracing"); + } + + switch (dtrace_work(g_dtp, g_ofp, chew, chewrec, NULL)) { + case DTRACE_WORKSTATUS_DONE: + done = 1; + break; + case DTRACE_WORKSTATUS_OKAY: + break; + default: + if (!g_impatient && dtrace_errno(g_dtp) != EINTR) + dfatal("processing aborted"); + } + + if (g_ofp != NULL && fflush(g_ofp) == EOF) + clearerr(g_ofp); + } while (!done); + + oprintf("\n"); + + if (!g_impatient) { + if (dtrace_aggregate_print(g_dtp, g_ofp, NULL) == -1 && + dtrace_errno(g_dtp) != EINTR) + dfatal("failed to print aggregations"); + } + + dtrace_close(g_dtp); + return (g_status); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/README b/cddl/contrib/opensolaris/cmd/dtrace/test/README new file mode 100644 index 000000000000..51ab650fd7d3 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/README @@ -0,0 +1,32 @@ + +CDDL HEADER START + +The contents of this file are subject to the terms of the +Common Development and Distribution License (the "License"). +You may not use this file except in compliance with the License. + +You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +or http://www.opensolaris.org/os/licensing. +See the License for the specific language governing permissions +and limitations under the License. + +When distributing Covered Code, include this CDDL HEADER in each +file and include the License file at usr/src/OPENSOLARIS.LICENSE. +If applicable, add the following below this CDDL HEADER, with the +fields enclosed by brackets "[]" replaced with your own identifying +information: Portions Copyright [yyyy] [name of copyright owner] + +CDDL HEADER END + +Copyright 2006 Sun Microsystems, Inc. All rights reserved. +Use is subject to license terms. + +ident "%Z%%M% %I% %E% SMI" + +DTrace Testing Suite + +The SUNWdtrt package delivers a set of test programs and D source +files into the directory /opt/SUNWdtrt. For more information see +the following web site: + + http://www.opensolaris.org/os/community/dtrace/dtest diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/baddof/baddof.c b/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/baddof/baddof.c new file mode 100644 index 000000000000..679ec53d86f1 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/baddof/baddof.c @@ -0,0 +1,209 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include +#include +#include +#include +#include +#include +#include +#include + +void +fatal(char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + + fprintf(stderr, "%s: ", "baddof"); + vfprintf(stderr, fmt, ap); + + if (fmt[strlen(fmt) - 1] != '\n') + fprintf(stderr, ": %s\n", strerror(errno)); + + exit(1); +} + +#define LEAP_DISTANCE 20 + +void +corrupt(int fd, unsigned char *buf, int len) +{ + static int ttl, valid; + int bit, i; + unsigned char saved; + int val[LEAP_DISTANCE], pos[LEAP_DISTANCE]; + int new, rv; + +again: + printf("valid DOF #%d\n", valid++); + + /* + * We are going iterate through, flipping one bit and attempting + * to enable. + */ + for (bit = 0; bit < len * 8; bit++) { + saved = buf[bit / 8]; + buf[bit / 8] ^= (1 << (bit % 8)); + + if ((bit % 100) == 0) + printf("%d\n", bit); + + if ((rv = ioctl(fd, DTRACEIOC_ENABLE, buf)) == -1) { + /* + * That failed -- restore the bit and drive on. + */ + buf[bit / 8] = saved; + continue; + } + + /* + * That worked -- and it may have enabled probes. To keep + * enabled probes down to a reasonable level, we'll close + * and reopen pseudodevice if we have more than 10,000 + * probes enabled. + */ + ttl += rv; + + if (ttl < 10000) { + buf[bit / 8] = saved; + continue; + } + + printf("enabled %d probes; resetting device.\n", ttl); + close(fd); + + new = open("/devices/pseudo/dtrace@0:dtrace", O_RDWR); + + if (new == -1) + fatal("couldn't open DTrace pseudo device"); + + if (new != fd) { + dup2(new, fd); + close(new); + } + + ttl = 0; + buf[bit / 8] = saved; + } + + for (;;) { + /* + * Now we want to get as many bits away as possible. We flip + * bits randomly -- getting as far away as we can until we don't + * seem to be making any progress. + */ + for (i = 0; i < LEAP_DISTANCE; i++) { + /* + * Pick a random bit and corrupt it. + */ + bit = lrand48() % (len * 8); + + val[i] = buf[bit / 8]; + pos[i] = bit / 8; + buf[bit / 8] ^= (1 << (bit % 8)); + } + + /* + * Let's see if that managed to get us valid DOF... + */ + if ((rv = ioctl(fd, DTRACEIOC_ENABLE, buf)) > 0) { + /* + * Success! This will be our new base for valid DOF. + */ + ttl += rv; + goto again; + } + + /* + * No luck -- we'll restore those bits and try flipping a + * different set. Note that this must be done in reverse + * order... + */ + for (i = LEAP_DISTANCE - 1; i >= 0; i--) + buf[pos[i]] = val[i]; + } +} + +int +main(int argc, char **argv) +{ + char *filename = argv[1]; + dtrace_hdl_t *dtp; + dtrace_prog_t *pgp; + int err, fd, len; + FILE *fp; + unsigned char *dof, *copy; + + if (argc < 1) + fatal("expected D script as argument\n"); + + if ((fp = fopen(filename, "r")) == NULL) + fatal("couldn't open %s", filename); + + /* + * First, we need to compile our provided D into DOF. + */ + if ((dtp = dtrace_open(DTRACE_VERSION, 0, &err)) == NULL) { + fatal("cannot open dtrace library: %s\n", + dtrace_errmsg(NULL, err)); + } + + pgp = dtrace_program_fcompile(dtp, fp, 0, 0, NULL); + fclose(fp); + + if (pgp == NULL) { + fatal("failed to compile script %s: %s\n", filename, + dtrace_errmsg(dtp, dtrace_errno(dtp))); + } + + dof = dtrace_dof_create(dtp, pgp, 0); + len = ((dof_hdr_t *)dof)->dofh_loadsz; + + if ((copy = malloc(len)) == NULL) + fatal("could not allocate copy of %d bytes", len); + + for (;;) { + bcopy(dof, copy, len); + /* + * Open another instance of the dtrace device. + */ + fd = open("/devices/pseudo/dtrace@0:dtrace", O_RDWR); + + if (fd == -1) + fatal("couldn't open DTrace pseudo device"); + + corrupt(fd, copy, len); + close(fd); + } + + /* NOTREACHED */ + return (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/badioctl/badioctl.c b/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/badioctl/badioctl.c new file mode 100644 index 000000000000..8d6833d52173 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/badioctl/badioctl.c @@ -0,0 +1,145 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DTRACEIOC (('d' << 24) | ('t' << 16) | ('r' << 8)) +#define DTRACEIOC_MAX 17 + +void +fatal(char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + + fprintf(stderr, "%s: ", "badioctl"); + vfprintf(stderr, fmt, ap); + + if (fmt[strlen(fmt) - 1] != '\n') + fprintf(stderr, ": %s\n", strerror(errno)); + + exit(1); +} + +void +badioctl(pid_t parent) +{ + int fd = -1, random, ps = sysconf(_SC_PAGESIZE); + int i = 0, seconds; + caddr_t addr; + hrtime_t now, last = 0, end; + + if ((random = open("/dev/random", O_RDONLY)) == -1) + fatal("couldn't open /dev/random"); + + if ((addr = mmap(0, ps, PROT_READ | PROT_WRITE, + MAP_ANON | MAP_PRIVATE, -1, 0)) == (caddr_t)-1) + fatal("mmap"); + + for (;;) { + unsigned int ioc; + + if ((now = gethrtime()) - last > NANOSEC) { + if (kill(parent, 0) == -1 && errno == ESRCH) { + /* + * Our parent died. We will kill ourselves in + * sympathy. + */ + exit(0); + } + + /* + * Once a second, we'll reopen the device. + */ + if (fd != -1) + close(fd); + + fd = open("/devices/pseudo/dtrace@0:dtrace", O_RDONLY); + + if (fd == -1) + fatal("couldn't open DTrace pseudo device"); + + last = now; + } + + + if ((i++ % 1000) == 0) { + /* + * Every thousand iterations, change our random gunk. + */ + read(random, addr, ps); + } + + read(random, &ioc, sizeof (ioc)); + ioc %= DTRACEIOC_MAX; + ioc++; + ioctl(fd, DTRACEIOC | ioc, addr); + } +} + +int +main() +{ + pid_t child, parent = getpid(); + int status; + + for (;;) { + if ((child = fork()) == 0) + badioctl(parent); + + while (waitpid(child, &status, WEXITED) != child) + continue; + + if (WIFEXITED(status)) { + /* + * Our child exited by design -- we'll exit with + * the same status code. + */ + exit(WEXITSTATUS(status)); + } + + /* + * Our child died on a signal. Respawn it. + */ + printf("badioctl: child died on signal %d; respawning.\n", + WTERMSIG(status)); + fflush(stdout); + } + + /* NOTREACHED */ + return (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/chkargs/chkargs.c b/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/chkargs/chkargs.c new file mode 100644 index 000000000000..36042e3f7274 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/chkargs/chkargs.c @@ -0,0 +1,148 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include +#include +#include + +static int g_count; +static int g_errs; +static int g_fd; +static int g_verbose; +static int g_errexit; + +static int +probe(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp, void *data) +{ + dtrace_probeinfo_t p; + dtrace_argdesc_t arg; + char buf[BUFSIZ]; + int i; + + (void) printf("\r%6d", ++g_count); + (void) fflush(stdout); + + if (dtrace_probe_info(dtp, pdp, &p) != 0) { + (void) printf(" failed to get probe info for " + "%s:%s:%s:%s [%d]\n", pdp->dtpd_provider, pdp->dtpd_mod, + pdp->dtpd_func, pdp->dtpd_name, pdp->dtpd_id); + g_errs++; + return (0); + } + + for (i = 0; i < p.dtp_argc; i++) { + if (p.dtp_argv[i].dtt_type == CTF_ERR) { + bzero(&arg, sizeof (dtrace_argdesc_t)); + arg.dtargd_id = pdp->dtpd_id; + arg.dtargd_ndx = i; + (void) ioctl(g_fd, DTRACEIOC_PROBEARG, &arg); + + (void) printf(" failed to get types for args[%d] " + "of %s:%s:%s:%s [%d]: <%s> -> <%s>\n", i, + pdp->dtpd_provider, pdp->dtpd_mod, pdp->dtpd_func, + pdp->dtpd_name, pdp->dtpd_id, + arg.dtargd_native, arg.dtargd_xlate); + + g_errs++; + + if (g_errexit) + return (-1); + + } else if (g_verbose) { + (void) printf("%d args[%d] : %s\n", pdp->dtpd_id, i, + ctf_type_name(p.dtp_argv[i].dtt_ctfp, + p.dtp_argv[i].dtt_type, buf, sizeof (buf))); + } + } + + return (0); +} + +int +main(int argc, char *argv[]) +{ + dtrace_probedesc_t pd, *pdp = NULL; + dtrace_hdl_t *dtp; + int err, c; + char *p; + + if ((dtp = dtrace_open(DTRACE_VERSION, 0, &err)) == NULL) { + (void) fprintf(stderr, "%s: failed to open dtrace: %s\n", + argv[0], dtrace_errmsg(dtp, err)); + return (1); + } + + while ((c = getopt(argc, argv, "evx:")) != -1) { + switch (c) { + case 'e': + g_errexit++; + break; + case 'v': + g_verbose++; + break; + case 'x': + if ((p = strchr(optarg, '=')) != NULL) + *p++ = '\0'; + + if (dtrace_setopt(dtp, optarg, p) != 0) { + (void) fprintf(stderr, "%s: failed to set " + "option -x %s: %s\n", argv[0], optarg, + dtrace_errmsg(dtp, dtrace_errno(dtp))); + return (2); + } + break; + + default: + (void) fprintf(stderr, "Usage: %s [-ev] " + "[-x opt[=arg]] [probedesc]\n", argv[0]); + return (2); + } + } + + argv += optind; + argc -= optind; + + if (argc > 0) { + if (dtrace_str2desc(dtp, DTRACE_PROBESPEC_NAME, argv[1], &pd)) { + (void) fprintf(stderr, "%s: invalid probe description " + "%s: %s\n", argv[0], argv[1], + dtrace_errmsg(dtp, dtrace_errno(dtp))); + return (2); + } + pdp = &pd; + } + + g_fd = dtrace_ctlfd(dtp); + (void) dtrace_probe_iter(dtp, pdp, probe, NULL); + dtrace_close(dtp); + + (void) printf("\nTotal probes: %d\n", g_count); + (void) printf("Total errors: %d\n\n", g_errs); + + return (g_errs != 0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/jdtrace/Getopt.java b/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/jdtrace/Getopt.java new file mode 100644 index 000000000000..e06a170d6a88 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/jdtrace/Getopt.java @@ -0,0 +1,453 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * ident "%Z%%M% %I% %E% SMI" + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +import java.io.StringWriter; +import java.io.PrintWriter; + +/** + * A Java port of Solaris {@code lib/libc/port/gen/getopt.c}, which is a + * port of System V UNIX getopt. See getopt(3C) and SUS/XPG + * getopt() for function definition and requirements. Unlike that + * definition, this implementation moves non-options to the end of the + * argv array rather than quitting at the first non-option. + */ +public class Getopt { + static final int EOF = -1; + + private String progname; + private String[] args; + private int argc; + private String optstring; + private int optind = 0; // args index + private int optopt = 0; + private String optarg = null; + private boolean opterr = true; + + /* + * _sp is required to keep state between successive calls to + * getopt() while extracting aggregated short-options (ie: -abcd). + */ + private int _sp = 1; + + /** + * Creates a {Code Getopt} instance to parse the given command-line + * arguments. Modifies the given args array by swapping the + * positions of non-options and options so that non-options appear + * at the end of the array. + */ + public Getopt(String programName, String[] args, + String optionString) + { + progname = programName; + // No defensive copy; Getopt is expected to modify the given + // args array + this.args = args; + argc = this.args.length; + optstring = optionString; + validate(); + } + + private void + validate() + { + if (progname == null) { + throw new NullPointerException("program name is null"); + } + int i = 0; + for (String s : args) { + if (s == null) { + throw new NullPointerException("null arg at index " + i); + } + ++i; + } + if (optstring == null) { + throw new NullPointerException("option string is null"); + } + } + + private static class StringRef { + private String s; + + public String + get() + { + return s; + } + + public StringRef + set(String value) + { + s = value; + return this; + } + } + + /* + * Generalized error processing method. If the optstr parameter is + * null, the character c is converted to a string and displayed + * instead. + */ + void + err(String format, char c, String optstr) + { + if (opterr && optstring.charAt(0) != ':') { + StringWriter w = new StringWriter(); + PrintWriter p = new PrintWriter(w); + p.printf(format, progname, (optstr == null ? + Character.toString(c) : optstr.substring(2))); + System.err.println(w.toString()); + } + } + + /* + * Determine if the specified character (c) is present in the string + * (optstring) as a regular, single character option. If the option + * is found, return an index into optstring where the short-option + * character is found, otherwise return -1. The characters ':' and + * '(' are not allowed. + */ + static int + parseshort(String optstring, char c) + { + if (c == ':' || c == '(') { + return -1; + } + + int ch; + int len = optstring.length(); + for (int i = 0; i < len; ++i) { + ch = optstring.charAt(i); + if (ch == c) { + return i; + } + + while (i < len && ch == '(') { + for (++i; i < len && (ch = optstring.charAt(i)) != ')'; ++i); + } + } + + return -1; + } + + /** + * Determine if the specified string (opt) is present in the string + * (optstring) as a long-option contained within parenthesis. If the + * long-option specifies option-argument, return a reference to it + * in longoptarg. Otherwise set the longoptarg reference to null. + * If the option is found, return an index into optstring at the + * position of the short-option character associated with the + * long-option; otherwise return -1. + * + * @param optstring the entire optstring passed to the {@code + * Getopt} constructor + * @param opt the long option read from the command line + * @param longoptarg the value of the option is returned in this + * parameter, if an option exists. Possible return values in + * longoptarg are: + *
    + *
  • NULL: No argument was found
  • + *
  • empty string (""): Argument was explicitly left empty + * by the user (e.g., --option= )
  • + *
  • valid string: Argument found on the command line
  • + *
+ * @return index to equivalent short-option in optstring, or -1 if + * option not found in optstring. + */ + static int + parselong(String optstring, String opt, StringRef longoptarg) + { + int cp; // index into optstring, beginning of one option spec + int ip; // index into optstring, traverses every char + char ic; // optstring char + int il; // optstring length + int op; // index into opt + char oc; // opt char + int ol; // opt length + boolean match; // true if opt is matching part of optstring + + longoptarg.set(null); + cp = ip = 0; + il = optstring.length(); + ol = opt.length(); + do { + ic = optstring.charAt(ip); + if (ic != '(' && ++ip == il) + break; + ic = optstring.charAt(ip); + if (ic == ':' && ++ip == il) + break; + ic = optstring.charAt(ip); + while (ic == '(') { + if (++ip == il) + break; + op = 0; + match = true; + while (ip < il && (ic = optstring.charAt(ip)) != ')' && + op < ol) { + oc = opt.charAt(op++); + match = (ic == oc && match); + ++ip; + } + + if (match && ip < il && ic == ')' && (op >= ol || + opt.charAt(op) == '=')) { + if (op < ol && opt.charAt(op) == '=') { + /* may be an empty string - OK */ + longoptarg.set(opt.substring(op + 1)); + } else { + longoptarg.set(null); + } + return cp; + } + if (ip < il && ic == ')' && ++ip == il) + break; + ic = optstring.charAt(ip); + } + cp = ip; + /* + * Handle double-colon in optstring ("a::(longa)") The old + * getopt() accepts it and treats it as a required argument. + */ + while ((cp > 0) && (cp < il) && (optstring.charAt(cp) == ':')) { + --cp; + } + } while (cp < il); + return -1; + } + + /** + * Get the current option value. + */ + public String + getOptarg() + { + return optarg; + } + + /** + * Get the index of the next option to be parsed. + */ + public int + getOptind() + { + return optind; + } + + /** + * Gets the command-line arguments. + */ + public String[] + getArgv() + { + // No defensive copy: Getopt is expected to modify the given + // args array. + return args; + } + + /** + * Gets the aggregated short option that just failed. Since long + * options can't be aggregated, a failed long option can be obtained + * by {@code getArgv()[getOptind() - 1]}. + */ + public int + getOptopt() + { + return optopt; + } + + /** + * Set to {@code false} to suppress diagnostic messages to stderr. + */ + public void + setOpterr(boolean err) + { + opterr = err; + } + + /** + * Gets the next option character, or -1 if there are no more + * options. If getopt() encounters a short-option character or a + * long-option string not described in the {@code optionString} + * argument to the constructor, it returns the question-mark (?) + * character. If it detects a missing option-argument, it also + * returns the question-mark (?) character, unless the first + * character of the {@code optionString} argument was a colon (:), + * in which case getopt() returns the colon (:) character. + *

+ * This implementation swaps the positions of options and + * non-options in the given argv array. + */ + public int + getopt() + { + char c; + int cp; + boolean longopt; + StringRef longoptarg = new StringRef(); + + /* + * Has the end of the options been encountered? The following + * implements the SUS requirements: + * + * If, when getopt() is called: + * - the first character of argv[optind] is not '-' + * - argv[optind] is the string "-" + * getopt() returns -1 without changing optind if + * - argv[optind] is the string "--" + * getopt() returns -1 after incrementing optind + */ + if (_sp == 1) { + boolean nonOption; + do { + nonOption = false; + if (optind >= argc || args[optind].equals("-")) { + return EOF; + } else if (args[optind].equals("--")) { + ++optind; + return EOF; + } else if (args[optind].charAt(0) != '-') { + // non-option: here we deviate from the SUS requirements + // by not quitting, and instead move non-options to the + // end of the args array + nonOption = true; + String tmp = args[optind]; + if (optind + 1 < args.length) { + System.arraycopy(args, optind + 1, args, optind, + args.length - (optind + 1)); + args[args.length - 1] = tmp; + } + --argc; + } + } while (nonOption); + } + + /* + * Getting this far indicates that an option has been encountered. + * Note that the syntax of optstring applies special meanings to + * the characters ':' and '(', so they are not permissible as + * option letters. A special meaning is also applied to the ')' + * character, but its meaning can be determined from context. + * Note that the specification only requires that the alnum + * characters be accepted. + * + * If the second character of the argument is a '-' this must be + * a long-option, otherwise it must be a short option. Scan for + * the option in optstring by the appropriate algorithm. Either + * scan will return an index to the short-option character in + * optstring if the option is found and -1 otherwise. + * + * For an unrecognized long-option, optopt will equal 0, but + * since long-options can't aggregate the failing option can be + * identified by argv[optind-1]. + */ + optopt = c = args[optind].charAt(_sp); + optarg = null; + longopt = (_sp == 1 && c == '-'); + if (!(longopt + ? ((cp = parselong(optstring, args[optind].substring(2), + longoptarg)) != -1) + : ((cp = parseshort(optstring, c)) != -1))) { + err("%s: illegal option -- %s", c, + (longopt ? args[optind] : null)); + /* + * Note: When the long option is unrecognized, optopt will + * be '-' here, which matches the specification. + */ + if (args[optind].length() == ++_sp || longopt) { + ++optind; + _sp = 1; + } + return '?'; + } + optopt = c = optstring.charAt(cp); + + /* + * A valid option has been identified. If it should have an + * option-argument, process that now. SUS defines the setting + * of optarg as follows: + * + * 1. If the option was the last character in an element of + * argv, then optarg contains the next element of argv, and + * optind is incremented by 2. If the resulting value of + * optind is not less than argc, this indicates a missing + * option-argument, and getopt() returns an error indication. + * + * 2. Otherwise, optarg points to the string following the + * option character in that element of argv, and optind is + * incremented by 1. + * + * The second clause allows -abcd (where b requires an + * option-argument) to be interpreted as "-a -b cd". + * + * Note that the option-argument can legally be an empty string, + * such as: + * command --option= operand + * which explicitly sets the value of --option to nil + */ + if (cp + 1 < optstring.length() && optstring.charAt(cp + 1) == ':') { + // The option takes an argument + if (!longopt && ((_sp + 1) < args[optind].length())) { + optarg = args[optind++].substring(_sp + 1); + } else if (longopt && (longoptarg.get() != null)) { + /* + * The option argument was explicitly set to the empty + * string on the command line (--option=) + */ + optind++; + optarg = longoptarg.get(); + } else if (++optind >= argc) { + err("%s: option requires an argument -- %s", c, + (longopt ? args[optind - 1] : null)); + _sp = 1; + optarg = null; + return (optstring.charAt(0) == ':' ? ':' : '?'); + } else + optarg = args[optind++]; + _sp = 1; + } else { + // The option does NOT take an argument + if (longopt && (longoptarg.get() != null)) { + // User supplied an arg to an option that takes none + err("%s: option doesn't take an argument -- %s", (char)0, + (longopt ? args[optind] : null)); + optarg = longoptarg.set(null).get(); + c = '?'; + } + + if (longopt || args[optind].length() == ++_sp) { + _sp = 1; + ++optind; + } + optarg = null; + } + return (c); + } +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/jdtrace/JDTrace.java b/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/jdtrace/JDTrace.java new file mode 100644 index 000000000000..3c5654d88df5 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/jdtrace/JDTrace.java @@ -0,0 +1,1042 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * ident "%Z%%M% %I% %E% SMI" + */ +import org.opensolaris.os.dtrace.*; +import java.io.*; +import java.util.*; +import java.util.logging.*; + +/** + * Emulates {@code dtrace(1M)} using the Java DTrace API. + */ +public class JDTrace { + static Logger logger = Logger.getLogger(JDTrace.class.getName()); + + static Consumer dtrace; + + static { + Handler handler = new ConsoleHandler(); + handler.setLevel(Level.ALL); + logger.addHandler(handler); + } + + static final String CLASSNAME = "JDTrace"; + static final String OPTSTR = + "3:6:b:c:CD:ef:Fi:I:lL:m:n:o:p:P:qs:U:vVwx:X:Z"; + static boolean heading = false; + static boolean quiet = false; + static boolean flow = false; + static int stackindent = 14; + static int exitStatus = 0; + static boolean started; + static boolean stopped; + static PrintStream out = System.out; + static final String ATS = "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"; + static final String SPACES = " "; + static final int QUANTIZE_ZERO_BUCKET = 63; + + enum Mode { + EXEC, + INFO, + LIST, + VERSION + } + + enum ProgramType { + STRING, + FILE + } + + static class CompileRequest { + String s; + ProgramType type; + ProbeDescription.Spec probespec; + } + + // Modify program string by expanding an incomplete probe + // description according to the requested probespec. + static void + applyProbespec(CompileRequest req) + { + ProbeDescription.Spec spec = ((req.probespec == null) + ? ProbeDescription.Spec.NAME + : req.probespec); + + int colons = 0; + switch (req.probespec) { + case PROVIDER: + colons = 3; + break; + case MODULE: + colons = 2; + break; + case FUNCTION: + colons = 1; + break; + } + + StringBuffer buf = new StringBuffer(); + if (colons > 0) { + char ch; + int len = req.s.length(); + + int i = 0; + // Find first whitespace character not including leading + // whitespace (end of first token). Ignore whitespace + // inside a block if the block is concatenated with the + // probe description. + for (; (i < len) && Character.isWhitespace(req.s.charAt(i)); ++i); + int npos = i; + boolean inBlock = false; + for (; (npos < len) && + (!Character.isWhitespace(ch = req.s.charAt(npos)) || + inBlock); ++npos) { + if (ch == '{') { + inBlock = true; + } else if (ch == '}') { + inBlock = false; + } + } + + // libdtrace lets you concatenate multiple probe + // descriptions separated by code blocks in curly braces, + // for example genunix::'{printf("FOUND");}'::entry, as long + // as the concatenated probe descriptions begin with ':' and + // not a specific field such as 'syscall'. So to expand the + // possibly multiple probe descriptions, we need to insert + // colons before each open curly brace, and again at the end + // only if there is at least one non-whitespace (probe + // specifying) character after the last closing curly brace. + + int prev_i = 0; + while (i < npos) { + for (; (i < npos) && (req.s.charAt(i) != '{'); ++i); + buf.append(req.s.substring(prev_i, i)); + if ((i < npos) || ((i > 0) && (req.s.charAt(i - 1) != '}'))) { + for (int c = 0; c < colons; ++c) { + buf.append(':'); + } + } + if (i < npos) { + buf.append(req.s.charAt(i++)); + } + prev_i = i; + } + + // append remainder of program text + buf.append(req.s.substring(i)); + + req.s = buf.toString(); + } + } + + static void + printValue(Object value, int bytes, String stringFormat) + { + if (value instanceof Integer) { + if (bytes == 1) { + out.printf(" %3d", (Integer)value); + } else if (bytes == 2) { + out.printf(" %5d", (Integer)value); + } else { + out.printf(" %8d", (Integer)value); + } + } else if (value instanceof Long) { + out.printf(" %16d", (Long)value); + } else { + out.printf(stringFormat, value.toString()); + } + } + + static void + consumeProbeData(ProbeData data) + { + if (logger.isLoggable(Level.FINER)) { + logger.finer(data.toString()); + } + + if (!heading) { + if (flow) { + out.printf("%3s %-41s\n", "CPU", "FUNCTION"); + } else { + if (!quiet) { + out.printf("%3s %6s %32s\n", + "CPU", "ID", "FUNCTION:NAME"); + } + } + heading = true; + } + ProbeDescription probe = data.getEnabledProbeDescription(); + if (flow) { + Flow flow = data.getFlow(); + int indent = (flow.getDepth() * 2); + StringBuffer buf = new StringBuffer(); + // indent + buf.append(' '); + for (int i = 0; i < indent; ++i) { + buf.append(' '); + } + // prefix + switch (flow.getKind()) { + case ENTRY: + if (indent == 0) { + buf.append("=> "); + } else { + buf.append("-> "); + } + break; + case RETURN: + if (indent == 0) { + buf.append("<= "); + } else { + buf.append("<- "); + } + break; + } + + switch (flow.getKind()) { + case NONE: + buf.append(probe.getFunction()); + buf.append(':'); + buf.append(probe.getName()); + break; + default: + buf.append(probe.getFunction()); + } + + out.printf("%3s %-41s ", data.getCPU(), + buf.toString()); + } else { + if (!quiet) { + StringBuffer buf = new StringBuffer(); + buf.append(probe.getFunction()); + buf.append(':'); + buf.append(probe.getName()); + out.printf("%3s %6s %32s ", + data.getCPU(), probe.getID(), + buf.toString()); + } + } + Record record = null; + Object value; + List records = data.getRecords(); + Iterator itr = records.iterator(); + while (itr.hasNext()) { + record = itr.next(); + + if (record instanceof ExitRecord) { + exitStatus = ((ExitRecord)record).getStatus(); + } else if (record instanceof ScalarRecord) { + ScalarRecord scalar = (ScalarRecord)record; + value = scalar.getValue(); + if (value instanceof byte[]) { + out.print(record.toString()); + } else { + if (quiet) { + out.print(value); + } else { + printValue(value, scalar.getNumberOfBytes(), + " %-33s"); + } + } + } else if (record instanceof PrintfRecord) { + out.print(record); + } else if (record instanceof PrintaRecord) { + PrintaRecord printa = (PrintaRecord)record; + List tuples = printa.getTuples(); + if (tuples.isEmpty()) { + out.print(printa.getOutput()); + } else { + for (Tuple t : tuples) { + out.print(printa.getFormattedString(t)); + } + } + + if (logger.isLoggable(Level.FINE)) { + logger.fine(printa.toString()); + } + } else if (record instanceof StackValueRecord) { + printStack((StackValueRecord)record); + } + } + if (!quiet) { + out.println(); + } + } + + static void + printDistribution(Distribution d) + { + out.printf("\n%16s %41s %-9s\n", "value", + "------------- Distribution -------------", + "count"); + long v; // bucket frequency (value) + long b; // lower bound of bucket range + double total = 0; + boolean positives = false; + boolean negatives = false; + + Distribution.Bucket bucket; + int b1 = 0; // first displayed bucket + int b2 = d.size() - 1; // last displayed bucket + for (; (b1 <= b2) && (d.get(b1).getFrequency() == 0); ++b1); + // If possible, get one bucket before the first non-zero + // bucket and one bucket after the last. + if (b1 > b2) { + // There isn't any data. This is possible if (and only if) + // negative increment values have been used. In this case, + // print the buckets around the base. + if (d instanceof LinearDistribution) { + b1 = 0; + b2 = 2; + } else { + b1 = QUANTIZE_ZERO_BUCKET - 1; + b2 = QUANTIZE_ZERO_BUCKET + 1; + } + } else { + if (b1 > 0) --b1; + for (; (b2 > 0) && (d.get(b2).getFrequency() == 0); --b2); + if (b2 < (d.size() - 1)) ++b2; + } + for (int i = b1; i <= b2; ++i) { + v = d.get(i).getFrequency(); + if (v > 0) { + positives = true; + } + if (v < 0) { + negatives = true; + } + total += Math.abs((double)v); + } + for (int i = b1; i <= b2; ++i) { + bucket = d.get(i); + v = bucket.getFrequency(); + b = bucket.getMin(); + + if (d instanceof LinearDistribution) { + if (b == Long.MIN_VALUE) { + String lt = "< " + ((LinearDistribution)d).getBase(); + out.printf("%16s ", lt); + } else if (bucket.getMax() == Long.MAX_VALUE) { + String ge = ">= " + b; + out.printf("%16s ", ge); + } else { + out.printf("%16d ", b); + } + } else { + out.printf("%16d ", b); + } + + printDistributionLine(v, total, positives, negatives); + } + } + + static void + printDistributionLine(long val, double total, boolean positives, + boolean negatives) + { + double f; + int depth, len = 40; + + assert (ATS.length() == len && SPACES.length() == len); + assert (!(total == 0 && (positives || negatives))); + assert (!(val < 0 && !negatives)); + assert (!(val > 0 && !positives)); + assert (!(val != 0 && total == 0)); + + if (!negatives) { + if (positives) { + f = (Math.abs((double)val) * (double)len) / total; + depth = (int)(f + 0.5); + } else { + depth = 0; + } + + out.printf("|%s%s %-9d\n", ATS.substring(len - depth), + SPACES.substring(depth), val); + return; + } + + if (!positives) { + f = (Math.abs((double)val) * (double)len) / total; + depth = (int)(f + 0.5); + + out.printf("%s%s| %-9d\n", SPACES.substring(depth), + ATS.substring(len - depth), val); + return; + } + + /* + * If we're here, we have both positive and negative bucket values. + * To express this graphically, we're going to generate both positive + * and negative bars separated by a centerline. These bars are half + * the size of normal quantize()/lquantize() bars, so we divide the + * length in half before calculating the bar length. + */ + len /= 2; + String ats = ATS.substring(len); + String spaces = SPACES.substring(len); + + f = (Math.abs((double)val) * (double)len) / total; + depth = (int)(f + 0.5); + + if (val <= 0) { + out.printf("%s%s|%s %-9d\n", spaces.substring(depth), + ats.substring(len - depth), repeat(" ", len), val); + return; + } else { + out.printf("%20s|%s%s %-9d\n", "", ats.substring(len - depth), + spaces.substring(depth), val); + } + } + + public static String + repeat(String s, int n) + { + StringBuffer buf = new StringBuffer(); + for (int i = 0; i < n; ++i) { + buf.append(s); + } + return buf.toString(); + } + + static void + printStack(StackValueRecord rec) + { + StackFrame[] frames = rec.getStackFrames(); + int i; + out.println(); + String s; + for (StackFrame f : frames) { + for (i = 0; i < stackindent; ++i) { + out.print(' '); + } + s = f.getFrame(); + if (s.indexOf('[') == 0) { + out.print(" "); + } + out.println(s); + } + } + + static void + printAggregate(Aggregate aggregate) + { + printAggregationRecords(aggregate.getOrderedRecords()); + } + + static void + printAggregationRecords(List list) + { + Tuple tuple; + AggregationValue value; + ValueRecord tupleRecord; + int i; + int len; + for (AggregationRecord r : list) { + tuple = r.getTuple(); + value = r.getValue(); + len = tuple.size(); + for (i = 0; i < len; ++i) { + tupleRecord = tuple.get(i); + if (tupleRecord instanceof StackValueRecord) { + printStack((StackValueRecord)tupleRecord); + } else if (tupleRecord instanceof SymbolValueRecord) { + printValue(tupleRecord.toString(), -1, " %-50s"); + } else { + printValue(tupleRecord.getValue(), + ((ScalarRecord)tupleRecord).getNumberOfBytes(), + " %-50s"); + } + } + if (value instanceof Distribution) { + Distribution d = (Distribution)value; + printDistribution(d); + } else { + Number v = value.getValue(); + printValue(v, -1, " %-50s"); + } + out.println(); + } + } + + static void + exit(int status) + { + out.flush(); + System.err.flush(); + if (status == 0) { + status = exitStatus; + } + System.exit(status); + } + + static void + usage() + { + String predact = "[[ predicate ] action ]"; + System.err.printf("Usage: java %s [-32|-64] [-CeFlqvVwZ] " + + "[-b bufsz] [-c cmd] [-D name[=def]]\n\t[-I path] [-L path] " + + "[-o output] [-p pid] [-s script] [-U name]\n\t" + + "[-x opt[=val]] [-X a|c|s|t]\n\n" + + "\t[-P provider %s]\n" + + "\t[-m [ provider: ] module %s]\n" + + "\t[-f [[ provider: ] module: ] func %s]\n" + + "\t[-n [[[ provider: ] module: ] func: ] name %s]\n" + + "\t[-i probe-id %s] [ args ... ]\n\n", CLASSNAME, + predact, predact, predact, predact, predact); + System.err.printf("\tpredicate -> '/' D-expression '/'\n"); + System.err.printf("\t action -> '{' D-statements '}'\n"); + System.err.printf("\n" + + "\t-32 generate 32-bit D programs\n" + + "\t-64 generate 64-bit D programs\n\n" + + "\t-b set trace buffer size\n" + + "\t-c run specified command and exit upon its completion\n" + + "\t-C run cpp(1) preprocessor on script files\n" + + "\t-D define symbol when invoking preprocessor\n" + + "\t-e exit after compiling request but prior to enabling " + + "probes\n" + + "\t-f enable or list probes matching the specified " + + "function name\n" + + "\t-F coalesce trace output by function\n" + + "\t-i enable or list probes matching the specified probe id\n" + + "\t-I add include directory to preprocessor search path\n" + + "\t-l list probes matching specified criteria\n" + + "\t-L add library directory to library search path\n" + + "\t-m enable or list probes matching the specified " + + "module name\n" + + "\t-n enable or list probes matching the specified probe name\n" + + "\t-o set output file\n" + + "\t-p grab specified process-ID and cache its symbol tables\n" + + "\t-P enable or list probes matching the specified " + + "provider name\n" + + "\t-q set quiet mode (only output explicitly traced data)\n" + + "\t-s enable or list probes according to the specified " + + "D script\n" + + "\t-U undefine symbol when invoking preprocessor\n" + + "\t-v set verbose mode (report stability attributes, " + + "arguments)\n" + + "\t-V report DTrace API version\n" + + "\t-w permit destructive actions\n" + + "\t-x enable or modify compiler and tracing options\n" + + "\t-X specify ISO C conformance settings for preprocessor\n" + + "\t-Z permit probe descriptions that match zero probes\n" + + "\n" + + "\tTo log PrintaRecord, set this environment variable:\n" + + "\t\tJDTRACE_LOGGING_LEVEL=FINE\n" + + "\tTo log ProbeData, set JDTRACE_LOGGING_LEVEL=FINER\n"); + exit(2); + } + + static void + printProgramStability(String programType, String programDescription, + ProgramInfo info) + { + out.println(); + out.printf("Stability data for %s %s:\n\n", + programType, programDescription); + InterfaceAttributes a; + out.println("\tMinimum probe description " + + "attributes"); + a = info.getMinimumProbeAttributes(); + out.printf("\t\tIdentifier Names: %s\n", + a.getNameStability()); + out.printf("\t\tData Semantics: %s\n", + a.getDataStability()); + out.printf("\t\tDependency Class: %s\n", + a.getDependencyClass()); + out.println("\tMinimum probe statement attributes"); + a = info.getMinimumStatementAttributes(); + out.printf("\t\tIdentifier Names: %s\n", + a.getNameStability()); + out.printf("\t\tData Semantics: %s\n", + a.getDataStability()); + out.printf("\t\tDependency Class: %s\n", + a.getDependencyClass()); + } + + static void + printProbeDescription(ProbeDescription p) + { + out.printf("%5d %10s %17s %33s %s\n", p.getID(), + p.getProvider(), p.getModule(), + p.getFunction(), p.getName()); + } + + static void + printProbeInfo(ProbeInfo p) + { + InterfaceAttributes a; + out.println("\n\tProbe Description Attributes"); + + a = p.getProbeAttributes(); + out.printf("\t\tIdentifier Names: %s\n", + a.getNameStability()); + out.printf("\t\tData Semantics: %s\n", + a.getDataStability()); + out.printf("\t\tDependency Class: %s\n", + a.getDependencyClass()); + + out.println("\n\tArgument Attributes"); + + a = p.getArgumentAttributes(); + out.printf("\t\tIdentifier Names: %s\n", + a.getNameStability()); + out.printf("\t\tData Semantics: %s\n", + a.getDataStability()); + out.printf("\t\tDependency Class: %s\n", + a.getDependencyClass()); + + // Argument types unsupported for now. + + out.println(); + } + + public static void + main(String[] args) + { + String loggingLevel = System.getenv().get("JDTRACE_LOGGING_LEVEL"); + try { + logger.setLevel(Level.parse(loggingLevel)); + } catch (Exception e) { + logger.setLevel(Level.OFF); + } + + if (args.length == 0) { + usage(); + } + + List compileRequests = new LinkedList + (); + List programList = new LinkedList (); + boolean verbose = false; + Mode mode = Mode.EXEC; + + final ExceptionHandler exceptionHandler = new ExceptionHandler() { + public void handleException(Throwable e) { + if (e instanceof DTraceException) { + DTraceException de = (DTraceException)e; + System.err.printf("dtrace: %s\n", de.getMessage()); + } else if (e instanceof ConsumerException) { + ConsumerException ce = (ConsumerException)e; + Object msg = ce.getNotificationObject(); + if ((msg instanceof org.opensolaris.os.dtrace.Error) || + (msg instanceof Drop)) { + System.err.printf("dtrace: %s\n", ce.getMessage()); + } else { + ce.printStackTrace(); + } + } else { + e.printStackTrace(); + } + exit(1); + } + }; + + Getopt g = new Getopt(CLASSNAME, args, OPTSTR); + int c = 0; + + List openFlags = + new ArrayList (); + + while ((c = g.getopt()) != -1) { + switch (c) { + case '3': { + String s = g.getOptarg(); + if (!s.equals("2")) { + System.err.println("dtrace: illegal option -- 3" + s); + usage(); + } + openFlags.add(Consumer.OpenFlag.ILP32); + break; + } + case '6': { + String s = g.getOptarg(); + if (!s.equals("4")) { + System.err.println("dtrace: illegal option -- 6" + s); + usage(); + } + openFlags.add(Consumer.OpenFlag.LP64); + break; + } + } + } + + Consumer.OpenFlag[] oflags = new Consumer.OpenFlag[openFlags.size()]; + oflags = openFlags.toArray(oflags); + + dtrace = new LocalConsumer() { + protected Thread createThread() { + Thread t = super.createThread(); + t.setDaemon(false); + t.setPriority(Thread.MIN_PRIORITY); + return t; + } + }; + + g = new Getopt(CLASSNAME, args, OPTSTR); + c = 0; + + try { + dtrace.open(oflags); + + // Set default options that may be overriden by options or #pragma + dtrace.setOption(Option.bufsize, Option.mb(4)); + dtrace.setOption(Option.aggsize, Option.mb(4)); + + CompileRequest r; + while ((c = g.getopt()) != -1) { + switch (c) { + case 'b': + dtrace.setOption(Option.bufsize, g.getOptarg()); + break; + case 'c': + dtrace.createProcess(g.getOptarg()); + break; + case 'C': + dtrace.setOption(Option.cpp); + break; + case 'D': + dtrace.setOption(Option.define, g.getOptarg()); + break; + case 'e': + mode = Mode.INFO; + break; + case 'f': + r = new CompileRequest(); + r.s = g.getOptarg(); + r.type = ProgramType.STRING; + r.probespec = ProbeDescription.Spec.FUNCTION; + compileRequests.add(r); + break; + case 'F': + dtrace.setOption(Option.flowindent); + break; + case 'i': + r = new CompileRequest(); + r.s = g.getOptarg(); + r.type = ProgramType.STRING; + r.probespec = ProbeDescription.Spec.NAME; + compileRequests.add(r); + break; + case 'I': + dtrace.setOption(Option.incdir, g.getOptarg()); + break; + case 'l': + mode = Mode.LIST; + dtrace.setOption(Option.zdefs); // -l implies -Z + break; + case 'L': + dtrace.setOption(Option.libdir, g.getOptarg()); + break; + case 'm': + r = new CompileRequest(); + r.s = g.getOptarg(); + r.type = ProgramType.STRING; + r.probespec = ProbeDescription.Spec.MODULE; + compileRequests.add(r); + break; + case 'n': + r = new CompileRequest(); + r.s = g.getOptarg(); + r.type = ProgramType.STRING; + r.probespec = ProbeDescription.Spec.NAME; + compileRequests.add(r); + break; + case 'o': + String outFileName = g.getOptarg(); + File outFile = new File(outFileName); + try { + FileOutputStream fos = new FileOutputStream( + outFile, true); + out = new PrintStream(fos); + } catch (FileNotFoundException e) { + System.err.println("failed to open " + + outFileName + " in write mode"); + exit(1); + } catch (SecurityException e) { + System.err.println("failed to open " + + outFileName); + exit(1); + } + break; + case 'p': + String pidstr = g.getOptarg(); + int pid = -1; + try { + pid = Integer.parseInt(pidstr); + } catch (NumberFormatException e) { + System.err.println("invalid pid: " + pidstr); + exit(1); + } + dtrace.grabProcess(pid); + break; + case 'P': + r = new CompileRequest(); + r.s = g.getOptarg(); + r.type = ProgramType.STRING; + r.probespec = ProbeDescription.Spec.PROVIDER; + compileRequests.add(r); + break; + case 'q': + dtrace.setOption(Option.quiet); + break; + case 's': + r = new CompileRequest(); + r.s = g.getOptarg(); + r.type = ProgramType.FILE; + compileRequests.add(r); + break; + case 'U': + dtrace.setOption(Option.undef, g.getOptarg()); + break; + case 'v': + verbose = true; + break; + case 'V': + mode = Mode.VERSION; + break; + case 'w': + dtrace.setOption(Option.destructive); + break; + case 'x': + String[] xarg = g.getOptarg().split("=", 2); + if (xarg.length > 1) { + dtrace.setOption(xarg[0], xarg[1]); + } else if (xarg.length == 1) { + dtrace.setOption(xarg[0]); + } + break; + case 'X': + dtrace.setOption(Option.stdc, g.getOptarg()); + break; + case 'Z': + dtrace.setOption(Option.zdefs); + break; + case '?': + usage(); // getopt() already printed an error + break; + default: + System.err.print("getopt() returned " + c + "\n"); + c = 0; + } + } + c = 0; + List argList = new LinkedList (); + for (int i = g.getOptind(); i < args.length; ++i) { + argList.add(args[i]); + } + + if (mode == Mode.VERSION) { + out.printf("dtrace: %s\n", dtrace.getVersion()); + dtrace.close(); + exit(0); + } + + String[] compileArgs = new String[argList.size()]; + compileArgs = argList.toArray(compileArgs); + + Program program; + for (CompileRequest req : compileRequests) { + switch (req.type) { + case STRING: + applyProbespec(req); + program = dtrace.compile(req.s, compileArgs); + break; + case FILE: + File file = new File(req.s); + program = dtrace.compile(file, compileArgs); + break; + default: + throw new IllegalArgumentException( + "Unexpected program type: " + req.type); + } + + programList.add(program); + } + + // Get options set by #pragmas in compiled program + long optval; + quiet = (dtrace.getOption(Option.quiet) != Option.UNSET); + flow = (dtrace.getOption(Option.flowindent) != Option.UNSET); + optval = dtrace.getOption("stackindent"); + if (optval != Option.UNSET) { + stackindent = (int)optval; + } + + if (mode == Mode.LIST) { + out.printf("%5s %10s %17s %33s %s\n", + "ID", "PROVIDER", "MODULE", "FUNCTION", "NAME"); + + if (verbose) { + List > lists = + new LinkedList > (); + for (Program p : programList) { + lists.add(dtrace.listProgramProbeDetail(p)); + } + ProbeDescription p; + ProbeInfo pinfo; + for (List list : lists) { + for (Probe probe : list) { + p = probe.getDescription(); + pinfo = probe.getInfo(); + printProbeDescription(p); + printProbeInfo(pinfo); + } + } + } else { + List > lists = + new LinkedList > (); + for (Program p : programList) { + lists.add(dtrace.listProgramProbes(p)); + } + for (List list : lists) { + for (ProbeDescription p : list) { + printProbeDescription(p); + } + } + } + exit(0); + } + + String programType; + String programDescription; + ProgramInfo info; + for (Program p : programList) { + if (p instanceof Program.File) { + Program.File pf = (Program.File)p; + programType = "script"; + programDescription = pf.getFile().getPath(); + } else { + programType = "description"; + programDescription = + p.getContents().split("[/{;]", 2)[0]; + } + + if (mode == Mode.EXEC) { + dtrace.enable(p); + } else { + dtrace.getProgramInfo(p); + } + info = p.getInfo(); + if ((mode == Mode.EXEC) && !quiet) { + System.err.printf("dtrace: %s '%s' matched %d probe%s\n", + programType, programDescription, + info.getMatchingProbeCount(), + info.getMatchingProbeCount() == 1 ? "" : "s"); + } + if (verbose) { + printProgramStability(programType, + programDescription, info); + } + } + if (mode != Mode.EXEC) { + exit(0); + } + dtrace.addConsumerListener(new ConsumerAdapter() { + public void consumerStarted(ConsumerEvent e) { + started = true; + } + public void consumerStopped(ConsumerEvent e) { + stopped = true; + out.println(); + try { + Aggregate aggregate = dtrace.getAggregate(); + if (aggregate != null) { + printAggregate(aggregate); + } + dtrace.close(); + } catch (Throwable x) { + exceptionHandler.handleException(x); + } + exit(0); + } + public void dataDropped(DropEvent e) { + System.err.printf("dtrace: %s", + e.getDrop().getDefaultMessage()); + } + public void errorEncountered(ErrorEvent e) + throws ConsumerException { + org.opensolaris.os.dtrace.Error error = e.getError(); + if (logger.isLoggable(Level.FINE)) { + logger.fine(error.toString()); + } + System.err.printf("dtrace: %s", + error.getDefaultMessage()); + } + public void dataReceived(DataEvent e) + throws ConsumerException { + consumeProbeData(e.getProbeData()); + } + public void processStateChanged(ProcessEvent e) + throws ConsumerException { + if (logger.isLoggable(Level.FINE)) { + logger.fine(e.getProcessState().toString()); + } + } + }); + // Print unprinted aggregations after Ctrl-C + Runtime.getRuntime().addShutdownHook(new Thread() { + public void run() { + if (stopped || !started) { + return; + } + + try { + Aggregate aggregate = dtrace.getAggregate(); + if (aggregate != null) { + out.println(); + out.println(); + printAggregate(aggregate); + } + } catch (Throwable x) { + exceptionHandler.handleException(x); + } + } + }); + dtrace.go(exceptionHandler); + } catch (DTraceException e) { + if (c > 0) { + // set option error + if (g.getOptarg() == null) { + System.err.printf("dtrace: failed to set -%c: %s\n", + c, e.getMessage()); + } else { + System.err.printf("dtrace: failed to set -%c %s: %s\n", + c, g.getOptarg(), e.getMessage()); + } + } else { + // any other error + System.err.printf("dtrace: %s\n", e.getMessage()); + } + exit(1); + } catch (Exception e) { + e.printStackTrace(); + exit(1); + } + } +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/jdtrace/exception.lst b/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/jdtrace/exception.lst new file mode 100644 index 000000000000..f07561862ce7 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/jdtrace/exception.lst @@ -0,0 +1,76 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" + +# Exception list: names tests that are bypassed when running in Java +# mode (relative to /opt/SUNWdtrt/tst) + +# double precision (64-bit floating point) not same in java +common/aggs/tst.neglquant.d +common/aggs/tst.negquant.d + +# freopen() (to suppress output) not supported by Java DTrace API +common/printa/tst.walltimestamp.ksh + +# -G option not supported by jdtrace +common/dtraceUtil/tst.ELFGenerationOut.d.ksh +common/dtraceUtil/tst.ELFGenerationWithO.d.ksh + +# -H option not supported by jdtrace +common/dtraceUtil/tst.PreprocessorStatement.d.ksh + +# -G and -h options not supported by jdtrace +common/usdt/tst.badguess.ksh +common/usdt/tst.dlclose1.ksh +common/usdt/tst.dlclose2.ksh +common/usdt/tst.dlclose3.ksh +common/usdt/tst.eliminate.ksh +common/usdt/tst.enabled.ksh +common/usdt/tst.entryreturn.ksh +common/usdt/tst.fork.ksh +common/usdt/tst.header.ksh +common/usdt/tst.guess32.ksh +common/usdt/tst.guess64.ksh +common/usdt/tst.linkpriv.ksh +common/usdt/tst.linkunpriv.ksh +common/usdt/tst.multiple.ksh +common/usdt/tst.nodtrace.ksh +common/usdt/tst.onlyenabled.ksh +common/usdt/tst.reeval.ksh +common/usdt/tst.static.ksh +common/usdt/tst.static2.ksh +common/usdt/tst.user.ksh +sparc/usdt/tst.tailcall.ksh +common/pid/tst.provregex3.ksh +common/pid/tst.provregex4.ksh + +# freopen() and ftruncate() not supported by Java DTrace API +common/funcs/tst.badfreopen.ksh +common/funcs/tst.freopen.ksh +common/funcs/tst.ftruncate.ksh + +# jdtrace doesn't pull in library files? +common/pragma/tst.libdepfullyconnected.ksh diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/jdtrace/jdtrace.c b/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/jdtrace/jdtrace.c new file mode 100644 index 000000000000..095126569cc1 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/jdtrace/jdtrace.c @@ -0,0 +1,60 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include +#include +#include +#include + +int +main(int argc, char **argv) +{ + int i, ac, has64; + char **av, **p; + + ac = argc + 3; + av = p = alloca(sizeof (char *) * ac); + + *p++ = "java"; + *p++ = "-jar"; + *p++ = "/opt/SUNWdtrt/lib/java/jdtrace.jar"; + + argc--; + argv++; + + for (i = 0; i < argc; i++) { + p[i] = argv[i]; + } + p[i] = NULL; + + (void) execvp(av[0], av); + + perror("exec failed"); + + return (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/jdtrace/manifest/jdtrace.jar-manifest b/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/jdtrace/manifest/jdtrace.jar-manifest new file mode 100644 index 000000000000..add47ebf4c8d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/jdtrace/manifest/jdtrace.jar-manifest @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: JDTrace +Class-Path: /usr/share/lib/java/dtrace.jar diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/scripts/dstyle.pl b/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/scripts/dstyle.pl new file mode 100644 index 000000000000..cb47c7cbfd1c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/scripts/dstyle.pl @@ -0,0 +1,236 @@ +#!/usr/local/bin/perl +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#pragma ident "%Z%%M% %I% %E% SMI" + +require 5.6.1; + +$PNAME = $0; +$PNAME =~ s:.*/::; +$USAGE = "Usage: $PNAME [file ...]\n"; +$errs = 0; + +sub err +{ + my($msg) = @_; + + print "$file: $lineno: $msg\n"; + $errs++; +} + +sub dstyle +{ + open(FILE, "$file"); + $lineno = 0; + $inclause = 0; + $skipnext = 0; + + while () { + $lineno++; + + chop; + + if ($skipnext) { + $skipnext = 0; + next; + } + + # + # Amazingly, some ident strings are longer than 80 characters! + # + if (/^#pragma ident/) { + next; + } + + # + # The algorithm to calculate line length from cstyle. + # + $line = $_; + if ($line =~ tr/\t/\t/ * 7 + length($line) > 80) { + # yes, there is a chance. + # replace tabs with spaces and check again. + $eline = $line; + 1 while $eline =~ + s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e; + + if (length($eline) > 80) { + err "line > 80 characters"; + } + } + + if (/\/\*DSTYLED\*\//) { + $skipnext = 1; + next; + } + + if (/^#pragma/) { + next; + } + + if (/^#include/) { + next; + } + + # + # Before we do any more analysis, we want to prune out any + # quoted strings. This is a bit tricky because we need + # to be careful of backslashed quotes within quoted strings. + # I'm sure there is a very crafty way to do this with a + # single regular expression, but that will have to wait for + # somone with better regex juju that I; we do this by first + # eliminating the backslashed quotes, and then eliminating + # whatever quoted strings are left. Note that we eliminate + # the string by replacing it with "quotedstr"; this is to + # allow lines to end with a quoted string. (If we simply + # eliminated the quoted string, dstyle might complain about + # the line ending in a space or tab.) + # + s/\\\"//g; + s/\"[^\"]*\"/quotedstr/g; + + if (/[ \t]$/) { + err "space or tab at end of line"; + } + + if (/^[\t]+[ ]+[\t]+/) { + err "spaces between tabs"; + } + + if (/^[\t]* \*/) { + next; + } + + if (/^ /) { + err "indented by spaces not tabs"; + } + + if (/^{}$/) { + next; + } + + if (!/^enum/ && !/^\t*struct/ && !/^\t*union/ && !/^typedef/ && + !/^translator/ && !/^provider/) { + if (/[\w\s]+{/) { + err "left brace not on its own line"; + } + + if (/{[\w\s]+/) { + err "left brace not on its own line"; + } + } + + if (!/;$/) { + if (/[\w\s]+}/) { + err "right brace not on its own line"; + } + + if (/}[\w\s]+/) { + err "right brace not on its own line"; + } + } + + if (/^}/) { + $inclause = 0; + } + + if (!$inclause && /^[\w ]+\//) { + err "predicate not at beginning of line"; + } + + if (!$inclause && /^\/[ \t]+\w/) { + err "space between '/' and expression in predicate"; + } + + if (!$inclause && /\w[ \t]+\/$/) { + err "space between expression and '/' in predicate"; + } + + if (!$inclause && /\s,/) { + err "space before comma in probe description"; + } + + if (!$inclause && /\w,[\w\s]/ && !/;$/) { + if (!/extern/ && !/\(/ && !/inline/) { + err "multiple probe descriptions on same line"; + } + } + + if ($inclause && /sizeof\(/) { + err "missing space after sizeof"; + } + + if ($inclause && /^[\w ]/) { + err "line doesn't begin with a tab"; + } + + if ($inclause && /,[\w]/) { + err "comma without trailing space"; + } + + if (/\w&&/ || /&&\w/ || /\w\|\|/ || /\|\|\w/) { + err "logical operator not set off with spaces"; + } + + # + # We want to catch "i<0" variants, but we don't want to + # erroneously flag translators. + # + if (!/\w<\w+>\(/) { + if (/\w>/ || / >\w/ || /\w=\w/ || /\w!=/ || /!=\w/) { + err "comparison operator not set off with spaces"; + } + + if (/\w=/ || /=\w/) { + err "assignment operator not set off with spaces"; + } + + if (/^{/) { + $inclause = 1; + } + } +} + +foreach $arg (@ARGV) { + if (-f $arg) { + push(@files, $arg); + } else { + die "$PNAME: $arg is not a valid file\n"; + } +} + +die $USAGE if (scalar(@files) == 0); + +foreach $file (@files) { + dstyle($file); +} + +exit($errs != 0); diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/scripts/dtest.pl b/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/scripts/dtest.pl new file mode 100644 index 000000000000..e8d9032fcd6c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/scripts/dtest.pl @@ -0,0 +1,703 @@ +#!/usr/local/bin/perl +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" + +require 5.6.1; + +use File::Find; +use File::Basename; +use Getopt::Std; +use Cwd; +use Cwd 'abs_path'; + +$PNAME = $0; +$PNAME =~ s:.*/::; +$OPTSTR = 'abd:fghi:jlnqsx:'; +$USAGE = "Usage: $PNAME [-abfghjlnqs] [-d dir] [-i isa] " + . "[-x opt[=arg]] [file | dir ...]\n"; +($MACH = `uname -p`) =~ s/\W*\n//; + +@dtrace_argv = (); + +$ksh_path = '/bin/sh'; + +@files = (); +%exceptions = (); +%results = (); +$errs = 0; + +# +# If no test files are specified on the command-line, execute a find on "." +# and append any tst.*.d, tst.*.ksh, err.*.d or drp.*.d files found within +# the directory tree. +# +sub wanted +{ + push(@files, $File::Find::name) + if ($_ =~ /^(tst|err|drp)\..+\.(d|ksh)$/ && -f "$_"); +} + +sub dirname { + my($s) = @_; + my($i); + + $s = substr($s, 0, $i) if (($i = rindex($s, '/')) != -1); + return $i == -1 ? '.' : $i == 0 ? '/' : $s; +} + +sub usage +{ + print $USAGE; + print "\t -a execute test suite using anonymous enablings\n"; + print "\t -b execute bad ioctl test program\n"; + print "\t -d specify directory for test results files and cores\n"; + print "\t -g enable libumem debugging when running tests\n"; + print "\t -f force bypassed tests to run\n"; + print "\t -h display verbose usage message\n"; + print "\t -i specify ISA to test instead of isaexec(3C) default\n"; + print "\t -j execute test suite using jdtrace (Java API) only\n"; + print "\t -l save log file of results and PIDs used by tests\n"; + print "\t -n execute test suite using dtrace(1m) only\n"; + print "\t -q set quiet mode (only report errors and summary)\n"; + print "\t -s save results files even for tests that pass\n"; + print "\t -x pass corresponding -x argument to dtrace(1M)\n"; + exit(2); +} + +sub errmsg +{ + my($msg) = @_; + + print STDERR $msg; + print LOG $msg if ($opt_l); + $errs++; +} + +sub fail +{ + my(@parms) = @_; + my($msg) = $parms[0]; + my($errfile) = $parms[1]; + my($n) = 0; + my($dest) = basename($file); + + while (-d "$opt_d/failure.$n") { + $n++; + } + + unless (mkdir "$opt_d/failure.$n") { + warn "ERROR: failed to make directory $opt_d/failure.$n: $!\n"; + exit(125); + } + + open(README, ">$opt_d/failure.$n/README"); + print README "ERROR: " . $file . " " . $msg; + + if (scalar @parms > 1) { + print README "; see $errfile\n"; + } else { + if (-f "$opt_d/$pid.core") { + print README "; see $pid.core\n"; + } else { + print README "\n"; + } + } + + close(README); + + if (-f "$opt_d/$pid.out") { + rename("$opt_d/$pid.out", "$opt_d/failure.$n/$pid.out"); + link("$file.out", "$opt_d/failure.$n/$dest.out"); + } + + if (-f "$opt_d/$pid.err") { + rename("$opt_d/$pid.err", "$opt_d/failure.$n/$pid.err"); + link("$file.err", "$opt_d/failure.$n/$dest.err"); + } + + if (-f "$opt_d/$pid.core") { + rename("$opt_d/$pid.core", "$opt_d/failure.$n/$pid.core"); + } + + link("$file", "$opt_d/failure.$n/$dest"); + + $msg = "ERROR: " . $dest . " " . $msg; + + if (scalar @parms > 1) { + $msg = $msg . "; see $errfile in failure.$n\n"; + } else { + $msg = $msg . "; details in failure.$n\n"; + } + + errmsg($msg); +} + +sub logmsg +{ + my($msg) = @_; + + print STDOUT $msg unless ($opt_q); + print LOG $msg if ($opt_l); +} + +# Trim leading and trailing whitespace +sub trim { + my($s) = @_; + + $s =~ s/^\s*//; + $s =~ s/\s*$//; + return $s; +} + +# Load exception set of skipped tests from the file at the given +# pathname. The test names are assumed to be paths relative to $dt_tst, +# for example: common/aggs/tst.neglquant.d, and specify tests to be +# skipped. +sub load_exceptions { + my($listfile) = @_; + my($line) = ""; + + %exceptions = (); + if (length($listfile) > 0) { + exit(123) unless open(STDIN, "<$listfile"); + while () { + chomp; + $line = $_; + # line is non-empty and not a comment + if ((length($line) > 0) && ($line =~ /^\s*[^\s#]/ )) { + $exceptions{trim($line)} = 1; + } + } + } +} + +# Return 1 if the test is found in the exception set, 0 otherwise. +sub is_exception { + my($file) = @_; + my($i) = -1; + + if (scalar(keys(%exceptions)) == 0) { + return 0; + } + + # hash absolute pathname after $dt_tst/ + $file = abs_path($file); + $i = index($file, $dt_tst); + if ($i == 0) { + $file = substr($file, length($dt_tst) + 1); + return $exceptions{$file}; + } + return 0; +} + +# +# Iterate over the set of test files specified on the command-line or by +# a find on "$defdir/common" and "$defdir/$MACH" and execute each one. +# If the test file is executable, we fork and exec it. If the test is a +# .ksh file, we run it with $ksh_path. Otherwise we run dtrace -s on it. +# If the file is named tst.* we assume it should return exit status 0. +# If the file is named err.* we assume it should return exit status 1. +# If the file is named err.D_[A-Z0-9]+[.*].d we use dtrace -xerrtags and +# examine stderr to ensure that a matching error tag was produced. +# If the file is named drp.[A-Z0-9]+[.*].d we use dtrace -xdroptags and +# examine stderr to ensure that a matching drop tag was produced. +# If any *.out or *.err files are found we perform output comparisons. +# +# run_tests takes two arguments: The first is the pathname of the dtrace +# command to invoke when running the tests. The second is the pathname +# of a file (may be the empty string) listing tests that ought to be +# skipped (skipped tests are listed as paths relative to $dt_tst, for +# example: common/aggs/tst.neglquant.d). +# +sub run_tests { + my($dtrace, $exceptions_path) = @_; + my($passed) = 0; + my($bypassed) = 0; + my($failed) = $errs; + my($total) = 0; + + die "$PNAME: $dtrace not found\n" unless (-x "$dtrace"); + logmsg($dtrace . "\n"); + + load_exceptions($exceptions_path); + + foreach $file (sort @files) { + $file =~ m:.*/((.*)\.(\w+)):; + $name = $1; + $base = $2; + $ext = $3; + + $dir = dirname($file); + $isksh = 0; + $tag = 0; + $droptag = 0; + + if ($name =~ /^tst\./) { + $isksh = ($ext eq 'ksh'); + $status = 0; + } elsif ($name =~ /^err\.(D_[A-Z0-9_]+)\./) { + $status = 1; + $tag = $1; + } elsif ($name =~ /^err\./) { + $status = 1; + } elsif ($name =~ /^drp\.([A-Z0-9_]+)\./) { + $status = 0; + $droptag = $1; + } else { + errmsg("ERROR: $file is not a valid test file name\n"); + next; + } + + $fullname = "$dir/$name"; + $exe = "./$base.exe"; + $exe_pid = -1; + + if ($opt_a && ($status != 0 || $tag != 0 || $droptag != 0 || + -x $exe || $isksh || -x $fullname)) { + $bypassed++; + next; + } + + if (!$opt_f && is_exception("$dir/$name")) { + $bypassed++; + next; + } + + if (!$isksh && -x $exe) { + if (($exe_pid = fork()) == -1) { + errmsg( + "ERROR: failed to fork to run $exe: $!\n"); + next; + } + + if ($exe_pid == 0) { + open(STDIN, '$opt_d/$$.out"); + exit(125) unless open(STDERR, ">$opt_d/$$.err"); + + unless (chdir($dir)) { + warn "ERROR: failed to chdir for $file: $!\n"; + exit(126); + } + + push(@dtrace_argv, '-xerrtags') if ($tag); + push(@dtrace_argv, '-xdroptags') if ($droptag); + push(@dtrace_argv, $exe_pid) if ($exe_pid != -1); + + if ($isksh) { + exit(123) unless open(STDIN, "<$name"); + exec("$ksh_path /dev/stdin $dtrace"); + } elsif (-x $name) { + warn "ERROR: $name is executable\n"; + exit(1); + } else { + if ($tag == 0 && $status == $0 && $opt_a) { + push(@dtrace_argv, '-A'); + } + + push(@dtrace_argv, '-C'); + push(@dtrace_argv, '-s'); + push(@dtrace_argv, $name); + exec($dtrace, @dtrace_argv); + } + + warn "ERROR: failed to exec for $file: $!\n"; + exit(127); + } + + if (waitpid($pid, 0) == -1) { + errmsg("ERROR: timed out waiting for $file\n"); + kill(9, $exe_pid) if ($exe_pid != -1); + kill(9, $pid); + next; + } + + kill(9, $exe_pid) if ($exe_pid != -1); + + if ($tag == 0 && $status == $0 && $opt_a) { + # + # We can chuck the earler output. + # + unlink($pid . '.out'); + unlink($pid . '.err'); + + # + # This is an anonymous enabling. We need to get + # the module unloaded. + # + system("dtrace -ae 1> /dev/null 2> /dev/null"); + system("svcadm disable -s " . + "svc:/network/nfs/mapid:default"); + system("modunload -i 0 ; modunload -i 0 ; " . + "modunload -i 0"); + if (!system("modinfo | grep dtrace")) { + warn "ERROR: couldn't unload dtrace\n"; + system("svcadm enable " . + "-s svc:/network/nfs/mapid:default"); + exit(124); + } + + # + # DTrace is gone. Now update_drv(1M), and rip + # everything out again. + # + system("update_drv dtrace"); + system("dtrace -ae 1> /dev/null 2> /dev/null"); + system("modunload -i 0 ; modunload -i 0 ; " . + "modunload -i 0"); + if (!system("modinfo | grep dtrace")) { + warn "ERROR: couldn't unload dtrace\n"; + system("svcadm enable " . + "-s svc:/network/nfs/mapid:default"); + exit(124); + } + + # + # Now bring DTrace back in. + # + system("sync ; sync"); + system("dtrace -l -n bogusprobe 1> /dev/null " . + "2> /dev/null"); + system("svcadm enable -s " . + "svc:/network/nfs/mapid:default"); + + # + # That should have caused DTrace to reload with + # the new configuration file. Now we can try to + # snag our anonymous state. + # + if (($pid = fork()) == -1) { + errmsg("ERROR: failed to fork to run " . + "test $file: $!\n"); + next; + } + + if ($pid == 0) { + open(STDIN, '$opt_d/$$.out"); + exit(125) unless open(STDERR, ">$opt_d/$$.err"); + + push(@dtrace_argv, '-a'); + + unless (chdir($dir)) { + warn "ERROR: failed to chdir " . + "for $file: $!\n"; + exit(126); + } + + exec($dtrace, @dtrace_argv); + warn "ERROR: failed to exec for $file: $!\n"; + exit(127); + } + + if (waitpid($pid, 0) == -1) { + errmsg("ERROR: timed out waiting for $file\n"); + kill(9, $pid); + next; + } + } + + logmsg("[$pid]\n"); + $wstat = $?; + $wifexited = ($wstat & 0xFF) == 0; + $wexitstat = ($wstat >> 8) & 0xFF; + $wtermsig = ($wstat & 0x7F); + + if (!$wifexited) { + fail("died from signal $wtermsig"); + next; + } + + if ($wexitstat == 125) { + die "$PNAME: failed to create output file in $opt_d " . + "(cd elsewhere or use -d)\n"; + } + + if ($wexitstat != $status) { + fail("returned $wexitstat instead of $status"); + next; + } + + if (-f "$file.out" && + system("cmp -s $file.out $opt_d/$pid.out") != 0) { + fail("stdout mismatch", "$pid.out"); + next; + } + + if (-f "$file.err" && + system("cmp -s $file.err $opt_d/$pid.err") != 0) { + fail("stderr mismatch: see $pid.err"); + next; + } + + if ($tag) { + open(TSTERR, "<$opt_d/$pid.err"); + $tsterr = ; + close(TSTERR); + + unless ($tsterr =~ /: \[$tag\] line \d+:/) { + fail("errtag mismatch: see $pid.err"); + next; + } + } + + if ($droptag) { + $found = 0; + open(TSTERR, "<$opt_d/$pid.err"); + + while () { + if (/\[$droptag\] /) { + $found = 1; + last; + } + } + + close (TSTERR); + + unless ($found) { + fail("droptag mismatch: see $pid.err"); + next; + } + } + + unless ($opt_s) { + unlink($pid . '.out'); + unlink($pid . '.err'); + } + } + + if ($opt_a) { + # + # If we're running with anonymous enablings, we need to + # restore the .conf file. + # + system("dtrace -A 1> /dev/null 2> /dev/null"); + system("dtrace -ae 1> /dev/null 2> /dev/null"); + system("modunload -i 0 ; modunload -i 0 ; modunload -i 0"); + system("update_drv dtrace"); + } + + $total = scalar(@files); + $failed = $errs - $failed; + $passed = ($total - $failed - $bypassed); + $results{$dtrace} = { + "passed" => $passed, + "bypassed" => $bypassed, + "failed" => $failed, + "total" => $total + }; +} + +die $USAGE unless (getopts($OPTSTR)); +usage() if ($opt_h); + +foreach $arg (@ARGV) { + if (-f $arg) { + push(@files, $arg); + } elsif (-d $arg) { + find(\&wanted, $arg); + } else { + die "$PNAME: $arg is not a valid file or directory\n"; + } +} + +$dt_tst = '/opt/SUNWdtrt/tst'; +$dt_bin = '/opt/SUNWdtrt/bin'; +$defdir = -d $dt_tst ? $dt_tst : '.'; +$bindir = -d $dt_bin ? $dt_bin : '.'; + +find(\&wanted, "$defdir/common") if (scalar(@ARGV) == 0); +find(\&wanted, "$defdir/$MACH") if (scalar(@ARGV) == 0); +die $USAGE if (scalar(@files) == 0); + +$dtrace_path = '/usr/sbin/dtrace'; +$jdtrace_path = "$bindir/jdtrace"; + +%exception_lists = ("$jdtrace_path" => "$bindir/exception.lst"); + +if ($opt_j || $opt_n || $opt_i) { + @dtrace_cmds = (); + push(@dtrace_cmds, $dtrace_path) if ($opt_n); + push(@dtrace_cmds, $jdtrace_path) if ($opt_j); + push(@dtrace_cmds, "/usr/sbin/$opt_i/dtrace") if ($opt_i); +} else { + @dtrace_cmds = ($dtrace_path, $jdtrace_path); +} + +if ($opt_d) { + die "$PNAME: -d arg must be absolute path\n" unless ($opt_d =~ /^\//); + die "$PNAME: -d arg $opt_d is not a directory\n" unless (-d "$opt_d"); + system("coreadm -p $opt_d/%p.core"); +} else { + my $dir = getcwd; + system("coreadm -p $dir/%p.core"); + $opt_d = '.'; +} + +if ($opt_x) { + push(@dtrace_argv, '-x'); + push(@dtrace_argv, $opt_x); +} + +die "$PNAME: failed to open $PNAME.$$.log: $!\n" + unless (!$opt_l || open(LOG, ">$PNAME.$$.log")); + +if ($opt_g) { + $ENV{'UMEM_DEBUG'} = 'default,verbose'; + $ENV{'UMEM_LOGGING'} = 'fail,contents'; + $ENV{'LD_PRELOAD'} = 'libumem.so'; +} + +# +# Ensure that $PATH contains a cc(1) so that we can execute the +# test programs that require compilation of C code. +# +#$ENV{'PATH'} = $ENV{'PATH'} . ':/ws/onnv-tools/SUNWspro/SS11/bin'; + +if ($opt_b) { + logmsg("badioctl'ing ... "); + + if (($badioctl = fork()) == -1) { + errmsg("ERROR: failed to fork to run badioctl: $!\n"); + next; + } + + if ($badioctl == 0) { + open(STDIN, '$opt_d/$$.out"); + exit(125) unless open(STDERR, ">$opt_d/$$.err"); + + exec($bindir . "/badioctl"); + warn "ERROR: failed to exec badioctl: $!\n"; + exit(127); + } + + + logmsg("[$badioctl]\n"); + + # + # If we're going to be bad, we're just going to iterate over each + # test file. + # + foreach $file (sort @files) { + ($name = $file) =~ s:.*/::; + $dir = dirname($file); + + if (!($name =~ /^tst\./ && $name =~ /\.d$/)) { + next; + } + + logmsg("baddof'ing $file ... "); + + if (($pid = fork()) == -1) { + errmsg("ERROR: failed to fork to run baddof: $!\n"); + next; + } + + if ($pid == 0) { + open(STDIN, '$opt_d/$$.out"); + exit(125) unless open(STDERR, ">$opt_d/$$.err"); + + unless (chdir($dir)) { + warn "ERROR: failed to chdir for $file: $!\n"; + exit(126); + } + + exec($bindir . "/baddof", $name); + + warn "ERROR: failed to exec for $file: $!\n"; + exit(127); + } + + sleep 60; + kill(9, $pid); + waitpid($pid, 0); + + logmsg("[$pid]\n"); + + unless ($opt_s) { + unlink($pid . '.out'); + unlink($pid . '.err'); + } + } + + kill(9, $badioctl); + waitpid($badioctl, 0); + + unless ($opt_s) { + unlink($badioctl . '.out'); + unlink($badioctl . '.err'); + } + + exit(0); +} + +# +# Run all the tests specified on the command-line (the entire test suite +# by default) once for each dtrace command tested, skipping any tests +# not valid for that command. +# +foreach $dtrace_cmd (@dtrace_cmds) { + run_tests($dtrace_cmd, $exception_lists{$dtrace_cmd}); +} + +$opt_q = 0; # force final summary to appear regardless of -q option + +logmsg("\n==== TEST RESULTS ====\n"); +foreach $key (keys %results) { + my $passed = $results{$key}{"passed"}; + my $bypassed = $results{$key}{"bypassed"}; + my $failed = $results{$key}{"failed"}; + my $total = $results{$key}{"total"}; + + logmsg("\n mode: " . $key . "\n"); + logmsg(" passed: " . $passed . "\n"); + if ($bypassed) { + logmsg(" bypassed: " . $bypassed . "\n"); + } + logmsg(" failed: " . $failed . "\n"); + logmsg(" total: " . $total . "\n"); +} + +exit($errs != 0); diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_FUNC.bad.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_FUNC.bad.d new file mode 100644 index 000000000000..d12454be4eb5 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_FUNC.bad.d @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * An aggregation must call an aggregating function. + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + + @counts["xyz"] = breakpoint(); + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_MDIM.bad.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_MDIM.bad.d new file mode 100644 index 000000000000..2c47289b54b5 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_MDIM.bad.d @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * An aggregation may not be used as a multi-dimensional array + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + + @counts[0][2] = count(); + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_NULL.bad.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_NULL.bad.d new file mode 100644 index 000000000000..87d18187c3f0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_NULL.bad.d @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * An aggregation must have an aggregating function applied. + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + + @a[1]; +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_REDEF.redef.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_REDEF.redef.d new file mode 100644 index 000000000000..9b4b425e4929 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_REDEF.redef.d @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Test redefining the aggregation + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + @a = count(); +} + +END +{ + @a = max(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.avgtoofew.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.avgtoofew.d new file mode 100644 index 000000000000..106f4cdebc41 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.avgtoofew.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * avg() should not accept a non-scalar value + * + * SECTION: Aggregations/Aggregations + * + */ + +#pragma D option quiet + +BEGIN +{ + @a[pid] = avg(probefunc); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.maxnoarg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.maxnoarg.d new file mode 100644 index 000000000000..181e1962febd --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.maxnoarg.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * max() should not accept a non-scalar value + * + * SECTION: Aggregations/Aggregations + * + */ +BEGIN +{ + @a[pid] = max(probefunc); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.mintoofew.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.mintoofew.d new file mode 100644 index 000000000000..3ca34ffbc1c0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.mintoofew.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * min() should not accept a non-scalar value + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + @a[pid] = min(probefunc); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.quantizetoofew.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.quantizetoofew.d new file mode 100644 index 000000000000..b7464552eb13 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.quantizetoofew.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * quantize() should not accept a non-scalar value + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + @a[pid] = quantize(probefunc); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.sumtoofew.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.sumtoofew.d new file mode 100644 index 000000000000..a77a2d5d2e08 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.sumtoofew.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * sum() should not accept a non-scalar value + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + @a[pid] = sum(probefunc); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_CLEAR_AGGARG.bad.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_CLEAR_AGGARG.bad.d new file mode 100644 index 000000000000..0e6060ae95c4 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_CLEAR_AGGARG.bad.d @@ -0,0 +1,77 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * The argument to clear() must be an aggregation. + * + * SECTION: Aggregations/Clearing aggregations + * + * + */ + +#pragma D option quiet +#pragma D option aggrate=10ms +#pragma D option switchrate=10ms + +BEGIN +{ + i = 0; + start = timestamp; +} + +tick-100ms +/i < 20/ +{ + @func[i%5] = sum(i * 100); + i++; +} + +tick-100ms +/i == 10/ +{ + printf("Aggregation data before clear():\n"); + printa(@func); + + clear(count()); + + printf("Aggregation data after clear():\n"); + printa(@func); + i++; +} + +tick-100ms +/i == 20/ +{ + printf("Final aggregation data:\n"); + printa(@func); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_CLEAR_PROTO.bad.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_CLEAR_PROTO.bad.d new file mode 100644 index 000000000000..57fa8841389c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_CLEAR_PROTO.bad.d @@ -0,0 +1,77 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * clear() should handle no args as an error. + * + * SECTION: Aggregations/Clearing aggregations + * + * + */ + +#pragma D option quiet +#pragma D option aggrate=10ms +#pragma D option switchrate=10ms + +BEGIN +{ + i = 0; + start = timestamp; +} + +tick-100ms +/i < 20/ +{ + @func[i%5] = sum(i * 100); + i++; +} + +tick-100ms +/i == 10/ +{ + printf("Aggregation data before clear():\n"); + printa(@func); + + clear(); + + printf("Aggregation data after clear():\n"); + printa(@func); + i++; +} + +tick-100ms +/i == 20/ +{ + printf("Final aggregation data:\n"); + printa(@func); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_FUNC_IDENT.bad.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_FUNC_IDENT.bad.d new file mode 100644 index 000000000000..866a7acf3b0e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_FUNC_IDENT.bad.d @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * An aggregation must call an aggregating function, not a probe + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + + @counts[0][2] = tick-1(); + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_FUNC_UNDEF.badaggfunc.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_FUNC_UNDEF.badaggfunc.d new file mode 100644 index 000000000000..65c12da4990a --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_FUNC_UNDEF.badaggfunc.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Test the use of a non-supported aggregate function. + * + * SECTION: Aggregations/Aggregations + * + */ + + + +BEGIN +{ + @counts["badtest"] = foo(); + +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_IDENT_UNDEF.badexpr.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_IDENT_UNDEF.badexpr.d new file mode 100644 index 000000000000..83e6ab796c59 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_IDENT_UNDEF.badexpr.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Test using an aggregation in an expression context. + * This should result in a compile-time error. + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + trace(@a + 3); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_IDENT_UNDEF.badkey3.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_IDENT_UNDEF.badkey3.d new file mode 100644 index 000000000000..67c5b64e4bd5 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_IDENT_UNDEF.badkey3.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Test the use of a dynamic expression as an aggregation key. + * + * SECTION: Aggregations/Aggregations + * + */ + + +BEGIN +{ + @t[i] = count(); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_IDENT_UNDEF.noeffect.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_IDENT_UNDEF.noeffect.d new file mode 100644 index 000000000000..9bdff78921df --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_IDENT_UNDEF.noeffect.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Test compiling an aggregation statement that has no effect. + * This should result in a compile-time error. + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + @a; +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_KEY_TYPE.badkey1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_KEY_TYPE.badkey1.d new file mode 100644 index 000000000000..abf3dd8c552d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_KEY_TYPE.badkey1.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Test the use of a void expression as an aggregation key. + * This should result in a compile-time error. + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + @a[1, (void)0] = count(); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_KEY_TYPE.badkey2.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_KEY_TYPE.badkey2.d new file mode 100644 index 000000000000..9490b821f6ee --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_KEY_TYPE.badkey2.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Test the use of a dynamic expression as an aggregation key. + * This should result in a compile-time error. + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + @a[0] = count(); + @b[@a] = count(); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_KEY_TYPE.badkey4.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_KEY_TYPE.badkey4.d new file mode 100644 index 000000000000..057746eb9da1 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_KEY_TYPE.badkey4.d @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * Test the use of a dynamic expression as an aggregation key. + * This should result in a compile-time error. + * + * SECTION: Aggregations/Aggregations + * + */ + + +BEGIN +{ + @a[curpsinfo] = count(); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_BASETYPE.lqbad1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_BASETYPE.lqbad1.d new file mode 100644 index 000000000000..6bb6765a7f4e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_BASETYPE.lqbad1.d @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * lquantize() lower bound around must be an integer constant + * + * SECTION: Aggregations/Aggregations + * + */ + + +BEGIN +{ + x = 'a'; + @a[1] = lquantize(timestamp, x, 1000, 1); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_BASETYPE.lqshort.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_BASETYPE.lqshort.d new file mode 100644 index 000000000000..6bb6765a7f4e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_BASETYPE.lqshort.d @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * lquantize() lower bound around must be an integer constant + * + * SECTION: Aggregations/Aggregations + * + */ + + +BEGIN +{ + x = 'a'; + @a[1] = lquantize(timestamp, x, 1000, 1); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_BASEVAL.bad.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_BASEVAL.bad.d new file mode 100644 index 000000000000..23d318e75a22 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_BASEVAL.bad.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * lquantize() lower bound must be a 32-bit quantity + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + @a[1] = lquantize(timestamp, 2147483657, 1000, 1); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_LIMTYPE.lqbad1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_LIMTYPE.lqbad1.d new file mode 100644 index 000000000000..894f064a4a6b --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_LIMTYPE.lqbad1.d @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * lquantize() upper bound around must be an integer constant + * + * SECTION: Aggregations/Aggregations + * + */ + + +BEGIN +{ + x = 'a'; + @a[1] = lquantize(timestamp, 100, rand(), 1); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_LIMVAL.bad.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_LIMVAL.bad.d new file mode 100644 index 000000000000..0a2f5e7f0796 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_LIMVAL.bad.d @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * lquantize() upper bound around must be an integer constant + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + x = 'a'; + @a[1] = lquantize(timestamp, 100, 2147483657, 1); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHBASE.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHBASE.d new file mode 100644 index 000000000000..b93ffabf88c1 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHBASE.d @@ -0,0 +1,33 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +BEGIN +{ + @ = lquantize(0, 10, 20, 1); + @ = lquantize(0, 15, 20, 1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHBASE.order.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHBASE.order.d new file mode 100644 index 000000000000..763c1e0b793f --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHBASE.order.d @@ -0,0 +1,33 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +BEGIN +{ + @ = lquantize(0, 10, 20, 1); + @ = lquantize(0, 15, 30, 10); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHLIM.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHLIM.d new file mode 100644 index 000000000000..d9ba023e4fa9 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHLIM.d @@ -0,0 +1,33 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +BEGIN +{ + @ = lquantize(0, 10, 20, 1); + @ = lquantize(0, 10, 2000, 1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHLIM.order.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHLIM.order.d new file mode 100644 index 000000000000..62be0c5b27b0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHLIM.order.d @@ -0,0 +1,33 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +BEGIN +{ + @ = lquantize(0, 10, 20, 1); + @ = lquantize(0, 10, 2000, 10); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHSTEP.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHSTEP.d new file mode 100644 index 000000000000..086f4392f3d3 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MATCHSTEP.d @@ -0,0 +1,33 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +BEGIN +{ + @ = lquantize(0, 10, 20, 1); + @ = lquantize(0, 10, 20, 2); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MISMATCH.lqbadarg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MISMATCH.lqbadarg.d new file mode 100644 index 000000000000..a4444ad11b8d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_MISMATCH.lqbadarg.d @@ -0,0 +1,55 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * Upper bound must be greater than lower bound argument + * + * SECTION: Aggregations/Aggregations + */ + +#pragma D option quiet + +BEGIN +{ + i = 0; +} + +tick-1 +/i < 1000/ +{ + @a[i] = lquantize(i, 1100, -100, -100 ); + i += 100; +} + +tick-1 +/i == 1000/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPLARGE.lqtoofew.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPLARGE.lqtoofew.d new file mode 100644 index 000000000000..664f70f29341 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPLARGE.lqtoofew.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * lquantize() should not accept more than 4 arguments. + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + @a[1] = lquantize(1, 2, 3, 4, 5); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPSMALL.bad.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPSMALL.bad.d new file mode 100644 index 000000000000..634e8c06a81d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPSMALL.bad.d @@ -0,0 +1,55 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Number of quantization levels must be a 16-bit quantity + * + * SECTION: Aggregations/Aggregations + * + */ + + +BEGIN +{ + i = 0; +} + +tick-10ms +/i < 1000/ +{ + @a[i] = lquantize(i, 0, 1000000, 10); + i += 100; +} + +tick-10ms +/i == 1000/ +{ + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPTYPE.lqbadinc.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPTYPE.lqbadinc.d new file mode 100644 index 000000000000..87c51273a7c5 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPTYPE.lqbadinc.d @@ -0,0 +1,56 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * Upper bound must be greater than lower bound argument + * + * SECTION: Aggregations/Aggregations + * + */ + +#pragma D option quiet + +BEGIN +{ + i = 0; +} + +tick-1 +/i < 1000/ +{ + @a[i] = lquantize(i, 0, 1100, -100); + i += 100; +} + +tick-1 +/i == 1000/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPVAL.bad.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPVAL.bad.d new file mode 100644 index 000000000000..a90d7571ac6a --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_LQUANT_STEPVAL.bad.d @@ -0,0 +1,56 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * lquantize() step value should be a 16-bit quantity + * + * SECTION: Aggregations/Aggregations + * + */ + + +BEGIN +{ + i = 0; +} + +tick-10ms +/i < 1000/ +{ + @a[i] = lquantize(i, 100, 1100, 200000 ); + i += 100; +} + +tick-10ms +/i == 1000/ +{ + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_NORMALIZE_AGGARG.bad.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_NORMALIZE_AGGARG.bad.d new file mode 100644 index 000000000000..7e5974c5b7ca --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_NORMALIZE_AGGARG.bad.d @@ -0,0 +1,65 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * The first argument to normalize() should be an aggregation. + * + * SECTION: Aggregations/Clearing aggregations + * + * + */ + + +#pragma D option quiet +#pragma D option aggrate=1ms +#pragma D option switchrate=1ms + +BEGIN +{ + i = 0; + start = timestamp; +} + +tick-100ms +/i < 20/ +{ + @func[i % 5] = sum(i * 100); + i++; +} + +tick-100ms +/i == 20/ +{ + + printf("normalized data:\n"); + normalize(count(), 4); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_NORMALIZE_PROTO.bad.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_NORMALIZE_PROTO.bad.d new file mode 100644 index 000000000000..82d819d4c02a --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_NORMALIZE_PROTO.bad.d @@ -0,0 +1,64 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * normalize() accepts 2 args - passing fewer is an error. + * + * SECTION: Aggregations/Clearing aggregations + * + * + */ + + +#pragma D option quiet +#pragma D option aggrate=1ms +#pragma D option switchrate=1ms + +BEGIN +{ + i = 0; + start = timestamp; +} + +tick-100ms +/i < 20/ +{ + @func[i % 5] = sum(i * 100); + i++; +} + +tick-100ms +/i == 20/ +{ + printf("normalized data:\n"); + normalize(@func); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_NORMALIZE_SCALAR.bad.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_NORMALIZE_SCALAR.bad.d new file mode 100644 index 000000000000..14a258648e5a --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_NORMALIZE_SCALAR.bad.d @@ -0,0 +1,64 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * The second argument to normalize() should be a scalar. + * + * SECTION: Aggregations/Clearing aggregations + * + * + */ + + +#pragma D option quiet +#pragma D option aggrate=1ms +#pragma D option switchrate=1ms + +BEGIN +{ + i = 0; + start = timestamp; +} + +tick-100ms +/i < 20/ +{ + @func[i % 5] = sum(i * 100); + i++; +} + +tick-100ms +/i == 20/ +{ + printf("normalized data:\n"); + normalize(@func, "hello"); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_ARG.lquantizetoofew.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_ARG.lquantizetoofew.d new file mode 100644 index 000000000000..db4567f8e851 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_ARG.lquantizetoofew.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * lquantize() should not accept a non-scalar value + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + @a[pid] = lquantize(probefunc, probefunc, probefunc, probefunc); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.avgnoarg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.avgnoarg.d new file mode 100644 index 000000000000..628eeabaccf0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.avgnoarg.d @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * avg() should not accept a call with no arguments + * + * SECTION: Aggregations/Aggregations + * + */ + +#pragma D option quiet + +BEGIN +{ + @a[1] = avg(); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.avgtoomany.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.avgtoomany.d new file mode 100644 index 000000000000..42e5c1cc91ca --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.avgtoomany.d @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * avg() should not more than one argument + * + * SECTION: Aggregations/Aggregations + * + */ + +#pragma D option quiet + +BEGIN +{ + @a[1] = avg(1, 2); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.counttoomany.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.counttoomany.d new file mode 100644 index 000000000000..5dc5b800bf2c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.counttoomany.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * count() should not accept any arguments + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + @a["badtest"] = count(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.lquantizenoarg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.lquantizenoarg.d new file mode 100644 index 000000000000..ae4b67247216 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.lquantizenoarg.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * lquantize() should not accept a call with no arguments + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + @a[1] = lquantize(); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.lquantizetoomany.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.lquantizetoomany.d new file mode 100644 index 000000000000..bf87a4688c1c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.lquantizetoomany.d @@ -0,0 +1,40 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * lquantize() should not have more than five (!) arguments + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + @[1] = lquantize(10, 0, 100, 1, 10, 20); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.maxnoarg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.maxnoarg.d new file mode 100644 index 000000000000..aad2c2498daf --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.maxnoarg.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * max() should not accept a call with no arguments + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + @a[1] = max(); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.maxtoomany.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.maxtoomany.d new file mode 100644 index 000000000000..d0fb0918c346 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.maxtoomany.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * max() should not more than one argument + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + @a[1] = max(1, 2); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.minnoarg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.minnoarg.d new file mode 100644 index 000000000000..09db51f2265a --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.minnoarg.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * min() should not accept a call with no arguments + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + @a[1] = min(); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.mintoomany.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.mintoomany.d new file mode 100644 index 000000000000..2647402cb87c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.mintoomany.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * min() should not more than one argument + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + @a[1] = min(1, 2); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.quantizenoarg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.quantizenoarg.d new file mode 100644 index 000000000000..b33957a232eb --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.quantizenoarg.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * quantize() should not accept a call with no arguments + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + @a[1] = quantize(); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.quantizetoomany.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.quantizetoomany.d new file mode 100644 index 000000000000..9b162bd252f5 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.quantizetoomany.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * quantize() should not have more than two arguments + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + @a[1] = quantize(1, 2, 3); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.sumnoarg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.sumnoarg.d new file mode 100644 index 000000000000..4f279017bd4d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.sumnoarg.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * sum() should not accept a call with no arguments + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + @a[pid] = sum(); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.sumtoomany.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.sumtoomany.d new file mode 100644 index 000000000000..5e899be64395 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.sumtoomany.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * sum() should not more than one argument + * + * SECTION: Aggregations/Aggregations + * + */ + +BEGIN +{ + @a[pid] = sum(1, 2); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_AGGARG.bad.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_AGGARG.bad.d new file mode 100644 index 000000000000..69cb729184a4 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_AGGARG.bad.d @@ -0,0 +1,35 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +int i; + +BEGIN +{ + trunc(i); + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_PROTO.badmany.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_PROTO.badmany.d new file mode 100644 index 000000000000..61271a74562e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_PROTO.badmany.d @@ -0,0 +1,34 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +BEGIN +{ + @[0] = count(); + trunc(@, 10, 20); + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_PROTO.badnone.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_PROTO.badnone.d new file mode 100644 index 000000000000..e141e6c97880 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_PROTO.badnone.d @@ -0,0 +1,33 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +BEGIN +{ + trunc(); + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_SCALAR.bad.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_SCALAR.bad.d new file mode 100644 index 000000000000..e5485766d14d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/err.D_TRUNC_SCALAR.bad.d @@ -0,0 +1,34 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +BEGIN +{ + @[0] = count(); + trunc(@, @); + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.allquant.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.allquant.d new file mode 100644 index 000000000000..26241b31ea4f --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.allquant.d @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +int i; + +tick-10ms +{ + @ = quantize(1LL << i); + @ = quantize((1LL << i) + 1); + @ = quantize(-(1LL << i)); + @ = quantize(-(1LL << i) - 1); + i++; +} + +tick-10ms +/i == 64/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.allquant.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.allquant.d.out new file mode 100644 index 000000000000..356d6b46080e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.allquant.d.out @@ -0,0 +1,131 @@ + + + value ------------- Distribution ------------- count +-4611686018427387904 |@ 5 +-2305843009213693952 | 2 +-1152921504606846976 | 2 +-576460752303423488 | 2 +-288230376151711744 | 2 +-144115188075855872 | 2 +-72057594037927936 | 2 +-36028797018963968 | 2 +-18014398509481984 | 2 +-9007199254740992 | 2 +-4503599627370496 | 2 +-2251799813685248 | 2 +-1125899906842624 | 2 +-562949953421312 | 2 +-281474976710656 | 2 +-140737488355328 | 2 + -70368744177664 | 2 + -35184372088832 | 2 + -17592186044416 | 2 + -8796093022208 | 2 + -4398046511104 | 2 + -2199023255552 | 2 + -1099511627776 | 2 + -549755813888 | 2 + -274877906944 | 2 + -137438953472 | 2 + -68719476736 | 2 + -34359738368 | 2 + -17179869184 | 2 + -8589934592 | 2 + -4294967296 | 2 + -2147483648 | 2 + -1073741824 | 2 + -536870912 | 2 + -268435456 | 2 + -134217728 | 2 + -67108864 | 2 + -33554432 | 2 + -16777216 | 2 + -8388608 | 2 + -4194304 | 2 + -2097152 | 2 + -1048576 | 2 + -524288 | 2 + -262144 | 2 + -131072 | 2 + -65536 | 2 + -32768 | 2 + -16384 | 2 + -8192 | 2 + -4096 | 2 + -2048 | 2 + -1024 | 2 + -512 | 2 + -256 | 2 + -128 | 2 + -64 | 2 + -32 | 2 + -16 | 2 + -8 | 2 + -4 | 2 + -2 | 3 + -1 | 1 + 0 | 0 + 1 | 1 + 2 | 3 + 4 | 2 + 8 | 2 + 16 | 2 + 32 | 2 + 64 | 2 + 128 | 2 + 256 | 2 + 512 | 2 + 1024 | 2 + 2048 | 2 + 4096 | 2 + 8192 | 2 + 16384 | 2 + 32768 | 2 + 65536 | 2 + 131072 | 2 + 262144 | 2 + 524288 | 2 + 1048576 | 2 + 2097152 | 2 + 4194304 | 2 + 8388608 | 2 + 16777216 | 2 + 33554432 | 2 + 67108864 | 2 + 134217728 | 2 + 268435456 | 2 + 536870912 | 2 + 1073741824 | 2 + 2147483648 | 2 + 4294967296 | 2 + 8589934592 | 2 + 17179869184 | 2 + 34359738368 | 2 + 68719476736 | 2 + 137438953472 | 2 + 274877906944 | 2 + 549755813888 | 2 + 1099511627776 | 2 + 2199023255552 | 2 + 4398046511104 | 2 + 8796093022208 | 2 + 17592186044416 | 2 + 35184372088832 | 2 + 70368744177664 | 2 + 140737488355328 | 2 + 281474976710656 | 2 + 562949953421312 | 2 +1125899906842624 | 2 +2251799813685248 | 2 +4503599627370496 | 2 +9007199254740992 | 2 +18014398509481984 | 2 +36028797018963968 | 2 +72057594037927936 | 2 +144115188075855872 | 2 +288230376151711744 | 2 +576460752303423488 | 2 +1152921504606846976 | 2 +2305843009213693952 | 2 +4611686018427387904 | 3 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.avg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.avg.d new file mode 100644 index 000000000000..a4bfd3cd213d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.avg.d @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * Positive avg() test + * + * SECTION: Aggregations/Aggregations + * + * NOTES: This is a simple verifiable positive test of the avg() function. + */ + +#pragma D option quiet + +BEGIN +{ + i = 0; +} + +tick-10ms +/i < 1000/ +{ + @a = avg(i); + i += 100; +} + +tick-10ms +/i == 1000/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.avg.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.avg.d.out new file mode 100644 index 000000000000..e3c0687d05d5 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.avg.d.out @@ -0,0 +1,2 @@ + + 450 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.avg_neg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.avg_neg.d new file mode 100644 index 000000000000..5c1e77d124e7 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.avg_neg.d @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * Positive avg() test using negative values + * + * SECTION: Aggregations/Aggregations + * + * NOTES: This is a simple verifiable positive test of the avg() function. + */ + +#pragma D option quiet + +BEGIN +{ + @ = avg(0); + @ = avg(-900); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.avg_neg.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.avg_neg.d.out new file mode 100644 index 000000000000..3fafcd452ac7 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.avg_neg.d.out @@ -0,0 +1,2 @@ + + -450 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clear.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clear.d new file mode 100644 index 000000000000..2acd8ee91758 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clear.d @@ -0,0 +1,75 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Positive test for clearing aggregations + * + * SECTION: Aggregations/Clearing aggregations + * + * + */ + +#pragma D option quiet +#pragma D option aggrate=1ms +#pragma D option switchrate=50ms + +BEGIN +{ + i = 0; + start = timestamp; +} + +tick-100ms +/i < 20/ +{ + @func[i%5] = sum(i * 100); + i++; +} + +tick-100ms +/i == 10/ +{ + printf("Aggregation data before clear():\n"); + printa(@func); + + clear(@func); + + printf("Aggregation data after clear():\n"); + printa(@func); + i++; +} + +tick-100ms +/i == 20/ +{ + printf("Final aggregation data:\n"); + printa(@func); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clear.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clear.d.out new file mode 100644 index 000000000000..486e4ac01a2f --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clear.d.out @@ -0,0 +1,22 @@ +Aggregation data before clear(): + + 0 500 + 1 700 + 2 900 + 3 1100 + 4 1300 +Aggregation data after clear(): + + 0 0 + 1 0 + 2 0 + 3 0 + 4 0 +Final aggregation data: + + 0 1500 + 1 2700 + 2 2900 + 3 3100 + 4 3300 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clearavg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clearavg.d new file mode 100644 index 000000000000..135e511b8d6d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clearavg.d @@ -0,0 +1,60 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * Positive avg() test + * + * SECTION: Aggregations/Aggregations + * + * NOTES: + * Verifies that printing a clear()'d aggregation with an avg() + * aggregation function doesn't cause problems. + * + */ + +#pragma D option quiet + +tick-10ms +/i++ < 5/ +{ + @a = avg(timestamp); +} + +tick-10ms +/i == 5/ +{ + exit(2); +} + +END +{ + clear(@a); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clearavg.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clearavg.d.out new file mode 100644 index 000000000000..8d23188fd1f0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clearavg.d.out @@ -0,0 +1,2 @@ + + 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clearavg2.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clearavg2.d new file mode 100644 index 000000000000..0f7a9584c0c2 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clearavg2.d @@ -0,0 +1,63 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * Positive avg() test + * + * SECTION: Aggregations/Aggregations + * + * NOTES: + * Verifies that printing a clear()'d aggregation with an avg() + * aggregation function of 0 doesn't cause divide-by-zero problems. + * + */ + +#pragma D option quiet +#pragma D option switchrate=50ms +#pragma D option aggrate=1ms + +tick-100ms +/(x++ % 5) == 0/ +{ + @time = avg(0); +} + +tick-100ms +/x > 5 && x <= 20/ +{ + printa(" %@d\n", @time); + clear(@time); +} + +tick-100ms +/x > 20/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clearavg2.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clearavg2.d.out new file mode 100644 index 000000000000..7cceedda7a5f --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clearavg2.d.out @@ -0,0 +1,16 @@ + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.cleardenormalize.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.cleardenormalize.d new file mode 100644 index 000000000000..7aefed038d11 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.cleardenormalize.d @@ -0,0 +1,78 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * Denormalized aggregations can be cleared + * + * SECTION: Aggregations/Normalization; + * Aggregations/Clearing aggregations + * + */ + +#pragma D option quiet +#pragma D option aggrate=1ms +#pragma D option switchrate=50ms + +BEGIN +{ + i = 0; + start = timestamp; +} + +tick-100ms +/i != 10 || i != 20/ +{ + @func[i%5] = sum(i * 100); + i++; +} + +tick-100ms +/i == 10/ +{ + printf("Denormalized data before clear:\n"); + denormalize(@func); + printa(@func); + + clear(@func); + + printf("Aggregation data after clear:\n"); + printa(@func); + i++ +} + +tick-100ms +/i == 20/ +{ + printf("Final (denormalized) aggregation data:\n"); + denormalize(@func); + printa(@func); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.cleardenormalize.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.cleardenormalize.d.out new file mode 100644 index 000000000000..ed7f2f3493a4 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.cleardenormalize.d.out @@ -0,0 +1,22 @@ +Denormalized data before clear: + + 0 500 + 1 700 + 2 900 + 3 1100 + 4 1300 +Aggregation data after clear: + + 0 0 + 1 0 + 2 0 + 3 0 + 4 0 +Final (denormalized) aggregation data: + + 0 1500 + 1 2700 + 2 2900 + 3 3100 + 4 3300 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clearlquantize.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clearlquantize.d new file mode 100644 index 000000000000..2d0ff83862da --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clearlquantize.d @@ -0,0 +1,67 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * Positive lquantize()/clear() test + * + * SECTION: Aggregations/Aggregations + * + * NOTES: + * Verifies that printing a clear()'d aggregation with an lquantize() + * aggregation function doesn't cause problems. + * + */ + + +#pragma D option switchrate=50ms +#pragma D option aggrate=1ms +#pragma D option quiet + +tick-100ms +{ + x++; + @a["linear"] = lquantize(x, 0, 100, 1); + @b["exp"] = quantize(x); +} + +tick-100ms +/(x % 5) == 0 && y++ < 5/ +{ + printa(@a); + printa(@b); + clear(@a); + clear(@b); +} + +tick-100ms +/(x % 5) == 0 && y == 5/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clearlquantize.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clearlquantize.d.out new file mode 100644 index 000000000000..e7e2a6006530 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clearlquantize.d.out @@ -0,0 +1,94 @@ + + linear + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@ 1 + 2 |@@@@@@@@ 1 + 3 |@@@@@@@@ 1 + 4 |@@@@@@@@ 1 + 5 |@@@@@@@@ 1 + 6 | 0 + + + exp + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@ 1 + 2 |@@@@@@@@@@@@@@@@ 2 + 4 |@@@@@@@@@@@@@@@@ 2 + 8 | 0 + + + linear + value ------------- Distribution ------------- count + 5 | 0 + 6 |@@@@@@@@ 1 + 7 |@@@@@@@@ 1 + 8 |@@@@@@@@ 1 + 9 |@@@@@@@@ 1 + 10 |@@@@@@@@ 1 + 11 | 0 + + + exp + value ------------- Distribution ------------- count + 2 | 0 + 4 |@@@@@@@@@@@@@@@@ 2 + 8 |@@@@@@@@@@@@@@@@@@@@@@@@ 3 + 16 | 0 + + + linear + value ------------- Distribution ------------- count + 10 | 0 + 11 |@@@@@@@@ 1 + 12 |@@@@@@@@ 1 + 13 |@@@@@@@@ 1 + 14 |@@@@@@@@ 1 + 15 |@@@@@@@@ 1 + 16 | 0 + + + exp + value ------------- Distribution ------------- count + 4 | 0 + 8 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5 + 16 | 0 + + + linear + value ------------- Distribution ------------- count + 15 | 0 + 16 |@@@@@@@@ 1 + 17 |@@@@@@@@ 1 + 18 |@@@@@@@@ 1 + 19 |@@@@@@@@ 1 + 20 |@@@@@@@@ 1 + 21 | 0 + + + exp + value ------------- Distribution ------------- count + 8 | 0 + 16 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5 + 32 | 0 + + + linear + value ------------- Distribution ------------- count + 20 | 0 + 21 |@@@@@@@@ 1 + 22 |@@@@@@@@ 1 + 23 |@@@@@@@@ 1 + 24 |@@@@@@@@ 1 + 25 |@@@@@@@@ 1 + 26 | 0 + + + exp + value ------------- Distribution ------------- count + 8 | 0 + 16 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5 + 32 | 0 + + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clearnormalize.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clearnormalize.d new file mode 100644 index 000000000000..75cfa2d1c606 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clearnormalize.d @@ -0,0 +1,77 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Normalized aggregation data can be cleared + * + * SECTION: Aggregations/Normalization; + * Aggregations/Clearing aggregations + * + */ + +#pragma D option quiet +#pragma D option aggrate=1ms +#pragma D option switchrate=50ms + +BEGIN +{ + i = 0; + start = timestamp; +} + +tick-100ms +/i < 20/ +{ + @func[i % 5] = sum(i * 100); + i++; +} + +tick-100ms +/i == 10/ +{ + printf("Normalized data before clear:\n"); + normalize(@func, 5); + printa(@func); + + clear(@func); + + printf("Aggregation data after clear:\n"); + printa(@func); + i++ +} + +tick-100ms +/i == 20/ +{ + printf("Final (normalized) aggregation data:\n"); + normalize(@func, 5); + printa(@func); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clearnormalize.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clearnormalize.d.out new file mode 100644 index 000000000000..e568427e16c5 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.clearnormalize.d.out @@ -0,0 +1,22 @@ +Normalized data before clear: + + 0 100 + 1 140 + 2 180 + 3 220 + 4 260 +Aggregation data after clear: + + 0 0 + 1 0 + 2 0 + 3 0 + 4 0 +Final (normalized) aggregation data: + + 0 300 + 1 540 + 2 580 + 3 620 + 4 660 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.count.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.count.d new file mode 100644 index 000000000000..e81d123d9881 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.count.d @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Postive count() test + * + * SECTION: Aggregations/Aggregations + * + */ + +#pragma D option quiet + +BEGIN +{ + @a = count(); + @a = count(); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.count.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.count.d.out new file mode 100644 index 000000000000..d34fd3b03750 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.count.d.out @@ -0,0 +1,2 @@ + + 2 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.count2.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.count2.d new file mode 100644 index 000000000000..624b1b4eeff9 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.count2.d @@ -0,0 +1,54 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Positive count() test + * + * SECTION: Aggregations/Aggregations + */ + +#pragma D option quiet + +BEGIN +{ + i = 0; +} + +tick-10ms +/i != 10/ +{ + i++; + @counts["tick-count"] = count(); +} + +tick-10ms +/i == 10/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.count2.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.count2.d.out new file mode 100644 index 000000000000..4998a339f8e6 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.count2.d.out @@ -0,0 +1,2 @@ + + tick-count 10 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.count3.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.count3.d new file mode 100644 index 000000000000..5913ff604c6d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.count3.d @@ -0,0 +1,56 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Test multiple count() calls. + * + * SECTION: Aggregations/Aggregations + * + */ + +#pragma D option quiet + +BEGIN +{ + i = 0; +} + +tick-10ms +/i != 10/ +{ + i++; + @counts1[execname] = count(); + @counts2[execname, arg0] = count(); +} + +tick-10ms +/i == 10/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.denormalize.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.denormalize.d new file mode 100644 index 000000000000..37269e82d9a0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.denormalize.d @@ -0,0 +1,63 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * Simple denormalization test + * + * SECTION: Aggregations/Normalization + * + */ + +#pragma D option quiet + + +BEGIN +{ + i = 0; + start = timestamp; +} + +tick-10ms +/i < 20/ +{ + @func[i % 5] = sum(i * 100); + i++; +} + +tick-10ms +/i == 20/ +{ + normalize(@func, 5); + + printf("denormalized:"); + denormalize(@func); + printa(@func); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.denormalize.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.denormalize.d.out new file mode 100644 index 000000000000..fa4d0da79e94 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.denormalize.d.out @@ -0,0 +1,7 @@ +denormalized: + 0 3000 + 1 3400 + 2 3800 + 3 4200 + 4 4600 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.denormalizeonly.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.denormalizeonly.d new file mode 100644 index 000000000000..d63a83e6f260 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.denormalizeonly.d @@ -0,0 +1,61 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * denormalize() should work even if normalize() isn't called. + * + * SECTION: Aggregations/Normalization + * + * + */ + +#pragma D option quiet + + +BEGIN +{ + i = 0; + start = timestamp; +} + +tick-10ms +/i < 20/ +{ + @func[i%5] = sum(i * 100); + i++; +} + +tick-10ms +/i == 20/ +{ + printf("denormalized:"); + denormalize(@func); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.denormalizeonly.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.denormalizeonly.d.out new file mode 100644 index 000000000000..cc16f277b78c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.denormalizeonly.d.out @@ -0,0 +1,6 @@ +denormalized: + 0 3000 + 1 3400 + 2 3800 + 3 4200 + 4 4600 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.fmtnormalize.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.fmtnormalize.d new file mode 100644 index 000000000000..8ff3aabf2796 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.fmtnormalize.d @@ -0,0 +1,61 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Positive test for normalization() with printa() + * + * SECTION: Aggregations/Normalization + * + */ + +#pragma D option quiet +#pragma D option aggrate=1ms +#pragma D option switchrate=50ms + +BEGIN +{ + i = 0; + start = timestamp; +} + +tick-100ms +/i < 20/ +{ + @func[i % 5] = sum(i * 100); + i++; +} + +tick-100ms +/i == 20/ +{ + printf("normalized data:\n"); + normalize(@func, 5); + printa("%u %@u\n", @func); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.fmtnormalize.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.fmtnormalize.d.out new file mode 100644 index 000000000000..bbf345be29d7 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.fmtnormalize.d.out @@ -0,0 +1,7 @@ +normalized data: +0 600 +1 680 +2 760 +3 840 +4 920 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.forms.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.forms.d new file mode 100644 index 000000000000..2b08a12d5ede --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.forms.d @@ -0,0 +1,53 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Positive aggregation test + * + * SECTION: Aggregations/Aggregations + * + */ + + +#pragma D option quiet + +BEGIN +{ + @a = count(); + @b = max(1); + @c[0] = count(); + @d[0] = max(1); + + printa("\n@a = %@u\n", @a); + printa("@b = %@u\n", @b); + printa("@c = %@u\n", @c); + printa("@d = %@u\n", @d); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.forms.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.forms.d.out new file mode 100644 index 000000000000..1f31450d34a5 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.forms.d.out @@ -0,0 +1,6 @@ + +@a = 1 +@b = 1 +@c = 1 +@d = 1 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.goodkey.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.goodkey.d new file mode 100644 index 000000000000..46becd56eff6 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.goodkey.d @@ -0,0 +1,55 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Positive aggregation key test + * + * SECTION: Aggregations/Aggregations + */ + +#pragma D option quiet + +BEGIN +{ + i = 0; +} + +tick-10ms +/i != 5/ +{ + i++; + @counts[execname, pid, id, tid, arg0, vtimestamp ] = count(); + +} + +tick-10ms +/i == 5/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.keysort.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.keysort.d new file mode 100644 index 000000000000..dbc8b6d27002 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.keysort.d @@ -0,0 +1,108 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +BEGIN +{ + i = 0; + j = 0; + + @tour["Ghent", i++, j] = sum(5 - j); + j++; + + @tour["Berlin", i++, j] = sum(5 - j); + j++; + + @tour["London", i++, j] = sum(5 - j); + @tour["Dublin", i++, j] = sum(5 - j); + j++; + + @tour["Shanghai", i++, j] = sum(5 - j); + j++; + + @tour["Zurich", i++, j] = sum(5 - j); + j++; + + @tour["Regina", i++, j] = sum(5 - j); + @tour["Winnipeg", i++, j] = sum(5 - j); + @tour["Edmonton", i++, j] = sum(5 - j); + @tour["Calgary", i++, j] = sum(5 - j); + @tour["Vancouver", i++, j] = sum(5 - j); + @tour["Victoria", i++, j] = sum(5 - j); + j++; + + @tour["Prague", i++, j] = sum(5 - j); + @tour["London", i++, j] = sum(5 - j); + j++; + + @tour["Brisbane", i++, j] = sum(5 - j); + @tour["Sydney", i++, j] = sum(5 - j); + @tour["Melbourne", i++, j] = sum(5 - j); + j++; + + setopt("aggsortkey", "false"); + setopt("aggsortkeypos", "0"); + @tour["Amsterdam", i++, j] = sum(5 - j); + + printf("By value:\n"); + printa("%20s %8d %8d %8@d\n", @tour); + + setopt("aggsortkey"); + printf("\nBy key, position 0:\n"); + printa("%20s %8d %8d %8@d\n", @tour); + + setopt("aggsortkeypos", "1"); + printf("\nBy key, position 1:\n"); + printa("%20s %8d %8d %8@d\n", @tour); + + setopt("aggsortkeypos", "2"); + printf("\nBy key, position 2:\n"); + printa("%20s %8d %8d %8@d\n", @tour); + + setopt("aggsortkey", "false"); + setopt("aggsortkeypos", "0"); + setopt("aggsortrev"); + + printf("\nReversed by value:\n"); + printa("%20s %8d %8d %8@d\n", @tour); + + setopt("aggsortkey"); + printf("\nReversed by key, position 0:\n"); + printa("%20s %8d %8d %8@d\n", @tour); + + setopt("aggsortkeypos", "1"); + printf("\nReversed by key, position 1:\n"); + printa("%20s %8d %8d %8@d\n", @tour); + + setopt("aggsortkeypos", "2"); + printf("\nReversed by key, position 2:\n"); + printa("%20s %8d %8d %8@d\n", @tour); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.keysort.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.keysort.d.out new file mode 100644 index 000000000000..250d84b92250 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.keysort.d.out @@ -0,0 +1,160 @@ +By value: + Amsterdam 17 8 -3 + Brisbane 14 7 -2 + Melbourne 16 7 -2 + Sydney 15 7 -2 + London 13 6 -1 + Prague 12 6 -1 + Calgary 9 5 0 + Edmonton 8 5 0 + Regina 6 5 0 + Vancouver 10 5 0 + Victoria 11 5 0 + Winnipeg 7 5 0 + Zurich 5 4 1 + Shanghai 4 3 2 + Dublin 3 2 3 + London 2 2 3 + Berlin 1 1 4 + Ghent 0 0 5 + +By key, position 0: + Amsterdam 17 8 -3 + Berlin 1 1 4 + Brisbane 14 7 -2 + Calgary 9 5 0 + Dublin 3 2 3 + Edmonton 8 5 0 + Ghent 0 0 5 + London 2 2 3 + London 13 6 -1 + Melbourne 16 7 -2 + Prague 12 6 -1 + Regina 6 5 0 + Shanghai 4 3 2 + Sydney 15 7 -2 + Vancouver 10 5 0 + Victoria 11 5 0 + Winnipeg 7 5 0 + Zurich 5 4 1 + +By key, position 1: + Ghent 0 0 5 + Berlin 1 1 4 + London 2 2 3 + Dublin 3 2 3 + Shanghai 4 3 2 + Zurich 5 4 1 + Regina 6 5 0 + Winnipeg 7 5 0 + Edmonton 8 5 0 + Calgary 9 5 0 + Vancouver 10 5 0 + Victoria 11 5 0 + Prague 12 6 -1 + London 13 6 -1 + Brisbane 14 7 -2 + Sydney 15 7 -2 + Melbourne 16 7 -2 + Amsterdam 17 8 -3 + +By key, position 2: + Ghent 0 0 5 + Berlin 1 1 4 + Dublin 3 2 3 + London 2 2 3 + Shanghai 4 3 2 + Zurich 5 4 1 + Calgary 9 5 0 + Edmonton 8 5 0 + Regina 6 5 0 + Vancouver 10 5 0 + Victoria 11 5 0 + Winnipeg 7 5 0 + London 13 6 -1 + Prague 12 6 -1 + Brisbane 14 7 -2 + Melbourne 16 7 -2 + Sydney 15 7 -2 + Amsterdam 17 8 -3 + +Reversed by value: + Ghent 0 0 5 + Berlin 1 1 4 + London 2 2 3 + Dublin 3 2 3 + Shanghai 4 3 2 + Zurich 5 4 1 + Winnipeg 7 5 0 + Victoria 11 5 0 + Vancouver 10 5 0 + Regina 6 5 0 + Edmonton 8 5 0 + Calgary 9 5 0 + Prague 12 6 -1 + London 13 6 -1 + Sydney 15 7 -2 + Melbourne 16 7 -2 + Brisbane 14 7 -2 + Amsterdam 17 8 -3 + +Reversed by key, position 0: + Zurich 5 4 1 + Winnipeg 7 5 0 + Victoria 11 5 0 + Vancouver 10 5 0 + Sydney 15 7 -2 + Shanghai 4 3 2 + Regina 6 5 0 + Prague 12 6 -1 + Melbourne 16 7 -2 + London 13 6 -1 + London 2 2 3 + Ghent 0 0 5 + Edmonton 8 5 0 + Dublin 3 2 3 + Calgary 9 5 0 + Brisbane 14 7 -2 + Berlin 1 1 4 + Amsterdam 17 8 -3 + +Reversed by key, position 1: + Amsterdam 17 8 -3 + Melbourne 16 7 -2 + Sydney 15 7 -2 + Brisbane 14 7 -2 + London 13 6 -1 + Prague 12 6 -1 + Victoria 11 5 0 + Vancouver 10 5 0 + Calgary 9 5 0 + Edmonton 8 5 0 + Winnipeg 7 5 0 + Regina 6 5 0 + Zurich 5 4 1 + Shanghai 4 3 2 + Dublin 3 2 3 + London 2 2 3 + Berlin 1 1 4 + Ghent 0 0 5 + +Reversed by key, position 2: + Amsterdam 17 8 -3 + Sydney 15 7 -2 + Melbourne 16 7 -2 + Brisbane 14 7 -2 + Prague 12 6 -1 + London 13 6 -1 + Winnipeg 7 5 0 + Victoria 11 5 0 + Vancouver 10 5 0 + Regina 6 5 0 + Edmonton 8 5 0 + Calgary 9 5 0 + Zurich 5 4 1 + Shanghai 4 3 2 + London 2 2 3 + Dublin 3 2 3 + Berlin 1 1 4 + Ghent 0 0 5 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantize.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantize.d new file mode 100644 index 000000000000..dd25f861caf2 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantize.d @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Positive lquantize() test + * + * SECTION: Aggregations/Aggregations + * + * NOTES: This is verifiable simple positive test of the lquantize() function. + * + */ + +#pragma D option quiet + +BEGIN +{ + i = 0; +} + +tick-10ms +/i < 1000/ +{ + @a[i] = lquantize(i, -100, 1100, 100 ); + i += 100; +} + +tick-10ms +/i == 1000/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantize.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantize.d.out new file mode 100644 index 000000000000..fecb4483c5ac --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantize.d.out @@ -0,0 +1,61 @@ + + 0 + value ------------- Distribution ------------- count + -100 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 100 | 0 + + 100 + value ------------- Distribution ------------- count + 0 | 0 + 100 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 200 | 0 + + 200 + value ------------- Distribution ------------- count + 100 | 0 + 200 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 300 | 0 + + 300 + value ------------- Distribution ------------- count + 200 | 0 + 300 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 400 | 0 + + 400 + value ------------- Distribution ------------- count + 300 | 0 + 400 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 500 | 0 + + 500 + value ------------- Distribution ------------- count + 400 | 0 + 500 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 600 | 0 + + 600 + value ------------- Distribution ------------- count + 500 | 0 + 600 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 700 | 0 + + 700 + value ------------- Distribution ------------- count + 600 | 0 + 700 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 800 | 0 + + 800 + value ------------- Distribution ------------- count + 700 | 0 + 800 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 900 | 0 + + 900 + value ------------- Distribution ------------- count + 800 | 0 + 900 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 1000 | 0 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantnormal.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantnormal.d new file mode 100644 index 000000000000..003f846f3884 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantnormal.d @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +tick-10ms +/i++ < 10/ +{ + @ = lquantize(i, 0, 10); + @ = lquantize(i, 0, 10); + @ = lquantize(i, 0, 10); + @ = lquantize(i, 0, 10); + @ = lquantize(i, 0, 10); +} + +tick-10ms +/i == 10/ +{ + exit(0); +} + +END +{ + normalize(@, 5); + printa(@); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantnormal.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantnormal.d.out new file mode 100644 index 000000000000..76b55b9c0822 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantnormal.d.out @@ -0,0 +1,16 @@ + + + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@ 1 + 2 |@@@@ 1 + 3 |@@@@ 1 + 4 |@@@@ 1 + 5 |@@@@ 1 + 6 |@@@@ 1 + 7 |@@@@ 1 + 8 |@@@@ 1 + 9 |@@@@ 1 + >= 10 |@@@@ 1 + + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantrange.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantrange.d new file mode 100644 index 000000000000..e9e671657cb7 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantrange.d @@ -0,0 +1,40 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +BEGIN +{ + @["Nixon"] = lquantize(-20, -10, 10, 1, 25); + @["Hoover"] = lquantize(20, -10, 10, 1, -100); + @["Harding"] = lquantize(-10, -10, 10, 1, 15); + @["Bush"] = lquantize(10, -10, 10, 1, 150); + + printa(@); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantrange.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantrange.d.out new file mode 100644 index 000000000000..88d3505b495a --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantrange.d.out @@ -0,0 +1,23 @@ + + Hoover + value ------------- Distribution ------------- count + 9 | 0 + >= 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -100 + + Nixon + value ------------- Distribution ------------- count + < -10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 25 + -10 | 0 + + Harding + value ------------- Distribution ------------- count + < -10 | 0 + -10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 15 + -9 | 0 + + Bush + value ------------- Distribution ------------- count + 9 | 0 + >= 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 150 + + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantround.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantround.d new file mode 100644 index 000000000000..ad609ed207da --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantround.d @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +/* + * This test verifies that the height of the ASCII quantization bars is + * determined using rounding and not truncated integer arithmetic. + */ +tick-10ms +/i++ >= 27/ +{ + exit(0); +} + +tick-10ms +/i > 8/ +{ + @ = lquantize(2, 0, 4); +} + +tick-10ms +/i > 2 && i <= 8/ +{ + @ = lquantize(1, 0, 4); +} + +tick-10ms +/i <= 2/ +{ + @ = lquantize(0, 0, 4); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantround.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantround.d.out new file mode 100644 index 000000000000..1aa94e33a8d4 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantround.d.out @@ -0,0 +1,9 @@ + + + value ------------- Distribution ------------- count + < 0 | 0 + 0 |@@@ 2 + 1 |@@@@@@@@@ 6 + 2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 19 + 3 | 0 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantzero.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantzero.d new file mode 100644 index 000000000000..3905f2bde346 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantzero.d @@ -0,0 +1,96 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + + +BEGIN +{ + a = 7; + b = 13; + val = (-a * b) + a; +} + +tick-1ms +{ + incr = val % b; + val += a; +} + +tick-1ms +/val == 0/ +{ + val += a; +} + +tick-1ms +/incr != 0/ +{ + i++; + @one[i] = lquantize(0, 10, 20, 1, incr); + @two[i] = lquantize(0, 1, 20, 5, incr); + @three[i] = lquantize(0, 0, 20, 1, incr); + @four[i] = lquantize(0, -10, 10, 1, incr); + @five[i] = lquantize(0, -10, 0, 1, incr); + @six[i] = lquantize(0, -10, -1, 1, incr); + @seven[i] = lquantize(0, -10, -2, 1, incr); +} + +tick-1ms +/incr == 0/ +{ + printf("Zero below the range:\n"); + printa(@one); + printf("\n"); + + printf("Zero just below the range:\n"); + printa(@two); + printf("\n"); + + printf("Zero at the bottom of the range:\n"); + printa(@three); + printf("\n"); + + printf("Zero within the range:\n"); + printa(@four); + printf("\n"); + + printf("Zero at the top of the range:\n"); + printa(@five); + printf("\n"); + + printf("Zero just above the range:\n"); + printa(@six); + printf("\n"); + + printf("Zero above the range:\n"); + printa(@seven); + printf("\n"); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantzero.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantzero.d.out new file mode 100644 index 000000000000..330de38a7952 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.lquantzero.d.out @@ -0,0 +1,910 @@ +Zero below the range: + + 2 + value ------------- Distribution ------------- count + < 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -12 + 10 | 0 + + 4 + value ------------- Distribution ------------- count + < 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -11 + 10 | 0 + + 6 + value ------------- Distribution ------------- count + < 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -10 + 10 | 0 + + 8 + value ------------- Distribution ------------- count + < 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -9 + 10 | 0 + + 10 + value ------------- Distribution ------------- count + < 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -8 + 10 | 0 + + 12 + value ------------- Distribution ------------- count + < 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -7 + 10 | 0 + + 1 + value ------------- Distribution ------------- count + < 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -6 + 10 | 0 + + 3 + value ------------- Distribution ------------- count + < 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -5 + 10 | 0 + + 5 + value ------------- Distribution ------------- count + < 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -4 + 10 | 0 + + 7 + value ------------- Distribution ------------- count + < 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -3 + 10 | 0 + + 9 + value ------------- Distribution ------------- count + < 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -2 + 10 | 0 + + 11 + value ------------- Distribution ------------- count + < 10 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -1 + 10 | 0 + + 14 + value ------------- Distribution ------------- count + < 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 10 | 0 + + 16 + value ------------- Distribution ------------- count + < 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2 + 10 | 0 + + 18 + value ------------- Distribution ------------- count + < 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3 + 10 | 0 + + 20 + value ------------- Distribution ------------- count + < 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 4 + 10 | 0 + + 22 + value ------------- Distribution ------------- count + < 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5 + 10 | 0 + + 24 + value ------------- Distribution ------------- count + < 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6 + 10 | 0 + + 13 + value ------------- Distribution ------------- count + < 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7 + 10 | 0 + + 15 + value ------------- Distribution ------------- count + < 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8 + 10 | 0 + + 17 + value ------------- Distribution ------------- count + < 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9 + 10 | 0 + + 19 + value ------------- Distribution ------------- count + < 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 10 + 10 | 0 + + 21 + value ------------- Distribution ------------- count + < 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 11 + 10 | 0 + + 23 + value ------------- Distribution ------------- count + < 10 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12 + 10 | 0 + + +Zero just below the range: + + 2 + value ------------- Distribution ------------- count + < 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -12 + 1 | 0 + + 4 + value ------------- Distribution ------------- count + < 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -11 + 1 | 0 + + 6 + value ------------- Distribution ------------- count + < 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -10 + 1 | 0 + + 8 + value ------------- Distribution ------------- count + < 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -9 + 1 | 0 + + 10 + value ------------- Distribution ------------- count + < 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -8 + 1 | 0 + + 12 + value ------------- Distribution ------------- count + < 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -7 + 1 | 0 + + 1 + value ------------- Distribution ------------- count + < 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -6 + 1 | 0 + + 3 + value ------------- Distribution ------------- count + < 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -5 + 1 | 0 + + 5 + value ------------- Distribution ------------- count + < 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -4 + 1 | 0 + + 7 + value ------------- Distribution ------------- count + < 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -3 + 1 | 0 + + 9 + value ------------- Distribution ------------- count + < 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -2 + 1 | 0 + + 11 + value ------------- Distribution ------------- count + < 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -1 + 1 | 0 + + 14 + value ------------- Distribution ------------- count + < 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 1 | 0 + + 16 + value ------------- Distribution ------------- count + < 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2 + 1 | 0 + + 18 + value ------------- Distribution ------------- count + < 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3 + 1 | 0 + + 20 + value ------------- Distribution ------------- count + < 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 4 + 1 | 0 + + 22 + value ------------- Distribution ------------- count + < 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5 + 1 | 0 + + 24 + value ------------- Distribution ------------- count + < 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6 + 1 | 0 + + 13 + value ------------- Distribution ------------- count + < 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7 + 1 | 0 + + 15 + value ------------- Distribution ------------- count + < 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8 + 1 | 0 + + 17 + value ------------- Distribution ------------- count + < 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9 + 1 | 0 + + 19 + value ------------- Distribution ------------- count + < 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 10 + 1 | 0 + + 21 + value ------------- Distribution ------------- count + < 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 11 + 1 | 0 + + 23 + value ------------- Distribution ------------- count + < 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12 + 1 | 0 + + +Zero at the bottom of the range: + + 2 + value ------------- Distribution ------------- count + < 0 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -12 + 1 | 0 + + 4 + value ------------- Distribution ------------- count + < 0 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -11 + 1 | 0 + + 6 + value ------------- Distribution ------------- count + < 0 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -10 + 1 | 0 + + 8 + value ------------- Distribution ------------- count + < 0 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -9 + 1 | 0 + + 10 + value ------------- Distribution ------------- count + < 0 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -8 + 1 | 0 + + 12 + value ------------- Distribution ------------- count + < 0 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -7 + 1 | 0 + + 1 + value ------------- Distribution ------------- count + < 0 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -6 + 1 | 0 + + 3 + value ------------- Distribution ------------- count + < 0 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -5 + 1 | 0 + + 5 + value ------------- Distribution ------------- count + < 0 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -4 + 1 | 0 + + 7 + value ------------- Distribution ------------- count + < 0 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -3 + 1 | 0 + + 9 + value ------------- Distribution ------------- count + < 0 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -2 + 1 | 0 + + 11 + value ------------- Distribution ------------- count + < 0 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -1 + 1 | 0 + + 14 + value ------------- Distribution ------------- count + < 0 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 1 | 0 + + 16 + value ------------- Distribution ------------- count + < 0 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2 + 1 | 0 + + 18 + value ------------- Distribution ------------- count + < 0 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3 + 1 | 0 + + 20 + value ------------- Distribution ------------- count + < 0 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 4 + 1 | 0 + + 22 + value ------------- Distribution ------------- count + < 0 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5 + 1 | 0 + + 24 + value ------------- Distribution ------------- count + < 0 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6 + 1 | 0 + + 13 + value ------------- Distribution ------------- count + < 0 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7 + 1 | 0 + + 15 + value ------------- Distribution ------------- count + < 0 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8 + 1 | 0 + + 17 + value ------------- Distribution ------------- count + < 0 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9 + 1 | 0 + + 19 + value ------------- Distribution ------------- count + < 0 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 10 + 1 | 0 + + 21 + value ------------- Distribution ------------- count + < 0 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 11 + 1 | 0 + + 23 + value ------------- Distribution ------------- count + < 0 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12 + 1 | 0 + + +Zero within the range: + + 2 + value ------------- Distribution ------------- count + -1 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -12 + 1 | 0 + + 4 + value ------------- Distribution ------------- count + -1 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -11 + 1 | 0 + + 6 + value ------------- Distribution ------------- count + -1 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -10 + 1 | 0 + + 8 + value ------------- Distribution ------------- count + -1 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -9 + 1 | 0 + + 10 + value ------------- Distribution ------------- count + -1 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -8 + 1 | 0 + + 12 + value ------------- Distribution ------------- count + -1 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -7 + 1 | 0 + + 1 + value ------------- Distribution ------------- count + -1 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -6 + 1 | 0 + + 3 + value ------------- Distribution ------------- count + -1 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -5 + 1 | 0 + + 5 + value ------------- Distribution ------------- count + -1 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -4 + 1 | 0 + + 7 + value ------------- Distribution ------------- count + -1 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -3 + 1 | 0 + + 9 + value ------------- Distribution ------------- count + -1 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -2 + 1 | 0 + + 11 + value ------------- Distribution ------------- count + -1 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -1 + 1 | 0 + + 14 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 1 | 0 + + 16 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2 + 1 | 0 + + 18 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3 + 1 | 0 + + 20 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 4 + 1 | 0 + + 22 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5 + 1 | 0 + + 24 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6 + 1 | 0 + + 13 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7 + 1 | 0 + + 15 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8 + 1 | 0 + + 17 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9 + 1 | 0 + + 19 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 10 + 1 | 0 + + 21 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 11 + 1 | 0 + + 23 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12 + 1 | 0 + + +Zero at the top of the range: + + 2 + value ------------- Distribution ------------- count + -1 | 0 + >= 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -12 + + 4 + value ------------- Distribution ------------- count + -1 | 0 + >= 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -11 + + 6 + value ------------- Distribution ------------- count + -1 | 0 + >= 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -10 + + 8 + value ------------- Distribution ------------- count + -1 | 0 + >= 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -9 + + 10 + value ------------- Distribution ------------- count + -1 | 0 + >= 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -8 + + 12 + value ------------- Distribution ------------- count + -1 | 0 + >= 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -7 + + 1 + value ------------- Distribution ------------- count + -1 | 0 + >= 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -6 + + 3 + value ------------- Distribution ------------- count + -1 | 0 + >= 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -5 + + 5 + value ------------- Distribution ------------- count + -1 | 0 + >= 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -4 + + 7 + value ------------- Distribution ------------- count + -1 | 0 + >= 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -3 + + 9 + value ------------- Distribution ------------- count + -1 | 0 + >= 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -2 + + 11 + value ------------- Distribution ------------- count + -1 | 0 + >= 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -1 + + 14 + value ------------- Distribution ------------- count + -1 | 0 + >= 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + + 16 + value ------------- Distribution ------------- count + -1 | 0 + >= 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2 + + 18 + value ------------- Distribution ------------- count + -1 | 0 + >= 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3 + + 20 + value ------------- Distribution ------------- count + -1 | 0 + >= 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 4 + + 22 + value ------------- Distribution ------------- count + -1 | 0 + >= 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5 + + 24 + value ------------- Distribution ------------- count + -1 | 0 + >= 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6 + + 13 + value ------------- Distribution ------------- count + -1 | 0 + >= 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7 + + 15 + value ------------- Distribution ------------- count + -1 | 0 + >= 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8 + + 17 + value ------------- Distribution ------------- count + -1 | 0 + >= 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9 + + 19 + value ------------- Distribution ------------- count + -1 | 0 + >= 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 10 + + 21 + value ------------- Distribution ------------- count + -1 | 0 + >= 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 11 + + 23 + value ------------- Distribution ------------- count + -1 | 0 + >= 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12 + + +Zero just above the range: + + 2 + value ------------- Distribution ------------- count + -2 | 0 + >= -1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -12 + + 4 + value ------------- Distribution ------------- count + -2 | 0 + >= -1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -11 + + 6 + value ------------- Distribution ------------- count + -2 | 0 + >= -1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -10 + + 8 + value ------------- Distribution ------------- count + -2 | 0 + >= -1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -9 + + 10 + value ------------- Distribution ------------- count + -2 | 0 + >= -1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -8 + + 12 + value ------------- Distribution ------------- count + -2 | 0 + >= -1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -7 + + 1 + value ------------- Distribution ------------- count + -2 | 0 + >= -1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -6 + + 3 + value ------------- Distribution ------------- count + -2 | 0 + >= -1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -5 + + 5 + value ------------- Distribution ------------- count + -2 | 0 + >= -1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -4 + + 7 + value ------------- Distribution ------------- count + -2 | 0 + >= -1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -3 + + 9 + value ------------- Distribution ------------- count + -2 | 0 + >= -1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -2 + + 11 + value ------------- Distribution ------------- count + -2 | 0 + >= -1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -1 + + 14 + value ------------- Distribution ------------- count + -2 | 0 + >= -1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + + 16 + value ------------- Distribution ------------- count + -2 | 0 + >= -1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2 + + 18 + value ------------- Distribution ------------- count + -2 | 0 + >= -1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3 + + 20 + value ------------- Distribution ------------- count + -2 | 0 + >= -1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 4 + + 22 + value ------------- Distribution ------------- count + -2 | 0 + >= -1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5 + + 24 + value ------------- Distribution ------------- count + -2 | 0 + >= -1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6 + + 13 + value ------------- Distribution ------------- count + -2 | 0 + >= -1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7 + + 15 + value ------------- Distribution ------------- count + -2 | 0 + >= -1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8 + + 17 + value ------------- Distribution ------------- count + -2 | 0 + >= -1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9 + + 19 + value ------------- Distribution ------------- count + -2 | 0 + >= -1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 10 + + 21 + value ------------- Distribution ------------- count + -2 | 0 + >= -1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 11 + + 23 + value ------------- Distribution ------------- count + -2 | 0 + >= -1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12 + + +Zero above the range: + + 23 + value ------------- Distribution ------------- count + -3 | 0 + >= -2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12 + + 21 + value ------------- Distribution ------------- count + -3 | 0 + >= -2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 11 + + 19 + value ------------- Distribution ------------- count + -3 | 0 + >= -2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 10 + + 17 + value ------------- Distribution ------------- count + -3 | 0 + >= -2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9 + + 15 + value ------------- Distribution ------------- count + -3 | 0 + >= -2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8 + + 13 + value ------------- Distribution ------------- count + -3 | 0 + >= -2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7 + + 24 + value ------------- Distribution ------------- count + -3 | 0 + >= -2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6 + + 22 + value ------------- Distribution ------------- count + -3 | 0 + >= -2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5 + + 20 + value ------------- Distribution ------------- count + -3 | 0 + >= -2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 4 + + 18 + value ------------- Distribution ------------- count + -3 | 0 + >= -2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3 + + 16 + value ------------- Distribution ------------- count + -3 | 0 + >= -2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2 + + 14 + value ------------- Distribution ------------- count + -3 | 0 + >= -2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + + 11 + value ------------- Distribution ------------- count + -3 | 0 + >= -2 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -1 + + 9 + value ------------- Distribution ------------- count + -3 | 0 + >= -2 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -2 + + 7 + value ------------- Distribution ------------- count + -3 | 0 + >= -2 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -3 + + 5 + value ------------- Distribution ------------- count + -3 | 0 + >= -2 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -4 + + 3 + value ------------- Distribution ------------- count + -3 | 0 + >= -2 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -5 + + 1 + value ------------- Distribution ------------- count + -3 | 0 + >= -2 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -6 + + 12 + value ------------- Distribution ------------- count + -3 | 0 + >= -2 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -7 + + 10 + value ------------- Distribution ------------- count + -3 | 0 + >= -2 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -8 + + 8 + value ------------- Distribution ------------- count + -3 | 0 + >= -2 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -9 + + 6 + value ------------- Distribution ------------- count + -3 | 0 + >= -2 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -10 + + 4 + value ------------- Distribution ------------- count + -3 | 0 + >= -2 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -11 + + 2 + value ------------- Distribution ------------- count + -3 | 0 + >= -2 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -12 + + + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.max.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.max.d new file mode 100644 index 000000000000..0c973ad56dc6 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.max.d @@ -0,0 +1,58 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Positive max() test + * + * SECTION: Aggregations/Aggregations + * + * NOTES: This is verifiable simple positive test of the max() function. + * + */ + +#pragma D option quiet + +BEGIN +{ + i = 0; +} + +tick-10ms +/i < 1000/ +{ + @a = max(i); + i += 100; +} + +tick-10ms +/i == 1000/ +{ + printa(@a); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.max.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.max.d.out new file mode 100644 index 000000000000..d3957f4ccf12 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.max.d.out @@ -0,0 +1,3 @@ + + 900 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.max_neg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.max_neg.d new file mode 100644 index 000000000000..63486e5fce21 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.max_neg.d @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Positive max() test using negative values + * + * SECTION: Aggregations/Aggregations + * + * NOTES: This is verifiable simple positive test of the max() function. + * + */ + +#pragma D option quiet + +BEGIN +{ + @ = max(0); + @ = max(-900); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.max_neg.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.max_neg.d.out new file mode 100644 index 000000000000..8d23188fd1f0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.max_neg.d.out @@ -0,0 +1,2 @@ + + 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.min.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.min.d new file mode 100644 index 000000000000..aff5452e62be --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.min.d @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Positive min() test + * + * SECTION: Aggregations/Aggregations + * + * NOTES: This is verifiable simple positive test of the min() function. + * + */ + +#pragma D option quiet + +BEGIN +{ + i = 0; +} + +tick-10ms +/i < 1000/ +{ + @a = min(i); + i += 100; +} + +tick-10ms +/i == 1000/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.min.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.min.d.out new file mode 100644 index 000000000000..8d23188fd1f0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.min.d.out @@ -0,0 +1,2 @@ + + 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.min_neg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.min_neg.d new file mode 100644 index 000000000000..20f0a56d8b88 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.min_neg.d @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Positive min() test using negative values + * + * SECTION: Aggregations/Aggregations + * + * NOTES: This is verifiable simple positive test of the min() function. + * + */ + +#pragma D option quiet + +BEGIN +{ + @ = min(0); + @ = min(-900); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.min_neg.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.min_neg.d.out new file mode 100644 index 000000000000..461b29cfd2d3 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.min_neg.d.out @@ -0,0 +1,2 @@ + + -900 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.multiaggs1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.multiaggs1.d new file mode 100644 index 000000000000..80cffd4c9694 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.multiaggs1.d @@ -0,0 +1,66 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Multiple aggregates can be used within the same D script. + * + * SECTION: Aggregations/Aggregations + * + */ + +#pragma D option quiet + +BEGIN +{ + time_1 = timestamp; + i = 0; +} + +tick-10ms +/i <= 10/ +{ + time_2 = timestamp; + new_time = time_2 - time_1; + @a[pid] = max(new_time); + @b[pid] = min(new_time); + @c[pid] = avg(new_time); + @d[pid] = sum(new_time); + @e[pid] = quantize(new_time); + @f[timestamp] = max(new_time); + @g[timestamp] = quantize(new_time); + @h[timestamp] = lquantize(new_time, 0, 10000, 1000); + time_1 = time_2; + i++; +} + +tick-10ms +/i == 10/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.multiaggs2.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.multiaggs2.d new file mode 100644 index 000000000000..21c05b8e844b --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.multiaggs2.d @@ -0,0 +1,62 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Test multiple aggregations and the default output order + * + * SECTION: Aggregations/Aggregations; + * Aggregations/Output + * + */ + +#pragma D option quiet + +BEGIN +{ + i = 0; +} + +tick-10ms +/i < 1000/ +{ + @a = avg(i); + @b = sum(i); + @c = min(i); + @d = max(i); + @e = quantize(i); + @f = lquantize(i, 0, 1000, 100); + + i += 100; +} + +tick-10ms +/i == 1000/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.multiaggs2.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.multiaggs2.d.out new file mode 100644 index 000000000000..2e84e08ead16 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.multiaggs2.d.out @@ -0,0 +1,36 @@ + + 450 + 4500 + 0 + 900 + + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@ 1 + 1 | 0 + 2 | 0 + 4 | 0 + 8 | 0 + 16 | 0 + 32 | 0 + 64 |@@@@ 1 + 128 |@@@@ 1 + 256 |@@@@@@@@@@@@ 3 + 512 |@@@@@@@@@@@@@@@@ 4 + 1024 | 0 + + + value ------------- Distribution ------------- count + < 0 | 0 + 0 |@@@@ 1 + 100 |@@@@ 1 + 200 |@@@@ 1 + 300 |@@@@ 1 + 400 |@@@@ 1 + 500 |@@@@ 1 + 600 |@@@@ 1 + 700 |@@@@ 1 + 800 |@@@@ 1 + 900 |@@@@ 1 + >= 1000 | 0 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.multiaggs3.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.multiaggs3.d new file mode 100644 index 000000000000..0685c0dac059 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.multiaggs3.d @@ -0,0 +1,74 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Test multiple aggregations and overriding default order with + * printa() statements. + * + * SECTION: Aggregations/Aggregations; + * Aggregations/Output + * + * NOTES: This is a simple verifiable test. + * + */ + +#pragma D option quiet + +BEGIN +{ + i = 0; +} + +tick-10ms +/i < 1000/ +{ + @a = count(); + @b = avg(i); + @c = sum(i); + @d = min(i); + @e = max(i); + @f = quantize(i); + @g = lquantize(i, 0, 1000, 100); + + i += 100; +} + +tick-10ms +/i == 1000/ +{ + printa("%@d\n", @g); + printa("%@d\n", @f); + printa("%@d\n", @e); + printa("%@d\n", @d); + printa("%@d\n", @c); + printa("%@d\n", @b); + printa("%@d\n", @a); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.multiaggs3.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.multiaggs3.d.out new file mode 100644 index 000000000000..b0c49a33d3e6 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.multiaggs3.d.out @@ -0,0 +1,37 @@ + + value ------------- Distribution ------------- count + < 0 | 0 + 0 |@@@@ 1 + 100 |@@@@ 1 + 200 |@@@@ 1 + 300 |@@@@ 1 + 400 |@@@@ 1 + 500 |@@@@ 1 + 600 |@@@@ 1 + 700 |@@@@ 1 + 800 |@@@@ 1 + 900 |@@@@ 1 + >= 1000 | 0 + + + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@ 1 + 1 | 0 + 2 | 0 + 4 | 0 + 8 | 0 + 16 | 0 + 32 | 0 + 64 |@@@@ 1 + 128 |@@@@ 1 + 256 |@@@@@@@@@@@@ 3 + 512 |@@@@@@@@@@@@@@@@ 4 + 1024 | 0 + +900 +0 +4500 +450 +10 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.multinormalize.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.multinormalize.d new file mode 100644 index 000000000000..2cfa1848bd3d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.multinormalize.d @@ -0,0 +1,65 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Multiple aggregations are supported + * + * SECTION: Aggregations/Normalization + * + */ + +#pragma D option quiet +#pragma D option aggrate=1ms +#pragma D option switchrate=50ms + +BEGIN +{ + i = 0; + start = timestamp; +} + +tick-100ms +/i < 20/ +{ + @func1[i % 5] = sum(i * 100); + @func2[i % 5 + 1] = sum(i * 200); + i++; +} + +tick-100ms +/i == 20/ +{ + printf("normalized data #1:\n"); + normalize(@func1, 5); + printa(@func1); + + printf("\nnormalized data #2:\n"); + normalize(@func2, 5); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.multinormalize.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.multinormalize.d.out new file mode 100644 index 000000000000..992b31e21fed --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.multinormalize.d.out @@ -0,0 +1,15 @@ +normalized data #1: + + 0 600 + 1 680 + 2 760 + 3 840 + 4 920 + +normalized data #2: + + 1 1200 + 2 1360 + 3 1520 + 4 1680 + 5 1840 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.neglquant.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.neglquant.d new file mode 100644 index 000000000000..d24884b5da6d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.neglquant.d @@ -0,0 +1,150 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +BEGIN +{ + @["j-church"] = lquantize(1, 0, 10, 1, 100); + @["j-church"] = lquantize(1, 0, 10, 1, -99); + @["j-church"] = lquantize(1, 0, 10, 1, -1); + val = 123; +} + +BEGIN +{ + @["k-ingleside"] = lquantize(1, 0, 10, 1, -val); +} + +BEGIN +{ + @["l-taraval"] = lquantize(0, 0, 10, 1, -val); + @["l-taraval"] = lquantize(-1, 0, 10, 1, -val); + @["l-taraval"] = lquantize(1, 0, 10, 1, val); + @["l-taraval"] = lquantize(1, 0, 10, 1, val); +} + +BEGIN +{ + @["m-oceanview"] = lquantize(1, 0, 10, 1, (1 << 63) - 1); + @["m-oceanview"] = lquantize(1, 0, 10, 1); + @["m-oceanview"] = lquantize(2, 0, 10, 1, (1 << 63) - 1); + @["m-oceanview"] = lquantize(8, 0, 10, 1, 400000); +} + +BEGIN +{ + @["n-judah"] = lquantize(1, 0, 10, 1, val); + @["n-judah"] = lquantize(2, 0, 10, 1, val); + @["n-judah"] = lquantize(2, 0, 10, 1, val); + @["n-judah"] = lquantize(2, 0, 10, 1); +} + +BEGIN +{ + this->i = 1; + this->val = (1 << 63) - 1; + + @["f-market"] = lquantize(this->i, 0, 10, 1, this->val); + this->i++; + this->val = ((1 << 63) - 1) / this->i; + + @["f-market"] = lquantize(this->i, 0, 10, 1, this->val); + this->i++; + this->val = ((1 << 63) - 1) / this->i; + + @["f-market"] = lquantize(this->i, 0, 10, 1, this->val); + this->i++; + this->val = ((1 << 63) - 1) / this->i; + + @["f-market"] = lquantize(this->i, 0, 10, 1, this->val); + this->i++; + this->val = ((1 << 63) - 1) / this->i; + + @["f-market"] = lquantize(this->i, 0, 10, 1, this->val); + this->i++; + this->val = ((1 << 63) - 1) / this->i; + + @["f-market"] = lquantize(this->i, 0, 10, 1, this->val); + this->i++; + this->val = ((1 << 63) - 1) / this->i; + + @["f-market"] = lquantize(this->i, 0, 10, 1, this->val); + this->i++; + this->val = ((1 << 63) - 1) / this->i; +} + +BEGIN +{ + this->i = 1; + + /* + * We want to test the ability to sort very large quantizations + * that differ by a small amount. Ideally, they would differ only + * by 1 -- but that is smaller than the precision of long doubles of + * this magnitude on x86. To assure that the same test works on x86 + * just as it does on SPARC, we pick a value that is just larger than + * the precision at this magnitude. It should go without saying that + * this robustness on new ISAs very much depends on the precision + * of the long double representation. + */ + this->val = (1 << 63) - 7; + + @["s-castro"] = lquantize(this->i, 0, 10, 1, this->val); + this->i++; + this->val = ((1 << 63) - 1) / this->i; + + @["s-castro"] = lquantize(this->i, 0, 10, 1, this->val); + this->i++; + this->val = ((1 << 63) - 1) / this->i; + + @["s-castro"] = lquantize(this->i, 0, 10, 1, this->val); + this->i++; + this->val = ((1 << 63) - 1) / this->i; + + @["s-castro"] = lquantize(this->i, 0, 10, 1, this->val); + this->i++; + this->val = ((1 << 63) - 1) / this->i; + + @["s-castro"] = lquantize(this->i, 0, 10, 1, this->val); + this->i++; + this->val = ((1 << 63) - 1) / this->i; + + @["s-castro"] = lquantize(this->i, 0, 10, 1, this->val); + this->i++; + this->val = ((1 << 63) - 1) / this->i; + + @["s-castro"] = lquantize(this->i, 0, 10, 1, this->val); + this->i++; + this->val = ((1 << 63) - 1) / this->i; +} + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.neglquant.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.neglquant.d.out new file mode 100644 index 000000000000..3b7533b17145 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.neglquant.d.out @@ -0,0 +1,64 @@ + + k-ingleside + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -123 + 2 | 0 + + j-church + value ------------- Distribution ------------- count + < 0 | 0 + 0 | 0 + 1 | 0 + + l-taraval + value ------------- Distribution ------------- count + < 0 @@@@@| -123 + 0 @@@@@| -123 + 1 |@@@@@@@@@@ 246 + 2 | 0 + + n-judah + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@ 123 + 2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@ 247 + 3 | 0 + + m-oceanview + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@| -9223372036854775808 + 2 |@@@@@@@@@@ 9223372036854775807 + 3 | 0 + 4 | 0 + 5 | 0 + 6 | 0 + 7 | 0 + 8 | 400000 + 9 | 0 + + s-castro + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@ 9223372036854775801 + 2 |@@@@@@@@ 4611686018427387903 + 3 |@@@@@ 3074457345618258602 + 4 |@@@@ 2305843009213693951 + 5 |@@@ 1844674407370955161 + 6 |@@@ 1537228672809129301 + 7 |@@ 1317624576693539401 + 8 | 0 + + f-market + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@ 9223372036854775807 + 2 |@@@@@@@@ 4611686018427387903 + 3 |@@@@@ 3074457345618258602 + 4 |@@@@ 2305843009213693951 + 5 |@@@ 1844674407370955161 + 6 |@@@ 1537228672809129301 + 7 |@@ 1317624576693539401 + 8 | 0 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.negorder.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.negorder.d new file mode 100644 index 000000000000..440c4839459e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.negorder.d @@ -0,0 +1,85 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +BEGIN +{ + a = 7; + b = 13; + val = (-a * b) + a; +} + +tick-1ms +{ + incr = val % b; + val += a; +} + +tick-1ms +/val == 0/ +{ + val += a; +} + +tick-1ms +/incr != 0/ +{ + i++; + @quanty[i] = quantize(1, incr); + @lquanty[i] = lquantize(1, -10, 10, 1, incr); + @summy[i] = sum(incr); + @maxxy[i] = max(incr); + @minny[i] = min(incr); +} + +tick-1ms +/incr == 0/ +{ + printf("Ordering of quantize() with some negative weights:\n"); + printa(@quanty); + printf("\n"); + + printf("Ordering of lquantize() with some negative weights:\n"); + printa(@lquanty); + printf("\n"); + + printf("Ordering of sum() with some negative weights:\n"); + printa(@summy); + printf("\n"); + + printf("Ordering of max() with some negative weights:\n"); + printa(@maxxy); + printf("\n"); + + printf("Ordering of min() with some negative weights:\n"); + printa(@minny); + printf("\n"); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.negorder.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.negorder.d.out new file mode 100644 index 000000000000..a03b685044a4 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.negorder.d.out @@ -0,0 +1,376 @@ +Ordering of quantize() with some negative weights: + + 2 + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -12 + 2 | 0 + + 4 + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -11 + 2 | 0 + + 6 + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -10 + 2 | 0 + + 8 + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -9 + 2 | 0 + + 10 + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -8 + 2 | 0 + + 12 + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -7 + 2 | 0 + + 1 + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -6 + 2 | 0 + + 3 + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -5 + 2 | 0 + + 5 + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -4 + 2 | 0 + + 7 + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -3 + 2 | 0 + + 9 + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -2 + 2 | 0 + + 11 + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -1 + 2 | 0 + + 14 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 2 | 0 + + 16 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2 + 2 | 0 + + 18 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3 + 2 | 0 + + 20 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 4 + 2 | 0 + + 22 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5 + 2 | 0 + + 24 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6 + 2 | 0 + + 13 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7 + 2 | 0 + + 15 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8 + 2 | 0 + + 17 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9 + 2 | 0 + + 19 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 10 + 2 | 0 + + 21 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 11 + 2 | 0 + + 23 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12 + 2 | 0 + + +Ordering of lquantize() with some negative weights: + + 2 + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -12 + 2 | 0 + + 4 + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -11 + 2 | 0 + + 6 + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -10 + 2 | 0 + + 8 + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -9 + 2 | 0 + + 10 + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -8 + 2 | 0 + + 12 + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -7 + 2 | 0 + + 1 + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -6 + 2 | 0 + + 3 + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -5 + 2 | 0 + + 5 + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -4 + 2 | 0 + + 7 + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -3 + 2 | 0 + + 9 + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -2 + 2 | 0 + + 11 + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -1 + 2 | 0 + + 14 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 2 | 0 + + 16 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2 + 2 | 0 + + 18 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3 + 2 | 0 + + 20 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 4 + 2 | 0 + + 22 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5 + 2 | 0 + + 24 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6 + 2 | 0 + + 13 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7 + 2 | 0 + + 15 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8 + 2 | 0 + + 17 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9 + 2 | 0 + + 19 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 10 + 2 | 0 + + 21 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 11 + 2 | 0 + + 23 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12 + 2 | 0 + + +Ordering of sum() with some negative weights: + + 2 -12 + 4 -11 + 6 -10 + 8 -9 + 10 -8 + 12 -7 + 1 -6 + 3 -5 + 5 -4 + 7 -3 + 9 -2 + 11 -1 + 14 1 + 16 2 + 18 3 + 20 4 + 22 5 + 24 6 + 13 7 + 15 8 + 17 9 + 19 10 + 21 11 + 23 12 + +Ordering of max() with some negative weights: + + 2 -12 + 4 -11 + 6 -10 + 8 -9 + 10 -8 + 12 -7 + 1 -6 + 3 -5 + 5 -4 + 7 -3 + 9 -2 + 11 -1 + 14 1 + 16 2 + 18 3 + 20 4 + 22 5 + 24 6 + 13 7 + 15 8 + 17 9 + 19 10 + 21 11 + 23 12 + +Ordering of min() with some negative weights: + + 2 -12 + 4 -11 + 6 -10 + 8 -9 + 10 -8 + 12 -7 + 1 -6 + 3 -5 + 5 -4 + 7 -3 + 9 -2 + 11 -1 + 14 1 + 16 2 + 18 3 + 20 4 + 22 5 + 24 6 + 13 7 + 15 8 + 17 9 + 19 10 + 21 11 + 23 12 + + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.negquant.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.negquant.d new file mode 100644 index 000000000000..bbc7263dc58c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.negquant.d @@ -0,0 +1,115 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +BEGIN +{ + @["j-church"] = quantize(1, 100); + @["j-church"] = quantize(1, -99); + @["j-church"] = quantize(1, -1); + val = 123; +} + +BEGIN +{ + @["k-ingleside"] = quantize(1, -val); +} + +BEGIN +{ + @["l-taraval"] = quantize(0, -val); + @["l-taraval"] = quantize(-1, -val); + @["l-taraval"] = quantize(1, val); + @["l-taraval"] = quantize(1, val); +} + +BEGIN +{ + @["m-oceanview"] = quantize(1, (1 << 63) - 1); + @["m-oceanview"] = quantize(1); + @["m-oceanview"] = quantize(2, (1 << 63) - 1); + @["m-oceanview"] = quantize(8, 400000); +} + +BEGIN +{ + @["n-judah"] = quantize(1, val); + @["n-judah"] = quantize(2, val); + @["n-judah"] = quantize(2, val); + @["n-judah"] = quantize(2); +} + +BEGIN +{ + this->i = 1; + this->val = (1 << 63) - 1; + + @["f-market"] = quantize(this->i, this->val); + this->i <<= 1; + this->val >>= 1; + + @["f-market"] = quantize(this->i, this->val); + this->i <<= 1; + this->val >>= 1; + + @["f-market"] = quantize(this->i, this->val); + this->i <<= 1; + this->val >>= 1; + + @["f-market"] = quantize(this->i, this->val); + this->i <<= 1; + this->val >>= 1; +} + +BEGIN +{ + this->i = 1; + this->val = (1 << 63) - 4; + + @["s-castro"] = quantize(this->i, this->val); + this->i <<= 1; + this->val >>= 1; + + @["s-castro"] = quantize(this->i, this->val); + this->i <<= 1; + this->val >>= 1; + + @["s-castro"] = quantize(this->i, this->val); + this->i <<= 1; + this->val >>= 1; + + @["s-castro"] = quantize(this->i, this->val); + this->i <<= 1; + this->val >>= 1; +} + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.negquant.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.negquant.d.out new file mode 100644 index 000000000000..f8466b3367ba --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.negquant.d.out @@ -0,0 +1,55 @@ + + k-ingleside + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -123 + 2 | 0 + + j-church + value ------------- Distribution ------------- count + -1 | 0 + 0 | 0 + 1 | 0 + + l-taraval + value ------------- Distribution ------------- count + -2 | 0 + -1 @@@@@| -123 + 0 @@@@@| -123 + 1 |@@@@@@@@@@ 246 + 2 | 0 + + n-judah + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@ 123 + 2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@ 247 + 4 | 0 + + m-oceanview + value ------------- Distribution ------------- count + 0 | 0 + 1 @@@@@@@@@@| -9223372036854775808 + 2 |@@@@@@@@@@ 9223372036854775807 + 4 | 0 + 8 | 400000 + 16 | 0 + + s-castro + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@ 9223372036854775804 + 2 |@@@@@@@@@@@ 4611686018427387902 + 4 |@@@@@ 2305843009213693951 + 8 |@@@ 1152921504606846975 + 16 | 0 + + f-market + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@@@@@@@@@ 9223372036854775807 + 2 |@@@@@@@@@@@ 4611686018427387903 + 4 |@@@@@ 2305843009213693951 + 8 |@@@ 1152921504606846975 + 16 | 0 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.negtrunc.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.negtrunc.d new file mode 100644 index 000000000000..f90eae134805 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.negtrunc.d @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +int i; + +tick-10ms +/i < 100/ +{ + @[i] = sum(i); + i++; +} + +tick-10ms +/i == 100/ +{ + exit(0); +} + +END +{ + trunc(@, -10); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.negtrunc.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.negtrunc.d.out new file mode 100644 index 000000000000..c1b07a6dae09 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.negtrunc.d.out @@ -0,0 +1,11 @@ + + 0 0 + 1 1 + 2 2 + 3 3 + 4 4 + 5 5 + 6 6 + 7 7 + 8 8 + 9 9 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.negtruncquant.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.negtruncquant.d new file mode 100644 index 000000000000..2a13d659331c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.negtruncquant.d @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +int i; + +tick-10ms +/i < 100/ +{ + @[i] = lquantize(i, 0, 150); + @[i] = lquantize(i + 1, 0, 150); + @[i] = lquantize(i + 2, 0, 150); + @[i] = lquantize(i + 3, 0, 150); + i++; +} + +tick-10ms +/i == 100/ +{ + exit(0); +} + +END +{ + trunc(@, -5); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.negtruncquant.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.negtruncquant.d.out new file mode 100644 index 000000000000..264aa392e2ab --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.negtruncquant.d.out @@ -0,0 +1,46 @@ + + 0 + value ------------- Distribution ------------- count + < 0 | 0 + 0 |@@@@@@@@@@ 1 + 1 |@@@@@@@@@@ 1 + 2 |@@@@@@@@@@ 1 + 3 |@@@@@@@@@@ 1 + 4 | 0 + + 1 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@ 1 + 2 |@@@@@@@@@@ 1 + 3 |@@@@@@@@@@ 1 + 4 |@@@@@@@@@@ 1 + 5 | 0 + + 2 + value ------------- Distribution ------------- count + 1 | 0 + 2 |@@@@@@@@@@ 1 + 3 |@@@@@@@@@@ 1 + 4 |@@@@@@@@@@ 1 + 5 |@@@@@@@@@@ 1 + 6 | 0 + + 3 + value ------------- Distribution ------------- count + 2 | 0 + 3 |@@@@@@@@@@ 1 + 4 |@@@@@@@@@@ 1 + 5 |@@@@@@@@@@ 1 + 6 |@@@@@@@@@@ 1 + 7 | 0 + + 4 + value ------------- Distribution ------------- count + 3 | 0 + 4 |@@@@@@@@@@ 1 + 5 |@@@@@@@@@@ 1 + 6 |@@@@@@@@@@ 1 + 7 |@@@@@@@@@@ 1 + 8 | 0 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.normalize.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.normalize.d new file mode 100644 index 000000000000..0bcc0fe9134e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.normalize.d @@ -0,0 +1,60 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Positive test for normalization() + * + * SECTION: Aggregations/Normalization + * + */ + +#pragma D option quiet +#pragma D option aggrate=1ms +#pragma D option switchrate=50ms + +BEGIN +{ + i = 0; + start = timestamp; +} + +tick-100ms +/i < 20/ +{ + @func[i % 5] = sum(i * 100); + i++; +} + +tick-100ms +/i == 20/ +{ + printf("normalized data:\n"); + normalize(@func, 5); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.normalize.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.normalize.d.out new file mode 100644 index 000000000000..11193e65d810 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.normalize.d.out @@ -0,0 +1,7 @@ +normalized data: + + 0 600 + 1 680 + 2 760 + 3 840 + 4 920 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.order.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.order.d new file mode 100644 index 000000000000..139001164b6a --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.order.d @@ -0,0 +1,78 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +BEGIN +{ + @[8] = sum(1); + @[6] = sum(1); + @[7] = sum(1); + @[5] = sum(1); + @[3] = sum(1); + @[0] = sum(1); + @[9] = sum(1); + + @tour["Ghent"] = sum(1); + @tour["Berlin"] = sum(1); + @tour["London"] = sum(1); + @tour["Dublin"] = sum(1); + @tour["Shanghai"] = sum(1); + @tour["Zurich"] = sum(1); + @tour["Regina"] = sum(1); + @tour["Winnipeg"] = sum(1); + @tour["Edmonton"] = sum(1); + @tour["Calgary"] = sum(1); + + @ate[8, "Rice"] = sum(1); + @ate[8, "Oatmeal"] = sum(1); + @ate[8, "Barley"] = sum(1); + @ate[8, "Carrots"] = sum(1); + @ate[8, "Sweet potato"] = sum(1); + @ate[8, "Asparagus"] = sum(1); + @ate[8, "Squash"] = sum(1); + + @chars['a'] = sum(1); + @chars['s'] = sum(1); + @chars['d'] = sum(1); + @chars['f'] = sum(1); + + printa("%d\n", @); + printf("\n"); + + printa("%s\n", @tour); + printf("\n"); + + printa("%d %s\n", @ate); + printf("\n"); + + printa("%c\n", @chars); + printf("\n"); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.order.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.order.d.out new file mode 100644 index 000000000000..505b0f32c9b9 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.order.d.out @@ -0,0 +1,33 @@ +0 +3 +5 +6 +7 +8 +9 + +Berlin +Calgary +Dublin +Edmonton +Ghent +London +Regina +Shanghai +Winnipeg +Zurich + +8 Asparagus +8 Barley +8 Carrots +8 Oatmeal +8 Rice +8 Squash +8 Sweet potato + +a +d +f +s + + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.quantize.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.quantize.d new file mode 100644 index 000000000000..fad472af4b95 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.quantize.d @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Positive quantize() test + * + * SECTION: Aggregations/Aggregations + * + * NOTES: This is verifiable simple positive test of the quantize() function. + * + */ + +#pragma D option quiet + +BEGIN +{ + i = 0; +} + +tick-10ms +/i < 1000/ +{ + @a[i] = quantize(i); + i += 100; +} + +tick-10ms +/i == 1000/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.quantize.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.quantize.d.out new file mode 100644 index 000000000000..f4882ed2bf5d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.quantize.d.out @@ -0,0 +1,61 @@ + + 0 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 1 | 0 + + 100 + value ------------- Distribution ------------- count + 32 | 0 + 64 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 128 | 0 + + 200 + value ------------- Distribution ------------- count + 64 | 0 + 128 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 256 | 0 + + 300 + value ------------- Distribution ------------- count + 128 | 0 + 256 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 512 | 0 + + 400 + value ------------- Distribution ------------- count + 128 | 0 + 256 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 512 | 0 + + 500 + value ------------- Distribution ------------- count + 128 | 0 + 256 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 512 | 0 + + 600 + value ------------- Distribution ------------- count + 256 | 0 + 512 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 1024 | 0 + + 700 + value ------------- Distribution ------------- count + 256 | 0 + 512 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 1024 | 0 + + 800 + value ------------- Distribution ------------- count + 256 | 0 + 512 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 1024 | 0 + + 900 + value ------------- Distribution ------------- count + 256 | 0 + 512 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 1024 | 0 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.quantmany.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.quantmany.d new file mode 100644 index 000000000000..e547b1ec73e4 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.quantmany.d @@ -0,0 +1,56 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +int64_t val, shift; + +tick-1ms +/val == 0/ +{ + val = -(1 << shift); + shift++; +} + +tick-1ms +/shift == 32/ +{ + exit(0); +} + +tick-1ms +/val == -1/ +{ + val = (1 << shift); +} + +tick-1ms +{ + @[shift] = quantize(val, val); + val >>= 1; +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.quantmany.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.quantmany.d.out new file mode 100644 index 000000000000..45df24910b84 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.quantmany.d.out @@ -0,0 +1,1208 @@ + + 1 + value ------------- Distribution ------------- count + 0 | 0 + 1 |@@@@@@@@@@@@@ 1 + 2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2 + 4 | 0 + + 2 + value ------------- Distribution ------------- count + -4 | 0 + -2 @@@@| -2 + -1 | 0 + 0 | 0 + 1 |@@ 1 + 2 |@@@@ 2 + 4 |@@@@@@@@@ 4 + 8 | 0 + + 3 + value ------------- Distribution ------------- count + -8 | 0 + -4 @@@@| -4 + -2 @@| -2 + -1 | 0 + 0 | 0 + 1 |@ 1 + 2 |@@ 2 + 4 |@@@@ 4 + 8 |@@@@@@@@ 8 + 16 | 0 + + 4 + value ------------- Distribution ------------- count + -16 | 0 + -8 @@@@| -8 + -4 @@| -4 + -2 @| -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 |@ 2 + 4 |@@ 4 + 8 |@@@@ 8 + 16 |@@@@@@@ 16 + 32 | 0 + + 5 + value ------------- Distribution ------------- count + -32 | 0 + -16 @@@| -16 + -8 @@| -8 + -4 @| -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 |@ 4 + 8 |@@ 8 + 16 |@@@ 16 + 32 |@@@@@@@ 32 + 64 | 0 + + 6 + value ------------- Distribution ------------- count + -64 | 0 + -32 @@@| -32 + -16 @@| -16 + -8 @| -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 |@ 8 + 16 |@@ 16 + 32 |@@@ 32 + 64 |@@@@@@@ 64 + 128 | 0 + + 7 + value ------------- Distribution ------------- count + -128 | 0 + -64 @@@| -64 + -32 @@| -32 + -16 @| -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 |@ 16 + 32 |@@ 32 + 64 |@@@ 64 + 128 |@@@@@@@ 128 + 256 | 0 + + 8 + value ------------- Distribution ------------- count + -256 | 0 + -128 @@@| -128 + -64 @@| -64 + -32 @| -32 + -16 | -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 | 16 + 32 |@ 32 + 64 |@@ 64 + 128 |@@@ 128 + 256 |@@@@@@@ 256 + 512 | 0 + + 9 + value ------------- Distribution ------------- count + -512 | 0 + -256 @@@| -256 + -128 @@| -128 + -64 @| -64 + -32 | -32 + -16 | -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 | 16 + 32 | 32 + 64 |@ 64 + 128 |@@ 128 + 256 |@@@ 256 + 512 |@@@@@@@ 512 + 1024 | 0 + + 10 + value ------------- Distribution ------------- count + -1024 | 0 + -512 @@@| -512 + -256 @@| -256 + -128 @| -128 + -64 | -64 + -32 | -32 + -16 | -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 | 16 + 32 | 32 + 64 | 64 + 128 |@ 128 + 256 |@@ 256 + 512 |@@@ 512 + 1024 |@@@@@@@ 1024 + 2048 | 0 + + 11 + value ------------- Distribution ------------- count + -2048 | 0 + -1024 @@@| -1024 + -512 @@| -512 + -256 @| -256 + -128 | -128 + -64 | -64 + -32 | -32 + -16 | -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 | 16 + 32 | 32 + 64 | 64 + 128 | 128 + 256 |@ 256 + 512 |@@ 512 + 1024 |@@@ 1024 + 2048 |@@@@@@@ 2048 + 4096 | 0 + + 12 + value ------------- Distribution ------------- count + -4096 | 0 + -2048 @@@| -2048 + -1024 @@| -1024 + -512 @| -512 + -256 | -256 + -128 | -128 + -64 | -64 + -32 | -32 + -16 | -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 | 16 + 32 | 32 + 64 | 64 + 128 | 128 + 256 | 256 + 512 |@ 512 + 1024 |@@ 1024 + 2048 |@@@ 2048 + 4096 |@@@@@@@ 4096 + 8192 | 0 + + 13 + value ------------- Distribution ------------- count + -8192 | 0 + -4096 @@@| -4096 + -2048 @@| -2048 + -1024 @| -1024 + -512 | -512 + -256 | -256 + -128 | -128 + -64 | -64 + -32 | -32 + -16 | -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 | 16 + 32 | 32 + 64 | 64 + 128 | 128 + 256 | 256 + 512 | 512 + 1024 |@ 1024 + 2048 |@@ 2048 + 4096 |@@@ 4096 + 8192 |@@@@@@@ 8192 + 16384 | 0 + + 14 + value ------------- Distribution ------------- count + -16384 | 0 + -8192 @@@| -8192 + -4096 @@| -4096 + -2048 @| -2048 + -1024 | -1024 + -512 | -512 + -256 | -256 + -128 | -128 + -64 | -64 + -32 | -32 + -16 | -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 | 16 + 32 | 32 + 64 | 64 + 128 | 128 + 256 | 256 + 512 | 512 + 1024 | 1024 + 2048 |@ 2048 + 4096 |@@ 4096 + 8192 |@@@ 8192 + 16384 |@@@@@@@ 16384 + 32768 | 0 + + 15 + value ------------- Distribution ------------- count + -32768 | 0 + -16384 @@@| -16384 + -8192 @@| -8192 + -4096 @| -4096 + -2048 | -2048 + -1024 | -1024 + -512 | -512 + -256 | -256 + -128 | -128 + -64 | -64 + -32 | -32 + -16 | -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 | 16 + 32 | 32 + 64 | 64 + 128 | 128 + 256 | 256 + 512 | 512 + 1024 | 1024 + 2048 | 2048 + 4096 |@ 4096 + 8192 |@@ 8192 + 16384 |@@@ 16384 + 32768 |@@@@@@@ 32768 + 65536 | 0 + + 16 + value ------------- Distribution ------------- count + -65536 | 0 + -32768 @@@| -32768 + -16384 @@| -16384 + -8192 @| -8192 + -4096 | -4096 + -2048 | -2048 + -1024 | -1024 + -512 | -512 + -256 | -256 + -128 | -128 + -64 | -64 + -32 | -32 + -16 | -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 | 16 + 32 | 32 + 64 | 64 + 128 | 128 + 256 | 256 + 512 | 512 + 1024 | 1024 + 2048 | 2048 + 4096 | 4096 + 8192 |@ 8192 + 16384 |@@ 16384 + 32768 |@@@ 32768 + 65536 |@@@@@@@ 65536 + 131072 | 0 + + 17 + value ------------- Distribution ------------- count + -131072 | 0 + -65536 @@@| -65536 + -32768 @@| -32768 + -16384 @| -16384 + -8192 | -8192 + -4096 | -4096 + -2048 | -2048 + -1024 | -1024 + -512 | -512 + -256 | -256 + -128 | -128 + -64 | -64 + -32 | -32 + -16 | -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 | 16 + 32 | 32 + 64 | 64 + 128 | 128 + 256 | 256 + 512 | 512 + 1024 | 1024 + 2048 | 2048 + 4096 | 4096 + 8192 | 8192 + 16384 |@ 16384 + 32768 |@@ 32768 + 65536 |@@@ 65536 + 131072 |@@@@@@@ 131072 + 262144 | 0 + + 18 + value ------------- Distribution ------------- count + -262144 | 0 + -131072 @@@| -131072 + -65536 @@| -65536 + -32768 @| -32768 + -16384 | -16384 + -8192 | -8192 + -4096 | -4096 + -2048 | -2048 + -1024 | -1024 + -512 | -512 + -256 | -256 + -128 | -128 + -64 | -64 + -32 | -32 + -16 | -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 | 16 + 32 | 32 + 64 | 64 + 128 | 128 + 256 | 256 + 512 | 512 + 1024 | 1024 + 2048 | 2048 + 4096 | 4096 + 8192 | 8192 + 16384 | 16384 + 32768 |@ 32768 + 65536 |@@ 65536 + 131072 |@@@ 131072 + 262144 |@@@@@@@ 262144 + 524288 | 0 + + 19 + value ------------- Distribution ------------- count + -524288 | 0 + -262144 @@@| -262144 + -131072 @@| -131072 + -65536 @| -65536 + -32768 | -32768 + -16384 | -16384 + -8192 | -8192 + -4096 | -4096 + -2048 | -2048 + -1024 | -1024 + -512 | -512 + -256 | -256 + -128 | -128 + -64 | -64 + -32 | -32 + -16 | -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 | 16 + 32 | 32 + 64 | 64 + 128 | 128 + 256 | 256 + 512 | 512 + 1024 | 1024 + 2048 | 2048 + 4096 | 4096 + 8192 | 8192 + 16384 | 16384 + 32768 | 32768 + 65536 |@ 65536 + 131072 |@@ 131072 + 262144 |@@@ 262144 + 524288 |@@@@@@@ 524288 + 1048576 | 0 + + 20 + value ------------- Distribution ------------- count + -1048576 | 0 + -524288 @@@| -524288 + -262144 @@| -262144 + -131072 @| -131072 + -65536 | -65536 + -32768 | -32768 + -16384 | -16384 + -8192 | -8192 + -4096 | -4096 + -2048 | -2048 + -1024 | -1024 + -512 | -512 + -256 | -256 + -128 | -128 + -64 | -64 + -32 | -32 + -16 | -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 | 16 + 32 | 32 + 64 | 64 + 128 | 128 + 256 | 256 + 512 | 512 + 1024 | 1024 + 2048 | 2048 + 4096 | 4096 + 8192 | 8192 + 16384 | 16384 + 32768 | 32768 + 65536 | 65536 + 131072 |@ 131072 + 262144 |@@ 262144 + 524288 |@@@ 524288 + 1048576 |@@@@@@@ 1048576 + 2097152 | 0 + + 21 + value ------------- Distribution ------------- count + -2097152 | 0 + -1048576 @@@| -1048576 + -524288 @@| -524288 + -262144 @| -262144 + -131072 | -131072 + -65536 | -65536 + -32768 | -32768 + -16384 | -16384 + -8192 | -8192 + -4096 | -4096 + -2048 | -2048 + -1024 | -1024 + -512 | -512 + -256 | -256 + -128 | -128 + -64 | -64 + -32 | -32 + -16 | -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 | 16 + 32 | 32 + 64 | 64 + 128 | 128 + 256 | 256 + 512 | 512 + 1024 | 1024 + 2048 | 2048 + 4096 | 4096 + 8192 | 8192 + 16384 | 16384 + 32768 | 32768 + 65536 | 65536 + 131072 | 131072 + 262144 |@ 262144 + 524288 |@@ 524288 + 1048576 |@@@ 1048576 + 2097152 |@@@@@@@ 2097152 + 4194304 | 0 + + 22 + value ------------- Distribution ------------- count + -4194304 | 0 + -2097152 @@@| -2097152 + -1048576 @@| -1048576 + -524288 @| -524288 + -262144 | -262144 + -131072 | -131072 + -65536 | -65536 + -32768 | -32768 + -16384 | -16384 + -8192 | -8192 + -4096 | -4096 + -2048 | -2048 + -1024 | -1024 + -512 | -512 + -256 | -256 + -128 | -128 + -64 | -64 + -32 | -32 + -16 | -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 | 16 + 32 | 32 + 64 | 64 + 128 | 128 + 256 | 256 + 512 | 512 + 1024 | 1024 + 2048 | 2048 + 4096 | 4096 + 8192 | 8192 + 16384 | 16384 + 32768 | 32768 + 65536 | 65536 + 131072 | 131072 + 262144 | 262144 + 524288 |@ 524288 + 1048576 |@@ 1048576 + 2097152 |@@@ 2097152 + 4194304 |@@@@@@@ 4194304 + 8388608 | 0 + + 23 + value ------------- Distribution ------------- count + -8388608 | 0 + -4194304 @@@| -4194304 + -2097152 @@| -2097152 + -1048576 @| -1048576 + -524288 | -524288 + -262144 | -262144 + -131072 | -131072 + -65536 | -65536 + -32768 | -32768 + -16384 | -16384 + -8192 | -8192 + -4096 | -4096 + -2048 | -2048 + -1024 | -1024 + -512 | -512 + -256 | -256 + -128 | -128 + -64 | -64 + -32 | -32 + -16 | -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 | 16 + 32 | 32 + 64 | 64 + 128 | 128 + 256 | 256 + 512 | 512 + 1024 | 1024 + 2048 | 2048 + 4096 | 4096 + 8192 | 8192 + 16384 | 16384 + 32768 | 32768 + 65536 | 65536 + 131072 | 131072 + 262144 | 262144 + 524288 | 524288 + 1048576 |@ 1048576 + 2097152 |@@ 2097152 + 4194304 |@@@ 4194304 + 8388608 |@@@@@@@ 8388608 + 16777216 | 0 + + 24 + value ------------- Distribution ------------- count + -16777216 | 0 + -8388608 @@@| -8388608 + -4194304 @@| -4194304 + -2097152 @| -2097152 + -1048576 | -1048576 + -524288 | -524288 + -262144 | -262144 + -131072 | -131072 + -65536 | -65536 + -32768 | -32768 + -16384 | -16384 + -8192 | -8192 + -4096 | -4096 + -2048 | -2048 + -1024 | -1024 + -512 | -512 + -256 | -256 + -128 | -128 + -64 | -64 + -32 | -32 + -16 | -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 | 16 + 32 | 32 + 64 | 64 + 128 | 128 + 256 | 256 + 512 | 512 + 1024 | 1024 + 2048 | 2048 + 4096 | 4096 + 8192 | 8192 + 16384 | 16384 + 32768 | 32768 + 65536 | 65536 + 131072 | 131072 + 262144 | 262144 + 524288 | 524288 + 1048576 | 1048576 + 2097152 |@ 2097152 + 4194304 |@@ 4194304 + 8388608 |@@@ 8388608 + 16777216 |@@@@@@@ 16777216 + 33554432 | 0 + + 25 + value ------------- Distribution ------------- count + -33554432 | 0 + -16777216 @@@| -16777216 + -8388608 @@| -8388608 + -4194304 @| -4194304 + -2097152 | -2097152 + -1048576 | -1048576 + -524288 | -524288 + -262144 | -262144 + -131072 | -131072 + -65536 | -65536 + -32768 | -32768 + -16384 | -16384 + -8192 | -8192 + -4096 | -4096 + -2048 | -2048 + -1024 | -1024 + -512 | -512 + -256 | -256 + -128 | -128 + -64 | -64 + -32 | -32 + -16 | -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 | 16 + 32 | 32 + 64 | 64 + 128 | 128 + 256 | 256 + 512 | 512 + 1024 | 1024 + 2048 | 2048 + 4096 | 4096 + 8192 | 8192 + 16384 | 16384 + 32768 | 32768 + 65536 | 65536 + 131072 | 131072 + 262144 | 262144 + 524288 | 524288 + 1048576 | 1048576 + 2097152 | 2097152 + 4194304 |@ 4194304 + 8388608 |@@ 8388608 + 16777216 |@@@ 16777216 + 33554432 |@@@@@@@ 33554432 + 67108864 | 0 + + 26 + value ------------- Distribution ------------- count + -67108864 | 0 + -33554432 @@@| -33554432 + -16777216 @@| -16777216 + -8388608 @| -8388608 + -4194304 | -4194304 + -2097152 | -2097152 + -1048576 | -1048576 + -524288 | -524288 + -262144 | -262144 + -131072 | -131072 + -65536 | -65536 + -32768 | -32768 + -16384 | -16384 + -8192 | -8192 + -4096 | -4096 + -2048 | -2048 + -1024 | -1024 + -512 | -512 + -256 | -256 + -128 | -128 + -64 | -64 + -32 | -32 + -16 | -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 | 16 + 32 | 32 + 64 | 64 + 128 | 128 + 256 | 256 + 512 | 512 + 1024 | 1024 + 2048 | 2048 + 4096 | 4096 + 8192 | 8192 + 16384 | 16384 + 32768 | 32768 + 65536 | 65536 + 131072 | 131072 + 262144 | 262144 + 524288 | 524288 + 1048576 | 1048576 + 2097152 | 2097152 + 4194304 | 4194304 + 8388608 |@ 8388608 + 16777216 |@@ 16777216 + 33554432 |@@@ 33554432 + 67108864 |@@@@@@@ 67108864 + 134217728 | 0 + + 27 + value ------------- Distribution ------------- count + -134217728 | 0 + -67108864 @@@| -67108864 + -33554432 @@| -33554432 + -16777216 @| -16777216 + -8388608 | -8388608 + -4194304 | -4194304 + -2097152 | -2097152 + -1048576 | -1048576 + -524288 | -524288 + -262144 | -262144 + -131072 | -131072 + -65536 | -65536 + -32768 | -32768 + -16384 | -16384 + -8192 | -8192 + -4096 | -4096 + -2048 | -2048 + -1024 | -1024 + -512 | -512 + -256 | -256 + -128 | -128 + -64 | -64 + -32 | -32 + -16 | -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 | 16 + 32 | 32 + 64 | 64 + 128 | 128 + 256 | 256 + 512 | 512 + 1024 | 1024 + 2048 | 2048 + 4096 | 4096 + 8192 | 8192 + 16384 | 16384 + 32768 | 32768 + 65536 | 65536 + 131072 | 131072 + 262144 | 262144 + 524288 | 524288 + 1048576 | 1048576 + 2097152 | 2097152 + 4194304 | 4194304 + 8388608 | 8388608 + 16777216 |@ 16777216 + 33554432 |@@ 33554432 + 67108864 |@@@ 67108864 + 134217728 |@@@@@@@ 134217728 + 268435456 | 0 + + 28 + value ------------- Distribution ------------- count + -268435456 | 0 + -134217728 @@@| -134217728 + -67108864 @@| -67108864 + -33554432 @| -33554432 + -16777216 | -16777216 + -8388608 | -8388608 + -4194304 | -4194304 + -2097152 | -2097152 + -1048576 | -1048576 + -524288 | -524288 + -262144 | -262144 + -131072 | -131072 + -65536 | -65536 + -32768 | -32768 + -16384 | -16384 + -8192 | -8192 + -4096 | -4096 + -2048 | -2048 + -1024 | -1024 + -512 | -512 + -256 | -256 + -128 | -128 + -64 | -64 + -32 | -32 + -16 | -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 | 16 + 32 | 32 + 64 | 64 + 128 | 128 + 256 | 256 + 512 | 512 + 1024 | 1024 + 2048 | 2048 + 4096 | 4096 + 8192 | 8192 + 16384 | 16384 + 32768 | 32768 + 65536 | 65536 + 131072 | 131072 + 262144 | 262144 + 524288 | 524288 + 1048576 | 1048576 + 2097152 | 2097152 + 4194304 | 4194304 + 8388608 | 8388608 + 16777216 | 16777216 + 33554432 |@ 33554432 + 67108864 |@@ 67108864 + 134217728 |@@@ 134217728 + 268435456 |@@@@@@@ 268435456 + 536870912 | 0 + + 29 + value ------------- Distribution ------------- count + -536870912 | 0 + -268435456 @@@| -268435456 + -134217728 @@| -134217728 + -67108864 @| -67108864 + -33554432 | -33554432 + -16777216 | -16777216 + -8388608 | -8388608 + -4194304 | -4194304 + -2097152 | -2097152 + -1048576 | -1048576 + -524288 | -524288 + -262144 | -262144 + -131072 | -131072 + -65536 | -65536 + -32768 | -32768 + -16384 | -16384 + -8192 | -8192 + -4096 | -4096 + -2048 | -2048 + -1024 | -1024 + -512 | -512 + -256 | -256 + -128 | -128 + -64 | -64 + -32 | -32 + -16 | -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 | 16 + 32 | 32 + 64 | 64 + 128 | 128 + 256 | 256 + 512 | 512 + 1024 | 1024 + 2048 | 2048 + 4096 | 4096 + 8192 | 8192 + 16384 | 16384 + 32768 | 32768 + 65536 | 65536 + 131072 | 131072 + 262144 | 262144 + 524288 | 524288 + 1048576 | 1048576 + 2097152 | 2097152 + 4194304 | 4194304 + 8388608 | 8388608 + 16777216 | 16777216 + 33554432 | 33554432 + 67108864 |@ 67108864 + 134217728 |@@ 134217728 + 268435456 |@@@ 268435456 + 536870912 |@@@@@@@ 536870912 + 1073741824 | 0 + + 30 + value ------------- Distribution ------------- count + -1073741824 | 0 + -536870912 @@@| -536870912 + -268435456 @@| -268435456 + -134217728 @| -134217728 + -67108864 | -67108864 + -33554432 | -33554432 + -16777216 | -16777216 + -8388608 | -8388608 + -4194304 | -4194304 + -2097152 | -2097152 + -1048576 | -1048576 + -524288 | -524288 + -262144 | -262144 + -131072 | -131072 + -65536 | -65536 + -32768 | -32768 + -16384 | -16384 + -8192 | -8192 + -4096 | -4096 + -2048 | -2048 + -1024 | -1024 + -512 | -512 + -256 | -256 + -128 | -128 + -64 | -64 + -32 | -32 + -16 | -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 | 16 + 32 | 32 + 64 | 64 + 128 | 128 + 256 | 256 + 512 | 512 + 1024 | 1024 + 2048 | 2048 + 4096 | 4096 + 8192 | 8192 + 16384 | 16384 + 32768 | 32768 + 65536 | 65536 + 131072 | 131072 + 262144 | 262144 + 524288 | 524288 + 1048576 | 1048576 + 2097152 | 2097152 + 4194304 | 4194304 + 8388608 | 8388608 + 16777216 | 16777216 + 33554432 | 33554432 + 67108864 | 67108864 + 134217728 |@ 134217728 + 268435456 |@@ 268435456 + 536870912 |@@@ 536870912 + 1073741824 |@@@@@@@ 1073741824 + 2147483648 | 0 + + 31 + value ------------- Distribution ------------- count + -2147483648 | 0 + -1073741824 @@@| -1073741824 + -536870912 @@| -536870912 + -268435456 @| -268435456 + -134217728 | -134217728 + -67108864 | -67108864 + -33554432 | -33554432 + -16777216 | -16777216 + -8388608 | -8388608 + -4194304 | -4194304 + -2097152 | -2097152 + -1048576 | -1048576 + -524288 | -524288 + -262144 | -262144 + -131072 | -131072 + -65536 | -65536 + -32768 | -32768 + -16384 | -16384 + -8192 | -8192 + -4096 | -4096 + -2048 | -2048 + -1024 | -1024 + -512 | -512 + -256 | -256 + -128 | -128 + -64 | -64 + -32 | -32 + -16 | -16 + -8 | -8 + -4 | -4 + -2 | -2 + -1 | 0 + 0 | 0 + 1 | 1 + 2 | 2 + 4 | 4 + 8 | 8 + 16 | 16 + 32 | 32 + 64 | 64 + 128 | 128 + 256 | 256 + 512 | 512 + 1024 | 1024 + 2048 | 2048 + 4096 | 4096 + 8192 | 8192 + 16384 | 16384 + 32768 | 32768 + 65536 | 65536 + 131072 | 131072 + 262144 | 262144 + 524288 | 524288 + 1048576 | 1048576 + 2097152 | 2097152 + 4194304 | 4194304 + 8388608 | 8388608 + 16777216 | 16777216 + 33554432 | 33554432 + 67108864 | 67108864 + 134217728 | 134217728 + 268435456 |@ 268435456 + 536870912 |@@ 536870912 + 1073741824 |@@@ 1073741824 + 2147483648 |@@@@@@@ 2147483648 + 4294967296 | 0 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.quantround.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.quantround.d new file mode 100644 index 000000000000..c40d69c081df --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.quantround.d @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +/* + * This test verifies that the height of the ASCII quantization bars is + * determined using rounding and not truncated integer arithmetic. + */ +tick-10ms +/i++ >= 27/ +{ + exit(0); +} + +tick-10ms +/i > 8/ +{ + @ = quantize(2); +} + +tick-10ms +/i > 2 && i <= 8/ +{ + @ = quantize(1); +} + +tick-10ms +/i <= 2/ +{ + @ = quantize(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.quantround.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.quantround.d.out new file mode 100644 index 000000000000..9b89ec144489 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.quantround.d.out @@ -0,0 +1,9 @@ + + + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@ 2 + 1 |@@@@@@@@@ 6 + 2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 19 + 4 | 0 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.quantzero.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.quantzero.d new file mode 100644 index 000000000000..bfa633cd03ac --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.quantzero.d @@ -0,0 +1,63 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + + +BEGIN +{ + a = 7; + b = 13; + val = (-a * b) + a; +} + +tick-1ms +{ + incr = val % b; + val += a; +} + +tick-1ms +/val == 0/ +{ + val += a; +} + +tick-1ms +/incr != 0/ +{ + i++; + @[i] = quantize(0, incr); +} + +tick-1ms +/incr == 0/ +{ + printa(@); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.quantzero.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.quantzero.d.out new file mode 100644 index 000000000000..c2c1cf02b6d7 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.quantzero.d.out @@ -0,0 +1,146 @@ + + 2 + value ------------- Distribution ------------- count + -1 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -12 + 1 | 0 + + 4 + value ------------- Distribution ------------- count + -1 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -11 + 1 | 0 + + 6 + value ------------- Distribution ------------- count + -1 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -10 + 1 | 0 + + 8 + value ------------- Distribution ------------- count + -1 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -9 + 1 | 0 + + 10 + value ------------- Distribution ------------- count + -1 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -8 + 1 | 0 + + 12 + value ------------- Distribution ------------- count + -1 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -7 + 1 | 0 + + 1 + value ------------- Distribution ------------- count + -1 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -6 + 1 | 0 + + 3 + value ------------- Distribution ------------- count + -1 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -5 + 1 | 0 + + 5 + value ------------- Distribution ------------- count + -1 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -4 + 1 | 0 + + 7 + value ------------- Distribution ------------- count + -1 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -3 + 1 | 0 + + 9 + value ------------- Distribution ------------- count + -1 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -2 + 1 | 0 + + 11 + value ------------- Distribution ------------- count + -1 | 0 + 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| -1 + 1 | 0 + + 14 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 + 1 | 0 + + 16 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2 + 1 | 0 + + 18 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3 + 1 | 0 + + 20 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 4 + 1 | 0 + + 22 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5 + 1 | 0 + + 24 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6 + 1 | 0 + + 13 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7 + 1 | 0 + + 15 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8 + 1 | 0 + + 17 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9 + 1 | 0 + + 19 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 10 + 1 | 0 + + 21 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 11 + 1 | 0 + + 23 + value ------------- Distribution ------------- count + -1 | 0 + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12 + 1 | 0 + + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.signature.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.signature.d new file mode 100644 index 000000000000..baa951a4e26c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.signature.d @@ -0,0 +1,54 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * This is a simple test to make sure that signature checking works properly + * for the fake-o types. + */ +BEGIN +{ + @stk[ustack()] = count(); + @symmy[sym(0)] = count(); + @usymmy[usym(0)] = count(); + @funky[func(0)] = count(); + @ufunky[ufunc(0)] = count(); + @moddy[mod(0)] = count(); + @umoddy[umod(0)] = count(); +} + +BEGIN +{ + @stk[ustack()] = count(); + @symmy[sym(0)] = count(); + @usymmy[usym(0)] = count(); + @funky[func(0)] = count(); + @ufunky[ufunc(0)] = count(); + @moddy[mod(0)] = count(); + @umoddy[umod(0)] = count(); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.signedkeys.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.signedkeys.d new file mode 100644 index 000000000000..ed3d13141af3 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.signedkeys.d @@ -0,0 +1,120 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * Signed integer keys print and sort as expected. + * + * SECTION: Aggregations, Printing Aggregations + * + * NOTES: DTrace sorts integer keys as unsigned values, yet prints 32- + * and 64-bit integers as signed values. Since the Java DTrace API is + * expected to emulate this behavior, this test was added to ensure that + * the behavior is preserved. Consistency with trace() output is also + * tested. + */ + +#pragma D option quiet +#pragma D option aggsortkey + +BEGIN +{ + trace((char)-2); + trace("\n"); + trace((char)-1); + trace("\n"); + trace((char)0); + trace("\n"); + trace((char)1); + trace("\n"); + trace((char)2); + trace("\n"); + trace("\n"); + + trace((short)-2); + trace("\n"); + trace((short)-1); + trace("\n"); + trace((short)0); + trace("\n"); + trace((short)1); + trace("\n"); + trace((short)2); + trace("\n"); + trace("\n"); + + trace(-2); + trace("\n"); + trace(-1); + trace("\n"); + trace(0); + trace("\n"); + trace(1); + trace("\n"); + trace(2); + trace("\n"); + trace("\n"); + + trace((long long)-2); + trace("\n"); + trace((long long)-1); + trace("\n"); + trace((long long)0); + trace("\n"); + trace((long long)1); + trace("\n"); + trace((long long)2); + trace("\n"); + + @i8[(char)-2] = sum(-2); + @i8[(char)-1] = sum(-1); + @i8[(char)0] = sum(0); + @i8[(char)1] = sum(1); + @i8[(char)2] = sum(2); + + @i16[(short)-2] = sum(-2); + @i16[(short)-1] = sum(-1); + @i16[(short)0] = sum(0); + @i16[(short)1] = sum(1); + @i16[(short)2] = sum(2); + + @i32[-2] = sum(-2); + @i32[-1] = sum(-1); + @i32[0] = sum(0); + @i32[1] = sum(1); + @i32[2] = sum(2); + + @i64[(long long)-2] = sum(-2); + @i64[(long long)-1] = sum(-1); + @i64[(long long)0] = sum(0); + @i64[(long long)1] = sum(1); + @i64[(long long)2] = sum(2); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.signedkeys.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.signedkeys.d.out new file mode 100644 index 000000000000..42e619e01200 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.signedkeys.d.out @@ -0,0 +1,44 @@ +254 +255 +0 +1 +2 + +65534 +65535 +0 +1 +2 + +-2 +-1 +0 +1 +2 + +-2 +-1 +0 +1 +2 + + 0 0 + 1 1 + 2 2 + 254 -2 + 255 -1 + 0 0 + 1 1 + 2 2 + 65534 -2 + 65535 -1 + 0 0 + 1 1 + 2 2 + -2 -2 + -1 -1 + 0 0 + 1 1 + 2 2 + -2 -2 + -1 -1 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.signedkeyspos.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.signedkeyspos.d new file mode 100644 index 000000000000..5836c6a5ef60 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.signedkeyspos.d @@ -0,0 +1,115 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * Signed integer keys print and sort as expected using the + * aggsortkeypos and aggsortrev options + * + * SECTION: Aggregations, Printing Aggregations + * + * NOTES: DTrace sorts integer keys as unsigned values, yet prints 32- + * and 64-bit integers as signed values. Since the Java DTrace API is + * expected to emulate this behavior, this test was added to ensure that + * the behavior is preserved. + */ + +#pragma D option quiet +#pragma D option aggsortkey +#pragma D option aggsortkeypos=1 +#pragma D option aggsortrev + +BEGIN +{ + @i8["cat", (char)-2] = sum(-2); + @i8["dog", (char)-2] = sum(-22); + @i8["mouse", (char)-2] = sum(-222); + @i8["cat", (char)-1] = sum(-1); + @i8["dog", (char)-1] = sum(-11); + @i8["mouse", (char)-1] = sum(-111); + @i8["cat", (char)0] = sum(0); + @i8["dog", (char)0] = sum(10); + @i8["mouse", (char)0] = sum(100); + @i8["cat", (char)1] = sum(1); + @i8["dog", (char)1] = sum(11); + @i8["mouse", (char)1] = sum(111); + @i8["cat", (char)2] = sum(2); + @i8["dog", (char)2] = sum(22); + @i8["mouse", (char)2] = sum(222); + + @i16["mouse", (short)-2] = sum(-2); + @i16["dog", (short)-2] = sum(-22); + @i16["cat", (short)-2] = sum(-222); + @i16["mouse", (short)-1] = sum(-1); + @i16["dog", (short)-1] = sum(-11); + @i16["cat", (short)-1] = sum(-111); + @i16["mouse", (short)0] = sum(0); + @i16["dog", (short)0] = sum(10); + @i16["cat", (short)0] = sum(100); + @i16["mouse", (short)1] = sum(1); + @i16["dog", (short)1] = sum(11); + @i16["cat", (short)1] = sum(111); + @i16["mouse", (short)2] = sum(2); + @i16["dog", (short)2] = sum(22); + @i16["cat", (short)2] = sum(222); + + @i32["mouse", -2] = sum(-2); + @i32["bear", -2] = sum(-22); + @i32["cat", -2] = sum(-222); + @i32["mouse", -1] = sum(-1); + @i32["bear", -1] = sum(-11); + @i32["cat", -1] = sum(-111); + @i32["mouse", 0] = sum(0); + @i32["bear", 0] = sum(10); + @i32["cat", 0] = sum(100); + @i32["mouse", 1] = sum(1); + @i32["bear", 1] = sum(11); + @i32["cat", 1] = sum(111); + @i32["mouse", 2] = sum(2); + @i32["bear", 2] = sum(22); + @i32["cat", 2] = sum(222); + + @i64["cat", (long long)-2] = sum(-2); + @i64["bear", (long long)-2] = sum(-22); + @i64["dog", (long long)-2] = sum(-222); + @i64["cat", (long long)-1] = sum(-1); + @i64["bear", (long long)-1] = sum(-11); + @i64["dog", (long long)-1] = sum(-111); + @i64["cat", (long long)0] = sum(0); + @i64["bear", (long long)0] = sum(10); + @i64["dog", (long long)0] = sum(100); + @i64["cat", (long long)1] = sum(1); + @i64["bear", (long long)1] = sum(11); + @i64["dog", (long long)1] = sum(111); + @i64["cat", (long long)2] = sum(2); + @i64["bear", (long long)2] = sum(22); + @i64["dog", (long long)2] = sum(222); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.signedkeyspos.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.signedkeyspos.d.out new file mode 100644 index 000000000000..28e95ac3196f --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.signedkeyspos.d.out @@ -0,0 +1,61 @@ + + dog -1 -111 + cat -1 -1 + bear -1 -11 + dog -2 -222 + cat -2 -2 + bear -2 -22 + dog 2 222 + cat 2 2 + bear 2 22 + dog 1 111 + cat 1 1 + bear 1 11 + dog 0 100 + cat 0 0 + bear 0 10 + mouse -1 -1 + cat -1 -111 + bear -1 -11 + mouse -2 -2 + cat -2 -222 + bear -2 -22 + mouse 2 2 + cat 2 222 + bear 2 22 + mouse 1 1 + cat 1 111 + bear 1 11 + mouse 0 0 + cat 0 100 + bear 0 10 + mouse 65535 -1 + dog 65535 -11 + cat 65535 -111 + mouse 65534 -2 + dog 65534 -22 + cat 65534 -222 + mouse 2 2 + dog 2 22 + cat 2 222 + mouse 1 1 + dog 1 11 + cat 1 111 + mouse 0 0 + dog 0 10 + cat 0 100 + mouse 255 -111 + dog 255 -11 + cat 255 -1 + mouse 254 -222 + dog 254 -22 + cat 254 -2 + mouse 2 222 + dog 2 22 + cat 2 2 + mouse 1 111 + dog 1 11 + cat 1 1 + mouse 0 100 + dog 0 10 + cat 0 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.stddev.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.stddev.d new file mode 100644 index 000000000000..11e99d390553 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.stddev.d @@ -0,0 +1,64 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * Positive stddev() test + * + * SECTION: Aggregations/Aggregations + * + * NOTES: This is a simple verifiable positive test of the stddev() function. + */ + +#pragma D option quiet + +BEGIN +{ + @a = stddev(5000000000); + @a = stddev(5000000100); + @a = stddev(5000000200); + @a = stddev(5000000300); + @a = stddev(5000000400); + @a = stddev(5000000500); + @a = stddev(5000000600); + @a = stddev(5000000700); + @a = stddev(5000000800); + @a = stddev(5000000900); + @b = stddev(-5000000000); + @b = stddev(-5000000100); + @b = stddev(-5000000200); + @b = stddev(-5000000300); + @b = stddev(-5000000400); + @b = stddev(-5000000500); + @b = stddev(-5000000600); + @b = stddev(-5000000700); + @b = stddev(-5000000800); + @b = stddev(-5000000900); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.stddev.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.stddev.d.out new file mode 100644 index 000000000000..cec6074081e1 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.stddev.d.out @@ -0,0 +1,3 @@ + + 287 + 287 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.subr.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.subr.d new file mode 100644 index 000000000000..5ca1f1ef9389 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.subr.d @@ -0,0 +1,112 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include + +#define INTFUNC(x) \ + BEGIN \ + /*DSTYLED*/ \ + { \ + subr++; \ + @[(long)x] = sum(1); \ + /*DSTYLED*/ \ + } + +#define STRFUNC(x) \ + BEGIN \ + /*DSTYLED*/ \ + { \ + subr++; \ + @str[x] = sum(1); \ + /*DSTYLED*/ \ + } + +#define VOIDFUNC(x) \ + BEGIN \ + /*DSTYLED*/ \ + { \ + subr++; \ + /*DSTYLED*/ \ + } + +INTFUNC(rand()) +INTFUNC(mutex_owned(&`cpu_lock)) +INTFUNC(mutex_owner(&`cpu_lock)) +INTFUNC(mutex_type_adaptive(&`cpu_lock)) +INTFUNC(mutex_type_spin(&`cpu_lock)) +INTFUNC(rw_read_held(&`vfssw_lock)) +INTFUNC(rw_write_held(&`vfssw_lock)) +INTFUNC(rw_iswriter(&`vfssw_lock)) +INTFUNC(copyin(NULL, 1)) +STRFUNC(copyinstr(NULL, 1)) +INTFUNC(speculation()) +INTFUNC(progenyof($pid)) +INTFUNC(strlen("fooey")) +VOIDFUNC(copyout) +VOIDFUNC(copyoutstr) +INTFUNC(alloca(10)) +VOIDFUNC(bcopy) +VOIDFUNC(copyinto) +INTFUNC(msgdsize(NULL)) +INTFUNC(msgsize(NULL)) +INTFUNC(getmajor(0)) +INTFUNC(getminor(0)) +STRFUNC(ddi_pathname(NULL, 0)) +STRFUNC(strjoin("foo", "bar")) +STRFUNC(lltostr(12373)) +STRFUNC(basename("/var/crash/systemtap")) +STRFUNC(dirname("/var/crash/systemtap")) +STRFUNC(cleanpath("/var/crash/systemtap")) +STRFUNC(strchr("The SystemTap, The.", 't')) +STRFUNC(strrchr("The SystemTap, The.", 't')) +STRFUNC(strstr("The SystemTap, The.", "The")) +STRFUNC(strtok("The SystemTap, The.", "T")) +STRFUNC(substr("The SystemTap, The.", 0)) +INTFUNC(index("The SystemTap, The.", "The")) +INTFUNC(rindex("The SystemTap, The.", "The")) +INTFUNC(htons(0x1234)) +INTFUNC(htonl(0x12345678)) +INTFUNC(htonll(0x1234567890abcdefL)) +INTFUNC(ntohs(0x1234)) +INTFUNC(ntohl(0x12345678)) +INTFUNC(ntohll(0x1234567890abcdefL)) +STRFUNC(inet_ntoa((ipaddr_t *)alloca(sizeof (ipaddr_t)))) +STRFUNC(inet_ntoa6((in6_addr_t *)alloca(sizeof (in6_addr_t)))) +STRFUNC(inet_ntop(AF_INET, (void *)alloca(sizeof (ipaddr_t)))) + +BEGIN +/subr == DIF_SUBR_MAX + 1/ +{ + exit(0); +} + +BEGIN +{ + printf("found %d subroutines, expected %d\n", subr, DIF_SUBR_MAX + 1); + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.sum.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.sum.d new file mode 100644 index 000000000000..1b9025af9715 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.sum.d @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * Positive sum() test + * + * SECTION: Aggregations/Aggregations + * + * NOTES: This is verifiable simple positive test of the sum() function. + */ + +#pragma D option quiet + +BEGIN +{ + i = 0; +} + +tick-10ms +/i < 1000/ +{ + @a = sum(i); + i += 100; +} + +tick-10ms +/i == 1000/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.sum.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.sum.d.out new file mode 100644 index 000000000000..5d8b37b8ac42 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.sum.d.out @@ -0,0 +1,2 @@ + + 4500 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.trunc.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.trunc.d new file mode 100644 index 000000000000..d1c1b3cc2f87 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.trunc.d @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +int i; + +tick-10ms +/i < 100/ +{ + @[i] = sum(i); + i++; +} + +tick-10ms +/i == 100/ +{ + exit(0); +} + +END +{ + trunc(@, 10); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.trunc.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.trunc.d.out new file mode 100644 index 000000000000..2e18ef8bff29 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.trunc.d.out @@ -0,0 +1,11 @@ + + 90 90 + 91 91 + 92 92 + 93 93 + 94 94 + 95 95 + 96 96 + 97 97 + 98 98 + 99 99 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.trunc0.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.trunc0.d new file mode 100644 index 000000000000..5c31069d8601 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.trunc0.d @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet +#pragma D option aggrate=1ms +#pragma D option switchrate=50ms + +int i; + +tick-100ms +/i < 10/ +{ + @[i] = sum(10 - i); + i++; +} + +tick-100ms +/i == 5/ +{ + trunc(@); +} + +tick-100ms +/i == 10/ +{ + exit(0); +} + +END +{ + printa(@); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.trunc0.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.trunc0.d.out new file mode 100644 index 000000000000..70dc7a026d8c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.trunc0.d.out @@ -0,0 +1,7 @@ + + 9 1 + 8 2 + 7 3 + 6 4 + 5 5 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.truncquant.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.truncquant.d new file mode 100644 index 000000000000..8baa56ab9512 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.truncquant.d @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +int i; + +tick-10ms +/i < 100/ +{ + @[i] = lquantize(i, 0, 150); + @[i] = lquantize(i + 1, 0, 150); + @[i] = lquantize(i + 2, 0, 150); + @[i] = lquantize(i + 3, 0, 150); + i++; +} + +tick-10ms +/i == 100/ +{ + exit(0); +} + +END +{ + trunc(@, 5); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.truncquant.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.truncquant.d.out new file mode 100644 index 000000000000..86975af33398 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.truncquant.d.out @@ -0,0 +1,46 @@ + + 95 + value ------------- Distribution ------------- count + 94 | 0 + 95 |@@@@@@@@@@ 1 + 96 |@@@@@@@@@@ 1 + 97 |@@@@@@@@@@ 1 + 98 |@@@@@@@@@@ 1 + 99 | 0 + + 96 + value ------------- Distribution ------------- count + 95 | 0 + 96 |@@@@@@@@@@ 1 + 97 |@@@@@@@@@@ 1 + 98 |@@@@@@@@@@ 1 + 99 |@@@@@@@@@@ 1 + 100 | 0 + + 97 + value ------------- Distribution ------------- count + 96 | 0 + 97 |@@@@@@@@@@ 1 + 98 |@@@@@@@@@@ 1 + 99 |@@@@@@@@@@ 1 + 100 |@@@@@@@@@@ 1 + 101 | 0 + + 98 + value ------------- Distribution ------------- count + 97 | 0 + 98 |@@@@@@@@@@ 1 + 99 |@@@@@@@@@@ 1 + 100 |@@@@@@@@@@ 1 + 101 |@@@@@@@@@@ 1 + 102 | 0 + + 99 + value ------------- Distribution ------------- count + 98 | 0 + 99 |@@@@@@@@@@ 1 + 100 |@@@@@@@@@@ 1 + 101 |@@@@@@@@@@ 1 + 102 |@@@@@@@@@@ 1 + 103 | 0 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.valsortkeypos.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.valsortkeypos.d new file mode 100644 index 000000000000..ec0bee32a25a --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.valsortkeypos.d @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * aggsortkeypos option works when sorting by values, values are + * equal, and keys are compared to break the tie + * + * SECTION: Aggregations, Printing Aggregations + * + */ + +#pragma D option quiet +#pragma D option aggsortkeypos=1 + +BEGIN +{ + @[1, 3] = sum(0); + @[2, 2] = sum(0); + @[3, 1] = sum(0); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.valsortkeypos.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.valsortkeypos.d.out new file mode 100644 index 000000000000..9b0acf92e64c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/aggs/tst.valsortkeypos.d.out @@ -0,0 +1,4 @@ + + 3 1 0 + 2 2 0 + 1 3 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.divby0.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.divby0.d new file mode 100644 index 000000000000..0b7b6610b377 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.divby0.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Verify that divide by 0 errors are caught + * + * SECTION: + * Types, Operators, and Expressions/Arithmetic Operators + */ + + +BEGIN +{ + c = 123/0; + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.divby0_1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.divby0_1.d new file mode 100644 index 000000000000..110179511ef2 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.divby0_1.d @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Verify that computed divide by 0 errors are caught + * + * SECTION: + * Types, Operators, and Expressions/Arithmetic Operators + */ + + + + +BEGIN +{ + c = 123/(7-7); + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.divby0_2.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.divby0_2.d new file mode 100644 index 000000000000..454696144fd9 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.divby0_2.d @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Verify that computed divide by 0 errors are caught + * + * SECTION: + * Types, Operators, and Expressions/Arithmetic Operators + */ + + + + + +BEGIN +{ + c = 123/((7-7) * 999); + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.modby0.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.modby0.d new file mode 100644 index 000000000000..b2bf1462fe67 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/err.D_DIV_ZERO.modby0.d @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Verify that mod by 0 errors are caught + * + * SECTION: + * Types, Operators, and Expressions/Arithmetic Operators + */ + + + +BEGIN +{ + c = 123%0; + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.addmin.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.addmin.d new file mode 100644 index 000000000000..f20339c169ed --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.addmin.d @@ -0,0 +1,47 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Call invalid / impossible arithmetic operations and make sure + * Test gives compilation error. + * + * SECTION: Types, Operators, and Expressions/Arithmetic Operators + * + */ + +#pragma D option quiet + +BEGIN +{ + i = 0; + i+-; + printf("The value of i is %d\n", i); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.divmin.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.divmin.d new file mode 100644 index 000000000000..c11e64fde5e9 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.divmin.d @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Call invalid / impossible arithmetic operations and make sure + * Test gives compilation error. + * + * SECTION: Types, Operators, and Expressions/Arithmetic Operators + * + */ + +#pragma D option quiet + +BEGIN +{ + i = 1; + i /-= i; + printf("The value of i is %d\n", i); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.muladd.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.muladd.d new file mode 100644 index 000000000000..bb107fb3aebd --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.muladd.d @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Call invalid / impossible arithmetic operations and make sure + * Test gives compilation error. + * + * SECTION: Types, Operators, and Expressions/Arithmetic Operators + * + */ + +#pragma D option quiet + +BEGIN +{ + i = 1; + i *+= i; + printf("The value of i is %d\n", i); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.muldiv.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.muldiv.d new file mode 100644 index 000000000000..7d44b6c76e55 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/err.D_SYNTAX.muldiv.d @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Call invalid / impossible arithmetic operations and make sure + * Test gives compilation error. + * + * SECTION: Types, Operators, and Expressions/Arithmetic Operators + * + */ + +#pragma D option quiet + +BEGIN +{ + i = 1; + i */= i; + printf("The value of i is %d\n", i); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.basics.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.basics.d new file mode 100644 index 000000000000..435f09f6d925 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.basics.d @@ -0,0 +1,66 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Simple Arithmetic expressions. + * Call simple expressions and make sure test succeeds. + * Match expected output in tst.basics.d.out + * + * SECTION: Types, Operators, and Expressions/Arithmetic Operators + * + */ + +#pragma D option quiet + +BEGIN +{ + i = 0; + i = 1 + 2 + 3; + printf("The value of i is %d\n", i); + + i = i * 3; + printf("The value of i is %d\n", i); + + i = (i * 3) + i; + printf("The value of i is %d\n", i); + + i = (i + (i * 3) + i) * i; + printf("The value of i is %d\n", i); + + i = i - (i + (i * 3) + i) * i / i * i; + printf("The value of i is %d\n", i); + + i = i * (i - 3 + 5 / i * i ) / i * 6; + printf("The value of i is %d\n", i); + + i = i ^ 5; + printf("The value of i is %d\n", i); + + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.complex.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.complex.d new file mode 100644 index 000000000000..2db1b6350b94 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arithmetic/tst.complex.d @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Complex expressions. + * Call complex expressions and make sure test succeeds. + * Match expected output in tst.complex.d.out + * + * SECTION: Types, Operators, and Expressions/Arithmetic Operators + * + */ + +#pragma D option quiet + +BEGIN +{ + i = 0; + i = i++ + ++i; + printf("The value of i is %d\n", i); + i = i-- - --i; + printf("The value of i is %d\n", i); + i = i-- + ++i; + printf("The value of i is %d\n", i); + i += i++ + -- i + ++i - ++i * i ; + printf("The value of i is %d\n", i); + i -= i++ * 3; + printf("The value of i is %d\n", i); + i = i++/i--+i++-++i-++i; + printf("The value of i is %d\n", i); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/err.D_ARR_BADREF.bad.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/err.D_ARR_BADREF.bad.d new file mode 100644 index 000000000000..d31b1f64c87c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/err.D_ARR_BADREF.bad.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Tuples can not be used in non-associative arrays. + * + * SECTION: Pointers and Arrays/Array Declarations and Storage + */ + +int x[5]; + +BEGIN +{ + x[1, 2] = 1; +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/err.D_DECL_ARRBIG.toobig.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/err.D_DECL_ARRBIG.toobig.d new file mode 100644 index 000000000000..80422e884796 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/err.D_DECL_ARRBIG.toobig.d @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Array declarations with indexs over INT_MAX return a + * D_DECL_ARRBIG errtag. + * + * SECTION: + * Pointers and Arrays/Array Declarations and Storage + */ + +int x[88294967295]; + +BEGIN +{ + exit(1); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/err.D_DECL_ARRNULL.bad.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/err.D_DECL_ARRNULL.bad.d new file mode 100644 index 000000000000..6e7a34ff01f3 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/err.D_DECL_ARRNULL.bad.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Arrays must have array dimensions + * + * SECTION: Pointers and Arrays/Array Declarations and Storage + */ + +int a[]; + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/err.D_DECL_ARRSUB.bad.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/err.D_DECL_ARRSUB.bad.d new file mode 100644 index 000000000000..f44036771b88 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/err.D_DECL_ARRSUB.bad.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Arrays declarations must have a positive constant as a + * subscription. + * + * SECTION: Pointers and Arrays/Array Declarations and Storage + */ + +int a[-7]; + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/err.D_DECL_PROTO_TYPE.badtuple.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/err.D_DECL_PROTO_TYPE.badtuple.d new file mode 100644 index 000000000000..7e879dc6120a --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/err.D_DECL_PROTO_TYPE.badtuple.d @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Invalid tuple types result in a DT_DECL_ARRTYPE error. + * + * SECTION: + * Pointers and Arrays/Array Declarations and Storage + */ + + +int x[void, char]; + +BEGIN +{ + x[trace(), 'a'] = 456; +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/err.D_IDENT_UNDEF.badureg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/err.D_IDENT_UNDEF.badureg.d new file mode 100644 index 000000000000..e48541b61670 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/err.D_IDENT_UNDEF.badureg.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Arrays declarations must have a positive constant as a + * subscription. + * + * SECTION: User Process Tracing/uregs Array + */ + +BEGIN +{ + printf("FOO = 0x%x\n", uregs[FOO]); + exit(1); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/tst.basic1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/tst.basic1.d new file mode 100644 index 000000000000..ba5b2cf0d15c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/tst.basic1.d @@ -0,0 +1,56 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Simple array test + * + * SECTION: Pointers and Arrays/Array Declarations and Storage + * + */ + + +#pragma D option quiet + +BEGIN +{ + a[1] = 0; +} + +tick-1 +/a[1] == 0/ +{ + exit(0); +} + +tick-1 +/a[1] != 0/ +{ + printf("Expected 0, got %d\n", a[1]); + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/tst.basic2.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/tst.basic2.d new file mode 100644 index 000000000000..14e1c5cf4503 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/tst.basic2.d @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Simple array test + * + * SECTION: Pointers and Arrays/Array Declarations and Storage + * + */ + + +#pragma D option quiet + +BEGIN +{ + a[1] = 0; + a[1]++; +} + +tick-1 +/a[1] == 1/ +{ + exit(0); +} + +tick-1 +/a[1] != 1/ +{ + printf("Expected 1, got %d\n", a[1]); + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/tst.basic3.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/tst.basic3.d new file mode 100644 index 000000000000..897a12f2f23e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/tst.basic3.d @@ -0,0 +1,56 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Simple array test + * + * SECTION: Pointers and Arrays/Array Declarations and Storage + * + */ + + +#pragma D option quiet + +BEGIN +{ + a[1] = 0; + ++a[1]; +} + +tick-1 +/a[1] == 1/ +{ + exit(0); +} + +tick-1 +/a[1] != 1/ +{ + printf("Expected 1, got %d\n", a[1]); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/tst.basic4.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/tst.basic4.d new file mode 100644 index 000000000000..3635a42d5387 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/tst.basic4.d @@ -0,0 +1,56 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Simple array test + * + * SECTION: Pointers and Arrays/Array Declarations and Storage + * + */ + + +#pragma D option quiet + +BEGIN +{ + a["test"] = 0; +} + +tick-1 +/a["test"] == 0/ +{ + exit(0); +} + +tick-1 +/a["test"] != 0/ +{ + printf("Expected 0, got %d\n", a["test"]); + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/tst.basic5.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/tst.basic5.d new file mode 100644 index 000000000000..866a8c39aeb2 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/tst.basic5.d @@ -0,0 +1,59 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Simple array test + * + * SECTION: Pointers and Arrays/Array Declarations and Storage + * + */ + + +#pragma D option quiet + +BEGIN +{ + a["test"] = 0; + b = ++a["test"]; +} + +tick-1 +/b == 1/ +{ + exit(0); +} + +tick-1 +/b != 1/ +{ + printf("Expected b = 1, got %d\n", b); + exit(1); +} + + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/tst.basic6.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/tst.basic6.d new file mode 100644 index 000000000000..0371db309331 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/tst.basic6.d @@ -0,0 +1,58 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Simple array test + * + * SECTION: Pointers and Arrays/Array Declarations and Storage + * + */ + + +#pragma D option quiet + +BEGIN +{ + a["test", "test"] = 0; + b = ++a["test", "test"]; +} + +tick-1 +/b == 1/ +{ + exit(0); +} + +tick-1 +/b != 1/ +{ + printf("Expected b = 1, got %d\n", b); + exit(1); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/tst.uregsarray.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/tst.uregsarray.d new file mode 100644 index 000000000000..b3fba0ca4c82 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/arrays/tst.uregsarray.d @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * Positive test to make sure that we can invoke common + * ureg[] aliases. + * + * SECTION: User Process Tracing/uregs Array + * + * NOTES: This test does no verification - the value of the output + * is not deterministic. + */ + +#pragma D option quiet + +BEGIN +{ + printf("R_PC = 0x%x\n", uregs[R_PC]); + printf("R_SP = 0x%x\n", uregs[R_SP]); + printf("R_R0 = 0x%x\n", uregs[R_R0]); + printf("R_R1 = 0x%x\n", uregs[R_R1]); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/err.D_OP_INCOMPAT.dupgtype.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/err.D_OP_INCOMPAT.dupgtype.d new file mode 100644 index 000000000000..267d121274c7 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/err.D_OP_INCOMPAT.dupgtype.d @@ -0,0 +1,47 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Test assigning a variable two different incompatible types. This should + * result in a compile-time error. + * + * SECTION: Variables/Associative Arrays + * + */ + +BEGIN +{ + x[123] = `kmem_flags; + x[456] = *`rootvp; +} + +ERROR +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/err.D_OP_INCOMPAT.dupttype.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/err.D_OP_INCOMPAT.dupttype.d new file mode 100644 index 000000000000..ce360cd25d9a --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/err.D_OP_INCOMPAT.dupttype.d @@ -0,0 +1,47 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Test assigning a variable two different incompatible types. This should + * result in a compile-time error. + * + * SECTION: Variables/Associative Arrays + * + */ + +BEGIN +{ + self->x[123] = `kmem_flags; + self->x[456] = *`rootvp; +} + +ERROR +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/err.D_OP_INCOMPAT.this.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/err.D_OP_INCOMPAT.this.d new file mode 100644 index 000000000000..2af07ca52ae1 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/err.D_OP_INCOMPAT.this.d @@ -0,0 +1,48 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * + * Declare 'this int' variable and assign inappropriate data type. + * + * SECTION: Variables/Associative Arrays + * + * + */ + +#pragma D option quiet + +this int x; + +BEGIN +{ + this->x = "dummy"; + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/err.D_PROTO_ARG.badsig.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/err.D_PROTO_ARG.badsig.d new file mode 100644 index 000000000000..d682fc68883d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/err.D_PROTO_ARG.badsig.d @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Test an associative array reference that is invalid because of a type + * signature mismatch -- this should produce a syntax error at compile time. + * + * SECTION: Variables/Associative Arrays + * + */ + +BEGIN +{ + x[123, "foo"] = timestamp; +} + +END +{ + x[123, 456] = timestamp; +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/err.D_PROTO_LEN.toofew.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/err.D_PROTO_LEN.toofew.d new file mode 100644 index 000000000000..b4e82b858880 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/err.D_PROTO_LEN.toofew.d @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Test an associative array reference that is invalid because of too few + * arguments -- this should produce a syntax error at compile time. + * + * SECTION: Variables/Associative Arrays + * + */ + +BEGIN +{ + x[123, 456] = timestamp; +} + +END +{ + x[123] = timestamp; +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/err.D_PROTO_LEN.toomany.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/err.D_PROTO_LEN.toomany.d new file mode 100644 index 000000000000..3dc5f7dd7917 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/err.D_PROTO_LEN.toomany.d @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Test an associative array reference that is invalid because of too many + * arguments -- this should produce a syntax error at compile time. + * + * SECTION: Variables/Associative Arrays + * + */ + +BEGIN +{ + x[123, 456] = timestamp; +} + +END +{ + x[123, 456, 789] = timestamp; +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/err.D_SYNTAX.errassign.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/err.D_SYNTAX.errassign.d new file mode 100644 index 000000000000..f31b66f11558 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/err.D_SYNTAX.errassign.d @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * + * Assign one to 10 elements; make sure fails to compile. + * + * SECTION: Variables/Associative Arrays + * + */ + +BEGIN +{ + x[10]=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +} + +END +{ +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/err.tupoflow.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/err.tupoflow.d new file mode 100644 index 000000000000..810420267523 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/err.tupoflow.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Generates an associative array reference that should overflow the tuple + * register stack. We should detect and report this at compile time. + * + * SECTION: Variables/Associative Arrays + * + */ + +BEGIN +{ + a[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] = 0; +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/tst.cpyarray.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/tst.cpyarray.d new file mode 100644 index 000000000000..ca31cc3590d9 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/tst.cpyarray.d @@ -0,0 +1,65 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * + * Copy value from associative arrays to local variables. + * + * SECTION: Variables/Associative Arrays + * + * + */ + +#pragma D option quiet + +this int x; + +BEGIN +{ + a["abc", 123] = 123; +} + +tick-10ms +{ + this->x = a["abc", 123]++; + printf("The value of x is %d\n", this->x); +} + +tick-10ms +{ + this->x = a["abc", 123]++; + printf("The value of x is %d\n", this->x); +} + +tick-10ms +{ + this->x = a["abc", 123]++; + printf("The value of x is %d\n", this->x); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/tst.diffprofile.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/tst.diffprofile.d new file mode 100644 index 000000000000..ad5fb377e55e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/tst.diffprofile.d @@ -0,0 +1,62 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * + * To test Clause Local Variables ' this' across different profiles. + * + * SECTION: Variables/Associative Arrays + * + * + */ + +#pragma D option quiet + +this int x; +this char c; + +tick-10ms +{ + this->x = 123; + this->c = 'D'; + printf("The value of x is %d\n", this->x); +} + +tick-10ms +{ + this->x = 235; + printf("The value of x is %d\n", this->x); +} + +tick-10ms +{ + this->x = 456; + printf("The value of x is %d\n", this->x); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/tst.initialize.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/tst.initialize.d new file mode 100644 index 000000000000..1ab222b151c0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/tst.initialize.d @@ -0,0 +1,47 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * + * Clause local variables are not initialized to zero. + * + * SECTION: Variables/Associative Arrays + * + * + */ + +#pragma D option quiet + +this int x; + +BEGIN +{ + printf("the value of x is %d\n", this->x); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/tst.invalidref.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/tst.invalidref.d new file mode 100644 index 000000000000..446acfad4d7f --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/tst.invalidref.d @@ -0,0 +1,75 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * Test to ensure that invalid stores to a global associative array + * are caught correctly. + */ + +#pragma D option quiet + +int last_cmds[int][4]; + +BEGIN +{ + errors = 0; + forward = 0; + backward = 0; +} + +tick-1s +/!forward/ +{ + forward = 1; + last_cmds[1][4] = 0xdeadbeef; +} + +tick-1s +/!backward/ +{ + backward = 1; + last_cmds[1][-5] = 0xdeadbeef; +} + +tick-1s +/errors > 1/ +{ + exit(0); +} + +tick-1s +/n++ > 5/ +{ + exit(1); +} + +ERROR +/arg4 == DTRACEFLT_BADADDR/ +{ + errors++; +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/tst.misc.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/tst.misc.d new file mode 100644 index 000000000000..43147dec694d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/tst.misc.d @@ -0,0 +1,69 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Test the different kinds of associative scalar references. + * + * SECTION: Variables/Associative Arrays + * + * NOTES: + * In particular, we test accessing a DTrace associative array + * defined with scalar type (first ref that forces creation as both global + * and TLS), and DTrace associative array scalar subsequent references + * (both global and TLS). + * + */ + +#pragma D option quiet + +BEGIN +{ + i = 0; +} + +tick-10ms +/i != 5/ +{ + x[123, "foo"] = 123; + self->x[456, "bar"] = 456; + i++; +} + +tick-10ms +/i != 5/ +{ + printf("x[] = %d\n", x[123, "foo"]); + printf("self->x[] = %d\n", self->x[456, "bar"]); +} + +tick-10ms +/i == 5/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/tst.orthogonality.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/tst.orthogonality.d new file mode 100644 index 000000000000..f474a572098e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/tst.orthogonality.d @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * This test confirms the orthogonality of associative arrays and thread-local + * variables by intentionally deriving a matching key signature (based on + * t_did). + */ +uint64_t b[uint64_t]; + +BEGIN +{ + self->a = 0xbad; +} + +BEGIN +/b[curthread->t_did] == 0/ +{ + exit(0); +} + +BEGIN +{ + printf("value should be 0; value is %x!", b[curthread->t_did]); + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/tst.this.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/tst.this.d new file mode 100644 index 000000000000..c4d01fa35fae --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/tst.this.d @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * + * To test Clause Local Variables ' this'. + * + * SECTION: Variables/Associative Arrays + * + * + */ + +#pragma D option quiet + +this int x; +this char c; + +BEGIN +{ + this->x = 123; + this->c = 'D'; + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/tst.valassign.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/tst.valassign.d.out new file mode 100644 index 000000000000..948d82e9d61d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/assocs/tst.valassign.d.out @@ -0,0 +1,2 @@ +The value of i is 123 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/begin/err.D_PDESC_ZERO.begin.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/begin/err.D_PDESC_ZERO.begin.d new file mode 100644 index 000000000000..c2a60889218b --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/begin/err.D_PDESC_ZERO.begin.d @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Arguments to BEGIN provider not allowed. + * + * SECTION: dtrace Provider + * + */ + + +#pragma D option quiet + +BEGIN::read:entry +{ + printf("Begin fired first\n"); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/begin/err.D_PDESC_ZERO.tick.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/begin/err.D_PDESC_ZERO.tick.d new file mode 100644 index 000000000000..44a363f80401 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/begin/err.D_PDESC_ZERO.tick.d @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * concat of providers not allowed with BEGIN + * + * SECTION: dtrace Provider + * + */ + + +#pragma D option quiet + + +BEGIN:tick-1 +{ + printf("Begin fired first\n"); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/begin/tst.begin.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/begin/tst.begin.d new file mode 100644 index 000000000000..43e7744e6e76 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/begin/tst.begin.d @@ -0,0 +1,55 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Order of provider flow, Begin, tick profile, and END. + * + * SECTION: dtrace Provider + * + */ + + +#pragma D option quiet + +END +{ + printf("End fired after exit\n"); +} + +BEGIN +{ + printf("Begin fired first\n"); +} + +tick-1ms +{ + printf("tick fired second\n"); + printf("Call exit\n"); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/begin/tst.begin.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/begin/tst.begin.d.out new file mode 100644 index 000000000000..a9d8ee1e7c3e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/begin/tst.begin.d.out @@ -0,0 +1,5 @@ +Begin fired first +tick fired second +Call exit +End fired after exit + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/begin/tst.multibegin.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/begin/tst.multibegin.d new file mode 100644 index 000000000000..3d5fd124f7fa --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/begin/tst.multibegin.d @@ -0,0 +1,60 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Multiple BEGIN providers + * + * SECTION: dtrace Provider + * + */ + + +#pragma D option quiet + +BEGIN +{ + printf("Begin fired first\n"); +} +BEGIN +{ + printf("Begin fired second\n"); +} +BEGIN +{ + printf("Begin fired third\n"); +} +BEGIN +{ + printf("Begin fired fourth\n"); +} +BEGIN +{ + printf("Begin fired fifth\n"); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/begin/tst.multibegin.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/begin/tst.multibegin.d.out new file mode 100644 index 000000000000..e5bb99669906 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/begin/tst.multibegin.d.out @@ -0,0 +1,6 @@ +Begin fired first +Begin fired second +Begin fired third +Begin fired fourth +Begin fired fifth + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/err.D_ADDROF_BITFIELD.BitfieldAddress.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/err.D_ADDROF_BITFIELD.BitfieldAddress.d new file mode 100644 index 000000000000..9c5aca4c1948 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/err.D_ADDROF_BITFIELD.BitfieldAddress.d @@ -0,0 +1,50 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Cannot take the address of a bit-field member using the & + * operator. + * + * SECTION: Structs and Unions/Bit-Fields + */ + +#pragma D option quiet + +struct bitRecord{ + int a : 1; + int b : 3; + int c : 12; +} var; + +BEGIN +{ + printf("address of a: %d\naddress of b: %d\naddress of c: %dn", + &var.a, &var.b, &var.c); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFCONST.NegBitField.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFCONST.NegBitField.d new file mode 100644 index 000000000000..acb296f4cec0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFCONST.NegBitField.d @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Bit-field width must be positive. + * + * SECTION: Structs and Unions/Bit-Fields + */ + +#pragma D option quiet + +struct bitRecord{ + int a : 1; + int b : -3; + int c : 12; +} var; + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFCONST.ZeroBitField.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFCONST.ZeroBitField.d new file mode 100644 index 000000000000..dfe24c59537c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFCONST.ZeroBitField.d @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Bit-fields must be positive and non-zero. + * + * SECTION: Structs and Unions/Bit-Fields + */ + +#pragma D option quiet + +struct bitRecord{ + int a : 1; + int b : 0; + int c : 12; +} var; + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFSIZE.ExceedBaseType.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFSIZE.ExceedBaseType.d new file mode 100644 index 000000000000..d9abfd1330b9 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFSIZE.ExceedBaseType.d @@ -0,0 +1,53 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Bit-field width must be of a number of bits not larger than + * that of the corresponding base type. + * + * SECTION: Structs and Unions/Bit-Fields + */ + +#pragma D option quiet + +struct bitRecord1{ + char a : 10; +} var1; + +struct bitRecord2{ + short a : 33; +} var2; + +struct bitRecord3{ + long long a : 65; +} var3; + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFSIZE.GreaterThan64.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFSIZE.GreaterThan64.d new file mode 100644 index 000000000000..c1e359ed8efc --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFSIZE.GreaterThan64.d @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Bit-field width cannot be greater than 64 bits in D. + * + * SECTION: Structs and Unions/Bit-Fields + */ + +#pragma D option quiet + +struct bitRecord{ + int a : 1; + int b : 65; + int c : 12; +} var; + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFTYPE.badtype.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFTYPE.badtype.d new file mode 100644 index 000000000000..5e7b5233055b --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/err.D_DECL_BFTYPE.badtype.d @@ -0,0 +1,47 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Non-integer types used for bitfields will result in a D_DECL_BFTYPE + * error. + * + * SECTION: Structs and Unions/Bit-Fields + */ + +#pragma D option quiet + +struct bits { + float : 1; +} xyz; + +BEGIN +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/err.D_OFFSETOF_BITFIELD.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/err.D_OFFSETOF_BITFIELD.d new file mode 100644 index 000000000000..402a209d1e39 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/err.D_OFFSETOF_BITFIELD.d @@ -0,0 +1,53 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Cannot apply offsetof operator to a bit-field member. + * + * SECTION: Structs and Unions/Bit-Fields + * + */ +#pragma D option quiet + +struct bitRecord{ + int a : 17; + int b : 3; + int c : 12; +} var; + +BEGIN +{ + printf("offsetof(struct bitRecord, a): %d\n", + offsetof(struct bitRecord, a)); + printf("offsetof(struct bitRecord, b): %d\n", + offsetof(struct bitRecord, b)); + printf("offsetof(struct bitRecord, c): %d\n", + offsetof(struct bitRecord, c)); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/err.D_SIZEOF_BITFIELD.SizeofBitfield.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/err.D_SIZEOF_BITFIELD.SizeofBitfield.d new file mode 100644 index 000000000000..70c28340d425 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/err.D_SIZEOF_BITFIELD.SizeofBitfield.d @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Cannot apply sizeof operator to a bit-field member. + * + * SECTION: Structs and Unions/Bit-Fields + */ + +#pragma D option quiet + +struct bitRecord{ + int a : 1; + int b : 3; + int c : 12; +} var; + +BEGIN +{ + printf("sizeof (a): %d\nsizeof (b): %d\nsizeof (c): %n", + sizeof (var.a), sizeof (var.b), sizeof (var.c)); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/tst.BitFieldPromotion.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/tst.BitFieldPromotion.d new file mode 100644 index 000000000000..07ec728bc500 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/tst.BitFieldPromotion.d @@ -0,0 +1,60 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Bit-field will be automatically promoted to the next largest + * integer type for use in any expression and then the value assigned will + * warp around the maximum number assignable to the data type. + * + * SECTION: Structs and Unions/Bit-Fields + */ + +#pragma D option quiet + +struct bitRecord{ + int a : 1; + int b : 15; + int c : 31; +} var; + +BEGIN +{ + var.a = 256; + var.b = 65536; + var.c = 4294967296; + + printf("bitRecord.a: %d\nbitRecord.b: %d\nbitRecord.c: %d\n", + var.a, var.b, var.c); + exit(0); +} + +END +/(0 != var.a) || (0 != var.b) || (0 != var.c)/ +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/tst.SizeofBitField.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/tst.SizeofBitField.d new file mode 100644 index 000000000000..ce307de6194a --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/bitfields/tst.SizeofBitField.d @@ -0,0 +1,109 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: C and D compilers try to pack bits as efficiently as possible. + * + * SECTION: Structs and Unions/Bit-Fields + */ + +#pragma D option quiet + +struct bitRecord1 { + int a : 1; +} var1; + +struct bitRecord2 { + int a : 1; + int b : 3; +} var2; + +struct bitRecord3 { + int a : 1; + int b : 3; + int c : 3; +} var3; + +struct bitRecord4 { + int a : 1; + int b : 3; + int c : 3; + int d : 3; +} var4; + +struct bitRecord5 { + int c : 12; + int a : 10; + int b : 3; +} var5; + +struct bitRecord6 { + int a : 20; + int b : 3; + int c : 12; +} var6; + +struct bitRecord7 { + long c : 32; + long long d: 9; + int e: 1; +} var7; + +struct bitRecord8 { + char a : 2; + short b : 12; + long c : 32; +} var8; + +struct bitRecord12 { + int a : 30; + int b : 30; + int c : 32; +} var12; + +BEGIN +{ + printf("sizeof (bitRecord1): %d\n", sizeof (var1)); + printf("sizeof (bitRecord2): %d\n", sizeof (var2)); + printf("sizeof (bitRecord3): %d\n", sizeof (var3)); + printf("sizeof (bitRecord4): %d\n", sizeof (var4)); + printf("sizeof (bitRecord5): %d\n", sizeof (var5)); + printf("sizeof (bitRecord6): %d\n", sizeof (var6)); + printf("sizeof (bitRecord7): %d\n", sizeof (var7)); + printf("sizeof (bitRecord8): %d\n", sizeof (var8)); + printf("sizeof (bitRecord12): %d\n", sizeof (var12)); + exit(0); +} + +END +/(1 != sizeof (var1)) || (2 != sizeof (var2)) || (3 != sizeof (var3)) || + (4 != sizeof (var4)) || (5 != sizeof (var5)) || (6 != sizeof (var6)) + || (7 != sizeof (var7)) || (8 != sizeof (var8)) || (12 != sizeof (var12))/ +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/err.end.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/err.end.d new file mode 100644 index 000000000000..a480d67a476d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/err.end.d @@ -0,0 +1,54 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Checks that buffer space for an END enabling is always reserved in a + * fill buffer. This will fail because the size of the END enabling + * (64 bytes) exceeds the size of the buffer (32 bytes). + * + * SECTION: Buffers and Buffering/fill Policy; + * Buffers and Buffering/Buffer Sizes; + * Options and Tunables/bufpolicy; + * Options and Tunables/bufsize; + * Options and Tunables/strsize + */ + +#pragma D option bufpolicy=fill +#pragma D option bufsize=32 +#pragma D option strsize=64 + +BEGIN +{ + exit(0); +} + +END +{ + trace(execname); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/err.resize1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/err.resize1.d new file mode 100644 index 000000000000..4731bd1ff8d2 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/err.resize1.d @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Checks that setting "bufresize" to "manual" will cause buffer + * allocation to fail for large principal buffer sizes. + * + * SECTION: Buffers and Buffering/Buffer Resizing Policy; + * Options and Tunables/bufsize; + * Options and Tunables/bufresize + * + */ + +#pragma D option bufresize=manual +#pragma D option bufsize=100t + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/err.resize2.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/err.resize2.d new file mode 100644 index 000000000000..4dfe6b65c545 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/err.resize2.d @@ -0,0 +1,47 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Checks that setting "bufresize" to "manual" will cause buffer + * allocation to fail for large aggregation buffer sizes. + * + * SECTION: Buffers and Buffering/Buffer Resizing Policy; + * Options and Tunables/bufresize; + * Options and Tunables/aggsize + * + */ + +#pragma D option bufresize=manual +#pragma D option aggsize=100t + +BEGIN +{ + @a[probeprov] = count(); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/err.resize3.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/err.resize3.d new file mode 100644 index 000000000000..866a56c6112d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/err.resize3.d @@ -0,0 +1,62 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Checks that setting "bufresize" to "manual" will cause buffer + * allocation to fail for large speculative buffer sizes. + * + * SECTION: Buffers and Buffering/Buffer Resizing Policy; + * Options and Tunables/bufresize; + * Options and Tunables/specsize + * + */ + +#pragma D option bufresize=manual +#pragma D option specsize=100t + +BEGIN +{ + spec = speculation(); +} + +BEGIN +{ + speculate(spec); + trace(epid); +} + +BEGIN +{ + commit(spec); +} + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/err.zerobuf.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/err.zerobuf.d new file mode 100644 index 000000000000..a2e44350eeda --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/err.zerobuf.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Test with a bufsize of 0 - should return an error. + * + * SECTION: + * Buffers and Buffering/Buffer Sizes; + * Options and Tunables/bufsize + */ + +#pragma D option bufsize=0 + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.alignring.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.alignring.d new file mode 100644 index 000000000000..152acb61cd9c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.alignring.d @@ -0,0 +1,81 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Positive test for ring buffer policy. + * + * SECTION: Buffers and Buffering/ring Policy; + * Buffers and Buffering/Buffer Sizes; + * Options and Tunables/bufsize; + * Options and Tunables/bufpolicy + */ + +#pragma D option bufpolicy=ring +#pragma D option bufsize=4k + +profile:::profile-1009hz +{ + printf("%x %x\n", (int)0xaaaa, (int)0xbbbb); +} + +profile:::profile-1237hz +{ + printf("%x %x %x %x %x %x\n", + (int)0xcccc, + (int)0xdddd, + (int)0xeeee, + (int)0xffff, + (int)0xabab, + (int)0xacac); + printf("%x %x\n", + (uint64_t)0xaabbaabbaabbaabb, + (int)0xadad); +} + +profile:::profile-1789hz +{ + printf("%x %x %x %x %x\n", + (int)0xaeae, + (int)0xafaf, + (unsigned char)0xaa, + (int)0xbcbc, + (int)0xbdbd); +} + +profile-1543hz +{} + +profile-1361hz +{} + +tick-1sec +/i++ >= 10/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.cputime.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.cputime.ksh new file mode 100644 index 000000000000..6ac0fa9e27a3 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.cputime.ksh @@ -0,0 +1,90 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" + +script() +{ + $dtrace -s /dev/stdin -x bufpolicy=$1 $1 <on = vtimestamp; + } + + sched:::off-cpu + /self->on/ + { + total += vtimestamp - self->on; + } + + tick-1sec + /i++ == 10/ + { + exit(0); + } + + END + /((total * 100) / (timestamp - start)) > thresh/ + { + printf("'%s' buffering policy took %d%% of CPU; ", + \$\$1, ((total * 100) / (timestamp - start))); + printf("expected no more than %d%%!\n", thresh); + exit(1); + } +EOF +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +for policy in "fill ring switch"; do + script $policy + + status=$? + + if [ "$status" -ne 0 ]; then + exit $status + fi +done + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.dynvarsize.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.dynvarsize.d new file mode 100644 index 000000000000..c8a074002d5d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.dynvarsize.d @@ -0,0 +1,67 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Positive test for dynamic variable size. + * + * SECTION: Buffers and Buffering/switch Policy; + * Buffers and Buffering/Buffer Sizes; + * Options and Tunables/bufsize; + * Options and Tunables/bufpolicy; + * Options and Tunables/switchrate + */ + +#pragma D option dynvarsize=100 +#pragma D option quiet + +int n; + +tick-10ms +/n++ < 100/ +{ + a[n] = 1; +} + +tick-10ms +/n == 100/ +{ + exit(2); +} + +END +/a[99]/ +{ + exit(1); +} + +END +/!a[99]/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.fill1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.fill1.d new file mode 100644 index 000000000000..143ed641f9e7 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.fill1.d @@ -0,0 +1,115 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Positive test for fill buffer policy. + * + * SECTION: Buffers and Buffering/fill Policy; + * Buffers and Buffering/Buffer Sizes; + * Options and Tunables/bufsize; + * Options and Tunables/bufpolicy; + * Options and Tunables/statusrate + */ +/* + * This is a brute-force way of testing fill buffers. We assume that each + * printf() stores 8 bytes. Because each fill buffer is per-CPU, we must + * fill up our buffer in one series of enablings on a single CPU. + */ +#pragma D option bufpolicy=fill +#pragma D option bufsize=64 +#pragma D option statusrate=10ms +#pragma D option quiet + +int i; + +tick-10ms +{ + printf("%d\n", i++); +} + +tick-10ms +{ + printf("%d\n", i++); +} + +tick-10ms +{ + printf("%d\n", i++); +} + +tick-10ms +{ + printf("%d\n", i++); +} + +tick-10ms +{ + printf("%d\n", i++); +} + +tick-10ms +{ + printf("%d\n", i++); +} + +tick-10ms +{ + printf("%d\n", i++); +} + +tick-10ms +{ + printf("%d\n", i++); +} + +tick-10ms +{ + printf("%d\n", i++); +} + +tick-10ms +{ + printf("%d\n", i++); +} + +tick-10ms +{ + printf("%d\n", i++); +} + +tick-10ms +{ + printf("%d\n", i++); +} + +tick-10ms +/i >= 100/ +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.fill1.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.fill1.d.out new file mode 100644 index 000000000000..fd8abec1dfe6 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.fill1.d.out @@ -0,0 +1,9 @@ +0 +1 +2 +3 +4 +5 +6 +7 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.resize1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.resize1.d new file mode 100644 index 000000000000..396a80811629 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.resize1.d @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Checks that setting "bufresize" to "auto" will cause buffer + * allocation to succeed, even for large principal buffer sizes. + * + * SECTION: Buffers and Buffering/Buffer Resizing Policy; + * Options and Tunables/bufsize; + * Options and Tunables/bufresize + * + * NOTES: + * We use the undocumented "preallocate" option to make sure dtrace(1M) + * has enough space in its heap to allocate a buffer as large as the + * kernel's trace buffer. + */ + +#pragma D option preallocate=100t +#pragma D option bufresize=auto +#pragma D option bufsize=100t + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.resize2.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.resize2.d new file mode 100644 index 000000000000..50b814b1bfc1 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.resize2.d @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Checks that setting "bufresize" to "auto" will cause buffer + * allocation to succeed, even for large aggregation buffer sizes. + * + * SECTION: Buffers and Buffering/Buffer Resizing Policy; + * Options and Tunables/aggsize; + * Options and Tunables/bufresize + * + * NOTES: + * We use the undocumented "preallocate" option to make sure dtrace(1M) + * has enough space in its heap to allocate a buffer as large as the + * kernel's trace buffer. + */ + +#pragma D option preallocate=100t +#pragma D option bufresize=auto +#pragma D option aggsize=100t + +BEGIN +{ + @a[probeprov] = count(); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.resize3.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.resize3.d new file mode 100644 index 000000000000..eb362fb31372 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.resize3.d @@ -0,0 +1,73 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Checks that setting "bufresize" to "auto" will cause buffer + * allocation to succeed, even for large speculative buffer sizes. + * + * SECTION: Buffers and Buffering/Buffer Resizing Policy; + * Options and Tunables/specsize; + * Options and Tunables/bufresize + * + * NOTES: + * On some small memory machines, this test may consume so much memory + * that it induces memory allocation failure in the dtrace library. This + * will manifest itself as an error like one of the following: + * + * dtrace: processing aborted: Memory allocation failure + * dtrace: could not enable tracing: Memory allocation failure + * + * These actually indicate that the test performed as expected; failures + * of the above nature should therefore be ignored. + * + */ + +#pragma D option bufresize=auto +#pragma D option specsize=100t + +BEGIN +{ + spec = speculation(); +} + +BEGIN +{ + speculate(spec); + trace(epid); +} + +BEGIN +{ + commit(spec); +} + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.ring1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.ring1.d new file mode 100644 index 000000000000..67e7b8755561 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.ring1.d @@ -0,0 +1,75 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Positive test for ring buffer policy. + * + * SECTION: Buffers and Buffering/ring Policy; + * Buffers and Buffering/Buffer Sizes; + * Options and Tunables/bufsize; + * Options and Tunables/bufpolicy; + * Options and Tunables/switchrate + */ + +/* + * We assume that a trace() of an integer stores at least 8 bytes. If ring + * buffering is not working properly, this trace() will induce a drop, and the + * counter won't be incremented. We set the switchrate to one second just to + * sure that a high switchrate doesn't mask broken ring buffers. + */ +#pragma D option bufpolicy=ring +#pragma D option bufsize=50 +#pragma D option switchrate=1sec + +int n; +int i; + +tick-10msec +/n < 300/ +{ + trace(i); + i++; +} + +tick-10msec +/n < 300/ +{ + n++; +} + +tick-10msec +/n == 300/ +{ + exit(2); +} + +END +{ + exit(i == 300 ? 0 : 1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.ring2.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.ring2.d new file mode 100644 index 000000000000..cbf48f2b0103 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.ring2.d @@ -0,0 +1,53 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Positive test for ring buffer policy. + * + * SECTION: Buffers and Buffering/ring Policy; + * SECTION: Buffers and Buffering/Buffer Sizes; + * Options and Tunables/bufsize; + * Options and Tunables/bufpolicy + */ + +#pragma D option bufpolicy=ring +#pragma D option bufsize=512k +#pragma D option quiet + +tick-1sec +/n < 5/ +{ + printf("%d\n", n++); +} + +tick-1sec +/n == 5/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.ring2.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.ring2.d.out new file mode 100644 index 000000000000..cc4d41aab2b2 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.ring2.d.out @@ -0,0 +1,6 @@ +0 +1 +2 +3 +4 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.ring3.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.ring3.d new file mode 100644 index 000000000000..68e35889eca0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.ring3.d @@ -0,0 +1,78 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Positive test for ring buffer policy. + * + * SECTION: Buffers and Buffering/ring Policy; + * Buffers and Buffering/Buffer Sizes; + * Options and Tunables/bufsize; + * Options and Tunables/bufpolicy + */ + +/* + * We make some regrettable assumptions about the implementation in this test. + * First, we assume that each entry for the printf() of an int takes _exactly_ + * eight bytes (four bytes for the EPID, four bytes for the payload). Second, + * we assume that by allocating storage for n + 1 records, we will get exactly + * n. Here is why: the final predicate that evaluates to false will reserve + * space that it won't use. This act of reservation will advance the wrapped + * offset. That record won't be subsequently used, but the wrapped offset has + * advanced. (And in this case, that old record is clobbered by the exit() + * anyway.) Thirdly: we rely on t_cpu/cpu_id. Finally: we rely on being + * able to run on the CPU that we first ran on. + */ +#pragma D option bufpolicy=ring +#pragma D option bufsize=40 +#pragma D option quiet + +int n; + +BEGIN +{ + cpuid = -1; +} + +tick-10msec +/cpuid == -1/ +{ + cpuid = curthread->t_cpu->cpu_id; +} + +tick-10msec +/curthread->t_cpu->cpu_id == cpuid && n < 100/ +{ + printf("%d\n", n++); +} + +tick-10msec +/n == 100/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.ring3.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.ring3.d.out new file mode 100644 index 000000000000..99fd231e65be --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.ring3.d.out @@ -0,0 +1,5 @@ +96 +97 +98 +99 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.smallring.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.smallring.d new file mode 100644 index 000000000000..2134a0b726ae --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.smallring.d @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Positive test for ring buffer policy. + * + * SECTION: Buffers and Buffering/ring Policy; + * Buffers and Buffering/Buffer Sizes; + * Options and Tunables/bufsize; + * Options and Tunables/bufpolicy + */ + +#pragma D option bufpolicy=ring +#pragma D option bufsize=16 + +tick-10ms +{ + trace(0xbadbaddefec8d); +} + +tick-10ms +/0/ +{ + trace((int)1); +} + +tick-100ms +/i++ > 2/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.switch1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.switch1.d new file mode 100644 index 000000000000..2840feeffd5d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.switch1.d @@ -0,0 +1,69 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Positive test for switch buffer policy. + * + * SECTION: Buffers and Buffering/switch Policy; + * Buffers and Buffering/Buffer Sizes; + * Options and Tunables/bufsize; + * Options and Tunables/bufpolicy; + * Options and Tunables/switchrate + */ + +/* + * We assume that a printf() of an integer stores at least 8 bytes, and no more + * than 16 bytes. + */ +#pragma D option bufpolicy=switch +#pragma D option bufsize=32 +#pragma D option switchrate=500msec +#pragma D option quiet + +int n; +int i; + +tick-1sec +/n < 10/ +{ + printf("%d\n", i); + i++; +} + +tick-1sec +/n < 10/ +{ + n++; +} + +tick-1sec +/n == 10/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.switch1.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.switch1.d.out new file mode 100644 index 000000000000..ce6c2bcb01fc --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.switch1.d.out @@ -0,0 +1,11 @@ +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.cpuusage.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.cpuusage.d new file mode 100644 index 000000000000..e1e0dd83792d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.cpuusage.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * print non assigned value and make sure it fails. + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ + printf("The cpuusage = %d\n", curlwpsinfo->pr_cpu); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.nice.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.nice.d new file mode 100644 index 000000000000..c7a4ad21884e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.nice.d @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * print non assigned value and make sure it fails. + * + * SECTION: Variables/Built-in Variables + * + * + */ + +#pragma D option quiet + +BEGIN +{ + printf("The nice for cpu usage %c\n", curlwpsinfo->pr_nice); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.priority.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.priority.d new file mode 100644 index 000000000000..6ebb3dfa1cd2 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.priority.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Print non assigned variables and make sure it fails. + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ + printf("The low value is high priority field = %d\n", + curlwpsinfo->pr_nice); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.prsize.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.prsize.d new file mode 100644 index 000000000000..f467f1927ad8 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.prsize.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * print non assigned variables and make sure it fails. + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ + printf("Size of process image in kbytes = %ld\n", curpsinfo->pr_size); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.rssize.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.rssize.d new file mode 100644 index 000000000000..48057e14c9d1 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/err.D_XLATE_NOCONV.rssize.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * print non assigned variables and make sure it fails. + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ + printf("Size of process image in kbytes = %ld\n", curpsinfo->pr_rssize); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.arg0.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.arg0.d new file mode 100644 index 000000000000..ec3c277f9abc --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.arg0.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * print arg0 and make sure it succeeds. + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ + printf("The argument is %u\n", arg0); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.arg0clause.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.arg0clause.d new file mode 100644 index 000000000000..4c782f835580 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.arg0clause.d @@ -0,0 +1,47 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * print arg0 from a profile and make sure it succeeds + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ + printf("Call probe read\n"); +} + +syscall:::entry +{ + printf("The argument is %u", arg0); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.arg1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.arg1.d new file mode 100644 index 000000000000..993a3765ffd4 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.arg1.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * print arg1 and make sure it succeeds. + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ + printf("The argument is %u\n", arg1); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.arg1to8.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.arg1to8.d new file mode 100644 index 000000000000..b696d7c22ca6 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.arg1to8.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * print arg1 to arg8 and make sure it succeeds. + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ + printf("The argument is %u %u %u %u %u %u %u %u\n", arg1, arg2, + arg3, arg4, arg5, arg6, arg7, arg8); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.arg1to8clause.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.arg1to8clause.d new file mode 100644 index 000000000000..fa62b03b122e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.arg1to8clause.d @@ -0,0 +1,47 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * print arg1 to arg8 from a profile and make sure it succeeds + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ +} + +syscall:::entry +{ + printf("The argument is %u %u %u %u %u %u %u %u\n", arg1, arg2, + arg3, arg4, arg5, arg6, arg7, arg8); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.caller.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.caller.d new file mode 100644 index 000000000000..db1eabce2f02 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.caller.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * print 'caller' and make sure it succeeds. + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ + printf("The caller is %u\n", caller); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.caller1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.caller1.d new file mode 100644 index 000000000000..f1bfeedfec6c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.caller1.d @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * To print caller form profile and make sure it succeeds. + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ +} + +tick-10ms +{ + printf("The caller is %u\n", caller); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.epid.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.epid.d new file mode 100644 index 000000000000..4f04c65679fa --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.epid.d @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * To print 'epid'from profile and make sure it succeeds + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ +} + +tick-10ms +{ + printf("epid of this probe = %d\n", epid); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.epid1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.epid1.d new file mode 100644 index 000000000000..4cba65e6da96 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.epid1.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * print epid and make sure it succeeds. + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ + printf("epid of this probe = %d\n", epid); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.errno.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.errno.d new file mode 100644 index 000000000000..4d7a4ffcc5f1 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.errno.d @@ -0,0 +1,47 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * To print errno from profile and make sure it succeeds. + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ +} + +tick-10ms +{ + printf("epid of this probe = %d\n", epid); + printf("the errno = %d\n", errno); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.errno1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.errno1.d new file mode 100644 index 000000000000..ed233bf04d08 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.errno1.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * To print errno and make sure it succeeds. + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ + printf("epid of this probe = %d\n", epid); + printf("the errno = %d\n", errno); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.execname.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.execname.d new file mode 100644 index 000000000000..b3007de38aee --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.execname.d @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * To print execname and make sure it succeeds. + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +/execname == "dtrace" || execname == "java"/ +{ + trace("execname matched"); + exit(0); +} + +BEGIN +{ + trace("execname didn't match"); + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.hpriority.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.hpriority.d new file mode 100644 index 000000000000..a0d8836780c8 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.hpriority.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * To print hpriority and make sure it succeeds + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ + printf("The high priority = %d\n", curlwpsinfo->pr_pri); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.id.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.id.d new file mode 100644 index 000000000000..291d91d96e1b --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.id.d @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * To print 'id' from profile. + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ +} + +tick-10ms +{ + printf("id of this probe = %d\n", id); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.id1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.id1.d new file mode 100644 index 000000000000..068cff65ede7 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.id1.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * To print id and make sure it succeeds. + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ + printf("id of this probe = %d\n", id); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.ipl.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.ipl.d new file mode 100644 index 000000000000..2e6f349d79f9 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.ipl.d @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * To print variable ipl + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ +} + +tick-10ms +{ + printf("The interrupt priority level = %u\n", ipl); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.ipl1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.ipl1.d new file mode 100644 index 000000000000..ef9278d1c6e9 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.ipl1.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * To print ipl and make sure it succeeds + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ + printf("The interrupt priority level = %u\n", ipl); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.lwpsinfo.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.lwpsinfo.d new file mode 100644 index 000000000000..f0e9d4605bf2 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.lwpsinfo.d @@ -0,0 +1,55 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * To print lwpsinfo_t structure values. + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ +} + +tick-10ms +{ + printf("The current thread's pr_flag is %d\n", curlwpsinfo->pr_flag); + printf("The current threads lwpid is %d\n", curlwpsinfo->pr_lwpid); + printf("The current thread's internal address is %u\n", + curlwpsinfo->pr_addr); + printf("The current thread's wait addr for sleeping lwp is %u\n", + curlwpsinfo->pr_wchan); + printf("The current lwp stat is %d\n", curlwpsinfo->pr_state); + printf("The printable character for pr_state %c\n", + curlwpsinfo->pr_sname); + printf("The syscall number = %d\n", curlwpsinfo->pr_syscall); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.lwpsinfo1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.lwpsinfo1.d new file mode 100644 index 000000000000..aa11b07d63a7 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.lwpsinfo1.d @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * To print lwpsinfo_t variables and make sure it succeeds + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ + printf("The current thread's pr_flag is %d\n", curlwpsinfo->pr_flag); + printf("The current threads lwpid is %d\n", curlwpsinfo->pr_lwpid); + printf("The current thread's internal address is %u\n", + curlwpsinfo->pr_addr); + printf("The current thread's wait addr for sleeping lwp is %u\n", + curlwpsinfo->pr_wchan); + printf("The current lwp stat is %d\n", curlwpsinfo->pr_state); + printf("The printable character for pr_state %c\n", + curlwpsinfo->pr_sname); + printf("The syscall number = %d\n", curlwpsinfo->pr_syscall); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.pid.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.pid.d new file mode 100644 index 000000000000..2dd80d71cd19 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.pid.d @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * To print 'pid' from profile. + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ +} + +tick-10ms +{ + printf("process id = %d \n", pid); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.pid1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.pid1.d new file mode 100644 index 000000000000..5cee07c5fbfb --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.pid1.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * To print 'pid' and make sure it succeeds. + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ + printf("process id = %d \n", pid); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.psinfo.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.psinfo.d new file mode 100644 index 000000000000..6961a0d58055 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.psinfo.d @@ -0,0 +1,60 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * To print psinfo structure values from profile. + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ +} + +tick-10ms +{ + printf("number of lwps in process = %d\n", curpsinfo->pr_nlwp); + printf("unique process id = %d\n", curpsinfo->pr_pid); + printf("process id of parent = %d\n", curpsinfo->pr_ppid); + printf("pid of process group leader = %d\n", curpsinfo->pr_pgid); + printf("session id = %d\n", curpsinfo->pr_sid); + printf("real user id = %d\n", curpsinfo->pr_uid); + printf("effective user id = %d\n", curpsinfo->pr_euid); + printf("real group id = %d\n", curpsinfo->pr_gid); + printf("effective group id = %d\n", curpsinfo->pr_egid); + printf("address of process = %u\n", curpsinfo->pr_addr); + exit (0); +} + +ERROR +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.psinfo1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.psinfo1.d new file mode 100644 index 000000000000..b805e2754502 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.psinfo1.d @@ -0,0 +1,56 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * To print psinfo structure values. + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ + printf("number of lwps in process = %d\n", curpsinfo->pr_nlwp); + printf("unique process id = %d\n", curpsinfo->pr_pid); + printf("process id of parent = %d\n", curpsinfo->pr_ppid); + printf("pid of process group leader = %d\n", curpsinfo->pr_pgid); + printf("session id = %d\n", curpsinfo->pr_sid); + printf("real user id = %d\n", curpsinfo->pr_uid); + printf("effective user id = %d\n", curpsinfo->pr_euid); + printf("real group id = %d\n", curpsinfo->pr_gid); + printf("effective group id = %d\n", curpsinfo->pr_egid); + printf("address of process = %u\n", curpsinfo->pr_addr); + exit (0); +} + +ERROR +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.tid.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.tid.d new file mode 100644 index 000000000000..1b16c8bb53da --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.tid.d @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * To print tid from profile + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ +} + +tick-10ms +{ + printf("Thread id = %d \n", tid); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.tid1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.tid1.d new file mode 100644 index 000000000000..a0567e7094dc --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.tid1.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * To print tid and make sure it succeeds. + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ + printf("Thread id = %d \n", tid); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.timestamp.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.timestamp.d new file mode 100644 index 000000000000..cd94eac842f2 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.timestamp.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * To print build-in variable 'timestamp' + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ + self->t = timestamp; + printf("The difftime = %d\n", timestamp - self->t); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.vtimestamp.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.vtimestamp.d new file mode 100644 index 000000000000..cdbecfc7a134 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/builtinvar/tst.vtimestamp.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * To print build-in variable 'vtimestamp' + * + * SECTION: Variables/Built-in Variables + */ + +#pragma D option quiet + +BEGIN +{ + self->t = vtimestamp; + printf("The difftime = %d\n", vtimestamp - self->t); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.aggfun.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.aggfun.d new file mode 100644 index 000000000000..f687717431da --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.aggfun.d @@ -0,0 +1,40 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Test a clause where an unknown identifier appears in a predicated + * clause inside an aggregating function. + * SECTION: Program Structure / Probe Clauses and Declarations + * + */ + +BEGIN +/1/ +{ + @a = max(x); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.aggtup.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.aggtup.d new file mode 100644 index 000000000000..1fa49747f2a7 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.aggtup.d @@ -0,0 +1,40 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Test a clause where an unknown identifier appears in a predicated + * clause inside an aggregation tuple. + * SECTION: Program Structure / Probe Clauses and Declarations + * + */ + +BEGIN +/1/ +{ + @a[x] = count(); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.arrtup.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.arrtup.d new file mode 100644 index 000000000000..6c1cdffbd37a --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.arrtup.d @@ -0,0 +1,40 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Test a clause where an unknown identifier appears in a predicated + * clause inside an associate array tuple. + * SECTION: Program Structure / Probe Clauses and Declarations + * + */ + +BEGIN +/1/ +{ + a[x]++; +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.body.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.body.d new file mode 100644 index 000000000000..da499cb570cd --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.body.d @@ -0,0 +1,38 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Test a clause where an unknown identifier appears in a clause. + * SECTION: Program Structure / Probe Clauses and Declarations + * + */ + +BEGIN +{ + exit(x); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.both.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.both.d new file mode 100644 index 000000000000..007082730c30 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.both.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Test a clause where an unknown identifier appears in a predicate + * and in a clause body. + * + * SECTION: Program Structure / Probe Clauses and Declarations + * + */ + +BEGIN +/x != 0/ +{ + exit(x); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.pred.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.pred.d new file mode 100644 index 000000000000..0bfc86f4cb87 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/err.D_IDENT_UNDEF.pred.d @@ -0,0 +1,39 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Test a clause where an unknown identifier appears in a predicate. + * SECTION: Program Structure / Probe Clauses and Declarations + * + */ + +BEGIN +/x != 0/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/tst.nopred.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/tst.nopred.d new file mode 100644 index 000000000000..44d11675f5b2 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/tst.nopred.d @@ -0,0 +1,38 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Test a clause that has a body but no predicate. + * SECTION: Program Structure / Probe Clauses and Declarations + * + */ + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/tst.pred.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/tst.pred.d new file mode 100644 index 000000000000..43bfedd8edce --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/tst.pred.d @@ -0,0 +1,39 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Test a clause that has a body and a predicate. + * SECTION: Program Structure / Probe Clauses and Declarations + * + */ + +BEGIN +/$pid != 0/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/tst.predfirst.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/tst.predfirst.d new file mode 100644 index 000000000000..c7f0b4eb2b75 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/tst.predfirst.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Test a clause that has a body and a predicate where the + * predicate must be cooked first because it creates a variable. + * + * SECTION: Program Structure / Probe Clauses and Declarations + * + */ + +BEGIN +/x++ == 0/ +{ + exit(x - 1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/tst.predlast.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/tst.predlast.d new file mode 100644 index 000000000000..9ed904f765c6 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/clauses/tst.predlast.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Test a clause that has a body and a predicate where the + * predicate must be cooked last because the clause creates + * a variable which is referenced in the predicate. + * + * SECTION: Program Structure / Probe Clauses and Declarations + * + */ + +BEGIN +/x == 0/ +{ + exit(x++); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_LOCASSC.NonLocalAssoc.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_LOCASSC.NonLocalAssoc.d new file mode 100644 index 000000000000..4c8ee508c682 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_LOCASSC.NonLocalAssoc.d @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * associative arrays may not be declared as local variables + * + * SECTION: Errtags/D_DECL_LOCASSC + * + */ + +#pragma D option quiet + +this int a[int]; + +BEGIN +{ + exit(0); +} + +ERROR +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_LONGINT.LongStruct.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_LONGINT.LongStruct.d new file mode 100644 index 000000000000..2c92bfdbaac3 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_LONGINT.LongStruct.d @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * long and long long may only be used with integer or floating-point type + * + * SECTION: Errtags/D_DECL_LONGINT + * + */ + +#pragma D option quiet + +long struct mystruct +{ + int i; +}; + +BEGIN +{ + exit(0); +} + +ERROR +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_PARMCLASS.BadStorageClass.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_PARMCLASS.BadStorageClass.d new file mode 100644 index 000000000000..8278747ed6ec --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_PARMCLASS.BadStorageClass.d @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * inappropriate storage class for function or associative array parameter + * throws a D_DECL_PARMCLASS + * + * SECTION: Errtags/D_DECL_PARMCLASS + * + */ + +#pragma D option quiet + + +int foo(static int); + +BEGIN +{ + exit(0); +} + +ERROR +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_NAME.VoidName.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_NAME.VoidName.d new file mode 100644 index 000000000000..3676c21cb713 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_NAME.VoidName.d @@ -0,0 +1,40 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * Assert that a void parameter in a declaration where void is permitted + * may not have a parameter formal name associated with it. + */ + +int a(void v); + +BEGIN, +ERROR +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_TYPE.Dyn.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_TYPE.Dyn.d new file mode 100644 index 000000000000..aecf54999970 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_TYPE.Dyn.d @@ -0,0 +1,40 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * Assert that a function parameter in a declaration may not use a dynamic + * DTrace type such as an associative array type. + */ + +int a(int a[int]); + +BEGIN, +ERROR +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_VARARGS.VarLenArgs.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_VARARGS.VarLenArgs.d new file mode 100644 index 000000000000..22dbbe9b82c0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_VARARGS.VarLenArgs.d @@ -0,0 +1,50 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * array tuples may not use variable-length argument lists + * + * SECTION: Errtags/ D_DECL_ARRVA + * + */ + +#pragma D option quiet + + +int a[...]; + +BEGIN +{ + exit(0); +} + +ERROR +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_VOID.NonSoleVoid.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_VOID.NonSoleVoid.d new file mode 100644 index 000000000000..620f0d7cca76 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_PROTO_VOID.NonSoleVoid.d @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * void must be sole parameter in a function declaration. + * + * SECTION: Errtags/D_DECL_FUNCVOID + * + */ + +#pragma D option quiet + +int foo(int, void); + +BEGIN +{ + exit(0); +} + +ERROR +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_SIGNINT.UnsignedStruct.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_SIGNINT.UnsignedStruct.d new file mode 100644 index 000000000000..db2e4510db30 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_SIGNINT.UnsignedStruct.d @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * signed and unsigned may only be used with integer type + * + * SECTION: Errtags/D_DECL_SIGNINT + * + */ + +#pragma D option quiet + +/*DSTYLED*/ +unsigned struct mystruct { + int i; +}; + +BEGIN +{ + exit(0); +} + +ERROR +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_VOIDATTR.ShortVoidDecl.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_VOIDATTR.ShortVoidDecl.d new file mode 100644 index 000000000000..81f90814bc8f --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/err.D_DECL_VOIDATTR.ShortVoidDecl.d @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Attributes may not be used with void type. + * + * SECTION: Errtags/D_DECL_VOIDATTR + * + */ + +#pragma D option quiet + +short void ptr; + +BEGIN +{ + exit(0); +} + +ERROR +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/tst.arrays.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/tst.arrays.d new file mode 100644 index 000000000000..34ddd5fcad66 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/tst.arrays.d @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * Test various kinds of array declarations. + * + * SECTION: Program Structure/Probe Clauses and Declarations + * + */ + +extern int a1[]; + +extern int a2[1]; + +extern int a3[123][456]; + +extern int a4[123][456][789]; + +extern int a5[5], a6[6][6], a7[7][7][7]; + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/tst.basics.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/tst.basics.d new file mode 100644 index 000000000000..4c1483e2381e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/tst.basics.d @@ -0,0 +1,67 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * Test a variety of extern declarations that exercise the different + * kinds of declarations that we can process. + * + * SECTION: Program Structure/Probe Clauses and Declarations + * + */ + +extern void *e1; +extern char e2; +extern signed char e3; +extern unsigned char e4; +extern short e5; +extern signed short e6; +extern unsigned short e7; +extern int e8; +extern e9; +extern signed int e10; +extern unsigned int e11; +extern long e12; +extern signed long e13; +extern unsigned long e14; +extern long long e15; +extern signed long long e16; +extern unsigned long long e17; +extern float e18; +extern double e19; +extern long double e20; +extern vnode_t e21; +extern struct vnode e22; +extern union sigval e23; +extern enum uio_rw e24; + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/tst.funcs.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/tst.funcs.d new file mode 100644 index 000000000000..3b691eb2873c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/tst.funcs.d @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * Test various kinds of function declarations. + * + * SECTION: Program Structure/Probe Clauses and Declarations + */ + +extern int getint(void); +extern int *getptr(void); +extern int *(*funcptr)(void); +extern int **(**funcptrptr)(void); + +extern int noparms(); +extern int oneparm(int); +extern int twoparms(int, int); + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/tst.pointers.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/tst.pointers.d new file mode 100644 index 000000000000..d0ab6087a00f --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/tst.pointers.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * Test multiple extern declarations in a single list which build + * up a chain of pointers to pointers to pointers ... + * + * SECTION: Program Structure/Probe Clauses and Declarations + */ + +extern int e0, *e1, **e2, ***e3, ****e4, *****e5; + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/tst.varargsfuncs.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/tst.varargsfuncs.d new file mode 100644 index 000000000000..c12363fb9595 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/decls/tst.varargsfuncs.d @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * Test functions declarations with varargs + * + * SECTION: Program Structure/Probe Clauses and Declarations + */ + +#pragma D option quiet + +extern int varargs1(...); +extern int varargs2(int, ...); + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/badptr.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/badptr.d new file mode 100644 index 000000000000..c48c7294b102 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/badptr.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Verify doc example 5-1 + * + * SECTION: + * DocExamples/badptr + */ + +BEGIN +{ + x = (int *)NULL; + y = *x; + trace(y); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/countdown.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/countdown.d new file mode 100644 index 000000000000..56b988154f6c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/countdown.d @@ -0,0 +1,53 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Verify doc example + * + * SECTION: + * DocExamples/other + */ + +dtrace:::BEGIN +{ + i = 10; +} + +profile:::tick-1sec +/i > 0/ +{ + trace(i--); +} + +profile:::tick-1000 +/i == 0/ +{ + trace("blastoff!"); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/counter.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/counter.d new file mode 100644 index 000000000000..8b7b1b3b19b0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/counter.d @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Verify doc + * + * SECTION: + * DocExamples/other + */ + + +dtrace:::BEGIN +{ + i = 0; +} + +profile:::tick-1sec +{ + i = i + 1; + trace(i); +} + +dtrace:::END +{ + trace(i); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/errorpath.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/errorpath.d new file mode 100644 index 000000000000..76fd07c2068b --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/errorpath.d @@ -0,0 +1,47 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Verify doc example 17-1 + * + * SECTION: + * DocExamples/errorpath + */ + + +BEGIN +{ + *(char *)NULL; +} + +ERROR +{ + printf("Hit an error!"); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/hello.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/hello.d new file mode 100644 index 000000000000..8e1ef8f79f30 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/hello.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Verify doc example 1-1 + * + * SECTION: + * DocExamples/hello + */ + + +BEGIN +{ + trace("hello, world"); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/kstat.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/kstat.d new file mode 100644 index 000000000000..49871497baea --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/kstat.d @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Verify doc example 7-3 + * + * SECTION: + * DocExamples/kstat + */ + + +#pragma D option quiet + +pid$1:libkstat:kstat_data_lookup:entry +{ + self->ksname = arg1; +} + +pid$1:libkstat:kstat_data_lookup:return +/self->ksname != NULL && arg1 != NULL/ +{ + this->str = copyinstr(self->ksname); + this->ksp = (kstat_named_t *)copyin(arg1, sizeof (kstat_named_t)); + printf("%s has ui64 value %u\n", this->str, this->ksp->value.ui64); +} + +pid$1:libkstat:kstat_data_lookup:return +/self->ksname != NULL && arg1 == NULL/ +{ + self->ksname = NULL; +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/ksyms.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/ksyms.d new file mode 100644 index 000000000000..932262b0b913 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/ksyms.d @@ -0,0 +1,63 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Verify doc example 7-2 + * + * SECTION: + * DocExamples/ksyms + */ + + +/* Must run "strings -a /dev/ksyms in another shell on the system */ + + +#pragma D option quiet + +syscall::read:entry +/curpsinfo->pr_psargs == "strings -a /dev/ksyms"/ +{ + printf("read %u bytes to user address %x\n", arg2, arg1); + self->watched = 1; +} + +syscall::read:return +/self->watched/ +{ + self->watched = 0; +} + +fbt::uiomove:entry +/self->watched/ +{ + this->iov = args[3]->uio_iov; + + printf("uiomove %u bytes to %p in pid %d\n", this->iov->iov_len, + this->iov->iov_base, pid); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/renormalize.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/renormalize.d new file mode 100644 index 000000000000..7d2c6af76f46 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/renormalize.d @@ -0,0 +1,55 @@ + +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * Verify doc example 9-1 + * + * SECTION: + * DocExamples/renormalize + */ + +#pragma D option quiet + +BEGIN +{ + start = timestamp; +} + +syscall:::entry +{ + @func[execname] = count(); +} + +tick-10sec +{ + normalize(@func, (timestamp - start) / 1000000000); + printa(@func); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/rtime.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/rtime.d new file mode 100644 index 000000000000..087e819314f0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/rtime.d @@ -0,0 +1,50 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Verify doc example 3-1 + * + * SECTION: + * DocExamples/rtime + */ + + +#pragma D option quiet + +syscall::read:entry +{ + self->t = timestamp; +} + +syscall::read:return +/self->t != 0/ +{ + printf("%d/%d spent %d nsecs in read(2)\n", pid, + tid, timestamp - self->t); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/rw.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/rw.d new file mode 100644 index 000000000000..6358a7dc0078 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/rw.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Verify doc example + * + * SECTION: + * DocExamples/other + */ + + +syscall::read:entry, +syscall::write:entry +/pid == 102429/ +{ +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/rwinfo.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/rwinfo.d new file mode 100644 index 000000000000..60f2b12a971e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/rwinfo.d @@ -0,0 +1,74 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Verify doc example 7-1 + * + * SECTION: + * DocExamples/rwinfo + */ + + +#pragma D option quiet + +struct callinfo { + uint64_t ts; + uint64_t elapsed; + uint64_t calls; + size_t maxbytes; +}; + +struct callinfo i[string]; + +syscall::read:entry, +syscall::write:entry +/pid == 100551/ +{ + i[probefunc].ts = timestamp; + i[probefunc].calls++; + i[probefunc].maxbytes = arg2 > i[probefunc].maxbytes ? + arg2 : i[probefunc].maxbytes; +} + +syscall::read:return, +syscall::write:return +/i[probefunc].ts != 0 && pid == 100551/ +{ + i[probefunc].elapsed += timestamp - i[probefunc].ts; +} + +END +{ + printf(" calls max bytes elapsed nsecs\n"); + printf("----- ----- --------- -------------\n"); + printf(" read %5d %9d %d\n", i["read"].calls, + i["read"].maxbytes, i["read"].elapsed); + printf(" write %5d %9d %d\n", i["write"].calls, + i["write"].maxbytes, i["write"].elapsed); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/rwtime.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/rwtime.d new file mode 100644 index 000000000000..2edffb907398 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/rwtime.d @@ -0,0 +1,50 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Verify doc example 7-1 + * + * SECTION: + * DocExamples/rwinfo + */ + + +syscall::read:entry, +syscall::write:entry +/pid == 100551/ +{ + ts[probefunc] = timestamp; +} + +syscall::read:return, +syscall::write:return +/(ts[probefunc] != 0) && (pid == 100551)/ +{ + printf("%d nsecs\n", timestamp - ts[probefunc]); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/specopen.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/specopen.d new file mode 100644 index 000000000000..dff3e6227b1b --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/specopen.d @@ -0,0 +1,79 @@ +#!/usr/sbin/dtrace -Fs + + +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Verify doc example 13-1 + * + * SECTION: + * DocExamples/specopen + */ + +syscall::open:entry, +syscall::open64:entry +{ + self->spec = speculation(); + speculate(self->spec); + + printf("%s", stringof(copyinstr(arg0))); +} + +fbt::: +/self->spec/ +{ + speculate(self->spec); +} + +syscall::open:return, +syscall::open64:return +/self->spec/ +{ + speculate(self->spec); + trace(errno); +} + +syscall::open:return, +syscall::open64:return +/self->spec && errno != 0/ +{ + commit(self->spec); + self->spec = 0; +} + +syscall::open:return, +syscall::open64:return +/self->spec && errno == 0/ +{ + discard(self->spec); + self->spec = 0; +} + + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/truss.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/truss.d new file mode 100644 index 000000000000..b79252051ac7 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/truss.d @@ -0,0 +1,55 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Verify doc + * + * SECTION: + * DocExamples/truss + */ + + + +dtrace:::BEGIN +{ + var = 30; + self->vaa = 24; +} + +syscall::read:entry +/pid == 102473/ +{ + printf("var: %d, self->vaa: %d", var++, self->vaa++); +} + +syscall::write:entry +/pid == 102473/ +{ + printf("var: %d, self->vaa: %d", var++, self->vaa++); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/trussrw.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/trussrw.d new file mode 100644 index 000000000000..9eb9bceda935 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/trussrw.d @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Verify doc example 1-2 + * + * SECTION: + * DocExamples/trussrw + */ + + +#pragma D option quiet + +syscall::read:entry, +syscall::write:entry +/pid == 100551/ +{ + printf("%s(%d, 0x%x, %4d)", probefunc, arg0, arg1, arg2); +} + +syscall::read:return, +syscall::write:return +/pid == 100551/ +{ + printf("\t\t = %d\n", arg1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/userfunc.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/userfunc.d new file mode 100644 index 000000000000..0d83465d0ae0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/docsExamples/userfunc.d @@ -0,0 +1,61 @@ +#!/usr/sbin/dtrace -s + +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Verifying doc example 21-1 + * + * SECTION: + * DocExamples/userfunc + * + */ + +pid$1::$2:entry +{ + self->trace = 1; +} + +pid$1::$2:return +/self->trace/ +{ + self->trace = 0; +} + +pid$1:::entry, +pid$1:::return +/self->trace/ +{ +} + + + + + + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_AGGREGATION.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_AGGREGATION.d new file mode 100644 index 000000000000..02b32438a560 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_AGGREGATION.d @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet +#pragma D option strsize=1024 +#pragma D option aggsize=512 + +BEGIN +{ + @["Harding"] = count(); + @["Hoover"] = count(); + @["Nixon"] = count(); + @["Bush"] = count(); +} + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_DBLERROR.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_DBLERROR.d new file mode 100644 index 000000000000..face4c8c0948 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_DBLERROR.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +BEGIN +{ + trace(*(int *)NULL); +} + +ERROR +{ + trace(*(int *)NULL); +} + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_DYNAMIC.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_DYNAMIC.d new file mode 100644 index 000000000000..f8a90f068f6b --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_DYNAMIC.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option strsize=1024 +#pragma D option dynvarsize=512 + +BEGIN +{ + a["Harding"] = 1; + a["Hoover"] = 1; + a["Nixon"] = 1; + a["Bush"] = 1; +} + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_PRINCIPAL.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_PRINCIPAL.d new file mode 100644 index 000000000000..8389ce02d2cb --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_PRINCIPAL.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option strsize=1024 +#pragma D option bufsize=512 + +BEGIN +{ + trace("Harding"); + trace("Hoover"); + trace("Nixon"); + trace("Bush"); +} + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_PRINCIPAL.end.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_PRINCIPAL.end.d new file mode 100644 index 000000000000..a723019f96a5 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_PRINCIPAL.end.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option strsize=1024 +#pragma D option bufsize=512 + +BEGIN +{ + exit(0); +} + +END +{ + trace("Harding"); + trace("Hoover"); + trace("Nixon"); + trace("Bush"); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_SPEC.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_SPEC.d new file mode 100644 index 000000000000..8f6df3c0a520 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_SPEC.d @@ -0,0 +1,48 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option nspec=1 +#pragma D option specsize=32 +#pragma D option strsize=512 + +BEGIN +{ + spec = speculation(); + speculate(spec); + trace("The, SystemTap, The."); +} + +BEGIN +{ + commit(spec); +} + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_SPECUNAVAIL.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_SPECUNAVAIL.d new file mode 100644 index 000000000000..1fd39748d3d7 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_SPECUNAVAIL.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option nspec=1 + +BEGIN, +BEGIN, +BEGIN, +BEGIN +{ + spec = speculation(); +} + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_STKSTROVERFLOW.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_STKSTROVERFLOW.d new file mode 100644 index 000000000000..f5d6416bce8f --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/drops/drp.DTRACEDROP_STKSTROVERFLOW.d @@ -0,0 +1,53 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option destructive +#pragma D option jstackstrsize=1 +#pragma D option quiet + +BEGIN +{ + system("java -version"); +} + +syscall:::entry +{ + @[jstack()] = count(); +} + +proc:::exit +/progenyof($pid) && execname == "java"/ +{ + exit(0); +} + +END +{ + printa("\r", @); + printf("\n"); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/err.D_PDESC_ZERO.InvalidDescription1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/err.D_PDESC_ZERO.InvalidDescription1.d new file mode 100644 index 000000000000..a0d17676140f --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/err.D_PDESC_ZERO.InvalidDescription1.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: An invalid probe description throws a D_PDESC_ZERO error. + * + * SECTION: Errtags/D_PDESC_ZERO + * + */ + +#pragma D option quiet + +fbt:bippity:boppity:boo +{ + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.APIVersion.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.APIVersion.d new file mode 100644 index 000000000000..21564897f120 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.APIVersion.d @@ -0,0 +1,37 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* Assertion: + * Use the -V option to printout API version. + * + * SECTION: + * dtrace Utility/-V Option + * + * NOTES: + * Use /usr/sbin/dtrace -V on command line. + */ diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.AddSearchPath.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.AddSearchPath.d new file mode 100644 index 000000000000..53fe67af7b70 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.AddSearchPath.d @@ -0,0 +1,55 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * The -I option can be used to search path for #include files when used + * in conjunction with the -C option. The specified directory is inserted into + * the search path adhead of the default directory list. + * + * SECTION: dtrace Utility/-C Option; + * dtrace Utility/-I Option + * + * NOTES: + * Create a file and define the variable VALUE in it. Move it a + * directory different from the current directory. Change the value + * of appropriately in the code below. + * Invoke: dtrace -C -I -s man.AddSearchPath.d + * Verify VALUE. + */ + + +#pragma D option quiet + +#include "filename" + +BEGIN +{ + printf("Value of VALUE: %d\n", VALUE); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.CoalesceTrace.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.CoalesceTrace.d new file mode 100644 index 000000000000..3cd9d02a1e18 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.CoalesceTrace.d @@ -0,0 +1,67 @@ +#!/bin/ksh -p + +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * + * ASSERTION: + * Testing -F option with several probes. + * + * SECTION: dtrace Utility/-F Option + * + * NOTES: Manually verify using: + * "/usr/sbin/dtrace -F -s man.CoalesceTrace.d" on command line. + * + * Verify that the for the indent characters are -> <- for non-syscall + * entry/return pairs (e.g. fbt ones) and => <= for syscall ones and + * | for profile ones. + * + */ + +BEGIN +{ + i = 0; + j = 0; + k = 0; +} + +syscall::read: +{ + printf("syscall: %d\n", i++); +} + +fbt:genunix:read: +{ + printf("fbt: %d\n", j++); +} + +profile:::tick-10sec +{ + printf("profile: %d\n", k++); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.ELFGeneration.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.ELFGeneration.d new file mode 100644 index 000000000000..a30a140e501a --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.ELFGeneration.d @@ -0,0 +1,48 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Using -G option with dtrace utility produces an ELF file containing a + * DTrace program. If the filename used with the -s option does ends + * with .d, and the -o option is not used, then the output ELF file is + * in filename.o + * + * SECTION: dtrace Utility/-G Option + * + * NOTES: Use this file as + * /usr/sbin/dtrace -G -s man.ELFGeneration.d + * Delete the file man.ELFGeneration.d.o + * + */ + +BEGIN +{ + printf("This test should compile.\n"); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.IncludedFilePath.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.IncludedFilePath.d new file mode 100644 index 000000000000..f4e4e4e1c51f --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.IncludedFilePath.d @@ -0,0 +1,48 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Using the -CH option with dtrace invocation displays the list of + * pathnames of included files one per line to the stderr. + * + * SECTION: dtrace Utility/-C Option; + * dtrace Utility/-H Option + * + * NOTES: Use this file as + * /usr/sbin/dtrace -qCH -s man.IncludedFilePath.d + * + */ + +#include "stdio.h" + +BEGIN +{ + printf("This test should compile.\n"); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithFunctions b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithFunctions new file mode 100644 index 000000000000..e3db1270abbd --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithFunctions @@ -0,0 +1,99 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Using -l option with -f option. + * + * SECTION: dtrace Utility/-l Option; + * dtrace Utility/-f Option + * + * NOTES: Manually check: + * + * 1) + * /usr/sbin/dtrace -lf profile + * RESULT: Silent output without any probes listed. + * + * 2) + * /usr/sbin/dtrace -lf genunix + * RESULT: Silent output without any probes listed. + * + * 3) + * /usr/sbin/dtrace -lf read + * RESULT: matching list of probes with function read. + * + * 4) + * /usr/sbin/dtrace -lf genunix:read + * RESULT: matching list of probes with module genunix and + * function read. + * + * 5) + * /usr/sbin/dtrace -lf sysinfo:genunix:read + * RESULT: matching list of probes with provider sysinfo, module + * genunix and function read. + * + * 6) + * /usr/sbin/dtrace -lf :genunix:: + * RESULT: Silent output without any probes listed. + * + * 7) + * /usr/sbin/dtrace -lf ::read: + * RESULT: Silent output without any probes listed. + * + * 8) + * /usr/sbin/dtrace -lf profile:::profile-97 + * RESULT: not a valid probe description. + * + * 9) + * /usr/sbin/dtrace -lf read -lf write + * RESULT: matching list of both read and write probes. + * + * 10) + * /usr/sbin/dtrace -lf read -lm fight + * RESULT: List of only read probes. + * + * 11) + * /usr/sbin/dtrace -lf fight -lf write + * RESULT: List of only write probes. + * + * 12) Has been automated. + * /usr/sbin/dtrace -lf fbt:des:des3_crunch_block:return + * RESULT: not a valid probe description. + * + * 13) + * /usr/sbin/dtrace -lf read'{printf("FOUND");}' + * RESULT: Silent output without any probes listed. + * + * 14) + * /usr/sbin/dtrace -lf read '{printf("FOUND");}' + * RESULT: List of only read probes. + * + * 15) + * /usr/sbin/dtrace -lf read'/probename == "entry"/{printf("FOUND");}' + * RESULT: Silent output without any probes listed. + */ diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithIDs b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithIDs new file mode 100644 index 000000000000..2b46ce34091b --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithIDs @@ -0,0 +1,77 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Using -l option with -i option. + * + * SECTION: dtrace Utility/-l Option; + * dtrace Utility/-i Option + * + * NOTES: Manually check: + * + * 1) + * /usr/sbin/dtrace -l + * RESULT: List of all available probes. + * + * 2) + * /usr/sbin/dtrace -li 0 + * RESULT: invalid probe identifier 0. + * + * 3) automated in tst.InvalidId1.d.ksh + * /usr/sbin/dtrace -li -3 + * RESULT: not a valid id range + * + * 4) + * /usr/sbin/dtrace -li 0-2 + * RESULT: List of probes including 1 and 2 or error. + * + * 5) automated in tst.InvalidId2.d.ksh + * /usr/sbin/dtrace -li 4-2 + * RESULT: not a valid id range + * + * 6) automated in tst.InvalidId3.d.ksh + * /usr/sbin/dtrace -li 2-2 + * RESULT: not a valid id range + * + * 7) + * /usr/sbin/dtrace -li 1 2 3 4 + * RESULT: only the first probe id is listed and other extraneous + * charaters are not considered. + * + * 8) + * /usr/sbin/dtrace -li 0 - 2 + * RESULT: only the first probe id is listed and other extraneous + * charaters are not considered. + * + * 9) + * /usr/sbin/dtrace -li 1 -li 2-4 -li 4 -li 5 + * RESULT: Probe descriptions listed for all ids specified. Once + * for each specification on the command line. + * + */ diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithModules b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithModules new file mode 100644 index 000000000000..167c72a02160 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithModules @@ -0,0 +1,91 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Using -l option with -m option. + * + * SECTION: dtrace Utility/-l Option; + * dtrace Utility/-m Option + * + * NOTES: Manually check: + * + * 1) + * /usr/sbin/dtrace -lm profile + * RESULT: Silent output without any probes listed. + * + * 2) + * /usr/sbin/dtrace -lm genunix + * RESULT: matching list of probes with module name genunix. + * + * 3) + * /usr/sbin/dtrace -lm vtrace:genunix + * RESULT: matching list of probes with provider vtrace and module + * genunix. + * + * 4) automated in tst.InvalidModule1.d.ksh + * /usr/sbin/dtrace -lm :genunix:: + * RESULT: not a valid probe description + * + * 5) automated in tst.InvalidModule2.d.ksh + * /usr/sbin/dtrace -lm profile:::profile-97 + * RESULT: not a valid probe description. + * + * 6) + * /usr/sbin/dtrace -lm genunix -lm unix + * RESULT: matching list of both genunix and unix probes. + * + * 7) + * /usr/sbin/dtrace -lm genunix -lm foounix + * RESULT: List of only genunix probes. + * + * 8) + * /usr/sbin/dtrace -lm foounix -lm unix + * RESULT: List of only unix probes. + * + * 9) automated in tst.InvalidModule3.d.ksh + * /usr/sbin/dtrace -lm fbt:des:des3_crunch_block:return + * RESULT: not a valid probe description. + * + * 10) + * /usr/sbin/dtrace -lm fbt:genunix'{printf("FOUND");}' + * RESULT: Silent output without any probes listed. + * + * 11) + * /usr/sbin/dtrace -lm genunix'{printf("FOUND");}' + * RESULT: Silent output without any probes listed. + * + * 12) + * /usr/sbin/dtrace -lm unix '{printf("FOUND");}' + * RESULT: List of only unix probes. + * + * 13) automated in tst.InvalidModule4.d.ksh + * /usr/sbin/dtrace -lm + * unix'/probefunc == "preempt"/{printf("FOUND");}' + * RESULT: not a valid probe description. + */ diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithNames b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithNames new file mode 100644 index 000000000000..aabf1b2dfff6 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithNames @@ -0,0 +1,128 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Using -l option with -n option. + * + * SECTION: dtrace Utility/-l Option; + * dtrace Utility/-n Option + * + * NOTES: Manually check: + * + * 1) + * /usr/sbin/dtrace -ln profile + * RESULT: Silent output without any probes listed. + * + * 2) + * /usr/sbin/dtrace -ln genunix + * RESULT: Silent output without any probes listed. + * + * 3) + * /usr/sbin/dtrace -ln read + * RESULT: Silent output without any probes listed. + * + * 4) + * /usr/sbin/dtrace -ln BEGIN + * RESULT: list of one probe with name BEGIN. + * + * 5) + * /usr/sbin/dtrace -ln begin + * RESULT: Silent output without any probes listed. + * + * 6) + * /usr/sbin/dtrace -ln genunix:read + * RESULT: Silent output without any probes listed. + * + * 7) + * /usr/sbin/dtrace -ln genunix:read: + * RESULT: matching list of probes with module genunix and + * function read. + * + * 8) + * /usr/sbin/dtrace -ln sysinfo:genunix:read + * RESULT: Silent output without any probes listed. + * + * 9) + * /usr/sbin/dtrace -ln sysinfo:genunix:read: + * RESULT: matching list of probes with provider sysinfo, module + * genunix and function read. + * + * 10) /usr/sbin/dtrace -ln :genunix:: + * RESULT: matching list of probes with module genunix + * + * 11) + * /usr/sbin/dtrace -ln :genunix: + * RESULT: Silent output without any probes listed. + * + * 12) + * /usr/sbin/dtrace -ln ::read: + * RESULT: matching list of probes with and function read. + * + * 13) + * /usr/sbin/dtrace -ln profile:::profile-97 + * RESULT: matching list of probes with provider profile and function + * profile-97 + * + * 14) + * /usr/sbin/dtrace -ln read: -ln write: + * RESULT: matching list of both read and write probes. + * + * 15) + * /usr/sbin/dtrace -ln read: -ln fight: + * RESULT: List of only read probes. + * + * 16) + * /usr/sbin/dtrace -ln fight: -ln write: + * RESULT: List of only write probes. + * + * 17) + * /usr/sbin/dtrace -ln fbt:des:des3_crunch_block:return + * RESULT: Silent output of only the header. + * + * 18) + * /usr/sbin/dtrace -ln read:'{printf("FOUND");}' + * RESULT: Silent output without any probes listed. + * + * 19) + * /usr/sbin/dtrace -ln read:entry'{printf("FOUND");}' + * RESULT: Silent output without any probes listed. + * + * 20) + * /usr/sbin/dtrace -ln BEGIN'{Printf("FOUND");}' + * RESULT: Silent output without any probes listed. + * + * 21) + * /usr/sbin/dtrace -ln BEGIN '{printf("FOUND");}' + * RESULT: List of only BEGIN probe. + * + * 22) + * /usr/sbin/dtrace -ln + * BEGIN'/probename == "entry"/{printf("FOUND");}' + * RESULT: Silent output without any probes listed. + */ diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithProviders b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithProviders new file mode 100644 index 000000000000..961d409640d7 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.ListProbesWithProviders @@ -0,0 +1,82 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Using -l option with -P option. + * + * SECTION: dtrace Utility/-l Option; + * dtrace Utility/-P Option + * + * NOTES: Manually check: + * + * 1) + * /usr/sbin/dtrace -lP profile + * RESULT: List of only profile probes. + * + * 2) + * /usr/sbin/dtrace -lP foofile + * RESULT: Silent output without any probes listed. + * + * 3) automated in tst.InvalidProvider2.d.ksh + * /usr/sbin/dtrace -lP profile::: + * RESULT: not a valid probe description + * + * 4) automated in tst.InvalidProvider1.d.ksh + * /usr/sbin/dtrace -lP profile:::profile-97 + * RESULT: not a valid probe description. + * + * 5) + * /usr/sbin/dtrace -lP profile -lP syscall + * RESULT: matching list of both profile and syscall probes. + * + * 6) + * /usr/sbin/dtrace -lP profile -lP foofile + * RESULT: List of only profile probes. + * + * 7) + * /usr/sbin/dtrace -lP foofile -lP profile + * RESULT: List of only profile probes. + * + * 8) authomated in tst.InvalidProvider3.d.ksh + * /usr/sbin/dtrace -lP fbt:des:des3_crunch_block:return + * RESULT: not a valid probe description. + * + * 9) + * /usr/sbin/dtrace -lP profile'{printf("FOUND");}' + * RESULT: Silent output without any probes listed. + * + * 10) + * /usr/sbin/dtrace -lP profile '{printf("FOUND");}' + * RESULT: List of only profile probes. + * + * 11) automated in tst.InvalidProvider4.d.ksh + * /usr/sbin/dtrace -lP + * profile'/probename == "profile-199"/{printf("FOUND");}' + * RESULT: not a valid probe description. + */ diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.ShowCompilerCode.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.ShowCompilerCode.d new file mode 100644 index 000000000000..556811d2db7c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.ShowCompilerCode.d @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Using -S option with dtrace utility shows the intermediate compiler code. + * + * SECTION: dtrace Utility/-S Option + * + * NOTES: Use this file as + * /usr/sbin/dtrace -qSs man.ShowCompilerCode.d + * + */ + +BEGIN +{ + printf("This test should compile %d\n", 1); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceFunctions b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceFunctions new file mode 100644 index 000000000000..4c9c1c5696a3 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceFunctions @@ -0,0 +1,115 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Using -f option. + * + * SECTION: dtrace Utility/-f Option + * + * NOTES: Manually check: + * + * 1) automated in tst.InvalidTraceFunc1.d.ksh + * /usr/sbin/dtrace -f profile + * RESULT: invalid probe specifier + * + * 2) automated in tst.InvalidTraceFunc2.d.ksh + * /usr/sbin/dtrace -f genunix + * RESULT: invalid probe specifier + * + * 3) + * /usr/sbin/dtrace -f read + * RESULT: tracing of matching list of probes with function read. + * + * 4) automated in tst.InvalidTraceFunc3.d.ksh + * /usr/sbin/dtrace -f read: + * RESULT: invalid probe specifier + * + * 5) + * /usr/sbin/dtrace -f ::read + * RESULT: tracing of matching list of probes with function read. + * + * 6) automated in tst.InvalidTraceFunc4.d.ksh + * /usr/sbin/dtrace -f ::read: + * RESULT: invalid probe specifier + * + * 7) + * /usr/sbin/dtrace -f genunix:read + * RESULT: tracing of probes with module genunix and function read. + * + * 8) + * /usr/sbin/dtrace -f sysinfo:genunix:read + * RESULT: tracing of probes with provider sysinfo, module genunix + * and function read. + * + * 9) + * /usr/sbin/dtrace -f sysinfo::read + * RESULT: tracing of probes with provider sysinfo and function read. + * + * 10) automated in tst.InvalidTraceFunc5.d.ksh + * /usr/sbin/dtrace -f :genunix:: + * RESULT: invalid probe specifier + * + * 11) automated in tst.InvalidTraceFunc6.d.ksh + * /usr/sbin/dtrace -f profile:::profile-97 + * RESULT: invalid probe specifier. + * + * 12) + * /usr/sbin/dtrace -f read -f write + * RESULT: tracing of both read and write probes. + * + * 13) + * /usr/sbin/dtrace -f read -f fight + * RESULT: Count of matching read probes and invalid probe specifier + * for fight + * + * 14) automated in tst.InvalidTraceFunc8.d.ksh + * /usr/sbin/dtrace -f fight -f write + * RESULT: invalid probe specifier. + * + * 15) automated in tst.InvalidTraceFunc7.d.ksh + * /usr/sbin/dtrace -f fbt:des:des3_crunch_block:return + * RESULT: invalid probe specifier. + * + * 16) + * /usr/sbin/dtrace -f read'{printf("FOUND");}' + * RESULT: tracing of probes with function read and with message FOUND + * + * 17) + * /usr/sbin/dtrace -f ::read'{printf("FOUND");}' + * RESULT: tracing of probes with function read and with message FOUND + * + * 18) automated in tst.InvalidTraceFunc9.d.ksh + * /usr/sbin/dtrace -f read '{printf("FOUND");}' + * RESULT: invalid probe specifier. + * + * 19) + * /usr/sbin/dtrace -f read'/probename == "entry"/{printf("FOUND");}' + * RESULT: tracing of probes with function read, name entry and with + * message FOUND + */ diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceIDs b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceIDs new file mode 100644 index 000000000000..d9615b5aadb8 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceIDs @@ -0,0 +1,70 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Using -l option with -i option. + * + * SECTION: dtrace Utility/-l Option; + * dtrace Utility/-i Option + * + * NOTES: Manually check: + * + * 1) automated in tst.InvalidTraceID1.d.ksh + * /usr/sbin/dtrace -i 0 + * RESULT: invalid probe specifier. + * + * 2) automated in tst.InvalidTraceID2.d.ksh + * /usr/sbin/dtrace -i -3 + * RESULT: not a valid id range + * + * 3) automated in tst.InvalidTraceID3.d.ksh + * /usr/sbin/dtrace -i 0-2 + * RESULT: not a valid id range + * + * 4) automated in tst.InvalidTraceID4.d.ksh + * /usr/sbin/dtrace -i 4-2 + * RESULT: not a valid id range + * + * 5) automated in tst.InvalidTraceID5.d.ksh + * /usr/sbin/dtrace -i 2-2 + * RESULT: not a valid id range + * + * 6) automated in tst.InvalidTraceID6.d.ksh + * /usr/sbin/dtrace -i 1 2 3 4 + * RESULT: invalid probe specifier. + * + * 7) automated in tst.InvalidTraceID7.d.ksh + * /usr/sbin/dtrace -i 0 - 2 + * RESULT: invalid probe specifier. + * + * 8) + * /usr/sbin/dtrace -i 1 -i 2-4 -i 4 -i 5 + * RESULT: Only the BEGIN probe is traced and the others are not. + * + */ diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceModule b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceModule new file mode 100644 index 000000000000..9c4401ead040 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceModule @@ -0,0 +1,114 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Tracing a module using the -m option. + * + * SECTION: dtrace Utility/-m Option + * + * NOTES: Manually check: + * + * 1) automated in tst.InvalidTraceModule1.d.ksh + * /usr/sbin/dtrace -m profile + * RESULT: invalid probe specifier + * + * 2) + * /usr/sbin/dtrace -m genunix + * RESULT: trace of all probes with module genunix. + * + * 3) + * /usr/sbin/dtrace -m vtrace:genunix + * RESULT: trace of probes with provider vtrace and module genunix. + * + * 4) automated in tst.InvalidTraceModule2.d.ksh + * /usr/sbin/dtrace -m :genunix:: + * RESULT: invalid probe specifier + * + * 5) + * /usr/sbin/dtrace -m :genunix + * RESULT: trace of all probes with module genunix. + * + * 6) automated in tst.InvalidTraceModule3.d.ksh + * /usr/sbin/dtrace -m genunix:: + * RESULT: invalid probe specifier + * + * 7) automated in tst.InvalidTraceModule4.d.ksh + * /usr/sbin/dtrace -m profile:::profile-97 + * RESULT: not a valid probe description. + * + * 8) + * /usr/sbin/dtrace -m genunix -m unix + * RESULT: tracing of both genunix and unix probes. + * + * 9) + * /usr/sbin/dtrace -m genunix -m foounix + * RESULT: Number of probes matching the description genunix + * and an invalid probe specifier for foounix. + * + * 10) automated in tst.InvalidTraceModule5.d.ksh + * /usr/sbin/dtrace -m foounix -m unix + * RESULT: invalid probe specifier for foounix. + * + * 11) automated in tst.InvalidTraceModule6.d.ksh + * /usr/sbin/dtrace -m fbt:des:des3_crunch_block:return + * RESULT: invalid probe description. + * + * 12) + * /usr/sbin/dtrace -m fbt:genunix'{printf("FOUND");}' + * RESULT: tracing of all the probes matching provider fbt and module + * genunix. + * + * 13) + * /usr/sbin/dtrace -m genunix'{printf("FOUND");}' + * RESULT: tracing of all the probes matching module genunix with + * message FOUND + * + * 14) + * /usr/sbin/dtrace -m :genunix'{printf("FOUND");}' + * RESULT: tracing of all the probes matching module genunix with + * message FOUND + * + * 15) automated in tst.InvalidTraceModule7.d.ksh + * /usr/sbin/dtrace -m genunix::'{printf("FOUND");}' + * RESULT: invalid probe specifier. + * + * 16) automated in tst.InvalidTraceModule8.d.ksh + * /usr/sbin/dtrace -m genunix:'{printf("FOUND");}' + * RESULT: invalid probe specifier. + * + * 17) + * /usr/sbin/dtrace -m unix '{printf("FOUND");}' + * RESULT: invalid probe specifier. + * + * 18) + * /usr/sbin/dtrace -m + * unix'/probefunc == "preempt"/{printf("FOUND");}' + * RESULT: tracing of all the probes matching module genunix, + * probe function preempt with message FOUND. + */ diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceNames b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceNames new file mode 100644 index 000000000000..c3e75554e025 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceNames @@ -0,0 +1,129 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Using -n option. + * + * SECTION: dtrace Utility/-n Option + * + * NOTES: Manually check: + * + * 1) automated in tst.InvalidTraceName1.d.ksh + * /usr/sbin/dtrace -n profile + * RESULT: invalid probe specifier + * + * 2) automated in tst.InvalidTraceName2.d.ksh + * /usr/sbin/dtrace -n genunix + * RESULT: invalid probe specifier + * + * 3) automated in tst.InvalidTraceName3.d.ksh + * /usr/sbin/dtrace -n read + * RESULT: invalid probe specifier + * + * 4) + * /usr/sbin/dtrace -n BEGIN + * RESULT: trace of one probe with name BEGIN. + * + * 5) automated in tst.InvalidTraceName4.d.ksh + * /usr/sbin/dtrace -n begin + * RESULT: invalid probe specifier + * + * 6) automated in tst.InvalidTraceName5.d.ksh + * /usr/sbin/dtrace -n genunix:read + * RESULT: invalid probe specifier + * + * 7) + * /usr/sbin/dtrace -n genunix:read: + * RESULT: trace of probes with module genunix and function read. + * + * 8) automated in tst.InvalidTraceName6.d.ksh + * /usr/sbin/dtrace -n sysinfo:genunix:read + * RESULT: invalid probe specifier + * + * 9) + * /usr/sbin/dtrace -n sysinfo:genunix:read: + * RESULT: tracing of probes with provider sysinfo, module genunix + * and function read. + * + * 10) + * /usr/sbin/dtrace -n :genunix:: + * RESULT: tracing of probes with module genunix + * + * 11) automated in tst.InvalidTraceName7.d.ksh + * /usr/sbin/dtrace -n :genunix: + * RESULT: invalid probe specifier + * + * 12) + * /usr/sbin/dtrace -n ::read: + * RESULT: tracing of probes with function read. + * + * 13) + * /usr/sbin/dtrace -n profile:::profile-97 + * RESULT: tracing of probes with provider profile and name + * profile-97 + * + * 14) + * /usr/sbin/dtrace -n read: -n write: + * RESULT: tracing of both read and write probes. + * + * 15) + * /usr/sbin/dtrace -n read: -n fight: + * RESULT: Count of mathching read probes and invalid probe specifier + * for fight: + * + * 16) automated in tst.InvalidTraceName8.d.ksh + * /usr/sbin/dtrace -n fight: -n write: + * RESULT: invalid probe specifier + * + * 17) + * /usr/sbin/dtrace -n fbt:des:des3_crunch_block:return + * RESULT: trace of the specified probe. + * + * 18) + * /usr/sbin/dtrace -n read:'{printf("FOUND");}' + * RESULT: Trace of all the probes with module read and a message + * saying FOUND. + * + * 19) + * /usr/sbin/dtrace -n read:entry'{printf("FOUND");}' + * RESULT: Trace of all the probes with module read, name entry.Output + * of a message saying FOUND. + * + * 20) + * /usr/sbin/dtrace -n BEGIN'{printf("FOUND");}' + * RESULT: Trace of the BEGIN probe with the message FOUND. + * + * 21) automated in tst.InvalidTraceName9.d.ksh + * /usr/sbin/dtrace -n BEGIN '{printf("FOUND");}' + * RESULT: invalid probe specifier + * + * 22) + * /usr/sbin/dtrace -n BEGIN'/probename == "entry"/{printf("FOUND");}' + * RESULT: Tracing of BEGIN function but no message FOUND. + */ diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceProvider b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceProvider new file mode 100644 index 000000000000..f52f395c41fe --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.TraceProvider @@ -0,0 +1,83 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Using -P option to trace all the probes provided by the particular + * provider. + * + * SECTION: dtrace Utility/-P Option + * + * NOTES: Manually check: + * + * 1) + * /usr/sbin/dtrace -P profile + * RESULT: Trace of all profile probes. + * + * 2) automated in tst.InvalidTraceProvider1.d.ksh + * /usr/sbin/dtrace -P foofile + * RESULT: invalid probe specifier + * + * 3) automated in tst.InvalidTraceProvider2.d.ksh + * /usr/sbin/dtrace -P profile::: + * RESULT: invalid probe specifier + * + * 4) automated in tst.InvalidTraceProvider3.d.ksh + * /usr/sbin/dtrace -P profile:::profile-97 + * RESULT: invalid probe specifier + * + * 5) + * /usr/sbin/dtrace -P profile -P syscall + * RESULT: matching traces of both profile and syscall probes. + * + * 6) + * /usr/sbin/dtrace -P profile -P foofile + * RESULT: Count of profile probes that matched and invalid + * probe specifier for foofile and no tracing. + * + * 7) automated in tst.InvalidTraceProvider4.d.ksh + * /usr/sbin/dtrace -P fbt:des:des3_crunch_block:return + * RESULT: invalid probe specifier + * + * 8) + * /usr/sbin/dtrace -P profile'{printf("FOUND");}' + * RESULT: Traces of all the matching profile probes with the + * FOUND message. + * + * 9) automated in tst.InvalidTraceProvider5.d.ksh + * /usr/sbin/dtrace -P profile '{printf("FOUND");}' + * RESULT: invalid probe specifier + * + * 10) + * /usr/sbin/dtrace -P + * profile'/probename == "profile-199"/{printf("FOUND");}' + * RESULT: Traces of the matching profile probe with the + * FOUND message. + * + * + */ diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.VerboseStabilityReport.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.VerboseStabilityReport.d new file mode 100644 index 000000000000..23742284cb98 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.VerboseStabilityReport.d @@ -0,0 +1,47 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Using -v option with dtrace utility produces a program stability report + * showing the minimum interface stability and dependency level for + * the specified D programs. + * + * SECTION: dtrace Utility/-s Option; + * dtrace Utility/-v Option + * + * NOTES: Use this file as + * /usr/sbin/dtrace -vs man.VerboseStabilityReport.d + * + */ + +BEGIN +{ + printf("This test should compile: %d\n", 2); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.AddSearchPath.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.AddSearchPath.d.ksh new file mode 100644 index 000000000000..2f49f733e3ef --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.AddSearchPath.d.ksh @@ -0,0 +1,82 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -I option can be used to search path for #include files when used +# in conjunction with the -C option. The specified directory is inserted into +# the search path adhead of the default directory list. +# +# SECTION: dtrace Utility/-C Option +# SECTION: dtrace Utility/-I Option +# +## + +script() +{ + $dtrace -C -I /tmp -s /dev/stdin <' + exit 2 +fi + +tempfile=/tmp/test.h +echo "#define VALUE 1520" > $tempfile + +dtrace=$1 +script +status=$? + +if [ "$status" -ne 0 ]; then + echo $tst: dtrace failed + exit $status +fi + +/usr/bin/rm -f $tempfile +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeGiga.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeGiga.d.ksh new file mode 100644 index 000000000000..2f0c56739426 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeGiga.d.ksh @@ -0,0 +1,45 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# ident "%Z%%M% %I% %E% SMI" + +# +# ASSERTION: +# The trace buffer size can include any of the size suffixes k, m, g or t +# +# SECTION: dtrace Utility/-b Option +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -b 1g -b 2g -e + +exit $? diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeKilo.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeKilo.d.ksh new file mode 100644 index 000000000000..d969b481d33f --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeKilo.d.ksh @@ -0,0 +1,45 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# ident "%Z%%M% %I% %E% SMI" + +# +# ASSERTION: +# The trace buffer size can include any of the size suffixes k, m, g or t +# +# SECTION: dtrace Utility/-b Option +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -b 1k -b 2k -e + +exit $? diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeMega.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeMega.d.ksh new file mode 100644 index 000000000000..a08327a30a51 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeMega.d.ksh @@ -0,0 +1,45 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# ident "%Z%%M% %I% %E% SMI" + +# +# ASSERTION: +# The trace buffer size can include any of the size suffixes k, m, g or t +# +# SECTION: dtrace Utility/-b Option +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -b 1m -b 2m -e + +exit $? diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeTera.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeTera.d.ksh new file mode 100644 index 000000000000..00f2c6622f3d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.BufsizeTera.d.ksh @@ -0,0 +1,45 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# ident "%Z%%M% %I% %E% SMI" + +# +# ASSERTION: +# The trace buffer size can include any of the size suffixes k, m, g or t +# +# SECTION: dtrace Utility/-b Option +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -b 1t -b 2t -e + +exit $? diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DataModel32.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DataModel32.d.ksh new file mode 100644 index 000000000000..e4ef38db431e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DataModel32.d.ksh @@ -0,0 +1,73 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# If the -32 option is specified, dtrace will force the D compiler to +# compile a program using the 32-bit data model. +# +# SECTION: dtrace Utility/-32 Option +# +## + +script() +{ + $dtrace -32 -s /dev/stdin <' + exit 2 +fi + +dtrace=$1 + +script +status=$? + +if [ "$status" -ne 0 ]; then + echo $tst: dtrace failed +fi + +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DataModel64.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DataModel64.d.ksh new file mode 100644 index 000000000000..8a9de0c87c73 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DataModel64.d.ksh @@ -0,0 +1,74 @@ +#!/bin/ksh + +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# If the -64 option is specified, dtrace will force the D compiler to +# compile a program using the 64-bit data model. +# +# SECTION: dtrace Utility/-64 Option +# +## + +script() +{ + $dtrace -64 -s /dev/stdin <' + exit 2 +fi + +dtrace=$1 + +script +status=$? + +if [ "$status" -ne 0 ]; then + echo $tst: dtrace failed +fi + +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DefineNameWithCPP.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DefineNameWithCPP.d.ksh new file mode 100644 index 000000000000..9be2b291d43f --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DefineNameWithCPP.d.ksh @@ -0,0 +1,68 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -D option can be used to define a name when used in conjunction +# with the -C option. +# +# SECTION: dtrace Utility/-C Option; +# dtrace Utility/-D Option +# +## + +script() +{ + $dtrace -C -D VALUE=40 -s /dev/stdin <' + exit 2 +fi + +dtrace=$1 + +script +status=$? + +if [ "$status" -ne 0 ]; then + echo $tst: dtrace failed +fi + +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DefineNameWithCPP.d.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DefineNameWithCPP.d.ksh.out new file mode 100644 index 000000000000..5f91ad16d56b --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DefineNameWithCPP.d.ksh.out @@ -0,0 +1,2 @@ +Value of VALUE: 40 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithFunction.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithFunction.d.ksh new file mode 100644 index 000000000000..0259db367e94 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithFunction.d.ksh @@ -0,0 +1,56 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -w option can be used to permit destructive actions in D programs. +# +# SECTION: dtrace Utility/-w Option; +# dtrace Utility/-f Option +# +## + + + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -qwf read'{chill(15); printf("Done chilling"); exit(0);}' +status=$? + +if [ "$status" -ne 0 ]; then + echo $tst: dtrace failed +fi + +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithFunction.d.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithFunction.d.ksh.out new file mode 100644 index 000000000000..8975980fdc0b --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithFunction.d.ksh.out @@ -0,0 +1 @@ +Done chilling diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithID.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithID.d.ksh new file mode 100644 index 000000000000..6d3913f852a9 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithID.d.ksh @@ -0,0 +1,54 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -w option can be used to permit destructive actions in D programs. +# +# SECTION: dtrace Utility/-w Option; +# dtrace Utility/-i Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -qwi 1'{chill(15); printf("Done chilling"); exit(0);}' +status=$? + +if [ "$status" -ne 0 ]; then + echo $tst: dtrace failed +fi + +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithID.d.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithID.d.ksh.out new file mode 100644 index 000000000000..8975980fdc0b --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithID.d.ksh.out @@ -0,0 +1 @@ +Done chilling diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithModule.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithModule.d.ksh new file mode 100644 index 000000000000..923be51c6992 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithModule.d.ksh @@ -0,0 +1,54 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -w option can be used to permit destructive actions in D programs. +# +# SECTION: dtrace Utility/-w Option; +# dtrace Utility/-m Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -qwm unix'{chill(15); printf("Done chilling"); exit(0);}' +status=$? + +if [ "$status" -ne 0 ]; then + echo $tst: dtrace failed +fi + +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithModule.d.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithModule.d.ksh.out new file mode 100644 index 000000000000..8975980fdc0b --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithModule.d.ksh.out @@ -0,0 +1 @@ +Done chilling diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithName.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithName.d.ksh new file mode 100644 index 000000000000..b21903fb5734 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithName.d.ksh @@ -0,0 +1,54 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -w option can be used to permit destructive actions in D programs. +# +# SECTION: dtrace Utility/-w Option; +# dtrace Utility/-n Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -qwn BEGIN'{chill(15); printf("Done chilling"); exit(0);}' +status=$? + +if [ "$status" -ne 0 ]; then + echo $tst: dtrace failed +fi + +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithName.d.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithName.d.ksh.out new file mode 100644 index 000000000000..8975980fdc0b --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithName.d.ksh.out @@ -0,0 +1 @@ +Done chilling diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithProvider.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithProvider.d.ksh new file mode 100644 index 000000000000..09dafecb9c90 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithProvider.d.ksh @@ -0,0 +1,54 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -w option can be used to permit destructive actions in D programs. +# +# SECTION: dtrace Utility/-w Option; +# dtrace Utility/-P Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -qwP syscall'{chill(15); printf("Done chilling"); exit(0);}' +status=$? + +if [ "$status" -ne 0 ]; then + echo $tst: dtrace failed +fi + +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithProvider.d.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithProvider.d.ksh.out new file mode 100644 index 000000000000..8975980fdc0b --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithProvider.d.ksh.out @@ -0,0 +1 @@ +Done chilling diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithoutW.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithoutW.d.ksh new file mode 100644 index 000000000000..9f051b4cbd41 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.DestructWithoutW.d.ksh @@ -0,0 +1,55 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# Destructive actions will not compile or are not enabled without the +# -w option in D programs. +# +# SECTION: dtrace Utility/-w Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -qP syscall'{chill(15); printf("Done chilling"); exit(0);}' +status=$? + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ELFGenerationOut.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ELFGenerationOut.d.ksh new file mode 100644 index 000000000000..b68fc1387497 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ELFGenerationOut.d.ksh @@ -0,0 +1,73 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# Using -G option with dtrace utility produces an ELF file containing a +# DTrace program. If the filename used with the -s option does not end +# with .d, and the -o option is not used, then the output ELF file is +# in d.out. +# +# SECTION: dtrace Utility/-G Option +# +## + +script() +{ + $dtrace -G -s /dev/stdin <' + exit 2 +fi + +dtrace=$1 +script +status=$? + +if [ "$status" -ne 0 ]; then + echo $tst: dtrace failed + exit $status +fi + +if [ ! -a "d.out" ]; then + echo $tst: file not generated + exit 1 +fi + +/usr/bin/rm -f "d.out" +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ELFGenerationWithO.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ELFGenerationWithO.d.ksh new file mode 100644 index 000000000000..ec38b50285fa --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ELFGenerationWithO.d.ksh @@ -0,0 +1,74 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# Using -G option with dtrace utility produces an ELF file containing a +# DTrace program. The output file can be named as required using the +# -o option in conjunction with the -G option. +# +# SECTION: dtrace Utility/-G Option; +# dtrace Utility/-o Option +# +## + +script() +{ + $dtrace -G -o outputFile -s /dev/stdin <' + exit 2 +fi + +dtrace=$1 + +script +status=$? + +if [ "$status" -ne 0 ]; then + echo $tst: dtrace failed + exit $status +fi + +if [ ! -a "outputFile" ]; then + echo $tst: file not generated + exit 1 +fi + +/usr/bin/rm -f "outputFile" +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ExitStatus1.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ExitStatus1.d.ksh new file mode 100644 index 000000000000..70a9f498fc5e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ExitStatus1.d.ksh @@ -0,0 +1,56 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# When a fatal error occurs such that the program compilation fails or the +# specified request cannot be satisfied, an exit status of 1 is returned. +# +# +# SECTION: dtrace Utility/Exit Status +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -s wassup +status=$? + +if [ "$status" -ne 1 ]; then + echo $tst: dtrace failed + exit 1 +fi + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ExitStatus2.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ExitStatus2.d.ksh new file mode 100644 index 000000000000..a058d3a35b52 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ExitStatus2.d.ksh @@ -0,0 +1,55 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# When invalid command line options or arguments are specified an exit status +# of 2 is returned. +# +# SECTION: dtrace Utility/Exit Status +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -9 +status=$? + +if [ "$status" -ne 2 ]; then + echo $tst: dtrace failed + exit 1 +fi + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ExtraneousProbeIds.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ExtraneousProbeIds.d.ksh new file mode 100644 index 000000000000..090fc4a069a4 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ExtraneousProbeIds.d.ksh @@ -0,0 +1,53 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# Testing -i option with extraneous probe identifiers. +# +# SECTION: dtrace Utility/-i Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -i 12 10 -i 23 + +if [ $? -ne 1 ]; then + echo $tst: dtrace failed + exit 1 +fi + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidFuncName1.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidFuncName1.d.ksh new file mode 100644 index 000000000000..c28c782374b2 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidFuncName1.d.ksh @@ -0,0 +1,53 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# Testing -f option with an invalid function name. +# +# SECTION: dtrace Utility/-f Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -f BEGIN + +if [ $? -ne 1 ]; then + echo $tst: dtrace failed + exit 1 +fi + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidFuncName2.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidFuncName2.d.ksh new file mode 100644 index 000000000000..d431579db6c5 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidFuncName2.d.ksh @@ -0,0 +1,53 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# Testing -f option with an invalid function name. +# +# SECTION: dtrace Utility/-f Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -f 4.56 + +if [ $? -ne 1 ]; then + echo $tst: dtrace failed + exit 1 +fi + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidId1.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidId1.d.ksh new file mode 100644 index 000000000000..814b88dd8188 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidId1.d.ksh @@ -0,0 +1,59 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -li option can be used to list the probes from their ids. An id of +# negative integer is invalid +# +# SECTION: dtrace Utility/-l Option; +# dtrace Utility/-i Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -li -3 + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidId2.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidId2.d.ksh new file mode 100644 index 000000000000..f9f440786669 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidId2.d.ksh @@ -0,0 +1,59 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -li option can be used to list the probes from their ids. A +# non-increasing range will not list any probes. +# +# SECTION: dtrace Utility/-l Option; +# dtrace Utility/-i Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -li 4-2 + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidId3.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidId3.d.ksh new file mode 100644 index 000000000000..efb03ae2f5d5 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidId3.d.ksh @@ -0,0 +1,59 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -li option can be used to list the probes from their ids. A +# non-increasing range will not list any probes. +# +# SECTION: dtrace Utility/-l Option; +# dtrace Utility/-i Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -li 2-2 + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule1.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule1.d.ksh new file mode 100644 index 000000000000..a896ff3d1539 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule1.d.ksh @@ -0,0 +1,59 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -lm option can be used to list the probes from their module names. +# Invalid module names result in error. +# +# SECTION: dtrace Utility/-l Option; +# dtrace Utility/-m Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -lm :genunix:: + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule2.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule2.d.ksh new file mode 100644 index 000000000000..820cc64dfbef --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule2.d.ksh @@ -0,0 +1,59 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -lm option can be used to list the probes from their module names. +# Invalid module names result in error. +# +# SECTION: dtrace Utility/-l Option; +# dtrace Utility/-m Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -lm profile:::profile-97 + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule3.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule3.d.ksh new file mode 100644 index 000000000000..b56e6c376fd3 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule3.d.ksh @@ -0,0 +1,59 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -lm option can be used to list the probes from their module names. +# Invalid module names result in error. +# +# SECTION: dtrace Utility/-l Option; +# dtrace Utility/-m Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -lm fbt:des:des3_crunch_block:return + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule4.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule4.d.ksh new file mode 100644 index 000000000000..0ef9d9563fdb --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidModule4.d.ksh @@ -0,0 +1,59 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -lm option can be used to list the probes from their module names. +# Invalid module names result in error. +# +# SECTION: dtrace Utility/-l Option; +# dtrace Utility/-m Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -lm unix'/probefunc == "preempt"/{printf("FOUND");}' + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProbeIdentifier.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProbeIdentifier.d.ksh new file mode 100644 index 000000000000..66e0e1a514ea --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProbeIdentifier.d.ksh @@ -0,0 +1,53 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# Testing -i option with invalid probe identifier. +# +# SECTION: dtrace Utility/-i Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -i i23 + +if [ $? -ne 1 ]; then + echo $tst: dtrace failed + exit 1 +fi + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider1.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider1.d.ksh new file mode 100644 index 000000000000..327e2d01bc04 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider1.d.ksh @@ -0,0 +1,59 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -lP option can be used to list the probes from their provider names. +# Invalid module names result in error. +# +# SECTION: dtrace Utility/-l Option; +# dtrace Utility/-P Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -lP profile:::profile-97 + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider2.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider2.d.ksh new file mode 100644 index 000000000000..22624495c699 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider2.d.ksh @@ -0,0 +1,59 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -lP option can be used to list the probes from their provider names. +# Invalid module names result in error. +# +# SECTION: dtrace Utility/-l Option; +# dtrace Utility/-P Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -lP profile::: + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider3.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider3.d.ksh new file mode 100644 index 000000000000..775b327c469d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider3.d.ksh @@ -0,0 +1,59 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -lP option can be used to list the probes from their provider names. +# Invalid module names result in error. +# +# SECTION: dtrace Utility/-l Option; +# dtrace Utility/-P Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -lP fbt:des:des3_crunch_block:return + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider4.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider4.d.ksh new file mode 100644 index 000000000000..04343f3e5425 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidProvider4.d.ksh @@ -0,0 +1,59 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -lP option can be used to list the probes from their provider names. +# Invalid module names result in error. +# +# SECTION: dtrace Utility/-l Option; +# dtrace Utility/-P Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -lP profile'/probename == "profile-199"/{printf("FOUND");}' + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc1.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc1.d.ksh new file mode 100644 index 000000000000..1395f3be807f --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc1.d.ksh @@ -0,0 +1,53 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# Testing -f option with an invalid function name. +# +# SECTION: dtrace Utility/-f Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -f profile + +if [ $? -ne 1 ]; then + echo $tst: dtrace failed + exit 1 +fi + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc2.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc2.d.ksh new file mode 100644 index 000000000000..4231e5c7057f --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc2.d.ksh @@ -0,0 +1,53 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# Testing -f option with an invalid function name. +# +# SECTION: dtrace Utility/-f Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -f genunix + +if [ $? -ne 1 ]; then + echo $tst: dtrace failed + exit 1 +fi + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc3.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc3.d.ksh new file mode 100644 index 000000000000..3c5b17831eb0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc3.d.ksh @@ -0,0 +1,53 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# Testing -f option with an invalid function name. +# +# SECTION: dtrace Utility/-f Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -f read: + +if [ $? -ne 1 ]; then + echo $tst: dtrace failed + exit 1 +fi + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc4.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc4.d.ksh new file mode 100644 index 000000000000..bb8460d06181 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc4.d.ksh @@ -0,0 +1,53 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# Testing -f option with an invalid function name. +# +# SECTION: dtrace Utility/-f Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -f ::read: + +if [ $? -ne 1 ]; then + echo $tst: dtrace failed + exit 1 +fi + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc5.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc5.d.ksh new file mode 100644 index 000000000000..544667618726 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc5.d.ksh @@ -0,0 +1,53 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# Testing -f option with an invalid function name. +# +# SECTION: dtrace Utility/-f Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -f :genunix:: + +if [ $? -ne 1 ]; then + echo $tst: dtrace failed + exit 1 +fi + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc6.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc6.d.ksh new file mode 100644 index 000000000000..645e6d9f3f05 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc6.d.ksh @@ -0,0 +1,53 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# Testing -f option with an invalid function name. +# +# SECTION: dtrace Utility/-f Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -f profile:::profile-97 + +if [ $? -ne 1 ]; then + echo $tst: dtrace failed + exit 1 +fi + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc7.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc7.d.ksh new file mode 100644 index 000000000000..a93d5c4b0772 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc7.d.ksh @@ -0,0 +1,53 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# Testing -f option with an invalid function name. +# +# SECTION: dtrace Utility/-f Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -f fbt:des:des3_crunch_block:return + +if [ $? -ne 1 ]; then + echo $tst: dtrace failed + exit 1 +fi + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc8.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc8.d.ksh new file mode 100644 index 000000000000..22ab3b16bc46 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc8.d.ksh @@ -0,0 +1,53 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# Testing -f option with an invalid function name. +# +# SECTION: dtrace Utility/-f Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -f fight -f write + +if [ $? -ne 1 ]; then + echo $tst: dtrace failed + exit 1 +fi + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc9.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc9.d.ksh new file mode 100644 index 000000000000..2af27a325aa4 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceFunc9.d.ksh @@ -0,0 +1,53 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# Testing -f option with an invalid function name. +# +# SECTION: dtrace Utility/-f Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -f read '{printf("FOUND");}' + +if [ $? -ne 1 ]; then + echo $tst: dtrace failed + exit 1 +fi + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID1.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID1.d.ksh new file mode 100644 index 000000000000..46096d216b6b --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID1.d.ksh @@ -0,0 +1,58 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -i option can be used to enable the trace of probes from their ids. A +# non-increasing range will not list any probes. +# +# SECTION: dtrace Utility/-i Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -i 0 + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID2.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID2.d.ksh new file mode 100644 index 000000000000..f406ce005948 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID2.d.ksh @@ -0,0 +1,58 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -i option can be used to enable the trace of probes from their ids. A +# non-increasing range will not list any probes. +# +# SECTION: dtrace Utility/-i Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -i -3 + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID3.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID3.d.ksh new file mode 100644 index 000000000000..fc2a24d57051 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID3.d.ksh @@ -0,0 +1,58 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -i option can be used to enable the trace of probes from their ids. A +# non-increasing range will not list any probes. +# +# SECTION: dtrace Utility/-i Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -i 0-2 + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID4.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID4.d.ksh new file mode 100644 index 000000000000..5fd6fd6c52b4 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID4.d.ksh @@ -0,0 +1,58 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -i option can be used to enable the trace of probes from their ids. A +# non-increasing range will not list any probes. +# +# SECTION: dtrace Utility/-i Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -i 4-2 + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID5.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID5.d.ksh new file mode 100644 index 000000000000..0ac46dbbad01 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID5.d.ksh @@ -0,0 +1,58 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -i option can be used to enable the trace of probes from their ids. A +# non-increasing range will not list any probes. +# +# SECTION: dtrace Utility/-i Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -i 2-2 + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID6.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID6.d.ksh new file mode 100644 index 000000000000..778d485ad21d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID6.d.ksh @@ -0,0 +1,58 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -i option can be used to enable the trace of probes from their ids. A +# non-increasing range will not list any probes. +# +# SECTION: dtrace Utility/-i Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -i 1 2 3 4 + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID7.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID7.d.ksh new file mode 100644 index 000000000000..8a0f2d4e5394 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceID7.d.ksh @@ -0,0 +1,58 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -i option can be used to enable the trace of probes from their ids. A +# non-increasing range will not list any probes. +# +# SECTION: dtrace Utility/-i Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -i 0 - 2 + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule1.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule1.d.ksh new file mode 100644 index 000000000000..56dee0dd30af --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule1.d.ksh @@ -0,0 +1,58 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -m option can be used to enable the probes from their module names. +# Invalid module names result in error. +# +# SECTION: dtrace Utility/-m Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -m profile + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule2.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule2.d.ksh new file mode 100644 index 000000000000..a508fe1030e2 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule2.d.ksh @@ -0,0 +1,58 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -m option can be used to enable the probes from their module names. +# Invalid module names result in error. +# +# SECTION: dtrace Utility/-m Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -m :genunix:: + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule3.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule3.d.ksh new file mode 100644 index 000000000000..599ce93e1d6d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule3.d.ksh @@ -0,0 +1,58 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -m option can be used to enable the probes from their module names. +# Invalid module names result in error. +# +# SECTION: dtrace Utility/-m Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -m genunix:: + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule4.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule4.d.ksh new file mode 100644 index 000000000000..e0e87861f732 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule4.d.ksh @@ -0,0 +1,58 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -m option can be used to enable the probes from their module names. +# Invalid module names result in error. +# +# SECTION: dtrace Utility/-m Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -m profile:::profile-97 + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule5.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule5.d.ksh new file mode 100644 index 000000000000..858306021cc9 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule5.d.ksh @@ -0,0 +1,58 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -m option can be used to enable the probes from their module names. +# Invalid module names result in error. +# +# SECTION: dtrace Utility/-m Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -m foounix -m unix + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule6.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule6.d.ksh new file mode 100644 index 000000000000..6125fb0f309f --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule6.d.ksh @@ -0,0 +1,58 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -m option can be used to enable the probes from their module names. +# Invalid module names result in error. +# +# SECTION: dtrace Utility/-m Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -m fbt:des:des3_crunch_block:return + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule7.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule7.d.ksh new file mode 100644 index 000000000000..e689627b8c81 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule7.d.ksh @@ -0,0 +1,58 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -m option can be used to enable the probes from their module names. +# Invalid module names result in error. +# +# SECTION: dtrace Utility/-m Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -m genunix::'{printf("FOUND");}' + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule8.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule8.d.ksh new file mode 100644 index 000000000000..692821b56159 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceModule8.d.ksh @@ -0,0 +1,58 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -m option can be used to enable the probes from their module names. +# Invalid module names result in error. +# +# SECTION: dtrace Utility/-m Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -m genunix:'{printf("FOUND");}' + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName1.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName1.d.ksh new file mode 100644 index 000000000000..43c61af3e359 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName1.d.ksh @@ -0,0 +1,57 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -n option can be used to enable the trace of probes from their names. +# +# SECTION: dtrace Utility/-n Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -n profile + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName2.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName2.d.ksh new file mode 100644 index 000000000000..70a52188021c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName2.d.ksh @@ -0,0 +1,57 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -n option can be used to enable the trace of probes from their names. +# +# SECTION: dtrace Utility/-n Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -n genunix + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName3.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName3.d.ksh new file mode 100644 index 000000000000..efb5ad088cf1 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName3.d.ksh @@ -0,0 +1,57 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -n option can be used to enable the trace of probes from their names. +# +# SECTION: dtrace Utility/-n Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -n not_a_valid_probe + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName4.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName4.d.ksh new file mode 100644 index 000000000000..04845b997117 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName4.d.ksh @@ -0,0 +1,57 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -n option can be used to enable the trace of probes from their names. +# +# SECTION: dtrace Utility/-n Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -n begin + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName5.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName5.d.ksh new file mode 100644 index 000000000000..df17231fc2de --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName5.d.ksh @@ -0,0 +1,57 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -n option can be used to enable the trace of probes from their names. +# +# SECTION: dtrace Utility/-n Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -n genunix:read + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName6.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName6.d.ksh new file mode 100644 index 000000000000..10f13cb3188b --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName6.d.ksh @@ -0,0 +1,57 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -n option can be used to enable the trace of probes from their names. +# +# SECTION: dtrace Utility/-n Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -n sysinfo:genunix:read + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName7.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName7.d.ksh new file mode 100644 index 000000000000..b22561fa0e19 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName7.d.ksh @@ -0,0 +1,57 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -n option can be used to enable the trace of probes from their names. +# +# SECTION: dtrace Utility/-n Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -n :genunix: + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName8.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName8.d.ksh new file mode 100644 index 000000000000..f66055e242fe --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName8.d.ksh @@ -0,0 +1,57 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -n option can be used to enable the trace of probes from their names. +# +# SECTION: dtrace Utility/-n Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -n fight: -n write: + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName9.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName9.d.ksh new file mode 100644 index 000000000000..a4239ff90375 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceName9.d.ksh @@ -0,0 +1,57 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -n option can be used to enable the trace of probes from their names. +# +# SECTION: dtrace Utility/-n Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -n BEGIN '{printf("FOUND");}' + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider1.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider1.d.ksh new file mode 100644 index 000000000000..0a792c595b15 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider1.d.ksh @@ -0,0 +1,58 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -P option can be used to list the probes from their provider names. +# Invalid module names result in error. +# +# SECTION: dtrace Utility/-P Option; +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -P foofile + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider2.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider2.d.ksh new file mode 100644 index 000000000000..1763142b7a8b --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider2.d.ksh @@ -0,0 +1,58 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -P option can be used to list the probes from their provider names. +# Invalid module names result in error. +# +# SECTION: dtrace Utility/-P Option; +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -P profile::: + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider3.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider3.d.ksh new file mode 100644 index 000000000000..a8549329cdca --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider3.d.ksh @@ -0,0 +1,58 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -P option can be used to list the probes from their provider names. +# Invalid module names result in error. +# +# SECTION: dtrace Utility/-P Option; +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -P profile:::profile-97 + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider4.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider4.d.ksh new file mode 100644 index 000000000000..f8a1359c5458 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider4.d.ksh @@ -0,0 +1,58 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -P option can be used to list the probes from their provider names. +# Invalid module names result in error. +# +# SECTION: dtrace Utility/-P Option; +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -P fbt:des:des3_crunch_block:return + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider5.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider5.d.ksh new file mode 100644 index 000000000000..cec4297c0328 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.InvalidTraceProvider5.d.ksh @@ -0,0 +1,58 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -P option can be used to list the probes from their provider names. +# Invalid module names result in error. +# +# SECTION: dtrace Utility/-P Option; +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -P profile '{printf("FOUND");}' + +status=$? + +echo $status + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.MultipleInvalidProbeId.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.MultipleInvalidProbeId.d.ksh new file mode 100644 index 000000000000..8f2ceefd9211 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.MultipleInvalidProbeId.d.ksh @@ -0,0 +1,53 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# Testing -i option with multiple valid and invalid probe identifiers. +# +# SECTION: dtrace Utility/-i Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -i 12 -i 10 -i 0 + +if [ $? -ne 1 ]; then + echo $tst: dtrace failed + exit 1 +fi + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.PreprocessorStatement.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.PreprocessorStatement.d.ksh new file mode 100644 index 000000000000..182466f4f8b1 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.PreprocessorStatement.d.ksh @@ -0,0 +1,70 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -C option is used to run the C preprocessor over D programs before +# compiling them. The -H option used in conjuction with the -C option +# lists the pathnames of the included files to STDERR. +# +# SECTION: dtrace Utility/-C Option; +# dtrace Utility/-H Option +# +## + +script() +{ + $dtrace -CH -s /dev/stdin < + + BEGIN + { + printf("This test should compile\n"); + exit(0); + } +EOF +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script +status=$? + +if [ "$status" -ne 0 ]; then + echo $tst: dtrace failed +fi + +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.QuietMode.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.QuietMode.d.ksh new file mode 100644 index 000000000000..4bfbf767d677 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.QuietMode.d.ksh @@ -0,0 +1,65 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# Using the -q option suppresses the dtrace messages and prints only the +# data traced by trace() and printf() to stdout. +# +# SECTION: dtrace Utility/-q Option +# +## + +script() +{ + $dtrace -q -s /dev/stdin <' + exit 2 +fi + +dtrace=$1 +script +status=$? + +if [ "$status" -ne 0 ]; then + echo $tst: dtrace failed +fi + +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.QuietMode.d.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.QuietMode.d.ksh.out new file mode 100644 index 000000000000..20e31b50ec48 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.QuietMode.d.ksh.out @@ -0,0 +1 @@ +I am the only one. diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.TestCompile.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.TestCompile.d.ksh new file mode 100644 index 000000000000..16cd05f95b4c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.TestCompile.d.ksh @@ -0,0 +1,67 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# Using the -e option exits after compiling any requests but before +# enabling probes. +# +# SECTION: dtrace Utility/-e Option +# +## + +script() +{ + $dtrace -e -s /dev/stdin <' + exit 2 +fi + +dtrace=$1 + +script +status=$? + +if [ "$status" -ne 0 ]; then + echo $tst: dtrace failed +fi + +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.TestCompile.d.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.TestCompile.d.ksh.out new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.UnDefineNameWithCPP.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.UnDefineNameWithCPP.d.ksh new file mode 100644 index 000000000000..4c1eb507d5eb --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.UnDefineNameWithCPP.d.ksh @@ -0,0 +1,71 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -D option can be used to define a name when used in conjunction +# with the -C option. The -U option can be used to undefine a name in +# conjunction with the -C option. +# +# SECTION: dtrace Utility/-C Option; +# dtrace Utility/-D Option; +# dtrace Utility/-U Option +# +## + +script() +{ + $dtrace -C -D VALUE=40 -U VALUE -s /dev/stdin <' + exit 2 +fi + +dtrace=$1 + +script +status=$? + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroFunctionProbes.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroFunctionProbes.d.ksh new file mode 100644 index 000000000000..5e61f053636f --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroFunctionProbes.d.ksh @@ -0,0 +1,58 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -Z option can be used to permit descriptions that match +# zero probes. +# +# SECTION: dtrace Utility/-Z Option; +# dtrace Utility/-f Option +# +## + + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -qZf wassup'{printf("Iamkool");}' \ +-qf read'{printf("I am done"); exit(0);}' + +status=$? + +if [ "$status" -ne 0 ]; then + echo $tst: dtrace failed +fi + +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroFunctionProbes.d.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroFunctionProbes.d.ksh.out new file mode 100644 index 000000000000..0f2e1aacd09e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroFunctionProbes.d.ksh.out @@ -0,0 +1 @@ +I am done diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroModuleProbes.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroModuleProbes.d.ksh new file mode 100644 index 000000000000..c34a4aabddfc --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroModuleProbes.d.ksh @@ -0,0 +1,57 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -Z option can be used to permit descriptions that match +# zero probes. +# +# SECTION: dtrace Utility/-Z Option; +# dtrace Utility/-m Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -qZm wassup'{printf("Iamkool");}' \ +-qm BEGIN'{printf("I am done"); exit(0);}' + +status=$? + +if [ "$status" -ne 0 ]; then + echo $tst: dtrace failed +fi + +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroModuleProbes.d.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroModuleProbes.d.ksh.out new file mode 100644 index 000000000000..0f2e1aacd09e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroModuleProbes.d.ksh.out @@ -0,0 +1 @@ +I am done diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroNameProbes.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroNameProbes.d.ksh new file mode 100644 index 000000000000..90175a50b7b0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroNameProbes.d.ksh @@ -0,0 +1,56 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -Z option can be used to permit descriptions that match +# zero probes. +# +# SECTION: dtrace Utility/-Z Option; +# dtrace Utility/-n Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -qZn wassup'{printf("Iamkool");}' \ +-qn BEGIN'{printf("I am done"); exit(0);}' +status=$? + +if [ "$status" -ne 0 ]; then + echo $tst: dtrace failed +fi + +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroNameProbes.d.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroNameProbes.d.ksh.out new file mode 100644 index 000000000000..0f2e1aacd09e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroNameProbes.d.ksh.out @@ -0,0 +1 @@ +I am done diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProbeIdentfier.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProbeIdentfier.d.ksh new file mode 100644 index 000000000000..9af4d2b8c836 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProbeIdentfier.d.ksh @@ -0,0 +1,53 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# Testing -i option with zero probe identifier. +# +# SECTION: dtrace Utility/-i Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -i 0 + +if [ $? -ne 1 ]; then + echo $tst: dtrace failed + exit 1 +fi + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProbesWithoutZ.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProbesWithoutZ.d.ksh new file mode 100644 index 000000000000..afc7d76d22bb --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProbesWithoutZ.d.ksh @@ -0,0 +1,57 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# Without the -Z option probe descriptions that do not match any known +# probes will cause an error or will not be enabled. +# +# SECTION: dtrace Utility/-Z Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -qP wassup'{printf("Iamkool");}' \ +-qP profile'{printf("I am done"); exit(0);}' + +status=$? + +if [ "$status" -ne 0 ]; then + exit 0 +fi + +echo $tst: dtrace failed +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProviderProbes.d.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProviderProbes.d.ksh new file mode 100644 index 000000000000..f2646bd53401 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProviderProbes.d.ksh @@ -0,0 +1,57 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + +## +# +# ASSERTION: +# The -Z option can be used to permit descriptions that match +# zero probes. +# +# SECTION: dtrace Utility/-Z Option; +# dtrace Utility/-P Option +# +## + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -qZP wassup'{printf("Iamkool");}' \ +-qP profile'{printf("I am done"); exit(0);}' + +status=$? + +if [ "$status" -ne 0 ]; then + echo $tst: dtrace failed +fi + +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProviderProbes.d.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProviderProbes.d.ksh.out new file mode 100644 index 000000000000..0f2e1aacd09e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/tst.ZeroProviderProbes.d.ksh.out @@ -0,0 +1 @@ +I am done diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/end/err.D_IDENT_UNDEF.timespent.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/end/err.D_IDENT_UNDEF.timespent.d new file mode 100644 index 000000000000..04ccb7266816 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/end/err.D_IDENT_UNDEF.timespent.d @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Calculate timestamp between BEGIN and END. + * + * SECTION: dtrace Provider + * + */ + + +#pragma D option quiet + +END +{ + total = timestamp - start; +} + +BEGIN +{ + start = timestamp; + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/end/tst.end.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/end/tst.end.d new file mode 100644 index 000000000000..56c1a4c42617 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/end/tst.end.d @@ -0,0 +1,55 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Sequence flow of END profile. + * + * SECTION: dtrace Provider + * + */ + + +#pragma D option quiet + +END +{ + printf("End fired after exit\n"); +} + +BEGIN +{ + printf("Begin fired first\n"); +} + +tick-1 +{ + printf("tick fired second\n"); + printf("Call exit\n"); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/end/tst.endwithoutbegin.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/end/tst.endwithoutbegin.d new file mode 100644 index 000000000000..6291960701cc --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/end/tst.endwithoutbegin.d @@ -0,0 +1,48 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * END without BEGIN profile + * + * SECTION: dtrace Provider + * + */ + + +#pragma D option quiet + +END +{ + printf("End fired after exit\n"); +} + +tick-1 +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/end/tst.multibeginend.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/end/tst.multibeginend.d new file mode 100644 index 000000000000..4f6ec9210beb --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/end/tst.multibeginend.d @@ -0,0 +1,77 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Tests multiple END profile. + * + * SECTION: dtrace Provider + * + */ + + +#pragma D option quiet + +END +{ + printf("End1 fired after exit\n"); +} +END +{ + printf("End2 fired after exit\n"); +} +END +{ + printf("End3 fired after exit\n"); +} +END +{ + printf("End4 fired after exit\n"); +} + +BEGIN +{ + printf("Begin fired first\n"); +} +BEGIN +{ + printf("Begin fired second\n"); +} +BEGIN +{ + printf("Begin fired third\n"); +} +BEGIN +{ + printf("Begin fired fourth\n"); +} +BEGIN +{ + printf("Begin fired fifth\n"); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/end/tst.multiend.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/end/tst.multiend.d new file mode 100644 index 000000000000..e6629fb5cb31 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/end/tst.multiend.d @@ -0,0 +1,61 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Tests Multiple END and single BEGIN + * + * SECTION: dtrace Provider + * + */ + + +#pragma D option quiet + +END +{ + printf("End1 fired after exit\n"); +} +END +{ + printf("End2 fired after exit\n"); +} +END +{ + printf("End3 fired after exit\n"); +} +END +{ + printf("End4 fired after exit\n"); +} + +BEGIN +{ + printf("Begin fired first\n"); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/enum/err.D_DECL_IDRED.EnumSameName.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/enum/err.D_DECL_IDRED.EnumSameName.d new file mode 100644 index 000000000000..7e5427a51085 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/enum/err.D_DECL_IDRED.EnumSameName.d @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * ASSERTION: + * Enumerations assigning same or different values to the same identifier in + * different enumerations should throw a compiler error. + * + * SECTION: Type and Constant Definitions/Enumerations + * + * + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +enum colors { + RED, + GREEN, + BLUE +}; + +enum shades { + RED, + ORANGE, + GREEN, + WHITE +}; + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/enum/err.D_UNKNOWN.RepeatIdentifiers.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/enum/err.D_UNKNOWN.RepeatIdentifiers.d new file mode 100644 index 000000000000..2b4266d5c015 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/enum/err.D_UNKNOWN.RepeatIdentifiers.d @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * ASSERTION: + * Repeating the same identifier in the same enumeration will throw a compiler + * error. + * + * SECTION: Type and Constant Definitions/Enumerations + * + * NOTES: + * + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +enum colors { + RED, + GREEN, + GREEN = 2, + BLUE +}; + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/enum/tst.EnumEquality.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/enum/tst.EnumEquality.d new file mode 100644 index 000000000000..cbf9369a8a6a --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/enum/tst.EnumEquality.d @@ -0,0 +1,56 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Test the identifiers in different D enumerations at same position for + * equality. + * + * SECTION: Type and Constant Definitions/Enumerations + */ + +#pragma D option quiet + +enum colors { + RED, + GREEN, + BLUE +}; + +enum shades { + WHITE, + BLACK, + YELLOW +}; + + +profile:::tick-1sec +/(WHITE == RED) && (YELLOW == BLUE) && (GREEN == BLACK)/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/enum/tst.EnumSameValue.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/enum/tst.EnumSameValue.d new file mode 100644 index 000000000000..26a4d504dcc4 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/enum/tst.EnumSameValue.d @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * ASSERTION: + * Enumerations assigning the same value to different identifiers in the same + * enumeration should work okay. + * + * SECTION: Type and Constant Definitions/Enumerations + * + * NOTES: + * + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +enum colors { + RED = 2, + GREEN = 2, + BLUE = 2 +}; + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/enum/tst.EnumValAssign.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/enum/tst.EnumValAssign.d new file mode 100644 index 000000000000..f721c50a3941 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/enum/tst.EnumValAssign.d @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * ASSERTION: + * Test the D enumerations with and without initilialization of the identifiers. + * Also test for values with negative integer assignments, expressions and + * fractions. + * + * SECTION: Type and Constant Definitions/Enumerations + * + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +enum colors { + RED, + ORANGE = 5 + 5, + YELLOW = 2, + GREEN, + BLUE = GREEN + ORANGE, + PINK = 5/4, + INDIGO = -2, + VIOLET +}; + +profile:::tick-1sec +/(0 == RED) && (10 == ORANGE) && (2 == YELLOW) && (3 == GREEN) && + (13 == BLUE) && (1 == PINK) && (-2 == INDIGO) && (-1 == VIOLET)/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/error/tst.DTRACEFLT_BADADDR.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/error/tst.DTRACEFLT_BADADDR.d new file mode 100644 index 000000000000..5eb3e94c2e38 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/error/tst.DTRACEFLT_BADADDR.d @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * To test DTRACEFLT_BADADDR error + * + * SECTION: dtrace Provider + * + */ + + +#pragma D option quiet + +ERROR +{ + printf("The arguments are %u %u %u %u %u\n", + arg1, arg2, arg3, arg4, arg5); + printf("The value of arg4 = %u\n", DTRACEFLT_BADADDR); + exit(0); +} + +BEGIN +{ + *(char *)NULL; +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/error/tst.DTRACEFLT_DIVZERO.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/error/tst.DTRACEFLT_DIVZERO.d new file mode 100644 index 000000000000..5b93168a127d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/error/tst.DTRACEFLT_DIVZERO.d @@ -0,0 +1,54 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * To test DTRACEFLT_DIVZERO error + * + * SECTION: dtrace Provider + * + */ + + +#pragma D option quiet + +ERROR +{ + printf("The arguments are %u %u %u %d %u\n", + arg1, arg2, arg3, arg4, arg5); + exit(0); +} + +char *s; + +BEGIN +{ + i = 1; + j = 2; + j = i/(j-2); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/error/tst.DTRACEFLT_UNKNOWN.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/error/tst.DTRACEFLT_UNKNOWN.d new file mode 100644 index 000000000000..6de75bbcce79 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/error/tst.DTRACEFLT_UNKNOWN.d @@ -0,0 +1,53 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * To test DTRACEFLT_UNKNOWN error + * + * SECTION: dtrace Provider + * + */ + + +#pragma D option quiet + +ERROR +{ + printf("The arguments are %u %u %u %u %u\n", + arg1, arg2, arg3, arg4, arg5); + printf("The value of arg4 = %u\n", DTRACEFLT_UNKNOWN); + exit(0); +} + +BEGIN +{ + x = (int *) 64; + y = *x; + trace(y); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/error/tst.error.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/error/tst.error.d new file mode 100644 index 000000000000..3b1d65399db6 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/error/tst.error.d @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * To fire ERROR probe + * + * SECTION: dtrace Provider + * + */ + + +#pragma D option quiet + +ERROR +{ + printf("Error fired\n"); + exit(0); +} + +BEGIN +{ + *(char *)NULL; +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/error/tst.errorend.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/error/tst.errorend.d new file mode 100644 index 000000000000..0bb4a6efce5b --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/error/tst.errorend.d @@ -0,0 +1,54 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Flow of ERROR probe + * + * SECTION: dtrace Provider + * + */ + + +#pragma D option quiet + +ERROR +{ + printf("Error fired\n"); + exit(0); +} + +END +{ + printf("End fired after exit\n"); +} + +BEGIN +{ + *(char *)NULL; +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/exit/err.D_PROTO_LEN.noarg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/exit/err.D_PROTO_LEN.noarg.d new file mode 100644 index 000000000000..9a9a8f934c18 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/exit/err.D_PROTO_LEN.noarg.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * Call exit() without arguments. + * + * SECTION: Actions and Subroutines/exit() + */ + +#pragma D option quiet + +dtrace:::BEGIN +{ + exit() +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/exit/err.exitarg1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/exit/err.exitarg1.d new file mode 100644 index 000000000000..d3067d126977 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/exit/err.exitarg1.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * Basic test - call with 1 + * + * SECTION: Actions and Subroutines/exit() + */ + +#pragma D option quiet + +dtrace:::BEGIN +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/exit/tst.basic1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/exit/tst.basic1.d new file mode 100644 index 000000000000..24f841c3478c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/exit/tst.basic1.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Positive test + * + * SECTION: Actions and Subroutines/exit() + */ + + +#pragma D option quiet + +dtrace:::BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/err.D_PDESC_ZERO.notreturn.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/err.D_PDESC_ZERO.notreturn.d new file mode 100644 index 000000000000..5e3d5fa7eb06 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/err.D_PDESC_ZERO.notreturn.d @@ -0,0 +1,56 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: Call fbt provider over non existent function and make + * sure it results in compilation error. + * + * SECTION: FBT Provider/Probes + */ + +#pragma D option quiet + +BEGIN +{ + self->traceme = 1; +} + +void bar(); + +fbt::bar:entry +{ + printf("Entering the function\n"); +} + +fbt::bar:return +{ + printf("Returning the function\n"); + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.basic.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.basic.d new file mode 100644 index 000000000000..ff6da26f318c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.basic.d @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: simple fbt arguments test. + * + * SECTION: FBT Provider/Probes + */ + +#pragma D option quiet + +tick-1 +{ + self->traceme = 1; +} + +fbt::: +/self->traceme/ +{ + printf("The arguments are %u %u %u %u %u %u %u %u\n", arg0, arg1, + arg3, arg4, arg5, arg6, arg7, arg8); + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.functionentry.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.functionentry.d new file mode 100644 index 000000000000..78e107eed492 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.functionentry.d @@ -0,0 +1,48 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: FBT provider function entry and exit test. + * + * SECTION: FBT Provider/Probe arguments + */ + +#pragma D option quiet +#pragma D option statusrate=10ms + +fbt::ioctl:entry +{ + printf("Entering the ioctl function\n"); +} + +fbt::ioctl:return +{ + printf("Returning from ioctl function\n"); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.functionreturnvalue.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.functionreturnvalue.d new file mode 100644 index 000000000000..6d1b8a8fab69 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.functionreturnvalue.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: Fbt provider return value verify test. + * + * SECTION: FBT Provider/Probe arguments + */ + +#pragma D option quiet +#pragma D option statusrate=10ms + +fbt::ioctl:return +{ + printf("The function return value is stored in %u\n", arg1); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.ioctlargs.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.ioctlargs.d new file mode 100644 index 000000000000..c2c7bf04d002 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.ioctlargs.d @@ -0,0 +1,50 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: FBT provider arguments scan test. + * + * SECTION: FBT Provider/Probe arguments + */ + +#pragma D option quiet +#pragma D option statusrate=10ms + +fbt::ioctl:entry +{ + printf("Entering the ioctl function\n"); + printf("The few arguments are %u %u %u %u\n", arg0, arg1, arg2, arg3); +} + +fbt::ioctl:return +{ + printf("Returning from ioctl function\n"); + printf("The few arguments are %u %u %u %u\n", arg0, arg1, arg2, arg3); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.offset.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.offset.d new file mode 100644 index 000000000000..be2c0d6a6169 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.offset.d @@ -0,0 +1,53 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: FBT provider return value offset verification test. + * + * SECTION: FBT Provider/Probe arguments + */ + +#pragma D option quiet +#pragma D option statusrate=10ms + +BEGIN +{ + self->traceme = 1; +} + +fbt::ioctl:entry +{ + printf("Entering the function\n"); +} + +fbt::ioctl:return +{ + printf("The offset = %u\n", arg0); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.offsetzero.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.offsetzero.d new file mode 100644 index 000000000000..240744bff38f --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.offsetzero.d @@ -0,0 +1,50 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: FBT provider argument 0 test + * + * SECTION: FBT Provider/Probe arguments + */ + +#pragma D option quiet +#pragma D option statusrate=10ms + +fbt::ioctl:entry +{ + printf("Entering the ioctl function\n"); + printf("The few arguments are %u %u %u %u\n", arg0, arg1, arg2, arg3); + exit(0); +} + +fbt::ioctl:return +{ + printf("Returning from ioctl function\n"); + printf("The few arguments are %u %u %u %u\n", arg0, arg1, arg2, arg3); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.return.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.return.d new file mode 100644 index 000000000000..b269710ec844 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.return.d @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: simple fbt provider return test. + * + * SECTION: FBT Provider/Probe arguments + */ + +#pragma D option quiet + +BEGIN +{ + self->traceme = 1; +} + +fbt:::entry +{ + printf("Entering the function\n"); +} + +fbt:::return +{ + printf("Returning the function\n"); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.return0.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.return0.d new file mode 100644 index 000000000000..cadbaa00f925 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.return0.d @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: simple fbt provider arg0 and probfunc print test. + * + * SECTION: FBT Provider/Probe arguments + */ + +#pragma D option quiet +#pragma D option statusrate=10ms + +fbt::ioctl:return +/arg1 == 0/ +{ + printf("%s %x returned 0", probefunc, arg0); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.tailcall.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.tailcall.d new file mode 100644 index 000000000000..67ef106fac0c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.tailcall.d @@ -0,0 +1,55 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: simple fbt provider tailcall test. + * + * SECTION: FBT Provider/Probe arguments + */ + +#pragma D option quiet +#pragma D option statusrate=10ms + +fbt::ioctl:entry +{ + self->traceme = 1; +} + +fbt:::entry +/self->traceme/ +{ + printf("called %s\n", probefunc); +} + +fbt::ioctl:return +/self->traceme/ +{ + self->traceme = 0; + exit (0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_FUNC_UNDEF.progenyofbad1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_FUNC_UNDEF.progenyofbad1.d new file mode 100644 index 000000000000..bfd1eedf83c0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_FUNC_UNDEF.progenyofbad1.d @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * progenyof() should accept one argument - a pid + * + * SECTION: Actions and Subroutines/progenyof() + * + */ + + +BEGIN +{ + progencyof(1, 2); + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_OP_VFPTR.badop.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_OP_VFPTR.badop.d new file mode 100644 index 000000000000..d219bb1fe9e2 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_OP_VFPTR.badop.d @@ -0,0 +1,47 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * +=, -= must handle invalid variables. + * + * SECTION: Types, Operators, and Expressions/Assignment Operators + * + */ + + +int p; + +BEGIN +{ + p = 1; + p -= alloca(10); + exit(1); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.chillbadarg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.chillbadarg.d new file mode 100644 index 000000000000..08bd98191f95 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.chillbadarg.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * chill() should handle a bad argument. + * + * SECTION: Actions and Subroutines/chill() + * + */ + + +BEGIN +{ + chill("badarg"); + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.copyoutbadarg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.copyoutbadarg.d new file mode 100644 index 000000000000..5c02378fb28c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.copyoutbadarg.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * copyout() must handle invalid argument types. + * + * SECTION: Actions and Subroutines/copyout() + * + */ + + +BEGIN +{ + copyout("not_void_*", "not_uinptr_t", "not_size_t"); + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.mobadarg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.mobadarg.d new file mode 100644 index 000000000000..4df8d1868cf8 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.mobadarg.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * mutex_owned() should handle an invalid argument passed. + * + * SECTION: Actions and Subroutines/mutex_owned() + * + */ + +BEGIN +{ + mutex_owned("badarg"); + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.raisebadarg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.raisebadarg.d new file mode 100644 index 000000000000..a3336efe8a98 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.raisebadarg.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * raise() should generate an error if any arguments are sent. + * + * SECTION: Actions and Subroutines/raise() + * + */ + + +BEGIN +{ + raise("badarg"); + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.allocanoarg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.allocanoarg.d new file mode 100644 index 000000000000..a2af00f9ea54 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.allocanoarg.d @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * alloca() should handle no arguments as an error + * + * SECTION: Actions and Subroutines/alloca() + * + */ + +#pragma D option quiet + + + +BEGIN +{ + ptr = alloca(); + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.badbreakpoint.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.badbreakpoint.d new file mode 100644 index 000000000000..0cb567a51b67 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.badbreakpoint.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * breakpoint() should handle arguments passed as an error. + * + * SECTION: Actions and Subroutines/breakpoint() + * + */ + + +BEGIN +{ + breakpoint(1, 2); + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.chilltoofew.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.chilltoofew.d new file mode 100644 index 000000000000..a0018fa85c4e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.chilltoofew.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * chill() should handle no arguments. + * + * SECTION: Actions and Subroutines/chill() + * + */ + + +BEGIN +{ + chill(); + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.chilltoomany.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.chilltoomany.d new file mode 100644 index 000000000000..f24e9ef1d284 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.chilltoomany.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * chill() should handle too many arguments. + * + * SECTION: Actions and Subroutines/chill() + * + */ + +BEGIN +{ + chill(1000, 1000, 1000); + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyoutstrbadarg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyoutstrbadarg.d new file mode 100644 index 000000000000..1f07814b6789 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyoutstrbadarg.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * copyoutstr() must handle invalid argument types. + * + * SECTION: Actions and Subroutines/copyoutstr() + * + */ + + +BEGIN +{ + copyoutstr("string", "not_uintptr_t"); + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyoutstrtoofew.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyoutstrtoofew.d new file mode 100644 index 000000000000..e01868c030ca --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyoutstrtoofew.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Calling copyoutstr() with less than 2 arguments will generate an error + * + * SECTION: Actions and Subroutines/copyoutstr() + * + */ + + +BEGIN +{ + copyoutstr("string"); + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyouttoofew.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyouttoofew.d new file mode 100644 index 000000000000..f3706f622805 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyouttoofew.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Calling copyout() with less than 3 arguments will generate an error + * + * SECTION: Actions and Subroutines/copyout() + * + */ + + +BEGIN +{ + copyout(0, 20); + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyouttoomany.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyouttoomany.d new file mode 100644 index 000000000000..6fab90d8fc53 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.copyouttoomany.d @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * copyout() should handle too many arguments passed. + * + * SECTION: Actions and Subroutines/copyin(); + * Actions and Subroutines/copyinstr() + * + */ + + +BEGIN +{ + copyout((void *)3, (uintptr_t)1000, (size_t)1000, "toomany"); + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.motoofew.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.motoofew.d new file mode 100644 index 000000000000..e878713abb27 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.motoofew.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * mutex_owned() should handle too few args passed + * + * SECTION: Actions and Subroutines/mutex_owned() + * + */ + +lockstat:genunix:mutex_enter:adaptive-acquire +{ + mutex_owned(); + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.motoomany.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.motoomany.d new file mode 100644 index 000000000000..d3b9ed486eb0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.motoomany.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * mutex_owned() should handle too many args passed + * + * SECTION: Actions and Subroutines/mutex_owned() + * + */ + +lockstat:genunix:mutex_enter:adaptive-acquire +{ + mutex_owned((kmutex_t *)arg0, 99); + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtabadarg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtabadarg.d new file mode 100644 index 000000000000..6ad1e47b434c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtabadarg.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * mutex_type_adaptive() should handle an invalid argument passed. + * + * SECTION: Actions and Subroutines/mutex_type_adaptive() + * + */ + + +BEGIN +{ + mutex_type_adaptive(trace()); + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtatoofew.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtatoofew.d new file mode 100644 index 000000000000..98bc5c9313dd --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtatoofew.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * mutex_type_adaptive() should handle too few args passed + * + * SECTION: Actions and Subroutines/mutex_type_adaptive() + * + */ + + +lockstat:genunix:mutex_enter:adaptive-acquire +{ + mutex_type_adaptive(); + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtatoomany.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtatoomany.d new file mode 100644 index 000000000000..e4f259a7e78c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtatoomany.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * mutex_type_adaptive() should handle too many args passed + * + * SECTION: Actions and Subroutines/mutex_type_adaptive() + * + */ + + +lockstat:genunix:mutex_enter:adaptive-acquire +{ + mutex_type_adaptive((kmutex_t *)arg0, 99); + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.panicbadarg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.panicbadarg.d new file mode 100644 index 000000000000..87589b48491c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.panicbadarg.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * panic() should handle any argument passed as an error. + * + * SECTION: Actions and Subroutines/panic() + * + */ + + +BEGIN +{ + panic("badarg"); + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.progenyofbad2.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.progenyofbad2.d new file mode 100644 index 000000000000..51c8674defe6 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.progenyofbad2.d @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * progenyof() should return an error if the argument is an + * incorrect type. + * + * SECTION: Actions and Subroutines/progenyof() + * + */ + + +BEGIN +{ + progenyof(trace()); + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.stopbadarg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.stopbadarg.d new file mode 100644 index 000000000000..8b6050715878 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.stopbadarg.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * stop() should generate an error if any arguments are sent. + * + * SECTION: Actions and Subroutines/stop() + * + */ + + +BEGIN +{ + stop("badarg"); + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_STRINGOF_TYPE.badstringof.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_STRINGOF_TYPE.badstringof.d new file mode 100644 index 000000000000..fec5649b5d30 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_STRINGOF_TYPE.badstringof.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * stringof() accepts a scalar, pointer, or string + * + * SECTION: Types, Operators, and Expressions/Precedence + * + */ + +#pragma D option quiet + +BEGIN +{ + printf("%s", stringof (trace(0))); + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_VAR_UNDEF.badvar.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_VAR_UNDEF.badvar.d new file mode 100644 index 000000000000..bb4fd2d18e97 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_VAR_UNDEF.badvar.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * +=, -= must handle invalid variables. + * + * SECTION: Types, Operators, and Expressions/Assignment Operators + * + */ + + +BEGIN +{ + p -= trace(0); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badalloca.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badalloca.d new file mode 100644 index 000000000000..572daa39fec0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badalloca.d @@ -0,0 +1,56 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * memory allocated by alloca() is only valid within the clause + * it is allocated. + * + * SECTION: Actions and Subroutines/alloca() + * + */ + +#pragma D option quiet + + +BEGIN +{ + ptr = alloca(sizeof (int)); +} + +tick-1 +{ + bcopy((void *)&`kmem_flags, ptr, sizeof (int)); + exit(0); +} + +ERROR +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badalloca2.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badalloca2.d new file mode 100644 index 000000000000..fbbf8e2e0503 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badalloca2.d @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * alloca() cannot be used to "unconsume" scratch space memory by + * accepting a negative offset. + * + * SECTION: Actions and Subroutines/alloca() + * + */ + +BEGIN +{ + ptr = alloca(10); + ptr = alloca(0xffffffffffffffff); + exit(0); +} + +ERROR +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badbcopy.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badbcopy.d new file mode 100644 index 000000000000..d7184b0f42b4 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badbcopy.d @@ -0,0 +1,55 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * bcopy should not allow a copy to memory that is not scratch memory. + * + * SECTION: Actions and Subroutines/alloca(); + * Actions and Subroutines/bcopy() + * + */ + +#pragma D option quiet + + +BEGIN +{ + ptr = alloca(sizeof (int)); + + /* Attempt a copy from scratch memory to a kernel address */ + + bcopy(ptr, (void *)&`kmem_flags, sizeof (int)); + exit(0); +} + +ERROR +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badbcopy1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badbcopy1.d new file mode 100644 index 000000000000..c29eb2bb8139 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badbcopy1.d @@ -0,0 +1,54 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * bcopy should not copy from one memory location to another + * if the memory is not properly allocated + * + * SECTION: Actions and Subroutines/alloca(); + * Actions and Subroutines/bcopy() + * + */ + +#pragma D option quiet + + +BEGIN +{ + ptr = alloca(0); + + /* Attempt to bcopy to scratch memory that isn't allocated */ + bcopy((void *)&`kmem_flags, ptr, sizeof (int)); + exit(0); +} + +ERROR +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badbcopy2.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badbcopy2.d new file mode 100644 index 000000000000..6d49e6ec5ff6 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badbcopy2.d @@ -0,0 +1,53 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * bcopy should not copy from one memory location to another + * if the memory is not properly allocated + * + * SECTION: Actions and Subroutines/bcopy() + * + */ + +#pragma D option quiet + +int *ptr; + +BEGIN +{ + /* Attempt to copy to non-scratch memory */ + + bcopy((void *)&`kmem_flags, ptr, sizeof (int)); + exit(0); +} + +ERROR +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badbcopy3.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badbcopy3.d new file mode 100644 index 000000000000..c362caad574c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badbcopy3.d @@ -0,0 +1,50 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * bcopy should not copy from one memory location to another + * if the memory is not properly allocated + * + * SECTION: Actions and Subroutines/bcopy() + * + */ + +#pragma D option quiet + +BEGIN +{ + /* Attempt to copy to a NULL address */ + bcopy((void *)&`kmem_flags, (void *)NULL, sizeof (int)); + exit(0); +} + +ERROR +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badbcopy4.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badbcopy4.d new file mode 100644 index 000000000000..4148ae7bf311 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badbcopy4.d @@ -0,0 +1,53 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * bcopy should not copy from one memory location to another + * if the source memory location is not valid. + * + * SECTION: Actions and Subroutines/alloca(); + * Actions and Subroutines/bcopy() + * + */ + +#pragma D option quiet + +BEGIN +{ + ptr = alloca(sizeof (int)); + + /* Attempt to copy from a NULL address */ + bcopy((void *)NULL, ptr, sizeof (int)); + exit(0); +} + +ERROR +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badbcopy5.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badbcopy5.d new file mode 100644 index 000000000000..a0cbd5d4a1f3 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badbcopy5.d @@ -0,0 +1,55 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * bcopy should not copy from one memory location to another + * if the source memory location is not valid. + * + * SECTION: Actions and Subroutines/alloca(); + * Actions and Subroutines/bcopy() + * + */ + +#pragma D option quiet + +int *badptr; + +BEGIN +{ + ptr = alloca(sizeof (int)); + + /* Attempt to copy from a invalid address */ + bcopy(badptr, ptr, sizeof (int)); + exit(0); +} + +ERROR +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badbcopy6.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badbcopy6.d new file mode 100644 index 000000000000..32770145ad6c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badbcopy6.d @@ -0,0 +1,40 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +BEGIN +{ + bcopy("bad news", alloca(1), -1); + exit(0); +} + +ERROR +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badchill.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badchill.d new file mode 100644 index 000000000000..b394a88b4ca1 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.badchill.d @@ -0,0 +1,39 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +BEGIN +{ + chill(200); + chill(((hrtime_t)1 << 63) - 1); + exit(0); +} + +ERROR +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.chillbadarg.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.chillbadarg.ksh new file mode 100644 index 000000000000..98f04dd20ce1 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.chillbadarg.ksh @@ -0,0 +1,69 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +# ident "%Z%%M% %I% %E% SMI" + +dtrace_script() +{ + + $dtrace -w -s /dev/stdin <' + exit 2 +fi + +dtrace=$1 + +dtrace_script & +child=$! + +wait $child +status=$? + +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.copyout.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.copyout.d new file mode 100644 index 000000000000..6b9db3b811a7 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.copyout.d @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * copyout() should handle invalid args. + * + * SECTION: Actions and Subroutines/copyout() + * + */ + +#pragma D option destructive + +BEGIN +{ + i = 3; + copyout((void *)i, 0, 5); + exit(0); +} + +ERROR +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.copyoutbadaddr.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.copyoutbadaddr.ksh new file mode 100644 index 000000000000..de5c47d5c043 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.copyoutbadaddr.ksh @@ -0,0 +1,71 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +# ident "%Z%%M% %I% %E% SMI" + + +dtrace_script() +{ + + $dtrace -w -s /dev/stdin <pr_envp, sizeof (char *), ptr); + copyout(ptr, 0, sizeof (char *)); + } + + ERROR + { + exit(1) + } +EOF +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +dtrace_script & +child=$! + +wait $child +status=$? + +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.copyoutstrbadaddr.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.copyoutstrbadaddr.ksh new file mode 100644 index 000000000000..181702b8ecf0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.copyoutstrbadaddr.ksh @@ -0,0 +1,70 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +# ident "%Z%%M% %I% %E% SMI" + + +dtrace_script() +{ + + $dtrace -w -s /dev/stdin <pr_envp, sizeof (char *), ptr); + copyout(ptr, 0, sizeof (char *)); + } + + ERROR + { + exit(1) + } +EOF +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +dtrace_script & +child=$! + +wait $child +status=$? + +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.inet_ntoa6badaddr.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.inet_ntoa6badaddr.d new file mode 100644 index 000000000000..81ce643f6b0b --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.inet_ntoa6badaddr.d @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +struct in6_addr *ip6a; + +BEGIN +{ + ip6a = 0; + + printf("%s\n", inet_ntop(AF_INET6, ip6a)); + + exit(0); +} + +ERROR +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.inet_ntoabadaddr.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.inet_ntoabadaddr.d new file mode 100644 index 000000000000..3f0d8e45ff8b --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.inet_ntoabadaddr.d @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +ipaddr_t *ip4a; + +BEGIN +{ + ip4a = 0; + + printf("%s\n", inet_ntoa(ip4a)); + + exit(0); +} + +ERROR +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadaddr.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadaddr.d new file mode 100644 index 000000000000..74ce760d8b66 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadaddr.d @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +ipaddr_t *ip4a; + +BEGIN +{ + ip4a = 0; + + printf("%s\n", inet_ntop(AF_INET, ip4a)); + + exit(0); +} + +ERROR +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadarg.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadarg.d new file mode 100644 index 000000000000..2731385d2db4 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadarg.d @@ -0,0 +1,47 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +ipaddr_t *ip4a; + +BEGIN +{ + this->buf4a = alloca(sizeof (ipaddr_t)); + ip4a = this->buf4a; + *ip4a = htonl(0xc0a80117); + + printf("%s\n", inet_ntop(-1, ip4a)); + + exit(0); +} + +ERROR +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.badfreopen.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.badfreopen.ksh new file mode 100644 index 000000000000..72f6b87f8115 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.badfreopen.ksh @@ -0,0 +1,102 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" + +script() +{ + $dtrace -wq -o $tmpfile -s /dev/stdin 2> $errfile <' + exit 2 +fi + +dtrace=$1 +tmpfile=/tmp/tst.badfreopen.$$ +errfile=/tmp/tst.badfreopen.$$.stderr + +script +status=$? + +if [ "$status" -eq 0 ]; then + i=`cat $tmpfile` + + if [[ $i != "123" ]]; then + echo "$0: unexpected contents in $tmpfile: " \ + "expected 123, found $i" + status=100 + fi + + i=`wc -l $errfile | nawk '{ print $1 }'` + + if [ "$i" -lt 6 ]; then + echo "$0: expected at least 6 lines of stderr, found $i lines" + status=101 + fi +else + cat $errfile > /dev/fd/2 +fi + +rm $tmpfile $errfile + +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.basename.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.basename.d new file mode 100644 index 000000000000..6fb996c96181 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.basename.d @@ -0,0 +1,87 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +/* + * This test verifies that the basename() and dirname() functions are working + * properly. Note that the output of this is a ksh script. When run, + * it will give no output if the output is correct. + */ +BEGIN +{ + dir[i++] = "/foo/bar/baz"; + dir[i++] = "/foo/bar///baz/"; + dir[i++] = "/foo/bar/baz/"; + dir[i++] = "/foo/bar/baz//"; + dir[i++] = "/foo/bar/baz/."; + dir[i++] = "/foo/bar/baz/./"; + dir[i++] = "/foo/bar/baz/.//"; + dir[i++] = "foo/bar/baz/"; + dir[i++] = "/"; + dir[i++] = "./"; + dir[i++] = "//"; + dir[i++] = "/."; + dir[i++] = "/./"; + dir[i++] = "/./."; + dir[i++] = "/.//"; + dir[i++] = "."; + dir[i++] = "f"; + dir[i++] = "f/"; + dir[i++] = "/////"; + dir[i++] = ""; + + end = i; + i = 0; + + printf("#!/usr/bin/ksh\n\n"); +} + +tick-1ms +/i < end/ +{ + printf("if [ `basename \"%s\"` != \"%s\" ]; then\n", + dir[i], basename(dir[i])); + printf(" echo \"basename(\\\"%s\\\") is \\\"%s\\\"; ", + dir[i], basename(dir[i])); + printf("expected \\\"`basename \"%s\"`\"\\\"\n", dir[i]); + printf("fi\n\n"); + printf("if [ `dirname \"%s\"` != \"%s\" ]; then\n", + dir[i], dirname(dir[i])); + printf(" echo \"dirname(\\\"%s\\\") is \\\"%s\\\"; ", + dir[i], dirname(dir[i])); + printf("expected \\\"`dirname \"%s\"`\"\\\"\n", dir[i]); + printf("fi\n\n"); + i++; +} + +tick-1ms +/i == end/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.basename.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.basename.d.out new file mode 100644 index 000000000000..e16541adbb03 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.basename.d.out @@ -0,0 +1,163 @@ +#!/usr/bin/ksh + +if [ `basename "/foo/bar/baz"` != "baz" ]; then + echo "basename(\"/foo/bar/baz\") is \"baz\"; expected \"`basename "/foo/bar/baz"`"\" +fi + +if [ `dirname "/foo/bar/baz"` != "/foo/bar" ]; then + echo "dirname(\"/foo/bar/baz\") is \"/foo/bar\"; expected \"`dirname "/foo/bar/baz"`"\" +fi + +if [ `basename "/foo/bar///baz/"` != "baz" ]; then + echo "basename(\"/foo/bar///baz/\") is \"baz\"; expected \"`basename "/foo/bar///baz/"`"\" +fi + +if [ `dirname "/foo/bar///baz/"` != "/foo/bar" ]; then + echo "dirname(\"/foo/bar///baz/\") is \"/foo/bar\"; expected \"`dirname "/foo/bar///baz/"`"\" +fi + +if [ `basename "/foo/bar/baz/"` != "baz" ]; then + echo "basename(\"/foo/bar/baz/\") is \"baz\"; expected \"`basename "/foo/bar/baz/"`"\" +fi + +if [ `dirname "/foo/bar/baz/"` != "/foo/bar" ]; then + echo "dirname(\"/foo/bar/baz/\") is \"/foo/bar\"; expected \"`dirname "/foo/bar/baz/"`"\" +fi + +if [ `basename "/foo/bar/baz//"` != "baz" ]; then + echo "basename(\"/foo/bar/baz//\") is \"baz\"; expected \"`basename "/foo/bar/baz//"`"\" +fi + +if [ `dirname "/foo/bar/baz//"` != "/foo/bar" ]; then + echo "dirname(\"/foo/bar/baz//\") is \"/foo/bar\"; expected \"`dirname "/foo/bar/baz//"`"\" +fi + +if [ `basename "/foo/bar/baz/."` != "." ]; then + echo "basename(\"/foo/bar/baz/.\") is \".\"; expected \"`basename "/foo/bar/baz/."`"\" +fi + +if [ `dirname "/foo/bar/baz/."` != "/foo/bar/baz" ]; then + echo "dirname(\"/foo/bar/baz/.\") is \"/foo/bar/baz\"; expected \"`dirname "/foo/bar/baz/."`"\" +fi + +if [ `basename "/foo/bar/baz/./"` != "." ]; then + echo "basename(\"/foo/bar/baz/./\") is \".\"; expected \"`basename "/foo/bar/baz/./"`"\" +fi + +if [ `dirname "/foo/bar/baz/./"` != "/foo/bar/baz" ]; then + echo "dirname(\"/foo/bar/baz/./\") is \"/foo/bar/baz\"; expected \"`dirname "/foo/bar/baz/./"`"\" +fi + +if [ `basename "/foo/bar/baz/.//"` != "." ]; then + echo "basename(\"/foo/bar/baz/.//\") is \".\"; expected \"`basename "/foo/bar/baz/.//"`"\" +fi + +if [ `dirname "/foo/bar/baz/.//"` != "/foo/bar/baz" ]; then + echo "dirname(\"/foo/bar/baz/.//\") is \"/foo/bar/baz\"; expected \"`dirname "/foo/bar/baz/.//"`"\" +fi + +if [ `basename "foo/bar/baz/"` != "baz" ]; then + echo "basename(\"foo/bar/baz/\") is \"baz\"; expected \"`basename "foo/bar/baz/"`"\" +fi + +if [ `dirname "foo/bar/baz/"` != "foo/bar" ]; then + echo "dirname(\"foo/bar/baz/\") is \"foo/bar\"; expected \"`dirname "foo/bar/baz/"`"\" +fi + +if [ `basename "/"` != "/" ]; then + echo "basename(\"/\") is \"/\"; expected \"`basename "/"`"\" +fi + +if [ `dirname "/"` != "/" ]; then + echo "dirname(\"/\") is \"/\"; expected \"`dirname "/"`"\" +fi + +if [ `basename "./"` != "." ]; then + echo "basename(\"./\") is \".\"; expected \"`basename "./"`"\" +fi + +if [ `dirname "./"` != "." ]; then + echo "dirname(\"./\") is \".\"; expected \"`dirname "./"`"\" +fi + +if [ `basename "//"` != "/" ]; then + echo "basename(\"//\") is \"/\"; expected \"`basename "//"`"\" +fi + +if [ `dirname "//"` != "/" ]; then + echo "dirname(\"//\") is \"/\"; expected \"`dirname "//"`"\" +fi + +if [ `basename "/."` != "." ]; then + echo "basename(\"/.\") is \".\"; expected \"`basename "/."`"\" +fi + +if [ `dirname "/."` != "/" ]; then + echo "dirname(\"/.\") is \"/\"; expected \"`dirname "/."`"\" +fi + +if [ `basename "/./"` != "." ]; then + echo "basename(\"/./\") is \".\"; expected \"`basename "/./"`"\" +fi + +if [ `dirname "/./"` != "/" ]; then + echo "dirname(\"/./\") is \"/\"; expected \"`dirname "/./"`"\" +fi + +if [ `basename "/./."` != "." ]; then + echo "basename(\"/./.\") is \".\"; expected \"`basename "/./."`"\" +fi + +if [ `dirname "/./."` != "/." ]; then + echo "dirname(\"/./.\") is \"/.\"; expected \"`dirname "/./."`"\" +fi + +if [ `basename "/.//"` != "." ]; then + echo "basename(\"/.//\") is \".\"; expected \"`basename "/.//"`"\" +fi + +if [ `dirname "/.//"` != "/" ]; then + echo "dirname(\"/.//\") is \"/\"; expected \"`dirname "/.//"`"\" +fi + +if [ `basename "."` != "." ]; then + echo "basename(\".\") is \".\"; expected \"`basename "."`"\" +fi + +if [ `dirname "."` != "." ]; then + echo "dirname(\".\") is \".\"; expected \"`dirname "."`"\" +fi + +if [ `basename "f"` != "f" ]; then + echo "basename(\"f\") is \"f\"; expected \"`basename "f"`"\" +fi + +if [ `dirname "f"` != "." ]; then + echo "dirname(\"f\") is \".\"; expected \"`dirname "f"`"\" +fi + +if [ `basename "f/"` != "f" ]; then + echo "basename(\"f/\") is \"f\"; expected \"`basename "f/"`"\" +fi + +if [ `dirname "f/"` != "." ]; then + echo "dirname(\"f/\") is \".\"; expected \"`dirname "f/"`"\" +fi + +if [ `basename "/////"` != "/" ]; then + echo "basename(\"/////\") is \"/\"; expected \"`basename "/////"`"\" +fi + +if [ `dirname "/////"` != "/" ]; then + echo "dirname(\"/////\") is \"/\"; expected \"`dirname "/////"`"\" +fi + +if [ `basename ""` != "." ]; then + echo "basename(\"\") is \".\"; expected \"`basename ""`"\" +fi + +if [ `dirname ""` != "." ]; then + echo "dirname(\"\") is \".\"; expected \"`dirname ""`"\" +fi + + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.bcopy.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.bcopy.d new file mode 100644 index 000000000000..8501ff441fc7 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.bcopy.d @@ -0,0 +1,61 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * bcopy should copy from one memory location to another + * + * SECTION: Actions and Subroutines/alloca(); + * Actions and Subroutines/bcopy() + * + */ + +#pragma D option quiet + + +BEGIN +{ + ptr = alloca(sizeof (int)); + bcopy((void *)&`kmem_flags, ptr, sizeof (int)); + intp = (int *)ptr; + ret = (`kmem_flags == *intp) ? 0 : 1; +} + +tick-1 +/ret == 0/ +{ + exit(0); +} + +tick-1 +/ret == 1/ +{ + printf("memory address contained 0x%x, expected 0x%x\n", + *intp, `kmem_flags); + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.chill.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.chill.ksh new file mode 100644 index 000000000000..aae1c6881b4d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.chill.ksh @@ -0,0 +1,77 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +dtrace_script() +{ + + $dtrace -w -s /dev/stdin < 5/ + { + exit(0); + } +EOF +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +dtrace_script & +child=$! + +wait $child +status=$? + +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.cleanpath.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.cleanpath.d new file mode 100644 index 000000000000..2f0541853a53 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.cleanpath.d @@ -0,0 +1,70 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +BEGIN +{ + path[i++] = "/foo/bar/baz"; + path[i++] = "/foo/bar///baz/"; + path[i++] = "/foo/bar/baz/"; + path[i++] = "/foo/bar/baz//"; + path[i++] = "/foo/bar/baz/."; + path[i++] = "/foo/bar/baz/./"; + path[i++] = "/foo/bar/../../baz/.//"; + path[i++] = "foo/bar/./././././baz/"; + path[i++] = "/foo/bar/baz/../../../../../../"; + path[i++] = "/../../../../../../"; + path[i++] = "/./"; + path[i++] = "/foo/bar/baz/../../bop/bang/../../bar/baz/"; + path[i++] = "./"; + path[i++] = "//"; + path[i++] = "/."; + path[i++] = "/./"; + path[i++] = "/./."; + path[i++] = "/.//"; + path[i++] = "."; + path[i++] = "/////"; + path[i++] = ""; + + end = i; + i = 0; +} + +tick-1ms +/i < end/ +{ + printf("cleanpath(\"%s\") = \"%s\"\n", path[i], cleanpath(path[i])); + i++; +} + +tick-1ms +/i == end/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.cleanpath.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.cleanpath.d.out new file mode 100644 index 000000000000..b8bdc0991e27 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.cleanpath.d.out @@ -0,0 +1,22 @@ +cleanpath("/foo/bar/baz") = "/foo/bar/baz" +cleanpath("/foo/bar///baz/") = "/foo/bar/baz/" +cleanpath("/foo/bar/baz/") = "/foo/bar/baz/" +cleanpath("/foo/bar/baz//") = "/foo/bar/baz/" +cleanpath("/foo/bar/baz/.") = "/foo/bar/baz/." +cleanpath("/foo/bar/baz/./") = "/foo/bar/baz/" +cleanpath("/foo/bar/../../baz/.//") = "/baz/" +cleanpath("foo/bar/./././././baz/") = "foo/bar/baz/" +cleanpath("/foo/bar/baz/../../../../../../") = "/" +cleanpath("/../../../../../../") = "/" +cleanpath("/./") = "/" +cleanpath("/foo/bar/baz/../../bop/bang/../../bar/baz/") = "/foo/bar/baz/" +cleanpath("./") = "./" +cleanpath("//") = "/" +cleanpath("/.") = "/." +cleanpath("/./") = "/" +cleanpath("/./.") = "/." +cleanpath("/.//") = "/" +cleanpath(".") = "." +cleanpath("/////") = "/" +cleanpath("") = "" + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.copyin.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.copyin.d new file mode 100644 index 000000000000..186b97419e82 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.copyin.d @@ -0,0 +1,54 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * This D ditty tests the ability to perform both copyin and copyinstr. We + * grab the value or pr_envp, read the first pointer from the user stack, + * and then copyinstr the first environment variable and print it. + * + * SECTION: Actions and Subroutines/copyin(); + * Actions and Subroutines/copyinstr(); + * User Process Tracing/copyin() and copyinstr() + */ + +BEGIN +/curpsinfo->pr_dmodel == PR_MODEL_ILP32/ +{ + envp = *(uint32_t *)copyin(curpsinfo->pr_envp, sizeof (uint32_t)); + printf("envp[0] = \"%s\"", copyinstr(envp)); + exit(0); +} + +BEGIN +/curpsinfo->pr_dmodel == PR_MODEL_LP64/ +{ + envp = *(uint64_t *)copyin(curpsinfo->pr_envp, sizeof (uint64_t)); + printf("envp[0] = \"%s\"", copyinstr(envp)); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.copyinto.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.copyinto.d new file mode 100644 index 000000000000..c282e61dec47 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.copyinto.d @@ -0,0 +1,56 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * test copyinto by copying the first string of the user's + * environment. + * + * SECTION: Actions and Subroutines/copyinto() + * + */ + +#pragma D option quiet + +BEGIN +/curpsinfo->pr_dmodel == PR_MODEL_ILP32/ +{ + envp = alloca(sizeof (uint32_t)); + copyinto(curpsinfo->pr_envp, sizeof (uint32_t), envp); + printf("envp[0] = \"%s\"", copyinstr(*(uint32_t *)envp)); + exit(0); +} + +BEGIN +/curpsinfo->pr_dmodel == PR_MODEL_LP64/ +{ + envp = alloca(sizeof (uint64_t)); + copyinto(curpsinfo->pr_envp, sizeof (uint64_t), envp); + printf("envp[0] = \"%s\"", copyinstr(*(uint64_t *)envp)); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.ddi_pathname.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.ddi_pathname.d new file mode 100644 index 000000000000..3716d0cef3ea --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.ddi_pathname.d @@ -0,0 +1,64 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +BEGIN +{ + this->dev = (struct dev_info *)alloca(sizeof (struct dev_info)); + this->minor1 = + (struct ddi_minor_data *)alloca(sizeof (struct ddi_minor_data)); + this->minor2 = + (struct ddi_minor_data *)alloca(sizeof (struct ddi_minor_data)); + this->minor3 = + (struct ddi_minor_data *)alloca(sizeof (struct ddi_minor_data)); + + this->minor1->d_minor.dev = 0; + this->minor1->next = this->minor2; + + this->minor2->d_minor.dev = 0; + this->minor2->next = this->minor3; + + this->minor3->d_minor.dev = 0; + this->minor3->next = this->minor1; + + this->dev->devi_minor = this->minor1; + trace(ddi_pathname(this->dev, 1)); +} + +ERROR +/arg4 == DTRACEFLT_ILLOP/ +{ + exit(0); +} + +ERROR +/arg4 != DTRACEFLT_ILLOP/ +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.default.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.default.d new file mode 100644 index 000000000000..c4a4e4f3b343 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.default.d @@ -0,0 +1,64 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * ASSERTION: + * Verify that empty clauses are OK. + * + * SECTION: Actions and Subroutines/Default Action + */ + + +#pragma D option quiet + +BEGIN +{ + i = 1; + +} + +syscall:::entry +{ + + +} + +tick-1 +/i != 0/ +{ + exit(0); +} + + +END +{ + +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.freopen.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.freopen.ksh new file mode 100644 index 000000000000..f87d6e18fae5 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.freopen.ksh @@ -0,0 +1,111 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" + +script() +{ + $dtrace -wq -o $tmpfile -s /dev/stdin $tmpfile <' + exit 2 +fi + +dtrace=$1 +tmpfile=/tmp/tst.freopen.$$ +iter=20 + +script +status=$? + +let i=0 + +if [ -f $tmpfile.$iter ]; then + echo "$0: did not expect to find file: $tmpfile.$iter" + cleanup + exit 100 +fi + +mv $tmpfile $tmpfile.$iter +let iter=iter+1 + +while [ "$i" -lt "$iter" ]; do + if [ ! -f $tmpfile.$i ]; then + echo "$0: did not find expected file: $tmpfile.$i" + cleanup + exit 101 + fi + + j=`cat $tmpfile.$i` + + if [ "$i" -ne "$j" ]; then + echo "$0: unexpected contents in $tmpfile.$i: " \ + "expected $i, found $j" + cleanup + exit 102 + fi + + rm $tmpfile.$i + let i=i+1 +done + +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.ftruncate.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.ftruncate.ksh new file mode 100644 index 000000000000..b02af07b4a69 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.ftruncate.ksh @@ -0,0 +1,64 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" + +script() +{ + $dtrace -q -o $tmpfile -s /dev/stdin <' + exit 2 +fi + +dtrace=$1 +tmpfile=/tmp/tst.ftruncate.$$ + +script +status=$? + +cat $tmpfile +rm $tmpfile + +exit $status diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.ftruncate.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.ftruncate.ksh.out new file mode 100644 index 000000000000..3360fd26d24b --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.ftruncate.ksh.out @@ -0,0 +1,11 @@ +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.hton.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.hton.d new file mode 100644 index 000000000000..4908251a68e0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.hton.d @@ -0,0 +1,99 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Test network byte-ordering routines. + */ + +#if defined(__amd64__) || defined(__i386__) +#define _LITTLE_ENDIAN +#endif + +BEGIN +{ + before[0] = 0x1122LL; + before[1] = 0x11223344LL; + before[2] = 0x1122334455667788LL; + +#ifdef _LITTLE_ENDIAN + after[0] = 0x2211LL; + after[1] = 0x44332211LL; + after[2] = 0x8877665544332211LL; +#else + after[0] = 0x1122LL; + after[1] = 0x11223344LL; + after[2] = 0x1122334455667788LL; +#endif +} + +BEGIN +/after[0] != htons(before[0])/ +{ + printf("%x rather than %x", htons(before[0]), after[0]); + exit(1); +} + +BEGIN +/after[0] != ntohs(before[0])/ +{ + printf("%x rather than %x", ntohs(before[0]), after[0]); + exit(1); +} + +BEGIN +/after[1] != htonl(before[1])/ +{ + printf("%x rather than %x", htonl(before[1]), after[1]); + exit(1); +} + +BEGIN +/after[1] != ntohl(before[1])/ +{ + printf("%x rather than %x", ntohl(before[1]), after[1]); + exit(1); +} + +BEGIN +/after[2] != htonll(before[2])/ +{ + printf("%x rather than %x", htonll(before[2]), after[2]); + exit(1); +} + +BEGIN +/after[2] != ntohll(before[2])/ +{ + printf("%x rather than %x", ntohll(before[2]), after[2]); + exit(1); +} + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.index.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.index.d new file mode 100644 index 000000000000..547730a14ea1 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.index.d @@ -0,0 +1,226 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +struct { + string str; + string substr; + int haspos; + int position; +} command[int]; + +int i; + +BEGIN +{ + command[i].str = "foobarbaz"; + command[i].substr = "barbaz"; + i++; + + command[i].str = "foofoofoo"; + command[i].substr = "foo"; + i++; + + command[i].str = "boofoofoo"; + command[i].substr = "foo"; + i++; + + command[i].str = "foobarbaz"; + command[i].substr = "barbazzy"; + i++; + + command[i].str = "foobar"; + command[i].substr = "foobar"; + i++; + + command[i].str = "foobar"; + command[i].substr = "foobarbaz"; + i++; + + command[i].str = ""; + command[i].substr = "foobar"; + i++; + + command[i].str = "foobar"; + command[i].substr = ""; + i++; + + command[i].str = ""; + command[i].substr = ""; + i++; + + command[i].str = "foo"; + command[i].substr = ""; + i++; + + end = j = k = 0; + printf("#!/usr/perl5/bin/perl\n\nBEGIN {\n"); +} + +tick-1ms +/j < i && end == 0/ +{ + command[i + k].str = command[j].str; + command[i + k].substr = command[j].substr; + command[i + k].haspos = 1; + command[i + k].position = -400; + k++; + + command[i + k].str = command[j].str; + command[i + k].substr = command[j].substr; + command[i + k].haspos = 1; + command[i + k].position = -1; + k++; + + command[i + k].str = command[j].str; + command[i + k].substr = command[j].substr; + command[i + k].haspos = 1; + command[i + k].position = 0; + k++; + + command[i + k].str = command[j].str; + command[i + k].substr = command[j].substr; + command[i + k].haspos = 1; + command[i + k].position = strlen(command[j].str) / 2; + k++; + + command[i + k].str = command[j].str; + command[i + k].substr = command[j].substr; + command[i + k].haspos = 1; + command[i + k].position = strlen(command[j].str); + k++; + + command[i + k].str = command[j].str; + command[i + k].substr = command[j].substr; + command[i + k].haspos = 1; + command[i + k].position = strlen(command[j].str) + 1; + k++; + + command[i + k].str = command[j].str; + command[i + k].substr = command[j].substr; + command[i + k].haspos = 1; + command[i + k].position = strlen(command[j].str) + 2; + k++; + + command[i + k].str = command[j].str; + command[i + k].substr = command[j].substr; + command[i + k].haspos = 1; + command[i + k].position = 400; + k++; + + j++; +} + +tick-1ms +/j == i && end == 0/ +{ + end = k; + i = 0; +} + +tick-1ms +/end != 0 && i < end && !command[i].haspos/ +{ + this->result = index(command[i].str, command[i].substr); + + printf("\tif (index(\"%s\", \"%s\") != %d) {\n", + command[i].str, command[i].substr, this->result); + printf("\t\tprintf(\"perl => index(\\\"%s\\\", \\\"%s\\\") = ", + command[i].str, command[i].substr); + printf("%%d\\n\",\n\t\t index(\"%s\", \"%s\"));\n", + command[i].str, command[i].substr); + printf("\t\tprintf(\" D => index(\\\"%s\\\", \\\"%s\\\") = ", + command[i].str, command[i].substr); + printf("%d\\n\");\n", this->result); + printf("\t\t$failed++;\n"); + printf("\t}\n\n"); +} + +tick-1ms +/end != 0 && i < end && !command[i].haspos/ +{ + this->result = rindex(command[i].str, command[i].substr); + + printf("\tif (rindex(\"%s\", \"%s\") != %d) {\n", + command[i].str, command[i].substr, this->result); + printf("\t\tprintf(\"perl => rindex(\\\"%s\\\", \\\"%s\\\") = ", + command[i].str, command[i].substr); + printf("%%d\\n\",\n\t\t rindex(\"%s\", \"%s\"));\n", + command[i].str, command[i].substr); + printf("\t\tprintf(\" D => rindex(\\\"%s\\\", \\\"%s\\\") = ", + command[i].str, command[i].substr); + printf("%d\\n\");\n", this->result); + printf("\t\t$failed++;\n"); + printf("\t}\n\n"); +} + +tick-1ms +/end != 0 && i < end && command[i].haspos/ +{ + this->result = index(command[i].str, + command[i].substr, command[i].position); + + printf("\tif (index(\"%s\", \"%s\", %d) != %d) {\n", command[i].str, + command[i].substr, command[i].position, this->result); + printf("\t\tprintf(\"perl => index(\\\"%s\\\", \\\"%s\\\", %d) = ", + command[i].str, command[i].substr, command[i].position); + printf("%%d\\n\",\n\t\t index(\"%s\", \"%s\", %d));\n", + command[i].str, command[i].substr, command[i].position); + printf("\t\tprintf(\" D => index(\\\"%s\\\", \\\"%s\\\", %d) = ", + command[i].str, command[i].substr, command[i].position); + printf("%d\\n\");\n", this->result); + printf("\t\t$failed++;\n"); + printf("\t}\n\n"); +} + +tick-1ms +/end != 0 && i < end && command[i].haspos/ +{ + this->result = rindex(command[i].str, + command[i].substr, command[i].position); + + printf("\tif (rindex(\"%s\", \"%s\", %d) != %d) {\n", command[i].str, + command[i].substr, command[i].position, this->result); + printf("\t\tprintf(\"perl => rindex(\\\"%s\\\", \\\"%s\\\", %d) = ", + command[i].str, command[i].substr, command[i].position); + printf("%%d\\n\",\n\t\t rindex(\"%s\", \"%s\", %d));\n", + command[i].str, command[i].substr, command[i].position); + printf("\t\tprintf(\" D => rindex(\\\"%s\\\", \\\"%s\\\", %d) = ", + command[i].str, command[i].substr, command[i].position); + printf("%d\\n\");\n", this->result); + printf("\t\t$failed++;\n"); + printf("\t}\n\n"); +} + +tick-1ms +/end != 0 && ++i == end/ +{ + printf("\texit($failed);\n}\n"); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.index.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.index.d.out new file mode 100644 index 000000000000..276576c26f7c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.index.d.out @@ -0,0 +1,1126 @@ +#!/usr/perl5/bin/perl + +BEGIN { + if (index("foobarbaz", "barbaz") != 3) { + printf("perl => index(\"foobarbaz\", \"barbaz\") = %d\n", + index("foobarbaz", "barbaz")); + printf(" D => index(\"foobarbaz\", \"barbaz\") = 3\n"); + $failed++; + } + + if (rindex("foobarbaz", "barbaz") != 3) { + printf("perl => rindex(\"foobarbaz\", \"barbaz\") = %d\n", + rindex("foobarbaz", "barbaz")); + printf(" D => rindex(\"foobarbaz\", \"barbaz\") = 3\n"); + $failed++; + } + + if (index("foofoofoo", "foo") != 0) { + printf("perl => index(\"foofoofoo\", \"foo\") = %d\n", + index("foofoofoo", "foo")); + printf(" D => index(\"foofoofoo\", \"foo\") = 0\n"); + $failed++; + } + + if (rindex("foofoofoo", "foo") != 6) { + printf("perl => rindex(\"foofoofoo\", \"foo\") = %d\n", + rindex("foofoofoo", "foo")); + printf(" D => rindex(\"foofoofoo\", \"foo\") = 6\n"); + $failed++; + } + + if (index("boofoofoo", "foo") != 3) { + printf("perl => index(\"boofoofoo\", \"foo\") = %d\n", + index("boofoofoo", "foo")); + printf(" D => index(\"boofoofoo\", \"foo\") = 3\n"); + $failed++; + } + + if (rindex("boofoofoo", "foo") != 6) { + printf("perl => rindex(\"boofoofoo\", \"foo\") = %d\n", + rindex("boofoofoo", "foo")); + printf(" D => rindex(\"boofoofoo\", \"foo\") = 6\n"); + $failed++; + } + + if (index("foobarbaz", "barbazzy") != -1) { + printf("perl => index(\"foobarbaz\", \"barbazzy\") = %d\n", + index("foobarbaz", "barbazzy")); + printf(" D => index(\"foobarbaz\", \"barbazzy\") = -1\n"); + $failed++; + } + + if (rindex("foobarbaz", "barbazzy") != -1) { + printf("perl => rindex(\"foobarbaz\", \"barbazzy\") = %d\n", + rindex("foobarbaz", "barbazzy")); + printf(" D => rindex(\"foobarbaz\", \"barbazzy\") = -1\n"); + $failed++; + } + + if (index("foobar", "foobar") != 0) { + printf("perl => index(\"foobar\", \"foobar\") = %d\n", + index("foobar", "foobar")); + printf(" D => index(\"foobar\", \"foobar\") = 0\n"); + $failed++; + } + + if (rindex("foobar", "foobar") != 0) { + printf("perl => rindex(\"foobar\", \"foobar\") = %d\n", + rindex("foobar", "foobar")); + printf(" D => rindex(\"foobar\", \"foobar\") = 0\n"); + $failed++; + } + + if (index("foobar", "foobarbaz") != -1) { + printf("perl => index(\"foobar\", \"foobarbaz\") = %d\n", + index("foobar", "foobarbaz")); + printf(" D => index(\"foobar\", \"foobarbaz\") = -1\n"); + $failed++; + } + + if (rindex("foobar", "foobarbaz") != -1) { + printf("perl => rindex(\"foobar\", \"foobarbaz\") = %d\n", + rindex("foobar", "foobarbaz")); + printf(" D => rindex(\"foobar\", \"foobarbaz\") = -1\n"); + $failed++; + } + + if (index("", "foobar") != -1) { + printf("perl => index(\"\", \"foobar\") = %d\n", + index("", "foobar")); + printf(" D => index(\"\", \"foobar\") = -1\n"); + $failed++; + } + + if (rindex("", "foobar") != -1) { + printf("perl => rindex(\"\", \"foobar\") = %d\n", + rindex("", "foobar")); + printf(" D => rindex(\"\", \"foobar\") = -1\n"); + $failed++; + } + + if (index("foobar", "") != 0) { + printf("perl => index(\"foobar\", \"\") = %d\n", + index("foobar", "")); + printf(" D => index(\"foobar\", \"\") = 0\n"); + $failed++; + } + + if (rindex("foobar", "") != 6) { + printf("perl => rindex(\"foobar\", \"\") = %d\n", + rindex("foobar", "")); + printf(" D => rindex(\"foobar\", \"\") = 6\n"); + $failed++; + } + + if (index("", "") != 0) { + printf("perl => index(\"\", \"\") = %d\n", + index("", "")); + printf(" D => index(\"\", \"\") = 0\n"); + $failed++; + } + + if (rindex("", "") != 0) { + printf("perl => rindex(\"\", \"\") = %d\n", + rindex("", "")); + printf(" D => rindex(\"\", \"\") = 0\n"); + $failed++; + } + + if (index("foo", "") != 0) { + printf("perl => index(\"foo\", \"\") = %d\n", + index("foo", "")); + printf(" D => index(\"foo\", \"\") = 0\n"); + $failed++; + } + + if (rindex("foo", "") != 3) { + printf("perl => rindex(\"foo\", \"\") = %d\n", + rindex("foo", "")); + printf(" D => rindex(\"foo\", \"\") = 3\n"); + $failed++; + } + + if (index("foobarbaz", "barbaz", -400) != 3) { + printf("perl => index(\"foobarbaz\", \"barbaz\", -400) = %d\n", + index("foobarbaz", "barbaz", -400)); + printf(" D => index(\"foobarbaz\", \"barbaz\", -400) = 3\n"); + $failed++; + } + + if (rindex("foobarbaz", "barbaz", -400) != -1) { + printf("perl => rindex(\"foobarbaz\", \"barbaz\", -400) = %d\n", + rindex("foobarbaz", "barbaz", -400)); + printf(" D => rindex(\"foobarbaz\", \"barbaz\", -400) = -1\n"); + $failed++; + } + + if (index("foobarbaz", "barbaz", -1) != 3) { + printf("perl => index(\"foobarbaz\", \"barbaz\", -1) = %d\n", + index("foobarbaz", "barbaz", -1)); + printf(" D => index(\"foobarbaz\", \"barbaz\", -1) = 3\n"); + $failed++; + } + + if (rindex("foobarbaz", "barbaz", -1) != -1) { + printf("perl => rindex(\"foobarbaz\", \"barbaz\", -1) = %d\n", + rindex("foobarbaz", "barbaz", -1)); + printf(" D => rindex(\"foobarbaz\", \"barbaz\", -1) = -1\n"); + $failed++; + } + + if (index("foobarbaz", "barbaz", 0) != 3) { + printf("perl => index(\"foobarbaz\", \"barbaz\", 0) = %d\n", + index("foobarbaz", "barbaz", 0)); + printf(" D => index(\"foobarbaz\", \"barbaz\", 0) = 3\n"); + $failed++; + } + + if (rindex("foobarbaz", "barbaz", 0) != -1) { + printf("perl => rindex(\"foobarbaz\", \"barbaz\", 0) = %d\n", + rindex("foobarbaz", "barbaz", 0)); + printf(" D => rindex(\"foobarbaz\", \"barbaz\", 0) = -1\n"); + $failed++; + } + + if (index("foobarbaz", "barbaz", 4) != -1) { + printf("perl => index(\"foobarbaz\", \"barbaz\", 4) = %d\n", + index("foobarbaz", "barbaz", 4)); + printf(" D => index(\"foobarbaz\", \"barbaz\", 4) = -1\n"); + $failed++; + } + + if (rindex("foobarbaz", "barbaz", 4) != 3) { + printf("perl => rindex(\"foobarbaz\", \"barbaz\", 4) = %d\n", + rindex("foobarbaz", "barbaz", 4)); + printf(" D => rindex(\"foobarbaz\", \"barbaz\", 4) = 3\n"); + $failed++; + } + + if (index("foobarbaz", "barbaz", 9) != -1) { + printf("perl => index(\"foobarbaz\", \"barbaz\", 9) = %d\n", + index("foobarbaz", "barbaz", 9)); + printf(" D => index(\"foobarbaz\", \"barbaz\", 9) = -1\n"); + $failed++; + } + + if (rindex("foobarbaz", "barbaz", 9) != 3) { + printf("perl => rindex(\"foobarbaz\", \"barbaz\", 9) = %d\n", + rindex("foobarbaz", "barbaz", 9)); + printf(" D => rindex(\"foobarbaz\", \"barbaz\", 9) = 3\n"); + $failed++; + } + + if (index("foobarbaz", "barbaz", 10) != -1) { + printf("perl => index(\"foobarbaz\", \"barbaz\", 10) = %d\n", + index("foobarbaz", "barbaz", 10)); + printf(" D => index(\"foobarbaz\", \"barbaz\", 10) = -1\n"); + $failed++; + } + + if (rindex("foobarbaz", "barbaz", 10) != 3) { + printf("perl => rindex(\"foobarbaz\", \"barbaz\", 10) = %d\n", + rindex("foobarbaz", "barbaz", 10)); + printf(" D => rindex(\"foobarbaz\", \"barbaz\", 10) = 3\n"); + $failed++; + } + + if (index("foobarbaz", "barbaz", 11) != -1) { + printf("perl => index(\"foobarbaz\", \"barbaz\", 11) = %d\n", + index("foobarbaz", "barbaz", 11)); + printf(" D => index(\"foobarbaz\", \"barbaz\", 11) = -1\n"); + $failed++; + } + + if (rindex("foobarbaz", "barbaz", 11) != 3) { + printf("perl => rindex(\"foobarbaz\", \"barbaz\", 11) = %d\n", + rindex("foobarbaz", "barbaz", 11)); + printf(" D => rindex(\"foobarbaz\", \"barbaz\", 11) = 3\n"); + $failed++; + } + + if (index("foobarbaz", "barbaz", 400) != -1) { + printf("perl => index(\"foobarbaz\", \"barbaz\", 400) = %d\n", + index("foobarbaz", "barbaz", 400)); + printf(" D => index(\"foobarbaz\", \"barbaz\", 400) = -1\n"); + $failed++; + } + + if (rindex("foobarbaz", "barbaz", 400) != 3) { + printf("perl => rindex(\"foobarbaz\", \"barbaz\", 400) = %d\n", + rindex("foobarbaz", "barbaz", 400)); + printf(" D => rindex(\"foobarbaz\", \"barbaz\", 400) = 3\n"); + $failed++; + } + + if (index("foofoofoo", "foo", -400) != 0) { + printf("perl => index(\"foofoofoo\", \"foo\", -400) = %d\n", + index("foofoofoo", "foo", -400)); + printf(" D => index(\"foofoofoo\", \"foo\", -400) = 0\n"); + $failed++; + } + + if (rindex("foofoofoo", "foo", -400) != -1) { + printf("perl => rindex(\"foofoofoo\", \"foo\", -400) = %d\n", + rindex("foofoofoo", "foo", -400)); + printf(" D => rindex(\"foofoofoo\", \"foo\", -400) = -1\n"); + $failed++; + } + + if (index("foofoofoo", "foo", -1) != 0) { + printf("perl => index(\"foofoofoo\", \"foo\", -1) = %d\n", + index("foofoofoo", "foo", -1)); + printf(" D => index(\"foofoofoo\", \"foo\", -1) = 0\n"); + $failed++; + } + + if (rindex("foofoofoo", "foo", -1) != -1) { + printf("perl => rindex(\"foofoofoo\", \"foo\", -1) = %d\n", + rindex("foofoofoo", "foo", -1)); + printf(" D => rindex(\"foofoofoo\", \"foo\", -1) = -1\n"); + $failed++; + } + + if (index("foofoofoo", "foo", 0) != 0) { + printf("perl => index(\"foofoofoo\", \"foo\", 0) = %d\n", + index("foofoofoo", "foo", 0)); + printf(" D => index(\"foofoofoo\", \"foo\", 0) = 0\n"); + $failed++; + } + + if (rindex("foofoofoo", "foo", 0) != 0) { + printf("perl => rindex(\"foofoofoo\", \"foo\", 0) = %d\n", + rindex("foofoofoo", "foo", 0)); + printf(" D => rindex(\"foofoofoo\", \"foo\", 0) = 0\n"); + $failed++; + } + + if (index("foofoofoo", "foo", 4) != 6) { + printf("perl => index(\"foofoofoo\", \"foo\", 4) = %d\n", + index("foofoofoo", "foo", 4)); + printf(" D => index(\"foofoofoo\", \"foo\", 4) = 6\n"); + $failed++; + } + + if (rindex("foofoofoo", "foo", 4) != 3) { + printf("perl => rindex(\"foofoofoo\", \"foo\", 4) = %d\n", + rindex("foofoofoo", "foo", 4)); + printf(" D => rindex(\"foofoofoo\", \"foo\", 4) = 3\n"); + $failed++; + } + + if (index("foofoofoo", "foo", 9) != -1) { + printf("perl => index(\"foofoofoo\", \"foo\", 9) = %d\n", + index("foofoofoo", "foo", 9)); + printf(" D => index(\"foofoofoo\", \"foo\", 9) = -1\n"); + $failed++; + } + + if (rindex("foofoofoo", "foo", 9) != 6) { + printf("perl => rindex(\"foofoofoo\", \"foo\", 9) = %d\n", + rindex("foofoofoo", "foo", 9)); + printf(" D => rindex(\"foofoofoo\", \"foo\", 9) = 6\n"); + $failed++; + } + + if (index("foofoofoo", "foo", 10) != -1) { + printf("perl => index(\"foofoofoo\", \"foo\", 10) = %d\n", + index("foofoofoo", "foo", 10)); + printf(" D => index(\"foofoofoo\", \"foo\", 10) = -1\n"); + $failed++; + } + + if (rindex("foofoofoo", "foo", 10) != 6) { + printf("perl => rindex(\"foofoofoo\", \"foo\", 10) = %d\n", + rindex("foofoofoo", "foo", 10)); + printf(" D => rindex(\"foofoofoo\", \"foo\", 10) = 6\n"); + $failed++; + } + + if (index("foofoofoo", "foo", 11) != -1) { + printf("perl => index(\"foofoofoo\", \"foo\", 11) = %d\n", + index("foofoofoo", "foo", 11)); + printf(" D => index(\"foofoofoo\", \"foo\", 11) = -1\n"); + $failed++; + } + + if (rindex("foofoofoo", "foo", 11) != 6) { + printf("perl => rindex(\"foofoofoo\", \"foo\", 11) = %d\n", + rindex("foofoofoo", "foo", 11)); + printf(" D => rindex(\"foofoofoo\", \"foo\", 11) = 6\n"); + $failed++; + } + + if (index("foofoofoo", "foo", 400) != -1) { + printf("perl => index(\"foofoofoo\", \"foo\", 400) = %d\n", + index("foofoofoo", "foo", 400)); + printf(" D => index(\"foofoofoo\", \"foo\", 400) = -1\n"); + $failed++; + } + + if (rindex("foofoofoo", "foo", 400) != 6) { + printf("perl => rindex(\"foofoofoo\", \"foo\", 400) = %d\n", + rindex("foofoofoo", "foo", 400)); + printf(" D => rindex(\"foofoofoo\", \"foo\", 400) = 6\n"); + $failed++; + } + + if (index("boofoofoo", "foo", -400) != 3) { + printf("perl => index(\"boofoofoo\", \"foo\", -400) = %d\n", + index("boofoofoo", "foo", -400)); + printf(" D => index(\"boofoofoo\", \"foo\", -400) = 3\n"); + $failed++; + } + + if (rindex("boofoofoo", "foo", -400) != -1) { + printf("perl => rindex(\"boofoofoo\", \"foo\", -400) = %d\n", + rindex("boofoofoo", "foo", -400)); + printf(" D => rindex(\"boofoofoo\", \"foo\", -400) = -1\n"); + $failed++; + } + + if (index("boofoofoo", "foo", -1) != 3) { + printf("perl => index(\"boofoofoo\", \"foo\", -1) = %d\n", + index("boofoofoo", "foo", -1)); + printf(" D => index(\"boofoofoo\", \"foo\", -1) = 3\n"); + $failed++; + } + + if (rindex("boofoofoo", "foo", -1) != -1) { + printf("perl => rindex(\"boofoofoo\", \"foo\", -1) = %d\n", + rindex("boofoofoo", "foo", -1)); + printf(" D => rindex(\"boofoofoo\", \"foo\", -1) = -1\n"); + $failed++; + } + + if (index("boofoofoo", "foo", 0) != 3) { + printf("perl => index(\"boofoofoo\", \"foo\", 0) = %d\n", + index("boofoofoo", "foo", 0)); + printf(" D => index(\"boofoofoo\", \"foo\", 0) = 3\n"); + $failed++; + } + + if (rindex("boofoofoo", "foo", 0) != -1) { + printf("perl => rindex(\"boofoofoo\", \"foo\", 0) = %d\n", + rindex("boofoofoo", "foo", 0)); + printf(" D => rindex(\"boofoofoo\", \"foo\", 0) = -1\n"); + $failed++; + } + + if (index("boofoofoo", "foo", 4) != 6) { + printf("perl => index(\"boofoofoo\", \"foo\", 4) = %d\n", + index("boofoofoo", "foo", 4)); + printf(" D => index(\"boofoofoo\", \"foo\", 4) = 6\n"); + $failed++; + } + + if (rindex("boofoofoo", "foo", 4) != 3) { + printf("perl => rindex(\"boofoofoo\", \"foo\", 4) = %d\n", + rindex("boofoofoo", "foo", 4)); + printf(" D => rindex(\"boofoofoo\", \"foo\", 4) = 3\n"); + $failed++; + } + + if (index("boofoofoo", "foo", 9) != -1) { + printf("perl => index(\"boofoofoo\", \"foo\", 9) = %d\n", + index("boofoofoo", "foo", 9)); + printf(" D => index(\"boofoofoo\", \"foo\", 9) = -1\n"); + $failed++; + } + + if (rindex("boofoofoo", "foo", 9) != 6) { + printf("perl => rindex(\"boofoofoo\", \"foo\", 9) = %d\n", + rindex("boofoofoo", "foo", 9)); + printf(" D => rindex(\"boofoofoo\", \"foo\", 9) = 6\n"); + $failed++; + } + + if (index("boofoofoo", "foo", 10) != -1) { + printf("perl => index(\"boofoofoo\", \"foo\", 10) = %d\n", + index("boofoofoo", "foo", 10)); + printf(" D => index(\"boofoofoo\", \"foo\", 10) = -1\n"); + $failed++; + } + + if (rindex("boofoofoo", "foo", 10) != 6) { + printf("perl => rindex(\"boofoofoo\", \"foo\", 10) = %d\n", + rindex("boofoofoo", "foo", 10)); + printf(" D => rindex(\"boofoofoo\", \"foo\", 10) = 6\n"); + $failed++; + } + + if (index("boofoofoo", "foo", 11) != -1) { + printf("perl => index(\"boofoofoo\", \"foo\", 11) = %d\n", + index("boofoofoo", "foo", 11)); + printf(" D => index(\"boofoofoo\", \"foo\", 11) = -1\n"); + $failed++; + } + + if (rindex("boofoofoo", "foo", 11) != 6) { + printf("perl => rindex(\"boofoofoo\", \"foo\", 11) = %d\n", + rindex("boofoofoo", "foo", 11)); + printf(" D => rindex(\"boofoofoo\", \"foo\", 11) = 6\n"); + $failed++; + } + + if (index("boofoofoo", "foo", 400) != -1) { + printf("perl => index(\"boofoofoo\", \"foo\", 400) = %d\n", + index("boofoofoo", "foo", 400)); + printf(" D => index(\"boofoofoo\", \"foo\", 400) = -1\n"); + $failed++; + } + + if (rindex("boofoofoo", "foo", 400) != 6) { + printf("perl => rindex(\"boofoofoo\", \"foo\", 400) = %d\n", + rindex("boofoofoo", "foo", 400)); + printf(" D => rindex(\"boofoofoo\", \"foo\", 400) = 6\n"); + $failed++; + } + + if (index("foobarbaz", "barbazzy", -400) != -1) { + printf("perl => index(\"foobarbaz\", \"barbazzy\", -400) = %d\n", + index("foobarbaz", "barbazzy", -400)); + printf(" D => index(\"foobarbaz\", \"barbazzy\", -400) = -1\n"); + $failed++; + } + + if (rindex("foobarbaz", "barbazzy", -400) != -1) { + printf("perl => rindex(\"foobarbaz\", \"barbazzy\", -400) = %d\n", + rindex("foobarbaz", "barbazzy", -400)); + printf(" D => rindex(\"foobarbaz\", \"barbazzy\", -400) = -1\n"); + $failed++; + } + + if (index("foobarbaz", "barbazzy", -1) != -1) { + printf("perl => index(\"foobarbaz\", \"barbazzy\", -1) = %d\n", + index("foobarbaz", "barbazzy", -1)); + printf(" D => index(\"foobarbaz\", \"barbazzy\", -1) = -1\n"); + $failed++; + } + + if (rindex("foobarbaz", "barbazzy", -1) != -1) { + printf("perl => rindex(\"foobarbaz\", \"barbazzy\", -1) = %d\n", + rindex("foobarbaz", "barbazzy", -1)); + printf(" D => rindex(\"foobarbaz\", \"barbazzy\", -1) = -1\n"); + $failed++; + } + + if (index("foobarbaz", "barbazzy", 0) != -1) { + printf("perl => index(\"foobarbaz\", \"barbazzy\", 0) = %d\n", + index("foobarbaz", "barbazzy", 0)); + printf(" D => index(\"foobarbaz\", \"barbazzy\", 0) = -1\n"); + $failed++; + } + + if (rindex("foobarbaz", "barbazzy", 0) != -1) { + printf("perl => rindex(\"foobarbaz\", \"barbazzy\", 0) = %d\n", + rindex("foobarbaz", "barbazzy", 0)); + printf(" D => rindex(\"foobarbaz\", \"barbazzy\", 0) = -1\n"); + $failed++; + } + + if (index("foobarbaz", "barbazzy", 4) != -1) { + printf("perl => index(\"foobarbaz\", \"barbazzy\", 4) = %d\n", + index("foobarbaz", "barbazzy", 4)); + printf(" D => index(\"foobarbaz\", \"barbazzy\", 4) = -1\n"); + $failed++; + } + + if (rindex("foobarbaz", "barbazzy", 4) != -1) { + printf("perl => rindex(\"foobarbaz\", \"barbazzy\", 4) = %d\n", + rindex("foobarbaz", "barbazzy", 4)); + printf(" D => rindex(\"foobarbaz\", \"barbazzy\", 4) = -1\n"); + $failed++; + } + + if (index("foobarbaz", "barbazzy", 9) != -1) { + printf("perl => index(\"foobarbaz\", \"barbazzy\", 9) = %d\n", + index("foobarbaz", "barbazzy", 9)); + printf(" D => index(\"foobarbaz\", \"barbazzy\", 9) = -1\n"); + $failed++; + } + + if (rindex("foobarbaz", "barbazzy", 9) != -1) { + printf("perl => rindex(\"foobarbaz\", \"barbazzy\", 9) = %d\n", + rindex("foobarbaz", "barbazzy", 9)); + printf(" D => rindex(\"foobarbaz\", \"barbazzy\", 9) = -1\n"); + $failed++; + } + + if (index("foobarbaz", "barbazzy", 10) != -1) { + printf("perl => index(\"foobarbaz\", \"barbazzy\", 10) = %d\n", + index("foobarbaz", "barbazzy", 10)); + printf(" D => index(\"foobarbaz\", \"barbazzy\", 10) = -1\n"); + $failed++; + } + + if (rindex("foobarbaz", "barbazzy", 10) != -1) { + printf("perl => rindex(\"foobarbaz\", \"barbazzy\", 10) = %d\n", + rindex("foobarbaz", "barbazzy", 10)); + printf(" D => rindex(\"foobarbaz\", \"barbazzy\", 10) = -1\n"); + $failed++; + } + + if (index("foobarbaz", "barbazzy", 11) != -1) { + printf("perl => index(\"foobarbaz\", \"barbazzy\", 11) = %d\n", + index("foobarbaz", "barbazzy", 11)); + printf(" D => index(\"foobarbaz\", \"barbazzy\", 11) = -1\n"); + $failed++; + } + + if (rindex("foobarbaz", "barbazzy", 11) != -1) { + printf("perl => rindex(\"foobarbaz\", \"barbazzy\", 11) = %d\n", + rindex("foobarbaz", "barbazzy", 11)); + printf(" D => rindex(\"foobarbaz\", \"barbazzy\", 11) = -1\n"); + $failed++; + } + + if (index("foobarbaz", "barbazzy", 400) != -1) { + printf("perl => index(\"foobarbaz\", \"barbazzy\", 400) = %d\n", + index("foobarbaz", "barbazzy", 400)); + printf(" D => index(\"foobarbaz\", \"barbazzy\", 400) = -1\n"); + $failed++; + } + + if (rindex("foobarbaz", "barbazzy", 400) != -1) { + printf("perl => rindex(\"foobarbaz\", \"barbazzy\", 400) = %d\n", + rindex("foobarbaz", "barbazzy", 400)); + printf(" D => rindex(\"foobarbaz\", \"barbazzy\", 400) = -1\n"); + $failed++; + } + + if (index("foobar", "foobar", -400) != 0) { + printf("perl => index(\"foobar\", \"foobar\", -400) = %d\n", + index("foobar", "foobar", -400)); + printf(" D => index(\"foobar\", \"foobar\", -400) = 0\n"); + $failed++; + } + + if (rindex("foobar", "foobar", -400) != -1) { + printf("perl => rindex(\"foobar\", \"foobar\", -400) = %d\n", + rindex("foobar", "foobar", -400)); + printf(" D => rindex(\"foobar\", \"foobar\", -400) = -1\n"); + $failed++; + } + + if (index("foobar", "foobar", -1) != 0) { + printf("perl => index(\"foobar\", \"foobar\", -1) = %d\n", + index("foobar", "foobar", -1)); + printf(" D => index(\"foobar\", \"foobar\", -1) = 0\n"); + $failed++; + } + + if (rindex("foobar", "foobar", -1) != -1) { + printf("perl => rindex(\"foobar\", \"foobar\", -1) = %d\n", + rindex("foobar", "foobar", -1)); + printf(" D => rindex(\"foobar\", \"foobar\", -1) = -1\n"); + $failed++; + } + + if (index("foobar", "foobar", 0) != 0) { + printf("perl => index(\"foobar\", \"foobar\", 0) = %d\n", + index("foobar", "foobar", 0)); + printf(" D => index(\"foobar\", \"foobar\", 0) = 0\n"); + $failed++; + } + + if (rindex("foobar", "foobar", 0) != 0) { + printf("perl => rindex(\"foobar\", \"foobar\", 0) = %d\n", + rindex("foobar", "foobar", 0)); + printf(" D => rindex(\"foobar\", \"foobar\", 0) = 0\n"); + $failed++; + } + + if (index("foobar", "foobar", 3) != -1) { + printf("perl => index(\"foobar\", \"foobar\", 3) = %d\n", + index("foobar", "foobar", 3)); + printf(" D => index(\"foobar\", \"foobar\", 3) = -1\n"); + $failed++; + } + + if (rindex("foobar", "foobar", 3) != 0) { + printf("perl => rindex(\"foobar\", \"foobar\", 3) = %d\n", + rindex("foobar", "foobar", 3)); + printf(" D => rindex(\"foobar\", \"foobar\", 3) = 0\n"); + $failed++; + } + + if (index("foobar", "foobar", 6) != -1) { + printf("perl => index(\"foobar\", \"foobar\", 6) = %d\n", + index("foobar", "foobar", 6)); + printf(" D => index(\"foobar\", \"foobar\", 6) = -1\n"); + $failed++; + } + + if (rindex("foobar", "foobar", 6) != 0) { + printf("perl => rindex(\"foobar\", \"foobar\", 6) = %d\n", + rindex("foobar", "foobar", 6)); + printf(" D => rindex(\"foobar\", \"foobar\", 6) = 0\n"); + $failed++; + } + + if (index("foobar", "foobar", 7) != -1) { + printf("perl => index(\"foobar\", \"foobar\", 7) = %d\n", + index("foobar", "foobar", 7)); + printf(" D => index(\"foobar\", \"foobar\", 7) = -1\n"); + $failed++; + } + + if (rindex("foobar", "foobar", 7) != 0) { + printf("perl => rindex(\"foobar\", \"foobar\", 7) = %d\n", + rindex("foobar", "foobar", 7)); + printf(" D => rindex(\"foobar\", \"foobar\", 7) = 0\n"); + $failed++; + } + + if (index("foobar", "foobar", 8) != -1) { + printf("perl => index(\"foobar\", \"foobar\", 8) = %d\n", + index("foobar", "foobar", 8)); + printf(" D => index(\"foobar\", \"foobar\", 8) = -1\n"); + $failed++; + } + + if (rindex("foobar", "foobar", 8) != 0) { + printf("perl => rindex(\"foobar\", \"foobar\", 8) = %d\n", + rindex("foobar", "foobar", 8)); + printf(" D => rindex(\"foobar\", \"foobar\", 8) = 0\n"); + $failed++; + } + + if (index("foobar", "foobar", 400) != -1) { + printf("perl => index(\"foobar\", \"foobar\", 400) = %d\n", + index("foobar", "foobar", 400)); + printf(" D => index(\"foobar\", \"foobar\", 400) = -1\n"); + $failed++; + } + + if (rindex("foobar", "foobar", 400) != 0) { + printf("perl => rindex(\"foobar\", \"foobar\", 400) = %d\n", + rindex("foobar", "foobar", 400)); + printf(" D => rindex(\"foobar\", \"foobar\", 400) = 0\n"); + $failed++; + } + + if (index("foobar", "foobarbaz", -400) != -1) { + printf("perl => index(\"foobar\", \"foobarbaz\", -400) = %d\n", + index("foobar", "foobarbaz", -400)); + printf(" D => index(\"foobar\", \"foobarbaz\", -400) = -1\n"); + $failed++; + } + + if (rindex("foobar", "foobarbaz", -400) != -1) { + printf("perl => rindex(\"foobar\", \"foobarbaz\", -400) = %d\n", + rindex("foobar", "foobarbaz", -400)); + printf(" D => rindex(\"foobar\", \"foobarbaz\", -400) = -1\n"); + $failed++; + } + + if (index("foobar", "foobarbaz", -1) != -1) { + printf("perl => index(\"foobar\", \"foobarbaz\", -1) = %d\n", + index("foobar", "foobarbaz", -1)); + printf(" D => index(\"foobar\", \"foobarbaz\", -1) = -1\n"); + $failed++; + } + + if (rindex("foobar", "foobarbaz", -1) != -1) { + printf("perl => rindex(\"foobar\", \"foobarbaz\", -1) = %d\n", + rindex("foobar", "foobarbaz", -1)); + printf(" D => rindex(\"foobar\", \"foobarbaz\", -1) = -1\n"); + $failed++; + } + + if (index("foobar", "foobarbaz", 0) != -1) { + printf("perl => index(\"foobar\", \"foobarbaz\", 0) = %d\n", + index("foobar", "foobarbaz", 0)); + printf(" D => index(\"foobar\", \"foobarbaz\", 0) = -1\n"); + $failed++; + } + + if (rindex("foobar", "foobarbaz", 0) != -1) { + printf("perl => rindex(\"foobar\", \"foobarbaz\", 0) = %d\n", + rindex("foobar", "foobarbaz", 0)); + printf(" D => rindex(\"foobar\", \"foobarbaz\", 0) = -1\n"); + $failed++; + } + + if (index("foobar", "foobarbaz", 3) != -1) { + printf("perl => index(\"foobar\", \"foobarbaz\", 3) = %d\n", + index("foobar", "foobarbaz", 3)); + printf(" D => index(\"foobar\", \"foobarbaz\", 3) = -1\n"); + $failed++; + } + + if (rindex("foobar", "foobarbaz", 3) != -1) { + printf("perl => rindex(\"foobar\", \"foobarbaz\", 3) = %d\n", + rindex("foobar", "foobarbaz", 3)); + printf(" D => rindex(\"foobar\", \"foobarbaz\", 3) = -1\n"); + $failed++; + } + + if (index("foobar", "foobarbaz", 6) != -1) { + printf("perl => index(\"foobar\", \"foobarbaz\", 6) = %d\n", + index("foobar", "foobarbaz", 6)); + printf(" D => index(\"foobar\", \"foobarbaz\", 6) = -1\n"); + $failed++; + } + + if (rindex("foobar", "foobarbaz", 6) != -1) { + printf("perl => rindex(\"foobar\", \"foobarbaz\", 6) = %d\n", + rindex("foobar", "foobarbaz", 6)); + printf(" D => rindex(\"foobar\", \"foobarbaz\", 6) = -1\n"); + $failed++; + } + + if (index("foobar", "foobarbaz", 7) != -1) { + printf("perl => index(\"foobar\", \"foobarbaz\", 7) = %d\n", + index("foobar", "foobarbaz", 7)); + printf(" D => index(\"foobar\", \"foobarbaz\", 7) = -1\n"); + $failed++; + } + + if (rindex("foobar", "foobarbaz", 7) != -1) { + printf("perl => rindex(\"foobar\", \"foobarbaz\", 7) = %d\n", + rindex("foobar", "foobarbaz", 7)); + printf(" D => rindex(\"foobar\", \"foobarbaz\", 7) = -1\n"); + $failed++; + } + + if (index("foobar", "foobarbaz", 8) != -1) { + printf("perl => index(\"foobar\", \"foobarbaz\", 8) = %d\n", + index("foobar", "foobarbaz", 8)); + printf(" D => index(\"foobar\", \"foobarbaz\", 8) = -1\n"); + $failed++; + } + + if (rindex("foobar", "foobarbaz", 8) != -1) { + printf("perl => rindex(\"foobar\", \"foobarbaz\", 8) = %d\n", + rindex("foobar", "foobarbaz", 8)); + printf(" D => rindex(\"foobar\", \"foobarbaz\", 8) = -1\n"); + $failed++; + } + + if (index("foobar", "foobarbaz", 400) != -1) { + printf("perl => index(\"foobar\", \"foobarbaz\", 400) = %d\n", + index("foobar", "foobarbaz", 400)); + printf(" D => index(\"foobar\", \"foobarbaz\", 400) = -1\n"); + $failed++; + } + + if (rindex("foobar", "foobarbaz", 400) != -1) { + printf("perl => rindex(\"foobar\", \"foobarbaz\", 400) = %d\n", + rindex("foobar", "foobarbaz", 400)); + printf(" D => rindex(\"foobar\", \"foobarbaz\", 400) = -1\n"); + $failed++; + } + + if (index("", "foobar", -400) != -1) { + printf("perl => index(\"\", \"foobar\", -400) = %d\n", + index("", "foobar", -400)); + printf(" D => index(\"\", \"foobar\", -400) = -1\n"); + $failed++; + } + + if (rindex("", "foobar", -400) != -1) { + printf("perl => rindex(\"\", \"foobar\", -400) = %d\n", + rindex("", "foobar", -400)); + printf(" D => rindex(\"\", \"foobar\", -400) = -1\n"); + $failed++; + } + + if (index("", "foobar", -1) != -1) { + printf("perl => index(\"\", \"foobar\", -1) = %d\n", + index("", "foobar", -1)); + printf(" D => index(\"\", \"foobar\", -1) = -1\n"); + $failed++; + } + + if (rindex("", "foobar", -1) != -1) { + printf("perl => rindex(\"\", \"foobar\", -1) = %d\n", + rindex("", "foobar", -1)); + printf(" D => rindex(\"\", \"foobar\", -1) = -1\n"); + $failed++; + } + + if (index("", "foobar", 0) != -1) { + printf("perl => index(\"\", \"foobar\", 0) = %d\n", + index("", "foobar", 0)); + printf(" D => index(\"\", \"foobar\", 0) = -1\n"); + $failed++; + } + + if (rindex("", "foobar", 0) != -1) { + printf("perl => rindex(\"\", \"foobar\", 0) = %d\n", + rindex("", "foobar", 0)); + printf(" D => rindex(\"\", \"foobar\", 0) = -1\n"); + $failed++; + } + + if (index("", "foobar", 0) != -1) { + printf("perl => index(\"\", \"foobar\", 0) = %d\n", + index("", "foobar", 0)); + printf(" D => index(\"\", \"foobar\", 0) = -1\n"); + $failed++; + } + + if (rindex("", "foobar", 0) != -1) { + printf("perl => rindex(\"\", \"foobar\", 0) = %d\n", + rindex("", "foobar", 0)); + printf(" D => rindex(\"\", \"foobar\", 0) = -1\n"); + $failed++; + } + + if (index("", "foobar", 0) != -1) { + printf("perl => index(\"\", \"foobar\", 0) = %d\n", + index("", "foobar", 0)); + printf(" D => index(\"\", \"foobar\", 0) = -1\n"); + $failed++; + } + + if (rindex("", "foobar", 0) != -1) { + printf("perl => rindex(\"\", \"foobar\", 0) = %d\n", + rindex("", "foobar", 0)); + printf(" D => rindex(\"\", \"foobar\", 0) = -1\n"); + $failed++; + } + + if (index("", "foobar", 1) != -1) { + printf("perl => index(\"\", \"foobar\", 1) = %d\n", + index("", "foobar", 1)); + printf(" D => index(\"\", \"foobar\", 1) = -1\n"); + $failed++; + } + + if (rindex("", "foobar", 1) != -1) { + printf("perl => rindex(\"\", \"foobar\", 1) = %d\n", + rindex("", "foobar", 1)); + printf(" D => rindex(\"\", \"foobar\", 1) = -1\n"); + $failed++; + } + + if (index("", "foobar", 2) != -1) { + printf("perl => index(\"\", \"foobar\", 2) = %d\n", + index("", "foobar", 2)); + printf(" D => index(\"\", \"foobar\", 2) = -1\n"); + $failed++; + } + + if (rindex("", "foobar", 2) != -1) { + printf("perl => rindex(\"\", \"foobar\", 2) = %d\n", + rindex("", "foobar", 2)); + printf(" D => rindex(\"\", \"foobar\", 2) = -1\n"); + $failed++; + } + + if (index("", "foobar", 400) != -1) { + printf("perl => index(\"\", \"foobar\", 400) = %d\n", + index("", "foobar", 400)); + printf(" D => index(\"\", \"foobar\", 400) = -1\n"); + $failed++; + } + + if (rindex("", "foobar", 400) != -1) { + printf("perl => rindex(\"\", \"foobar\", 400) = %d\n", + rindex("", "foobar", 400)); + printf(" D => rindex(\"\", \"foobar\", 400) = -1\n"); + $failed++; + } + + if (index("foobar", "", -400) != 0) { + printf("perl => index(\"foobar\", \"\", -400) = %d\n", + index("foobar", "", -400)); + printf(" D => index(\"foobar\", \"\", -400) = 0\n"); + $failed++; + } + + if (rindex("foobar", "", -400) != 0) { + printf("perl => rindex(\"foobar\", \"\", -400) = %d\n", + rindex("foobar", "", -400)); + printf(" D => rindex(\"foobar\", \"\", -400) = 0\n"); + $failed++; + } + + if (index("foobar", "", -1) != 0) { + printf("perl => index(\"foobar\", \"\", -1) = %d\n", + index("foobar", "", -1)); + printf(" D => index(\"foobar\", \"\", -1) = 0\n"); + $failed++; + } + + if (rindex("foobar", "", -1) != 0) { + printf("perl => rindex(\"foobar\", \"\", -1) = %d\n", + rindex("foobar", "", -1)); + printf(" D => rindex(\"foobar\", \"\", -1) = 0\n"); + $failed++; + } + + if (index("foobar", "", 0) != 0) { + printf("perl => index(\"foobar\", \"\", 0) = %d\n", + index("foobar", "", 0)); + printf(" D => index(\"foobar\", \"\", 0) = 0\n"); + $failed++; + } + + if (rindex("foobar", "", 0) != 0) { + printf("perl => rindex(\"foobar\", \"\", 0) = %d\n", + rindex("foobar", "", 0)); + printf(" D => rindex(\"foobar\", \"\", 0) = 0\n"); + $failed++; + } + + if (index("foobar", "", 3) != 3) { + printf("perl => index(\"foobar\", \"\", 3) = %d\n", + index("foobar", "", 3)); + printf(" D => index(\"foobar\", \"\", 3) = 3\n"); + $failed++; + } + + if (rindex("foobar", "", 3) != 3) { + printf("perl => rindex(\"foobar\", \"\", 3) = %d\n", + rindex("foobar", "", 3)); + printf(" D => rindex(\"foobar\", \"\", 3) = 3\n"); + $failed++; + } + + if (index("foobar", "", 6) != 6) { + printf("perl => index(\"foobar\", \"\", 6) = %d\n", + index("foobar", "", 6)); + printf(" D => index(\"foobar\", \"\", 6) = 6\n"); + $failed++; + } + + if (rindex("foobar", "", 6) != 6) { + printf("perl => rindex(\"foobar\", \"\", 6) = %d\n", + rindex("foobar", "", 6)); + printf(" D => rindex(\"foobar\", \"\", 6) = 6\n"); + $failed++; + } + + if (index("foobar", "", 7) != 6) { + printf("perl => index(\"foobar\", \"\", 7) = %d\n", + index("foobar", "", 7)); + printf(" D => index(\"foobar\", \"\", 7) = 6\n"); + $failed++; + } + + if (rindex("foobar", "", 7) != 6) { + printf("perl => rindex(\"foobar\", \"\", 7) = %d\n", + rindex("foobar", "", 7)); + printf(" D => rindex(\"foobar\", \"\", 7) = 6\n"); + $failed++; + } + + if (index("foobar", "", 8) != 6) { + printf("perl => index(\"foobar\", \"\", 8) = %d\n", + index("foobar", "", 8)); + printf(" D => index(\"foobar\", \"\", 8) = 6\n"); + $failed++; + } + + if (rindex("foobar", "", 8) != 6) { + printf("perl => rindex(\"foobar\", \"\", 8) = %d\n", + rindex("foobar", "", 8)); + printf(" D => rindex(\"foobar\", \"\", 8) = 6\n"); + $failed++; + } + + if (index("foobar", "", 400) != 6) { + printf("perl => index(\"foobar\", \"\", 400) = %d\n", + index("foobar", "", 400)); + printf(" D => index(\"foobar\", \"\", 400) = 6\n"); + $failed++; + } + + if (rindex("foobar", "", 400) != 6) { + printf("perl => rindex(\"foobar\", \"\", 400) = %d\n", + rindex("foobar", "", 400)); + printf(" D => rindex(\"foobar\", \"\", 400) = 6\n"); + $failed++; + } + + if (index("", "", -400) != 0) { + printf("perl => index(\"\", \"\", -400) = %d\n", + index("", "", -400)); + printf(" D => index(\"\", \"\", -400) = 0\n"); + $failed++; + } + + if (rindex("", "", -400) != 0) { + printf("perl => rindex(\"\", \"\", -400) = %d\n", + rindex("", "", -400)); + printf(" D => rindex(\"\", \"\", -400) = 0\n"); + $failed++; + } + + if (index("", "", -1) != 0) { + printf("perl => index(\"\", \"\", -1) = %d\n", + index("", "", -1)); + printf(" D => index(\"\", \"\", -1) = 0\n"); + $failed++; + } + + if (rindex("", "", -1) != 0) { + printf("perl => rindex(\"\", \"\", -1) = %d\n", + rindex("", "", -1)); + printf(" D => rindex(\"\", \"\", -1) = 0\n"); + $failed++; + } + + if (index("", "", 0) != 0) { + printf("perl => index(\"\", \"\", 0) = %d\n", + index("", "", 0)); + printf(" D => index(\"\", \"\", 0) = 0\n"); + $failed++; + } + + if (rindex("", "", 0) != 0) { + printf("perl => rindex(\"\", \"\", 0) = %d\n", + rindex("", "", 0)); + printf(" D => rindex(\"\", \"\", 0) = 0\n"); + $failed++; + } + + if (index("", "", 0) != 0) { + printf("perl => index(\"\", \"\", 0) = %d\n", + index("", "", 0)); + printf(" D => index(\"\", \"\", 0) = 0\n"); + $failed++; + } + + if (rindex("", "", 0) != 0) { + printf("perl => rindex(\"\", \"\", 0) = %d\n", + rindex("", "", 0)); + printf(" D => rindex(\"\", \"\", 0) = 0\n"); + $failed++; + } + + if (index("", "", 0) != 0) { + printf("perl => index(\"\", \"\", 0) = %d\n", + index("", "", 0)); + printf(" D => index(\"\", \"\", 0) = 0\n"); + $failed++; + } + + if (rindex("", "", 0) != 0) { + printf("perl => rindex(\"\", \"\", 0) = %d\n", + rindex("", "", 0)); + printf(" D => rindex(\"\", \"\", 0) = 0\n"); + $failed++; + } + + if (index("", "", 1) != 0) { + printf("perl => index(\"\", \"\", 1) = %d\n", + index("", "", 1)); + printf(" D => index(\"\", \"\", 1) = 0\n"); + $failed++; + } + + if (rindex("", "", 1) != 0) { + printf("perl => rindex(\"\", \"\", 1) = %d\n", + rindex("", "", 1)); + printf(" D => rindex(\"\", \"\", 1) = 0\n"); + $failed++; + } + + exit($failed); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d new file mode 100644 index 000000000000..fbc56203d5e6 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d @@ -0,0 +1,58 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +in_addr_t *ip4a; +in_addr_t *ip4b; +in_addr_t *ip4c; +in_addr_t *ip4d; + +BEGIN +{ + this->buf4a = alloca(sizeof (in_addr_t)); + this->buf4b = alloca(sizeof (in_addr_t)); + this->buf4c = alloca(sizeof (in_addr_t)); + this->buf4d = alloca(sizeof (in_addr_t)); + ip4a = this->buf4a; + ip4b = this->buf4b; + ip4c = this->buf4c; + ip4d = this->buf4d; + + *ip4a = htonl(0xc0a80117); + *ip4b = htonl(0x7f000001); + *ip4c = htonl(0xffffffff); + *ip4d = htonl(0x00000000); + + printf("%s\n", inet_ntoa(ip4a)); + printf("%s\n", inet_ntoa(ip4b)); + printf("%s\n", inet_ntoa(ip4c)); + printf("%s\n", inet_ntoa(ip4d)); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d.out new file mode 100644 index 000000000000..ab535e78c117 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d.out @@ -0,0 +1,5 @@ +192.168.1.23 +127.0.0.1 +255.255.255.255 +0.0.0.0 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d new file mode 100644 index 000000000000..40b3849da278 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d @@ -0,0 +1,95 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +struct in6_addr *ip6a; +struct in6_addr *ip6b; +struct in6_addr *ip6c; +struct in6_addr *ip6d; +struct in6_addr *ip6e; +struct in6_addr *ip6f; +struct in6_addr *ip6g; + +BEGIN +{ + this->buf6a = alloca(sizeof (struct in6_addr)); + this->buf6b = alloca(sizeof (struct in6_addr)); + this->buf6c = alloca(sizeof (struct in6_addr)); + this->buf6d = alloca(sizeof (struct in6_addr)); + this->buf6e = alloca(sizeof (struct in6_addr)); + this->buf6f = alloca(sizeof (struct in6_addr)); + this->buf6g = alloca(sizeof (struct in6_addr)); + ip6a = this->buf6a; + ip6b = this->buf6b; + ip6c = this->buf6c; + ip6d = this->buf6d; + ip6e = this->buf6e; + ip6f = this->buf6f; + ip6g = this->buf6g; + + ip6a->__u6_addr.__u6_addr8[0] = 0xfe; + ip6a->__u6_addr.__u6_addr8[1] = 0x80; + ip6a->__u6_addr.__u6_addr8[8] = 0x02; + ip6a->__u6_addr.__u6_addr8[9] = 0x14; + ip6a->__u6_addr.__u6_addr8[10] = 0x4f; + ip6a->__u6_addr.__u6_addr8[11] = 0xff; + ip6a->__u6_addr.__u6_addr8[12] = 0xfe; + ip6a->__u6_addr.__u6_addr8[13] = 0x0b; + ip6a->__u6_addr.__u6_addr8[14] = 0x76; + ip6a->__u6_addr.__u6_addr8[15] = 0xc8; + ip6b->__u6_addr.__u6_addr8[0] = 0x10; + ip6b->__u6_addr.__u6_addr8[1] = 0x80; + ip6b->__u6_addr.__u6_addr8[10] = 0x08; + ip6b->__u6_addr.__u6_addr8[11] = 0x08; + ip6b->__u6_addr.__u6_addr8[13] = 0x20; + ip6b->__u6_addr.__u6_addr8[13] = 0x0c; + ip6b->__u6_addr.__u6_addr8[14] = 0x41; + ip6b->__u6_addr.__u6_addr8[15] = 0x7a; + ip6c->__u6_addr.__u6_addr8[15] = 0x01; + ip6e->__u6_addr.__u6_addr8[12] = 0x7f; + ip6e->__u6_addr.__u6_addr8[15] = 0x01; + ip6f->__u6_addr.__u6_addr8[10] = 0xff; + ip6f->__u6_addr.__u6_addr8[11] = 0xff; + ip6f->__u6_addr.__u6_addr8[12] = 0x7f; + ip6f->__u6_addr.__u6_addr8[15] = 0x01; + ip6g->__u6_addr.__u6_addr8[10] = 0xff; + ip6g->__u6_addr.__u6_addr8[11] = 0xfe; + ip6g->__u6_addr.__u6_addr8[12] = 0x7f; + ip6g->__u6_addr.__u6_addr8[15] = 0x01; + + printf("%s\n", inet_ntoa6(ip6a)); + printf("%s\n", inet_ntoa6(ip6b)); + printf("%s\n", inet_ntoa6(ip6c)); + printf("%s\n", inet_ntoa6(ip6d)); + printf("%s\n", inet_ntoa6(ip6e)); + printf("%s\n", inet_ntoa6(ip6f)); + printf("%s\n", inet_ntoa6(ip6g)); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d.out new file mode 100644 index 000000000000..d87c1f6141d3 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d.out @@ -0,0 +1,8 @@ +fe80::214:4fff:fe0b:76c8 +1080::808:c:417a +::1 +:: +127.0.0.1 +127.0.0.1 +::fffe:7f00:1 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d new file mode 100644 index 000000000000..21452d6e96e7 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d @@ -0,0 +1,138 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +inline int AF_INET = 2; +inline int AF_INET6 = 28; + +in_addr_t *ip4a; +in_addr_t *ip4b; +in_addr_t *ip4c; +in_addr_t *ip4d; +struct in6_addr *ip6a; +struct in6_addr *ip6b; +struct in6_addr *ip6c; +struct in6_addr *ip6d; +struct in6_addr *ip6e; +struct in6_addr *ip6f; +struct in6_addr *ip6g; +struct in6_addr *ip6h; + +BEGIN +{ + this->buf4a = alloca(sizeof (in_addr_t)); + this->buf4b = alloca(sizeof (in_addr_t)); + this->buf4c = alloca(sizeof (in_addr_t)); + this->buf4d = alloca(sizeof (in_addr_t)); + this->buf6a = alloca(sizeof (struct in6_addr)); + this->buf6b = alloca(sizeof (struct in6_addr)); + this->buf6c = alloca(sizeof (struct in6_addr)); + this->buf6d = alloca(sizeof (struct in6_addr)); + this->buf6e = alloca(sizeof (struct in6_addr)); + this->buf6f = alloca(sizeof (struct in6_addr)); + this->buf6g = alloca(sizeof (struct in6_addr)); + this->buf6h = alloca(sizeof (struct in6_addr)); + ip4a = this->buf4a; + ip4b = this->buf4b; + ip4c = this->buf4c; + ip4d = this->buf4d; + ip6a = this->buf6a; + ip6b = this->buf6b; + ip6c = this->buf6c; + ip6d = this->buf6d; + ip6e = this->buf6e; + ip6f = this->buf6f; + ip6g = this->buf6g; + ip6h = this->buf6h; + + *ip4a = htonl(0xc0a80117); + *ip4b = htonl(0x7f000001); + *ip4c = htonl(0xffffffff); + *ip4d = htonl(0x00000000); + ip6a->__u6_addr.__u6_addr8[0] = 0xfe; + ip6a->__u6_addr.__u6_addr8[1] = 0x80; + ip6a->__u6_addr.__u6_addr8[8] = 0x02; + ip6a->__u6_addr.__u6_addr8[9] = 0x14; + ip6a->__u6_addr.__u6_addr8[10] = 0x4f; + ip6a->__u6_addr.__u6_addr8[11] = 0xff; + ip6a->__u6_addr.__u6_addr8[12] = 0xfe; + ip6a->__u6_addr.__u6_addr8[13] = 0x0b; + ip6a->__u6_addr.__u6_addr8[14] = 0x76; + ip6a->__u6_addr.__u6_addr8[15] = 0xc8; + ip6b->__u6_addr.__u6_addr8[0] = 0x10; + ip6b->__u6_addr.__u6_addr8[1] = 0x80; + ip6b->__u6_addr.__u6_addr8[10] = 0x08; + ip6b->__u6_addr.__u6_addr8[11] = 0x08; + ip6b->__u6_addr.__u6_addr8[13] = 0x20; + ip6b->__u6_addr.__u6_addr8[13] = 0x0c; + ip6b->__u6_addr.__u6_addr8[14] = 0x41; + ip6b->__u6_addr.__u6_addr8[15] = 0x7a; + ip6c->__u6_addr.__u6_addr8[15] = 0x01; + ip6e->__u6_addr.__u6_addr8[12] = 0x7f; + ip6e->__u6_addr.__u6_addr8[15] = 0x01; + ip6f->__u6_addr.__u6_addr8[10] = 0xff; + ip6f->__u6_addr.__u6_addr8[11] = 0xff; + ip6f->__u6_addr.__u6_addr8[12] = 0x7f; + ip6f->__u6_addr.__u6_addr8[15] = 0x01; + ip6g->__u6_addr.__u6_addr8[10] = 0xff; + ip6g->__u6_addr.__u6_addr8[11] = 0xfe; + ip6g->__u6_addr.__u6_addr8[12] = 0x7f; + ip6g->__u6_addr.__u6_addr8[15] = 0x01; + ip6h->__u6_addr.__u6_addr8[0] = 0xff; + ip6h->__u6_addr.__u6_addr8[1] = 0xff; + ip6h->__u6_addr.__u6_addr8[2] = 0xff; + ip6h->__u6_addr.__u6_addr8[3] = 0xff; + ip6h->__u6_addr.__u6_addr8[4] = 0xff; + ip6h->__u6_addr.__u6_addr8[5] = 0xff; + ip6h->__u6_addr.__u6_addr8[6] = 0xff; + ip6h->__u6_addr.__u6_addr8[7] = 0xff; + ip6h->__u6_addr.__u6_addr8[8] = 0xff; + ip6h->__u6_addr.__u6_addr8[9] = 0xff; + ip6h->__u6_addr.__u6_addr8[10] = 0xff; + ip6h->__u6_addr.__u6_addr8[11] = 0xff; + ip6h->__u6_addr.__u6_addr8[12] = 0xff; + ip6h->__u6_addr.__u6_addr8[13] = 0xff; + ip6h->__u6_addr.__u6_addr8[14] = 0xff; + ip6h->__u6_addr.__u6_addr8[15] = 0xff; + + printf("%s\n", inet_ntop(AF_INET, ip4a)); + printf("%s\n", inet_ntop(AF_INET, ip4b)); + printf("%s\n", inet_ntop(AF_INET, ip4c)); + printf("%s\n", inet_ntop(AF_INET, ip4d)); + printf("%s\n", inet_ntop(AF_INET6, ip6a)); + printf("%s\n", inet_ntop(AF_INET6, ip6b)); + printf("%s\n", inet_ntop(AF_INET6, ip6c)); + printf("%s\n", inet_ntop(AF_INET6, ip6d)); + printf("%s\n", inet_ntop(AF_INET6, ip6e)); + printf("%s\n", inet_ntop(AF_INET6, ip6f)); + printf("%s\n", inet_ntop(AF_INET6, ip6g)); + printf("%s\n", inet_ntop(AF_INET6, ip6h)); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d.out new file mode 100644 index 000000000000..7c8311c2b8ef --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d.out @@ -0,0 +1,13 @@ +192.168.1.23 +127.0.0.1 +255.255.255.255 +0.0.0.0 +fe80::214:4fff:fe0b:76c8 +1080::808:c:417a +::1 +:: +::127.0.0.1 +::ffff:127.0.0.1 +::fffe:7f00:1 +ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.lltostr.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.lltostr.d new file mode 100644 index 000000000000..03e295a74d5b --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.lltostr.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +BEGIN +{ + printf("%s\n", lltostr(0)); + printf("%s\n", lltostr(1)); + printf("%s\n", lltostr(-1)); + printf("%s\n", lltostr(123456789)); + printf("%s\n", lltostr(-123456789)); + printf("%s\n", lltostr(1LL << 62)); + printf("%s\n", lltostr(-(1LL << 62))); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.lltostr.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.lltostr.d.out new file mode 100644 index 000000000000..e007c648aa65 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.lltostr.d.out @@ -0,0 +1,8 @@ +0 +1 +-1 +123456789 +-123456789 +4611686018427387904 +-4611686018427387904 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.mutex_owned.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.mutex_owned.d new file mode 100644 index 000000000000..0f97aa1a951e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.mutex_owned.d @@ -0,0 +1,62 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * mutex_owned() should return a non-zero value if the calling + * thread currently holds the mutex. + * + * SECTION: Actions and Subroutines/mutex_owned() + */ + +#pragma D option quiet + +lockstat:::adaptive-acquire +{ + this->owned = mutex_owned((struct mtx *)arg0); + this->owner = mutex_owner((struct mtx *)arg0); +} + +lockstat:::adaptive-acquire +/!this->owned/ +{ + printf("mutex_owned() returned 0, expected non-zero\n"); + exit(1); +} + +lockstat:::adaptive-acquire +/this->owner != curthread/ +{ + printf("current thread is not current owner of owned lock\n"); + exit(1); +} + +lockstat:::adaptive-acquire +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.mutex_owner.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.mutex_owner.d new file mode 100644 index 000000000000..dbb10c3fd598 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.mutex_owner.d @@ -0,0 +1,63 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * mutex_owner() should return a pointer to the kernel thread holding + * the mutex. + * + * SECTION: Actions and Subroutines/mutex_owner() + * + * NOTES: This assertion can't be verified so we'll just call it. + */ + + + + +#pragma D option quiet + +struct thread *ptr; + +BEGIN +{ + i = 0; +} + +lockstat::mtx_lock:adaptive-acquire +{ + + ptr = mutex_owner((struct mtx *)arg0); + i++; +} + +tick-1 +/i > 5/ +{ + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.mutex_type_adaptive.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.mutex_type_adaptive.d new file mode 100644 index 000000000000..ac43e790b7b3 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.mutex_type_adaptive.d @@ -0,0 +1,71 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * mutex_type_adaptive() should return a non-zero value if the + * mutex is an adaptive one. + * + * SECTION: Actions and Subroutines/mutex_type_adaptive() + */ + + +#pragma D option quiet + +BEGIN +{ + i = 0; + ret = -99; +} + +mtx_lock:adaptive-acquire +{ + ret = mutex_type_adaptive((struct mtx *)arg0); + i++; +} + +tick-1 +/ret == 1/ +{ + exit(0); +} + +tick-1 +/i == 100 && ret == 0/ +{ + printf("mutex_type_adaptive returned 0, expected non-zero\n"); + exit(1); +} + +tick-1 +/i == 100 && ret == -99/ +{ + printf("No adaptive_mutexs called in the time this test was run.\n"); + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.progenyof.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.progenyof.d new file mode 100644 index 000000000000..02911580e50e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.progenyof.d @@ -0,0 +1,64 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * progenyof() should return non-zero if the pid passed is in the + # progeny of the calling process. + * + * SECTION: Actions and Subroutines/progenyof() + * + */ + +#pragma D option quiet + + +BEGIN +{ + res_1 = -1; + res_2 = -1; + res_3 = -1; + + res_1 = progenyof($ppid); /* this will always be true */ + res_2 = progenyof($ppid + 1); /* this will always be false */ + res_3 = progenyof(1); /* this will always be true */ +} + + +tick-1 +/res_1 > 0 && res_2 == 0 && res_3 > 0/ +{ + exit(0); +} + +tick-1 +/res_1 <= 0 || res_2 != 0 || res_3 <= 0/ +{ + exit(1); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.rand.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.rand.d new file mode 100644 index 000000000000..51f4491177d2 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.rand.d @@ -0,0 +1,54 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Test rand() + * + * SECTION: Actions and Subroutines/rand() + */ + + + +BEGIN +{ + i = 0; +} + +tick-1 +/i != 10/ +{ + i++; + trace(rand()); +} + +tick-1 +/i == 10/ +{ + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strchr.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strchr.d new file mode 100644 index 000000000000..8dc8f89ba225 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strchr.d @@ -0,0 +1,71 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +BEGIN +{ + str = "fooeyfooeyfoo"; + this->success = 0; + + c = 'f'; + printf("strchr(\"%s\", '%c') = \"%s\"\n", str, c, strchr(str, c)); + printf("strrchr(\"%s\", '%c') = \"%s\"\n", str, c, strrchr(str, c)); + + c = 'y'; + printf("strchr(\"%s\", '%c') = \"%s\"\n", str, c, strchr(str, c)); + printf("strrchr(\"%s\", '%c') = \"%s\"\n", str, c, strrchr(str, c)); + + printf("strrchr(\"%s\", '%c') = \"%s\"\n", strchr(str, c), c, + strrchr(strchr(str, c), c)); + + this->success = 1; +} + +BEGIN +/!this->success/ +{ + exit(1); +} + +BEGIN +/strchr(str, 'a') != NULL/ +{ + exit(2); +} + +BEGIN +/strrchr(str, 'a') != NULL/ +{ + exit(3); +} + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strchr.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strchr.d.out new file mode 100644 index 000000000000..328b5318bc8e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strchr.d.out @@ -0,0 +1,6 @@ +strchr("fooeyfooeyfoo", 'f') = "fooeyfooeyfoo" +strrchr("fooeyfooeyfoo", 'f') = "foo" +strchr("fooeyfooeyfoo", 'y') = "yfooeyfoo" +strrchr("fooeyfooeyfoo", 'y') = "yfoo" +strrchr("yfooeyfoo", 'y') = "yfoo" + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strjoin.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strjoin.d new file mode 100644 index 000000000000..392c18a6df89 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strjoin.d @@ -0,0 +1,38 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +BEGIN +{ + printf("%s\n", strjoin("foo", "baz")); + printf("%s\n", strjoin("foo", "")); + printf("%s\n", strjoin("", "baz")); + printf("%s\n", strjoin("", "")); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strjoin.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strjoin.d.out new file mode 100644 index 000000000000..657286944a75 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strjoin.d.out @@ -0,0 +1,5 @@ +foobaz +foo +baz + + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strstr.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strstr.d new file mode 100644 index 000000000000..0c81b7a892ab --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strstr.d @@ -0,0 +1,89 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +BEGIN +{ + str = "foobarbarbazbarbop"; + this->success = 0; + + c = str; + printf("strstr(\"%s\", \"%s\") = \"%s\"\n", str, c, strstr(str, c)); + + c = "baz"; + printf("strstr(\"%s\", \"%s\") = \"%s\"\n", str, c, strstr(str, c)); + + c = "bar"; + printf("strstr(\"%s\", \"%s\") = \"%s\"\n", str, c, strstr(str, c)); + + c = "bazbarbop"; + printf("strstr(\"%s\", \"%s\") = \"%s\"\n", str, c, strstr(str, c)); + + c = "barba"; + printf("strstr(\"%s\", \"%s\") = \"%s\"\n", str, c, strstr(str, c)); + + printf("strstr(\"%s\", \"%s\") = \"%s\"\n", + strstr(str, "baz"), strstr(str, "zba"), + strstr(strstr(str, "baz"), strstr(str, "zba"))); + + c = ""; + printf("strstr(\"%s\", \"%s\") = \"%s\"\n", str, c, strstr(str, c)); + + str = ""; + printf("strstr(\"%s\", \"%s\") = \"%s\"\n", str, c, strstr(str, c)); + + str = "f"; + c = "f"; + printf("strstr(\"%s\", \"%s\") = \"%s\"\n", str, c, strstr(str, c)); + + this->success = 1; +} + +BEGIN +/!this->success/ +{ + exit(1); +} + +BEGIN +/strstr(str, "barbarf") != NULL/ +{ + exit(2); +} + +BEGIN +/strstr(str, "foobarbarbazbarbopp") != NULL/ +{ + exit(3); +} + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strstr.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strstr.d.out new file mode 100644 index 000000000000..f9121dbcfb8d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strstr.d.out @@ -0,0 +1,10 @@ +strstr("foobarbarbazbarbop", "foobarbarbazbarbop") = "foobarbarbazbarbop" +strstr("foobarbarbazbarbop", "baz") = "bazbarbop" +strstr("foobarbarbazbarbop", "bar") = "barbarbazbarbop" +strstr("foobarbarbazbarbop", "bazbarbop") = "bazbarbop" +strstr("foobarbarbazbarbop", "barba") = "barbarbazbarbop" +strstr("bazbarbop", "zbarbop") = "zbarbop" +strstr("foobarbarbazbarbop", "") = "foobarbarbazbarbop" +strstr("", "") = "" +strstr("f", "f") = "f" + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strtok.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strtok.d new file mode 100644 index 000000000000..47092ba46ba1 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strtok.d @@ -0,0 +1,146 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + +BEGIN +{ + this->str = ",,,Carrots,,Barley,Oatmeal,,,Beans,"; +} + +BEGIN +/(this->field = strtok(this->str, ",")) == NULL/ +{ + exit(1); +} + +BEGIN +{ + printf("%s\n", this->field); +} + +BEGIN +/(this->field = strtok(NULL, ",")) == NULL/ +{ + exit(2); +} + +BEGIN +{ + printf("%s\n", this->field); +} + +BEGIN +/(this->field = strtok(NULL, ",")) == NULL/ +{ + exit(3); +} + +BEGIN +{ + printf("%s\n", this->field); +} + +BEGIN +/(this->field = strtok(NULL, ",")) == NULL/ +{ + exit(4); +} + +BEGIN +{ + printf("%s\n", this->field); +} + +BEGIN +/(self->a = strtok(NULL, ",")) != NULL/ +{ + printf("unexpected field: %s\n", this->field); + exit(5); +} + +struct { + string s1; + string s2; + string result; +} command[int]; + +int i; + +BEGIN +{ + command[i].s1 = ""; + command[i].s2 = ""; + command[i].result = ""; + i++; + + command[i].s1 = "foo"; + command[i].s2 = ""; + command[i].result = command[i].s1; + i++; + + command[i].s1 = "foobar"; + command[i].s2 = "o"; + command[i].result = "f"; + i++; + + command[i].s1 = "oobar"; + command[i].s2 = "o"; + command[i].result = "bar"; + i++; + + command[i].s1 = "foo"; + command[i].s2 = "bar"; + command[i].result = command[i].s1; + i++; + + command[i].s1 = ""; + command[i].s2 = "foo"; + command[i].result = ""; + i++; + + end = i; + i = 0; +} + +tick-1ms +/i < end && + (this->result = strtok(command[i].s1, command[i].s2)) != command[i].result/ +{ + printf("strtok(\"%s\", \"%s\") = \"%s\", expected \"%s\"", + command[i].s1, command[i].s2, + this->result != NULL ? this->result : "", + command[i].result != NULL ? command[i].result : ""); + exit(6 + i); +} + +tick-1ms +/++i == end/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strtok.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strtok.d.out new file mode 100644 index 000000000000..4bc37274b928 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strtok.d.out @@ -0,0 +1,5 @@ +Carrots +Barley +Oatmeal +Beans + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strtok_null.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strtok_null.d new file mode 100644 index 000000000000..6de4f97d18fb --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.strtok_null.d @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * Test that a strtok(NULL, ...) without first calling strtok(string, ...) + * produces an error + */ + +BEGIN +{ + trace(strtok(NULL, "!")); + exit(1); +} + +ERROR +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.substr.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.substr.d new file mode 100644 index 000000000000..edee6442e350 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.substr.d @@ -0,0 +1,231 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet +#pragma D option strsize=32 + +struct { + int index; + int length; + int nolen; + int alt; +} command[int]; + +int i; + +BEGIN +{ + str = "foobarbazbop"; + str2 = ""; + altstr = "CRAIG: Positioned them, I don't "; + altstr2 = "know... I'm fairly wide guy."; + + command[i].index = 3; + command[i].nolen = 1; + i++; + + command[i].index = 300; + command[i].nolen = 1; + i++; + + command[i].index = -10; + command[i].nolen = 1; + i++; + + command[i].index = 0; + command[i].nolen = 1; + i++; + + command[i].index = 1; + command[i].nolen = 1; + i++; + + command[i].index = strlen(str) - 1; + command[i].nolen = 1; + i++; + + command[i].index = strlen(str); + command[i].nolen = 1; + i++; + + command[i].index = strlen(str) + 1; + command[i].nolen = 1; + i++; + + command[i].index = 8; + command[i].length = 20; + i++; + + command[i].index = 4; + command[i].length = 4; + i++; + + command[i].index = 5; + command[i].length = strlen(str) - command[i].index + 1; + i++; + + command[i].index = 5; + command[i].length = strlen(str) - command[i].index + 2; + i++; + + command[i].index = 400; + command[i].length = 20; + i++; + + command[i].index = 400; + command[i].length = 0; + i++; + + command[i].index = 400; + command[i].length = -1; + i++; + + command[i].index = 3; + command[i].length = 0; + i++; + + command[i].index = 3; + command[i].length = -1; + i++; + + command[i].index = 3; + command[i].length = -4; + i++; + + command[i].index = 3; + command[i].length = -20; + i++; + + command[i].index = -10; + command[i].length = -5; + i++; + + command[i].index = 0; + command[i].length = 400; + i++; + + command[i].index = -1; + command[i].length = 400; + i++; + + command[i].index = -1; + command[i].length = 0; + i++; + + command[i].index = -1; + command[i].length = -1; + i++; + + command[i].index = -2 * strlen(str); + command[i].length = 2 * strlen(str); + i++; + + command[i].index = -2 * strlen(str); + command[i].length = strlen(str); + i++; + + command[i].index = -2 * strlen(str); + command[i].length = strlen(str) + 1; + i++; + + command[i].index = -1 * strlen(str); + command[i].length = strlen(str); + i++; + + command[i].index = -1 * strlen(str); + command[i].length = strlen(str) - 1; + i++; + + command[i].index = 100; + command[i].length = 10; + command[i].alt = 1; + i++; + + command[i].index = 100; + command[i].nolen = 1; + command[i].alt = 1; + i++; + + end = i; + i = 0; + printf("#!/usr/perl5/bin/perl\n\nBEGIN {\n"); + +} + +tick-1ms +/i < end && command[i].nolen/ +{ + this->str = command[i].alt ? altstr : str; + this->str2 = command[i].alt ? altstr2 : str2; + this->result = substr(command[i].alt ? + "CRAIG: Positioned them, I don't know... I'm fairly wide guy." : + str, command[i].index); + + printf("\tif (substr(\"%s%s\", %d) ne \"%s\") {\n", + this->str, this->str2, command[i].index, this->result); + + printf("\t\tprintf(\"perl => substr(\\\"%s%s\\\", %d) = ", + this->str, this->str2, command[i].index); + printf("\\\"%%s\\\"\\n\",\n\t\t substr(\"%s%s\", %d));\n", + this->str, this->str2, command[i].index); + printf("\t\tprintf(\" D => substr(\\\"%s%s\\\", %d) = ", + this->str, this->str2, command[i].index); + printf("\\\"%%s\\\"\\n\",\n\t\t \"%s\");\n", this->result); + printf("\t\t$failed++;\n"); + printf("\t}\n\n"); +} + +tick-1ms +/i < end && !command[i].nolen/ +{ + this->str = command[i].alt ? altstr : str; + this->str2 = command[i].alt ? altstr2 : str2; + this->result = substr(command[i].alt ? + "CRAIG: Positioned them, I don't know... I'm fairly wide guy." : + str, command[i].index, command[i].length); + + printf("\tif (substr(\"%s%s\", %d, %d) ne \"%s\") {\n", + this->str, this->str2, command[i].index, command[i].length, + this->result); + printf("\t\tprintf(\"perl => substr(\\\"%s%s\\\", %d, %d) = ", + this->str, this->str2, command[i].index, command[i].length); + printf("\\\"%%s\\\"\\n\",\n\t\t substr(\"%s%s\", %d, %d));\n", + this->str, this->str2, command[i].index, command[i].length); + printf("\t\tprintf(\" D => substr(\\\"%s%s\\\", %d, %d) = ", + this->str, this->str2, command[i].index, command[i].length); + printf("\\\"%%s\\\"\\n\",\n\t\t \"%s\");\n", this->result); + printf("\t\t$failed++;\n"); + printf("\t}\n\n"); +} + +tick-1ms +/++i == end/ +{ + printf("\texit($failed);\n}\n"); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.substr.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.substr.d.out new file mode 100644 index 000000000000..5b498ef36be9 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.substr.d.out @@ -0,0 +1,254 @@ +#!/usr/perl5/bin/perl + +BEGIN { + if (substr("foobarbazbop", 3) ne "barbazbop") { + printf("perl => substr(\"foobarbazbop\", 3) = \"%s\"\n", + substr("foobarbazbop", 3)); + printf(" D => substr(\"foobarbazbop\", 3) = \"%s\"\n", + "barbazbop"); + $failed++; + } + + if (substr("foobarbazbop", 300) ne "") { + printf("perl => substr(\"foobarbazbop\", 300) = \"%s\"\n", + substr("foobarbazbop", 300)); + printf(" D => substr(\"foobarbazbop\", 300) = \"%s\"\n", + ""); + $failed++; + } + + if (substr("foobarbazbop", -10) ne "obarbazbop") { + printf("perl => substr(\"foobarbazbop\", -10) = \"%s\"\n", + substr("foobarbazbop", -10)); + printf(" D => substr(\"foobarbazbop\", -10) = \"%s\"\n", + "obarbazbop"); + $failed++; + } + + if (substr("foobarbazbop", 0) ne "foobarbazbop") { + printf("perl => substr(\"foobarbazbop\", 0) = \"%s\"\n", + substr("foobarbazbop", 0)); + printf(" D => substr(\"foobarbazbop\", 0) = \"%s\"\n", + "foobarbazbop"); + $failed++; + } + + if (substr("foobarbazbop", 1) ne "oobarbazbop") { + printf("perl => substr(\"foobarbazbop\", 1) = \"%s\"\n", + substr("foobarbazbop", 1)); + printf(" D => substr(\"foobarbazbop\", 1) = \"%s\"\n", + "oobarbazbop"); + $failed++; + } + + if (substr("foobarbazbop", 11) ne "p") { + printf("perl => substr(\"foobarbazbop\", 11) = \"%s\"\n", + substr("foobarbazbop", 11)); + printf(" D => substr(\"foobarbazbop\", 11) = \"%s\"\n", + "p"); + $failed++; + } + + if (substr("foobarbazbop", 12) ne "") { + printf("perl => substr(\"foobarbazbop\", 12) = \"%s\"\n", + substr("foobarbazbop", 12)); + printf(" D => substr(\"foobarbazbop\", 12) = \"%s\"\n", + ""); + $failed++; + } + + if (substr("foobarbazbop", 13) ne "") { + printf("perl => substr(\"foobarbazbop\", 13) = \"%s\"\n", + substr("foobarbazbop", 13)); + printf(" D => substr(\"foobarbazbop\", 13) = \"%s\"\n", + ""); + $failed++; + } + + if (substr("foobarbazbop", 8, 20) ne "zbop") { + printf("perl => substr(\"foobarbazbop\", 8, 20) = \"%s\"\n", + substr("foobarbazbop", 8, 20)); + printf(" D => substr(\"foobarbazbop\", 8, 20) = \"%s\"\n", + "zbop"); + $failed++; + } + + if (substr("foobarbazbop", 4, 4) ne "arba") { + printf("perl => substr(\"foobarbazbop\", 4, 4) = \"%s\"\n", + substr("foobarbazbop", 4, 4)); + printf(" D => substr(\"foobarbazbop\", 4, 4) = \"%s\"\n", + "arba"); + $failed++; + } + + if (substr("foobarbazbop", 5, 8) ne "rbazbop") { + printf("perl => substr(\"foobarbazbop\", 5, 8) = \"%s\"\n", + substr("foobarbazbop", 5, 8)); + printf(" D => substr(\"foobarbazbop\", 5, 8) = \"%s\"\n", + "rbazbop"); + $failed++; + } + + if (substr("foobarbazbop", 5, 9) ne "rbazbop") { + printf("perl => substr(\"foobarbazbop\", 5, 9) = \"%s\"\n", + substr("foobarbazbop", 5, 9)); + printf(" D => substr(\"foobarbazbop\", 5, 9) = \"%s\"\n", + "rbazbop"); + $failed++; + } + + if (substr("foobarbazbop", 400, 20) ne "") { + printf("perl => substr(\"foobarbazbop\", 400, 20) = \"%s\"\n", + substr("foobarbazbop", 400, 20)); + printf(" D => substr(\"foobarbazbop\", 400, 20) = \"%s\"\n", + ""); + $failed++; + } + + if (substr("foobarbazbop", 400, 0) ne "") { + printf("perl => substr(\"foobarbazbop\", 400, 0) = \"%s\"\n", + substr("foobarbazbop", 400, 0)); + printf(" D => substr(\"foobarbazbop\", 400, 0) = \"%s\"\n", + ""); + $failed++; + } + + if (substr("foobarbazbop", 400, -1) ne "") { + printf("perl => substr(\"foobarbazbop\", 400, -1) = \"%s\"\n", + substr("foobarbazbop", 400, -1)); + printf(" D => substr(\"foobarbazbop\", 400, -1) = \"%s\"\n", + ""); + $failed++; + } + + if (substr("foobarbazbop", 3, 0) ne "") { + printf("perl => substr(\"foobarbazbop\", 3, 0) = \"%s\"\n", + substr("foobarbazbop", 3, 0)); + printf(" D => substr(\"foobarbazbop\", 3, 0) = \"%s\"\n", + ""); + $failed++; + } + + if (substr("foobarbazbop", 3, -1) ne "barbazbo") { + printf("perl => substr(\"foobarbazbop\", 3, -1) = \"%s\"\n", + substr("foobarbazbop", 3, -1)); + printf(" D => substr(\"foobarbazbop\", 3, -1) = \"%s\"\n", + "barbazbo"); + $failed++; + } + + if (substr("foobarbazbop", 3, -4) ne "barba") { + printf("perl => substr(\"foobarbazbop\", 3, -4) = \"%s\"\n", + substr("foobarbazbop", 3, -4)); + printf(" D => substr(\"foobarbazbop\", 3, -4) = \"%s\"\n", + "barba"); + $failed++; + } + + if (substr("foobarbazbop", 3, -20) ne "") { + printf("perl => substr(\"foobarbazbop\", 3, -20) = \"%s\"\n", + substr("foobarbazbop", 3, -20)); + printf(" D => substr(\"foobarbazbop\", 3, -20) = \"%s\"\n", + ""); + $failed++; + } + + if (substr("foobarbazbop", -10, -5) ne "obarb") { + printf("perl => substr(\"foobarbazbop\", -10, -5) = \"%s\"\n", + substr("foobarbazbop", -10, -5)); + printf(" D => substr(\"foobarbazbop\", -10, -5) = \"%s\"\n", + "obarb"); + $failed++; + } + + if (substr("foobarbazbop", 0, 400) ne "foobarbazbop") { + printf("perl => substr(\"foobarbazbop\", 0, 400) = \"%s\"\n", + substr("foobarbazbop", 0, 400)); + printf(" D => substr(\"foobarbazbop\", 0, 400) = \"%s\"\n", + "foobarbazbop"); + $failed++; + } + + if (substr("foobarbazbop", -1, 400) ne "p") { + printf("perl => substr(\"foobarbazbop\", -1, 400) = \"%s\"\n", + substr("foobarbazbop", -1, 400)); + printf(" D => substr(\"foobarbazbop\", -1, 400) = \"%s\"\n", + "p"); + $failed++; + } + + if (substr("foobarbazbop", -1, 0) ne "") { + printf("perl => substr(\"foobarbazbop\", -1, 0) = \"%s\"\n", + substr("foobarbazbop", -1, 0)); + printf(" D => substr(\"foobarbazbop\", -1, 0) = \"%s\"\n", + ""); + $failed++; + } + + if (substr("foobarbazbop", -1, -1) ne "") { + printf("perl => substr(\"foobarbazbop\", -1, -1) = \"%s\"\n", + substr("foobarbazbop", -1, -1)); + printf(" D => substr(\"foobarbazbop\", -1, -1) = \"%s\"\n", + ""); + $failed++; + } + + if (substr("foobarbazbop", -24, 24) ne "foobarbazbop") { + printf("perl => substr(\"foobarbazbop\", -24, 24) = \"%s\"\n", + substr("foobarbazbop", -24, 24)); + printf(" D => substr(\"foobarbazbop\", -24, 24) = \"%s\"\n", + "foobarbazbop"); + $failed++; + } + + if (substr("foobarbazbop", -24, 12) ne "") { + printf("perl => substr(\"foobarbazbop\", -24, 12) = \"%s\"\n", + substr("foobarbazbop", -24, 12)); + printf(" D => substr(\"foobarbazbop\", -24, 12) = \"%s\"\n", + ""); + $failed++; + } + + if (substr("foobarbazbop", -24, 13) ne "f") { + printf("perl => substr(\"foobarbazbop\", -24, 13) = \"%s\"\n", + substr("foobarbazbop", -24, 13)); + printf(" D => substr(\"foobarbazbop\", -24, 13) = \"%s\"\n", + "f"); + $failed++; + } + + if (substr("foobarbazbop", -12, 12) ne "foobarbazbop") { + printf("perl => substr(\"foobarbazbop\", -12, 12) = \"%s\"\n", + substr("foobarbazbop", -12, 12)); + printf(" D => substr(\"foobarbazbop\", -12, 12) = \"%s\"\n", + "foobarbazbop"); + $failed++; + } + + if (substr("foobarbazbop", -12, 11) ne "foobarbazbo") { + printf("perl => substr(\"foobarbazbop\", -12, 11) = \"%s\"\n", + substr("foobarbazbop", -12, 11)); + printf(" D => substr(\"foobarbazbop\", -12, 11) = \"%s\"\n", + "foobarbazbo"); + $failed++; + } + + if (substr("CRAIG: Positioned them, I don't know... I'm fairly wide guy.", 100, 10) ne "") { + printf("perl => substr(\"CRAIG: Positioned them, I don't know... I'm fairly wide guy.\", 100, 10) = \"%s\"\n", + substr("CRAIG: Positioned them, I don't know... I'm fairly wide guy.", 100, 10)); + printf(" D => substr(\"CRAIG: Positioned them, I don't know... I'm fairly wide guy.\", 100, 10) = \"%s\"\n", + ""); + $failed++; + } + + if (substr("CRAIG: Positioned them, I don't know... I'm fairly wide guy.", 100) ne "") { + printf("perl => substr(\"CRAIG: Positioned them, I don't know... I'm fairly wide guy.\", 100) = \"%s\"\n", + substr("CRAIG: Positioned them, I don't know... I'm fairly wide guy.", 100)); + printf(" D => substr(\"CRAIG: Positioned them, I don't know... I'm fairly wide guy.\", 100) = \"%s\"\n", + ""); + $failed++; + } + + exit($failed); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.substrminate.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.substrminate.d new file mode 100644 index 000000000000..2c025410d443 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.substrminate.d @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet +#pragma D option aggsortkey + +/* + * This is to check that we're correctly null-terminating the result of the + * substr() subroutine. + */ + +tick-1ms +/i++ > 1000/ +{ + exit(0); +} + +tick-1ms +{ + @[substr((i & 1) ? "Bryan is smart" : "he's not a dummy", 0, + (i & 1) ? 8 : 18)] = count(); +} + +END +{ + printa("%s\n", @); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.substrminate.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.substrminate.d.out new file mode 100644 index 000000000000..26c19aa2c5a3 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.substrminate.d.out @@ -0,0 +1,3 @@ +Bryan is +he's not a dummy + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.system.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.system.d new file mode 100644 index 000000000000..b7ffbfa4329c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.system.d @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet +#pragma D option destructive + +BEGIN +{ + this->a = 9; + this->b = -2; + + system("echo %s %d %d", "foo", this->a, this->b); + system("ping localhost"); + system("echo %d", ++this->a); + system("ping localhost"); + system("echo %d", ++this->a); + system("ping localhost"); + system("echo %d", ++this->a); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.system.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.system.d.out new file mode 100644 index 000000000000..cd0d735f0fb2 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.system.d.out @@ -0,0 +1,8 @@ +foo 9 -2 +localhost is alive +10 +localhost is alive +11 +localhost is alive +12 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/grammar/err.D_ADDROF_LVAL.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/grammar/err.D_ADDROF_LVAL.d new file mode 100644 index 000000000000..8f5d694ae51b --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/grammar/err.D_ADDROF_LVAL.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * & can not be applied to a non-lvalue + * + * SECTION: Pointers and Arrays/Pointers and Addresses + * + */ + +BEGIN +{ + trace(&1); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/grammar/err.D_EMPTY.empty.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/grammar/err.D_EMPTY.empty.d new file mode 100644 index 000000000000..929ccc69ce84 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/grammar/err.D_EMPTY.empty.d @@ -0,0 +1,34 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Test the "empty translation unit" error path. + * + * SECTION: Program Structure/Probe Clauses and Declarations + * + */ diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/grammar/tst.clauses.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/grammar/tst.clauses.d new file mode 100644 index 000000000000..a9930292eff3 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/grammar/tst.clauses.d @@ -0,0 +1,48 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Test the kinds of probe definition clause grammar rules. + * + * SECTION: Program Structure/Probe Clauses and Declarations; + * Program Structure/Actions + */ + + +BEGIN +{} + +BEGIN +/1/ +{} + +tick-1 +{ + exit(0); +} + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/grammar/tst.stmts.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/grammar/tst.stmts.d new file mode 100644 index 000000000000..03a015ad3229 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/grammar/tst.stmts.d @@ -0,0 +1,59 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Test the various kinds of D probe description statement + * rules in the grammar. + * + * SECTION: Program Structure/Probe Descriptions + * + */ + + +BEGIN +{ + i = 0; +} + +tick-1 +/i != 20/ +{ + i++; + x = 0; + stack(); + @a = count(); + @b = max(x); + @c[x] = count(); + @d[x] = max(x); +} + +tick-1 +/i = 20/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/err.D_DECL_IDRED.redef1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/err.D_DECL_IDRED.redef1.d new file mode 100644 index 000000000000..39f2996ad277 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/err.D_DECL_IDRED.redef1.d @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * + * Test handling of an inline definition that overrides a previous + * definition of an inline definition. + * + * SECTION: Type and Constant Definitions/Inlines + * + * NOTES: + * + */ + +inline int foo = timestamp; +inline int foo = 8; diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/err.D_DECL_IDRED.redef2.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/err.D_DECL_IDRED.redef2.d new file mode 100644 index 000000000000..1df590802866 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/err.D_DECL_IDRED.redef2.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * + * Test handling of an inline definition that overrides a previous + * definition of a dtrace built-in function. + * + * SECTION: Type and Constant Definitions/Inlines + * + * NOTES: + * + */ + +inline int rand = 7; diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/err.D_IDENT_UNDEF.recur.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/err.D_IDENT_UNDEF.recur.d new file mode 100644 index 000000000000..95522d0eb60a --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/err.D_IDENT_UNDEF.recur.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * + * D program to test recursive inline definitions. This script should + * properly detect that foo is undefined on the right-hand side and fail. + * + * SECTION: Type and Constant Definitions/Inlines + * + * NOTES: + * + */ + +inline int foo = foo + 3; diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/err.D_OP_INCOMPAT.baddef1.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/err.D_OP_INCOMPAT.baddef1.d new file mode 100644 index 000000000000..a42afb747e97 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/err.D_OP_INCOMPAT.baddef1.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * + * Attempt to create an invalid inline definition by creating an + * inline of a function type. This should fail to compile. + * + * SECTION: Type and Constant Definitions/Inlines + * + * NOTES: + * + */ + +inline cyc_func_t i = "i am a cyclic function"; diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/err.D_OP_INCOMPAT.baddef2.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/err.D_OP_INCOMPAT.baddef2.d new file mode 100644 index 000000000000..9a246b4b123e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/err.D_OP_INCOMPAT.baddef2.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * + * Attempt to create an invalid inline definition by creating an + * inline of incompatible types. This should fail to compile. + * + * SECTION: Type and Constant Definitions/Inlines + * + * NOTES: + * + */ + +inline int i = "i am a string"; diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/err.D_OP_INCOMPAT.badxlate.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/err.D_OP_INCOMPAT.badxlate.d new file mode 100644 index 000000000000..963b604839a3 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/err.D_OP_INCOMPAT.badxlate.d @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * + * Test an invalid inline definition of a translator. An inlined translation + * must have the same type as the translator output. + * + * SECTION: Type and Constant Definitions/Inlines + * + * NOTES: + * + */ + +inline vfs_t *invalid = xlate(curthread->t_procp); diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/tst.InlineDataAssign.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/tst.InlineDataAssign.d new file mode 100644 index 000000000000..c7ab62fd9ce6 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/tst.InlineDataAssign.d @@ -0,0 +1,68 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * ASSERTION: + * Declare different types of inline data types. + * + * SECTION: Type and Constant Definitions/Inlines + * + * NOTES: The commented lines defining floats and doubles should be uncommented + * once the functionality is provided. + * + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + + +inline char new_char = 'c'; +inline short new_short = 10; +inline int new_int = 100; +inline long new_long = 1234567890; +inline long long new_long_long = 1234512345; +inline int8_t new_int8 = 'p'; +inline int16_t new_int16 = 20; +inline int32_t new_int32 = 200; +inline int64_t new_int64 = 2000000; +inline intptr_t new_intptr = 0x12345; +inline uint8_t new_uint8 = 'q'; +inline uint16_t new_uint16 = 30; +inline uint32_t new_uint32 = 300; +inline uint64_t new_uint64 = 3000000; +inline uintptr_t new_uintptr = 0x67890; +/* inline float new_float = 1.23456; +inline double new_double = 2.34567890; +inline long double new_long_double = 3.567890123; +*/ + +inline int * pointer = &`kmem_flags; + +BEGIN +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/tst.InlineExpression.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/tst.InlineExpression.d new file mode 100644 index 000000000000..d67d3f27d0fe --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/tst.InlineExpression.d @@ -0,0 +1,80 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * ASSERTION: + * + * Test different inline assignments by various expressions. + * + * SECTION: Type and Constant Definitions/Inlines + * + * NOTES: The commented lines for the floats and doubles should be uncommented + * once the functionality is implemented. + * + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + + +inline char new_char = 'c' + 2; +inline short new_short = 10 * new_char; +inline int new_int = 100 + new_short; +inline long new_long = 1234567890; +inline long long new_long_long = 1234512345 * new_long; +inline int8_t new_int8 = 'p'; +inline int16_t new_int16 = 20 / new_int8; +inline int32_t new_int32 = 200; +inline int64_t new_int64 = 2000000 * (-new_int16); +inline intptr_t new_intptr = 0x12345 - 129; +inline uint8_t new_uint8 = 'q'; +inline uint16_t new_uint16 = 30 - new_uint8; +inline uint32_t new_uint32 = 300 - 0; +inline uint64_t new_uint64 = 3000000; +inline uintptr_t new_uintptr = 0x67890 / new_uint64; + +/* inline float new_float = 1.23456; +inline double new_double = 2.34567890; +inline long double new_long_double = 3.567890123; +*/ + +inline int * pointer = &`kmem_flags; +inline int result = 3 > 2 ? 3 : 2; + +BEGIN +{ + printf("new_char: %c\nnew_short: %d\nnew_int: %d\nnew_long: %d\n", + new_char, new_short, new_int, new_long); + printf("new_long_long: %d\nnew_int8: %d\nnew_int16: %d\n", + new_long_long, new_int8, new_int16); + printf("new_int32: %d\nnew_int64: %d\n", new_int32, new_int64); + printf("new_intptr: %d\nnew_uint8: %d\nnew_uint16: %d\n", + new_intptr, new_uint8, new_uint16); + printf("new_uint32:%d\nnew_uint64: %d\nnew_uintptr:%d\nresult:%d", + new_uint32, new_uint64, new_uintptr, result); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/tst.InlineKinds.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/tst.InlineKinds.d new file mode 100644 index 000000000000..7f188fb0d575 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/tst.InlineKinds.d @@ -0,0 +1,64 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * Test the code generation and results of the various kinds of inlines. + * In particular, we test constant and expression-based scalar inlines, + * associative array inlines, and inlines using translators. + */ + +#pragma D option quiet + +inline int i0 = 100 + 23; /* constant-folded integer constant */ +inline string i1 = probename; /* string variable reference */ +inline int i2 = pid != 0; /* expression involving a variable */ + +struct s { + int s_x; +}; + +translator struct s < int T > { + s_x = T + 1; +}; + +inline struct s i3 = xlate < struct s > (i0); /* translator */ +inline int i4[int x, int y] = x + y; /* associative array */ +inline int i5[int x] = (xlate < struct s > (x)).s_x; /* array by xlate */ + +BEGIN +{ + printf("i0 = %d\n", i0); + printf("i1 = %s\n", i1); + printf("i2 = %d\n", i2); + + printf("i3.s_x = %d\n", i3.s_x); + printf("i4[10, 20] = %d\n", i4[10, 20]); + printf("i5[123] = %d\n", i5[123]); + + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/tst.InlineKinds.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/tst.InlineKinds.d.out new file mode 100644 index 000000000000..c9a603b24ef0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/tst.InlineKinds.d.out @@ -0,0 +1,7 @@ +i0 = 123 +i1 = BEGIN +i2 = 1 +i3.s_x = 124 +i4[10, 20] = 30 +i5[123] = 124 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/tst.InlineTypedef.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/tst.InlineTypedef.d new file mode 100644 index 000000000000..a6247659afa8 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/tst.InlineTypedef.d @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * ASSERTION: + * Create inline names from aliases created using typedef. + * + * SECTION: Type and Constant Definitions/Inlines + * + * NOTES: + * + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + + +typedef char new_char; +inline new_char char_var = 'c'; + +typedef int * pointer; +inline pointer p = &`kmem_flags; + +BEGIN +{ + printf("char_var: %c\npointer p: %d", char_var, *p); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/tst.InlineWritableAssign.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/tst.InlineWritableAssign.d new file mode 100644 index 000000000000..a7842a334da3 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/inline/tst.InlineWritableAssign.d @@ -0,0 +1,66 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * ASSERTION: + * Create inline names from aliases created using typedef. + * + * SECTION: Type and Constant Definitions/Inlines + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option quiet + + +struct record { + char c; + int i; +}; + +struct record rec1; +inline struct record rec2 = rec1; + +union var { + char c; + int i; +}; + +union var un1; +inline union var un2 = un1; + + +BEGIN +{ + rec1.c = 'c'; + rec1.i = 10; + + un1.c = 'd'; + + printf("rec1.c: %c\nrec1.i:%d\nun1.c: %c\n", rec1.c, rec1.i, un1.c); + printf("rec2.c: %c\nrec2.i:%d\nun2.c: %c\n", rec2.c, rec2.i, un2.c); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.c new file mode 100644 index 000000000000..2785b51f3084 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.c @@ -0,0 +1,100 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include +#include +#include +#include +#include +#include +#include + +static sigjmp_buf env; + +static void +interrupt(int sig) +{ + siglongjmp(env, sig); +} + +int +main(int argc, char *argv[]) +{ + const char *file = "/dev/null"; + int i, n, fds[10]; + struct sigaction act; + + if (argc > 1) { + (void) fprintf(stderr, "Usage: %s\n", argv[0]); + return (EXIT_FAILURE); + } + + act.sa_handler = interrupt; + act.sa_flags = 0; + + (void) sigemptyset(&act.sa_mask); + (void) sigaction(SIGUSR1, &act, NULL); + + closefrom(0); + n = 0; + + /* + * With all of our file descriptors closed, wait here spinning in bogus + * ioctl() calls until DTrace hits us with a SIGUSR1 to start the test. + */ + if (sigsetjmp(env, 1) == 0) { + for (;;) + (void) ioctl(-1, -1, NULL); + } + + /* + * To test the fds[] array, we open /dev/null (a file with reliable + * pathname and properties) using various flags and seek offsets. + */ + fds[n++] = open(file, O_RDONLY); + fds[n++] = open(file, O_WRONLY); + fds[n++] = open(file, O_RDWR); + + fds[n++] = open(file, O_RDWR | O_APPEND | O_CREAT | O_DSYNC | + O_LARGEFILE | O_NOCTTY | O_NONBLOCK | O_NDELAY | O_RSYNC | + O_SYNC | O_TRUNC | O_XATTR); + + fds[n++] = open(file, O_RDWR); + (void) lseek(fds[n - 1], 123, SEEK_SET); + + /* + * Once we have all the file descriptors in the state we want to test, + * issue a bogus ioctl() on each fd with cmd -1 and arg NULL to whack + * our DTrace script into recording the content of the fds[] array. + */ + for (i = 0; i < n; i++) + (void) ioctl(fds[i], -1, NULL); + + assert(n <= sizeof (fds) / sizeof (fds[0])); + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.d new file mode 100644 index 000000000000..52a3312da984 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.d @@ -0,0 +1,54 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma D option destructive +#pragma D option quiet + +syscall::ioctl:entry +/pid == $1 && arg0 == -1u/ +{ + raise(SIGUSR1); /* kick tst.fds.c out of its busy-wait loop */ +} + +syscall::ioctl:entry +/pid == $1 && arg0 != -1u && arg1 == -1u && arg2 == NULL/ +{ + printf("fds[%d] fi_name = %s\n", arg0, fds[arg0].fi_name); + printf("fds[%d] fi_dirname = %s\n", arg0, fds[arg0].fi_dirname); + printf("fds[%d] fi_pathname = %s\n", arg0, fds[arg0].fi_pathname); + printf("fds[%d] fi_fs = %s\n", arg0, fds[arg0].fi_fs); + printf("fds[%d] fi_mount = %s\n", arg0, fds[arg0].fi_mount); + printf("fds[%d] fi_offset = %d\n", arg0, fds[arg0].fi_offset); + printf("fds[%d] fi_oflags = 0x%x\n", arg0, fds[arg0].fi_oflags); +} + +proc:::exit +/pid == $1/ +{ + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.d.out new file mode 100644 index 000000000000..9d268268570d --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.d.out @@ -0,0 +1,36 @@ +fds[0] fi_name = mm@0:null +fds[0] fi_dirname = /devices/pseudo +fds[0] fi_pathname = /devices/pseudo/mm@0:null +fds[0] fi_fs = specfs +fds[0] fi_mount = /devices +fds[0] fi_offset = 0 +fds[0] fi_oflags = 0x0 +fds[1] fi_name = mm@0:null +fds[1] fi_dirname = /devices/pseudo +fds[1] fi_pathname = /devices/pseudo/mm@0:null +fds[1] fi_fs = specfs +fds[1] fi_mount = /devices +fds[1] fi_offset = 0 +fds[1] fi_oflags = 0x1 +fds[2] fi_name = mm@0:null +fds[2] fi_dirname = /devices/pseudo +fds[2] fi_pathname = /devices/pseudo/mm@0:null +fds[2] fi_fs = specfs +fds[2] fi_mount = /devices +fds[2] fi_offset = 0 +fds[2] fi_oflags = 0x2 +fds[3] fi_name = mm@0:null +fds[3] fi_dirname = /devices/pseudo +fds[3] fi_pathname = /devices/pseudo/mm@0:null +fds[3] fi_fs = specfs +fds[3] fi_mount = /devices +fds[3] fi_offset = 0 +fds[3] fi_oflags = 0xebda +fds[4] fi_name = mm@0:null +fds[4] fi_dirname = /devices/pseudo +fds[4] fi_pathname = /devices/pseudo/mm@0:null +fds[4] fi_fs = specfs +fds[4] fi_mount = /devices +fds[4] fi_offset = 123 +fds[4] fi_oflags = 0x2 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/manifest/test.jar-manifest b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/manifest/test.jar-manifest new file mode 100644 index 000000000000..8f07fb2cf3b9 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/manifest/test.jar-manifest @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 +Class-Path: /usr/share/lib/java/dtrace.jar diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/src/TestAbort.java b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/src/TestAbort.java new file mode 100644 index 000000000000..310dd184a726 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/src/TestAbort.java @@ -0,0 +1,158 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * ident "%Z%%M% %I% %E% SMI" + */ + +import org.opensolaris.os.dtrace.*; +import java.util.NoSuchElementException; + +/** + * Regression for 6426129 abort() after close() throws + * NoSuchElementException. + */ +public class TestAbort { + static boolean aborted = false; + + public static void + main(String[] args) + { + Consumer consumer = new LocalConsumer(); + + // Test for deadlock (bug 6419880) + try { + consumer.open(); + consumer.compile("syscall:::entry { @[execname] = count(); } " + + "tick-101ms { printa(@); }"); + consumer.enable(); + consumer.go(); + try { + Thread.currentThread().sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + System.exit(1); + } + consumer.close(); + } catch (DTraceException e) { + e.printStackTrace(); + System.exit(1); + } + + consumer = new LocalConsumer(); + + // Should be able to abort an unopened consumer + try { + aborted = false; + consumer.addConsumerListener(new ConsumerAdapter() { + public void consumerStopped(ConsumerEvent e) { + aborted = true; + } + }); + consumer.abort(); + consumer.open(); + consumer.compile("syscall:::entry { @[execname] = count(); } " + + "tick-101ms { printa(@); }"); + consumer.enable(); + consumer.go(); + try { + Thread.currentThread().sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + System.exit(1); + } + if (!aborted) { + throw new IllegalStateException("consumer not aborted"); + } + consumer.close(); + } catch (Exception e) { + e.printStackTrace(); + System.exit(1); + } + + consumer = new LocalConsumer(); + + // Should be safe to call abort() in any state + try { + consumer.abort(); + consumer.open(); + consumer.abort(); + consumer.compile("syscall:::entry { @[execname] = count(); } " + + "tick-101ms { printa(@); }"); + consumer.abort(); + consumer.enable(); + consumer.abort(); + consumer.go(); + consumer.abort(); + consumer.close(); + // Should be safe to call after close() + try { + consumer.abort(); + } catch (NoSuchElementException e) { + e.printStackTrace(); + System.exit(1); + } + } catch (Exception e) { + e.printStackTrace(); + System.exit(1); + } + + consumer = new LocalConsumer(); + + // Tests that close() throws expected exception when called on + // synchronized consumer. + try { + consumer.open(); + consumer.compile("syscall:::entry { @[execname] = count(); } " + + "tick-101ms { printa(@); }"); + consumer.enable(); + consumer.go(); + try { + Thread.currentThread().sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + System.exit(1); + } + try { + synchronized (consumer) { + consumer.close(); + } + } catch (IllegalThreadStateException e) { + try { + consumer.close(); + System.out.println("Successful"); + System.exit(0); + } catch (NoSuchElementException x) { + x.printStackTrace(); + System.exit(1); + } + } + } catch (DTraceException e) { + e.printStackTrace(); + System.exit(1); + } + System.err.println("Failed"); + System.exit(1); + } +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/src/TestBean.java b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/src/TestBean.java new file mode 100644 index 000000000000..dd4a969d4355 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/src/TestBean.java @@ -0,0 +1,706 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * ident "%Z%%M% %I% %E% SMI" + */ + +import org.opensolaris.os.dtrace.*; +import java.util.*; +import java.io.*; +import java.beans.*; +import java.lang.reflect.*; + +/** + * Regression test for serialization and XML encoding/decoding. Tests + * every Serializable class in the Java DTrace API by creating a dummy + * instance, writing it to a file, then reading it back in and comparing + * the string values of the object before and after, as well as + * verifying object equality before and after if the class overrides the + * equals() method. + */ +public class TestBean { + public static final String[] TESTS = new String[] { + "ExitRecord", + "AggregationRecord", + "Aggregation", + "Tuple", + "ScalarRecord", + "KernelStackRecord", + "LogDistribution", + "LinearDistribution", + "Option", + "ProcessState", + "ProbeDescription", + "PrintaRecord", + "PrintfRecord", + "ProbeData", + "Aggregate", + "UserStackRecord", + "AvgValue", + "CountValue", + "SumValue", + "MinValue", + "MaxValue", + "Error", + "Drop", + "InterfaceAttributes", + "ProgramInfo", + "ProbeInfo", + "Probe", + "Flow", + "KernelSymbolRecord", + "UserSymbolRecord", + "UserSymbolRecord$Value", + "Program", + "Program$File", + "StddevValue" + }; + + static File file; + + static void + exit(int status) + { + System.out.flush(); + System.err.flush(); + System.exit(status); + } + + public static XMLEncoder + getXMLEncoder(File file) + { + XMLEncoder encoder = null; + try { + OutputStream out = new BufferedOutputStream + (new FileOutputStream(file)); + encoder = new XMLEncoder(out); + } catch (Exception e) { + e.printStackTrace(); + exit(1); + } + return encoder; + } + + public static XMLDecoder + getXMLDecoder(File file) + { + return getXMLDecoder(file, null); + } + + public static XMLDecoder + getXMLDecoder(File file, ExceptionListener exceptionListener) + { + XMLDecoder decoder = null; + try { + InputStream in = new BufferedInputStream + (new FileInputStream(file)); + decoder = new XMLDecoder(in, null, exceptionListener); + } catch (Exception e) { + e.printStackTrace(); + exit(1); + } + return decoder; + } + + public static ExitRecord + getExitRecord() + { + ExitRecord r = new ExitRecord(1); + return r; + } + + public static AggregationRecord + getAggregationRecord() + { + Tuple tuple = getTuple(); + AggregationValue value = new CountValue(7); + AggregationRecord r = new AggregationRecord(tuple, value); + return r; + } + + public static Aggregation + getAggregation() + { + List < AggregationRecord > list = + new ArrayList < AggregationRecord > (); + AggregationRecord r; + r = getAggregationRecord(); + list.add(r); + + ValueRecord v1 = new ScalarRecord(new byte[] {(byte)1, (byte)2, + (byte)3}, 3); + ValueRecord v2 = new ScalarRecord("shebang!", 256); + Tuple tuple = new Tuple(v1, v2); + AggregationValue value = getLinearDistribution(); + r = new AggregationRecord(tuple, value); + list.add(r); + + Aggregation a = new Aggregation("counts", 2, list); + return a; + } + + public static Tuple + getTuple() + { + ValueRecord r1 = new ScalarRecord("cat", 256); + ValueRecord r2 = new ScalarRecord(new Integer(9), 2); + ValueRecord r3 = new KernelStackRecord( + new StackFrame[] { + new StackFrame("has"), + new StackFrame("nine"), + new StackFrame("lives")}, + new byte[] { (byte)0, (byte)1, (byte)2 }); + ValueRecord r4 = new ScalarRecord(new byte[] {(byte)1, (byte)2, + (byte)3}, 3); + + Tuple tuple = new Tuple(r1, r2, r3, r4); + return tuple; + } + + public static ScalarRecord + getScalarRecord() + { + Object v = new byte[] {(byte)1, (byte)2, (byte)3}; + ScalarRecord r = new ScalarRecord(v, 3); + return r; + } + + public static KernelStackRecord + getKernelStackRecord() + { + StackFrame[] stackFrames = new StackFrame[] { + new StackFrame("Frame 1"), + new StackFrame("Frame 2"), + new StackFrame("Frame 3") + }; + KernelStackRecord r = new KernelStackRecord(stackFrames, + new byte[] { (byte)0, (byte)1, (byte)2 }); + return r; + } + + public static LogDistribution + getLogDistribution() + { + List < Distribution.Bucket > buckets = + new ArrayList < Distribution.Bucket > (); + Distribution.Bucket bucket; + int n = 0; + long base = 0; + long i; + long sign; + long nextSign; + long power; + long nextPower; + long lowerBound; + long upperBound; + for (i = -62; i <= 62; ++i) { + if (i == 0) { + bucket = new Distribution.Bucket(-1, -1, n++); + buckets.add(bucket); + bucket = new Distribution.Bucket(0, 0, n++); + buckets.add(bucket); + bucket = new Distribution.Bucket(1, 1, n++); + buckets.add(bucket); + continue; + } + sign = ((i < 0) ? -1L : 1L); + power = (sign * i); + nextSign = (((i + 1) < 0) ? -1L : 1L); + nextPower = (nextSign * (i + 1)); + lowerBound = sign * ((long) Math.pow(2L, power)); + upperBound = (nextPower == 0 ? -2L : + (nextSign * ((long) Math.pow(2L, nextPower))) - 1); + if ((upperBound > 0) && ((upperBound * 2L) < 0)) { + upperBound = Long.MAX_VALUE; + } + bucket = new Distribution.Bucket(lowerBound, upperBound, n++); + buckets.add(bucket); + } + LogDistribution d = new LogDistribution(buckets); + return d; + } + + public static LinearDistribution + getLinearDistribution() + { + List < Distribution.Bucket > buckets = + new ArrayList < Distribution.Bucket > (); + Distribution.Bucket bucket; + int n = 10; // number of buckets + int base = 1; + int step = 10; + bucket = new Distribution.Bucket(Long.MIN_VALUE, (base - 1), 0); + buckets.add(bucket); + for (int i = base; i < (n * step); i += step) { + bucket = new Distribution.Bucket(i, (i + (step - 1)), + ((i - 1) / step)); + buckets.add(bucket); + } + bucket = new Distribution.Bucket((n * step) + 1, Long.MAX_VALUE, 0); + buckets.add(bucket); + LinearDistribution d = new LinearDistribution(base, step, buckets); + return d; + } + + public static Option + getOption() + { + Option option = new Option("aggrate", "1s"); + return option; + } + + public static ProcessState + getProcessState() + { + ProcessState p = new ProcessState(123456, "UNDEAD", + 3, "SIGSTOP", + -2, "Process stopped on dime"); + return p; + } + + public static ProbeDescription + getProbeDescription() + { + ProbeDescription d = new ProbeDescription(256, "syscall", null, + "malloc", "entry"); + return d; + } + + public static PrintaRecord + getPrintaRecord() + { + List < Aggregation > aggregations = new ArrayList < Aggregation > (); + Aggregation a = getAggregation(); + aggregations.add(a); + aggregations.add(a); + Map < Tuple, String > formattedOutput = + new HashMap < Tuple, String > (); + for (Tuple t : a.asMap().keySet()) { + formattedOutput.put(t, "cat"); + } + List < Tuple > tuples = new ArrayList < Tuple > (); + for (Tuple t : a.asMap().keySet()) { + tuples.add(t); + } + Collections.sort(tuples); + PrintaRecord r = new PrintaRecord(1234567890L, + aggregations, formattedOutput, tuples, + "Yes, this is the formatted printa() output"); + return r; + } + + public static PrintfRecord + getPrintfRecord() + { + List < ValueRecord > list = new ArrayList < ValueRecord > (); + ValueRecord v1 = getScalarRecord(); + ValueRecord v2 = new ScalarRecord(new Integer(7), 4); + list.add(v1); + list.add(v2); + PrintfRecord r = new PrintfRecord(list, + "long formatted string"); + return r; + } + + public static ProbeData + getProbeData() + { + List < Record > list = new ArrayList < Record > (); + list.add(getPrintaRecord()); + list.add(getPrintfRecord()); + list.add(getScalarRecord()); + list.add(getUserSymbolRecord()); + list.add(getUserStackRecord()); + list.add(getExitRecord()); + ProbeData d = new ProbeData(7, 1, getProbeDescription(), + getFlow(), list); + return d; + } + + public static Aggregate + getAggregate() + { + List < Aggregation > list = new ArrayList < Aggregation > (); + list.add(getAggregation()); + + List < AggregationRecord > reclist = + new ArrayList < AggregationRecord > (); + AggregationRecord r; + ValueRecord v1 = new ScalarRecord("cat", 256); + ValueRecord v2 = new ScalarRecord("dog", 256); + ValueRecord v3 = new ScalarRecord("mouse", 256); + ValueRecord v4 = new ScalarRecord("mouse", 256); + ValueRecord v5 = new ScalarRecord(new Byte((byte) 'C'), 1); + ValueRecord v6 = new ScalarRecord(new Short((short) 7), 2); + Tuple tuple = new Tuple(v1, v2, v3, v4, v5, v6); + AggregationValue value = getCountValue(); + r = new AggregationRecord(tuple, value); + reclist.add(r); + list.add(new Aggregation("times", 1, reclist)); + + Aggregate a = new Aggregate(1234567890L, list); + return a; + } + + public static UserStackRecord + getUserStackRecord() + { + StackFrame[] frames = new StackFrame[] { + new StackFrame("User Stack Frame 1"), + new StackFrame("User Stack Frame 2"), + new StackFrame("User Stack Frame 3") + }; + UserStackRecord r = new UserStackRecord(123456, frames, + new byte[] { (byte)0, (byte)1, (byte)2 }); + return r; + } + + public static AvgValue + getAvgValue() + { + AvgValue v = new AvgValue(5, 20, 4); + return v; + } + + public static CountValue + getCountValue() + { + CountValue v = new CountValue(9); + return v; + } + + public static MinValue + getMinValue() + { + MinValue v = new MinValue(101); + return v; + } + + public static MaxValue + getMaxValue() + { + MaxValue v = new MaxValue(101); + return v; + } + + public static SumValue + getSumValue() + { + SumValue v = new SumValue(25); + return v; + } + + public static org.opensolaris.os.dtrace.Error + getError() + { + ProbeDescription probe = getProbeDescription(); + org.opensolaris.os.dtrace.Error e = + new org.opensolaris.os.dtrace.Error(probe, 8, 3, + 1, 20, "DTRACEFLT_BADALIGN", -1, "error on enabled probe ID 8 " + + "(ID " + probe.getID() + ": " + probe + "): Bad alignment " + + "(0x33ef) in action #1 at DIF offset 20"); + return e; + } + + public static Drop + getDrop() + { + Drop drop = new Drop(2, "SPECBUSY", 72, 1041, + "Guess we dropped stuff all over the place."); + return drop; + } + + public static InterfaceAttributes + getInterfaceAttributes() + { + InterfaceAttributes a = new InterfaceAttributes( + InterfaceAttributes.Stability.UNSTABLE, + InterfaceAttributes.Stability.EVOLVING, + InterfaceAttributes.DependencyClass.ISA); + return a; + } + + public static ProgramInfo + getProgramInfo() + { + ProgramInfo info = new ProgramInfo(getInterfaceAttributes(), + getInterfaceAttributes(), 256); + return info; + } + + public static ProbeInfo + getProbeInfo() + { + ProbeInfo info = new ProbeInfo(getInterfaceAttributes(), + getInterfaceAttributes()); + return info; + } + + public static Probe + getProbe() + { + Probe p = new Probe(getProbeDescription(), getProbeInfo()); + return p; + } + + public static Flow + getFlow() + { + Flow f = new Flow(Flow.Kind.RETURN.name(), 3); + return f; + } + + public static KernelSymbolRecord + getKernelSymbolRecord() + { + KernelSymbolRecord r = new KernelSymbolRecord("mod`func+0x4", -1L); + return r; + } + + public static UserSymbolRecord + getUserSymbolRecord() + { + UserSymbolRecord r = new UserSymbolRecord(7, "mod`func+0x4", -1L); + return r; + } + + public static UserSymbolRecord.Value + getUserSymbolRecord$Value() + { + UserSymbolRecord.Value v = new UserSymbolRecord.Value(7, -1L); + return v; + } + + public static Program + getProgram() + { + final String PROGRAM = "syscall:::entry { @[execname] = count(); }"; + Consumer consumer = new LocalConsumer(); + Program p; + try { + consumer.open(); + p = consumer.compile(PROGRAM); + consumer.close(); + } catch (DTraceException e) { + e.printStackTrace(); + p = null; + } + return p; + } + + public static Program.File + getProgram$File() + { + final String PROGRAM = "syscall:::entry { @[execname] = count(); }"; + Consumer consumer = new LocalConsumer(); + Program p; + try { + OutputStream out = new FileOutputStream(file); + out.write(PROGRAM.getBytes(), 0, PROGRAM.length()); + out.flush(); + out.close(); + consumer.open(); + p = consumer.compile(file); + consumer.close(); + } catch (Exception e) { + e.printStackTrace(); + p = null; + } + return Program.File.class.cast(p); + } + + public static StddevValue + getStddevValue() + { + StddevValue v = new StddevValue(37, 114, 5, Integer.toString(9544)); + return v; + } + + @SuppressWarnings("unchecked") + static String + getString(Object o) + { + String s; + if (o instanceof ScalarRecord) { + o = ((ScalarRecord)o).getValue(); + } + + if (o instanceof byte[]) { + s = Arrays.toString((byte[])o); + } else if (o instanceof Object[]) { + s = Arrays.toString((Object[])o); + } else { + Class c = o.getClass(); + try { + Method m = c.getDeclaredMethod("toLogString"); + s = (String)m.invoke(o); + } catch (Exception e) { + s = o.toString(); + } + } + return s; + } + + static void + checkEquality(Object obj, Object newobj) + { + // If the class overrides equals(), make sure the re-created + // object still equals the original object + try { + Method eq = obj.getClass().getDeclaredMethod("equals", + Object.class); + Boolean ret = (Boolean) eq.invoke(obj, newobj); + if (ret != true) { + System.err.println("serialization failed: " + + obj.getClass().getName()); + exit(1); + } + } catch (Exception e) { + // Does not override equals(), although a super-class might. + // A better test would check for any superclass other than + // Object.class. + } + } + + static void + performSerializationTest(File file, String classname) + throws IOException, ClassNotFoundException + { + String methodName = "get" + classname; + Object obj = null; + Object newobj = null; + try { + Method method = TestBean.class.getDeclaredMethod(methodName); + obj = method.invoke(null); + } catch (Exception e) { + e.printStackTrace(); + exit(1); + } + + System.out.println(classname + ":"); + String serialized = getString(obj); + System.out.println(" serialized: " + serialized); + FileOutputStream fos = new FileOutputStream(file); + ObjectOutputStream out = new ObjectOutputStream(fos); + out.writeObject(obj); + out.close(); + FileInputStream fis = new FileInputStream(file); + ObjectInputStream in = new ObjectInputStream(fis); + newobj = in.readObject(); + in.close(); + String deserialized = getString(newobj); + System.out.println(" deserialized: " + deserialized); + + if (!serialized.equals(deserialized)) { + System.err.println("serialization failed: " + classname); + exit(1); + } + checkEquality(obj, newobj); + } + + static void + performBeanTest(File file, String classname) + { + String methodName = "get" + classname; + Object obj = null; + Object newobj = null; + try { + Method method = TestBean.class.getDeclaredMethod(methodName); + obj = method.invoke(null); + } catch (Exception e) { + e.printStackTrace(); + exit(1); + } + + Class c = obj.getClass(); + if (c.getConstructors().length == 0) { + return; + } + + System.out.println(classname + ":"); + XMLEncoder encoder = getXMLEncoder(file); + String encoded = getString(obj); + System.out.println(" encoded: " + encoded); + encoder.writeObject(obj); + encoder.close(); + XMLDecoder decoder = getXMLDecoder(file); + newobj = decoder.readObject(); + String decoded = getString(newobj); + System.out.println(" decoded: " + decoded); + decoder.close(); + + if (!encoded.equals(decoded)) { + System.err.println("bean persistence failed: " + classname); + exit(1); + } + checkEquality(obj, newobj); + } + + public static void + main(String[] args) + { + if ((args.length != 1) && (args.length != 2)) { + System.err.println("usage: java TestBean < filename > " + + "[ < classname > ]"); + exit(1); + } + + String filename = args[0]; + String classname = null; + if (args.length >= 2) { + classname = args[1]; + } + + file = new File(filename); + try { + if (!file.canRead()) { + try { + file.createNewFile(); + } catch (Exception e) { + System.err.println("failed to create " + filename); + exit(1); + } + } + } catch (SecurityException e) { + System.err.println("failed to open " + filename); + exit(1); + } + + String[] tests = (classname == null ? TESTS: + new String[] { classname }); + try { + for (int i = 0; i < tests.length; ++i) { + performSerializationTest(file, tests[i]); + performBeanTest(file, tests[i]); + } + } catch (IOException e) { + e.printStackTrace(); + exit(1); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + exit(1); + } + } +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/src/TestClose.java b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/src/TestClose.java new file mode 100644 index 000000000000..c7a9e89d0383 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/src/TestClose.java @@ -0,0 +1,90 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * ident "%Z%%M% %I% %E% SMI" + */ + +import org.opensolaris.os.dtrace.*; + +/** + * Regression for bug 6419880 close() hangs running consumer. + */ +public class TestClose { + public static void + main(String[] args) + { + Consumer consumer = new LocalConsumer(); + + try { + consumer.open(); + consumer.compile("syscall:::entry { @[execname] = count(); } " + + "tick-101ms { printa(@); }"); + consumer.enable(); + consumer.go(); + try { + Thread.currentThread().sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + System.exit(1); + } + consumer.close(); + } catch (DTraceException e) { + e.printStackTrace(); + System.exit(1); + } + + consumer = new LocalConsumer(); + + try { + consumer.open(); + consumer.compile("syscall:::entry { @[execname] = count(); } " + + "tick-101ms { printa(@); }"); + consumer.enable(); + consumer.go(); + try { + Thread.currentThread().sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + System.exit(1); + } + try { + // Test new rule that close() is illegal while holding + // lock on consumer. + synchronized (consumer) { + consumer.close(); + } + } catch (IllegalThreadStateException e) { + consumer.close(); + System.out.println("Successful"); + System.exit(0); + } + } catch (DTraceException e) { + e.printStackTrace(); + System.exit(1); + } + System.err.println("Failed"); + System.exit(1); + } +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/src/TestDrop.java b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/src/TestDrop.java new file mode 100644 index 000000000000..b5ace25bdbde --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/src/TestDrop.java @@ -0,0 +1,169 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * ident "%Z%%M% %I% %E% SMI" + */ +import java.util.*; +import java.util.concurrent.atomic.*; +import org.opensolaris.os.dtrace.*; + +/** + * Regression test for 6521523 aggregation drops can hang the Java + * DTrace API. + */ +public class TestDrop { + static final String PROGRAM = + "fbt:genunix::entry { @[execname, pid] = count(); }"; + + static AtomicLong consumerThreadID = new AtomicLong(); + static AtomicLong getAggregateThreadID = new AtomicLong(); + static AtomicBoolean done = new AtomicBoolean(); + static int seconds; + + private static void + startTimer() + { + if (seconds <= 0) { + return; + } + + final Timer timer = new Timer(); + timer.schedule(new TimerTask() { + public void run() { + done.set(true); + timer.cancel(); + } + }, seconds * 1000L); + } + + private static void + sampleAggregate(Consumer consumer) throws DTraceException + { + while (consumer.isRunning() && !done.get()) { + try { + Thread.currentThread().sleep(50); + } catch (InterruptedException e) { + } + + consumer.getAggregate(Collections. emptySet()); + } + } + + private static void + startAggregateThread(final Consumer consumer) + { + Runnable aggregateSampler = new Runnable() { + public void run() { + Thread t = Thread.currentThread(); + getAggregateThreadID.set(t.getId()); + Throwable x = null; + try { + sampleAggregate(consumer); + } catch (Throwable e) { + x = e; + } + + if (Thread.holdsLock(LocalConsumer.class)) { + if (x != null) { + x.printStackTrace(); + } + System.out.println("Lock held"); + System.exit(1); + } else { + System.out.println("Lock released"); + consumer.close(); // blocks if lock held + } + } + }; + + Thread t = new Thread(aggregateSampler, "Aggregate Sampler"); + t.start(); + } + + static void + usage() + { + System.err.println("usage: java TestDrop [ seconds ]"); + System.exit(2); + } + + public static void + main(String[] args) + { + if (args.length == 1) { + try { + seconds = Integer.parseInt(args[0]); + } catch (NumberFormatException e) { + usage(); + } + } else if (args.length > 1) { + usage(); + } + + final Consumer consumer = new LocalConsumer() { + protected Thread createThread() { + Runnable worker = new Runnable() { + public void run() { + Thread t = Thread.currentThread(); + consumerThreadID.set(t.getId()); + work(); + } + }; + Thread t = new Thread(worker); + return t; + } + }; + + consumer.addConsumerListener(new ConsumerAdapter() { + public void consumerStarted(ConsumerEvent e) { + startAggregateThread(consumer); + startTimer(); + } + public void dataDropped(DropEvent e) throws ConsumerException { + Thread t = Thread.currentThread(); + if (t.getId() == getAggregateThreadID.get()) { + Drop drop = e.getDrop(); + throw new ConsumerException(drop.getDefaultMessage(), + drop); + } + } + }); + + try { + consumer.open(); + consumer.setOption(Option.aggsize, Option.kb(1)); + consumer.setOption(Option.aggrate, Option.millis(101)); + consumer.compile(PROGRAM); + consumer.enable(); + consumer.go(new ExceptionHandler() { + public void handleException(Throwable e) { + e.printStackTrace(); + } + }); + } catch (DTraceException e) { + e.printStackTrace(); + } + } +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/src/TestEnable.java b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/src/TestEnable.java new file mode 100644 index 000000000000..0e5a608691c0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/src/TestEnable.java @@ -0,0 +1,151 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * ident "%Z%%M% %I% %E% SMI" + */ + +import org.opensolaris.os.dtrace.*; + +/** + * Prove that enable() handles multiple programs, recognizing programs + * that are already enabled and programs that were compiled by another + * consumer. + */ +public class TestEnable { + static void + exit(int status) + { + System.out.flush(); + System.err.flush(); + System.exit(status); + } + + public static void + main(String[] args) + { + Consumer consumer = new LocalConsumer(); + + try { + consumer.open(); + Program p0 = consumer.compile("dtrace:::BEGIN"); + Program p1 = consumer.compile("syscall:::entry"); + Program p2 = consumer.compile("dtrace:::END"); + consumer.enable(p0); + consumer.enable(p1); + try { + consumer.go(); + System.err.println("go() illegal, not all programs " + + "enabled (p0, p1)"); + exit(1); + } catch (IllegalStateException e) { + System.out.println(e); + } catch (Exception e) { + e.printStackTrace(); + exit(1); + } + try { + consumer.enable(); + System.err.println("enable() illegal, some programs " + + "already enabled (p0, p1)"); + exit(1); + } catch (IllegalStateException e) { + System.out.println(e); + } catch (Exception e) { + e.printStackTrace(); + exit(1); + } + try { + consumer.enable(p0); + System.err.println("cannot enable a program that " + + "has already been enabled (p0)"); + exit(1); + } catch (IllegalStateException e) { + System.out.println(e); + } catch (Exception e) { + e.printStackTrace(); + exit(1); + } + consumer.enable(p2); + Program p3 = consumer.compile("syscall:::return"); + try { + consumer.go(); + System.err.println("go() illegal, not all programs " + + "enabled (p0, p1, p2)"); + exit(1); + } catch (IllegalStateException e) { + System.out.println(e); + } catch (Exception e) { + e.printStackTrace(); + exit(1); + } + try { + consumer.enable(); + System.err.println("enable() illegal, some programs " + + "already enabled (p0, p1, p2)"); + exit(1); + } catch (IllegalStateException e) { + System.out.println(e); + } catch (Exception e) { + e.printStackTrace(); + exit(1); + } + // Try to fool the consumer with a program compiled by + // another consumer + Consumer consumer2 = new LocalConsumer(); + consumer2.open(); + Program p3x = consumer2.compile("syscall:::return"); + try { + consumer.enable(p3x); + System.err.println("cannot enable program compiled " + + "by another consumer"); + exit(1); + } catch (IllegalArgumentException e) { + System.out.println(e); + } catch (Exception e) { + e.printStackTrace(); + exit(1); + } finally { + consumer2.close(); + } + consumer.enable(p3); + consumer.go(); + consumer.close(); + + // Enable all compiled programs at once + consumer = new LocalConsumer(); + consumer.open(); + consumer.compile("dtrace:::BEGIN"); + consumer.compile("syscall:::entry"); + consumer.compile("dtrace:::END"); + consumer.enable(); + consumer.go(); + consumer.close(); + exit(0); + } catch (DTraceException e) { + e.printStackTrace(); + exit(1); + } + } +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/src/TestFunctionLookup.java b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/src/TestFunctionLookup.java new file mode 100644 index 000000000000..3488903c19ea --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/src/TestFunctionLookup.java @@ -0,0 +1,116 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * ident "%Z%%M% %I% %E% SMI" + */ + +import org.opensolaris.os.dtrace.*; + +/** + * Regression for bug 6413280 lookupKernelFunction() and + * lookupUserFunction() truncate last character. + */ +public class TestFunctionLookup { + static final String kernelLookupProgram = "sdt:::callout-start { " + + "@[((callout_t *)arg0)->c_func] = count(); }"; + static final String userLookupProgram = "pid$target::f2:entry { " + + "@[arg0] = count(); }"; + + public static void + main(String[] args) + { + if (args.length != 1) { + System.err.println("usage: java TestFunctionLookup "); + System.exit(1); + } + String cmd = args[0]; + + Consumer consumer = new LocalConsumer(); + try { + consumer.open(); + consumer.compile(kernelLookupProgram); + consumer.enable(); + consumer.go(); + Aggregate a; + Number address; + String f; + boolean done = false; + for (int i = 0; (i < 20) && !done; ++i) { + Thread.currentThread().sleep(100); + a = consumer.getAggregate(); + for (Aggregation agg : a.getAggregations()) { + for (Tuple tuple : agg.asMap().keySet()) { + address = (Number)tuple.get(0).getValue(); + if (address instanceof Integer) { + int addr = (Integer)address; + f = consumer.lookupKernelFunction(addr); + } else { + long addr = (Long)address; + f = consumer.lookupKernelFunction(addr); + } + if (f.equals("genunix`setrun")) { + System.out.println(f); + done = true; + } + } + } + } + consumer.close(); + } catch (Exception e) { + e.printStackTrace(); + System.exit(1); + } + + consumer = new LocalConsumer(); + try { + consumer.open(); + int pid = consumer.createProcess(cmd); + consumer.compile(userLookupProgram); + consumer.enable(); + consumer.go(); + Thread.currentThread().sleep(500); + Aggregate a = consumer.getAggregate(); + Number address; + String f; + for (Aggregation agg : a.getAggregations()) { + for (Tuple tuple : agg.asMap().keySet()) { + address = (Number)tuple.get(0).getValue(); + if (address instanceof Integer) { + int addr = (Integer)address; + f = consumer.lookupUserFunction(pid, addr); + } else { + long addr = (Long)address; + f = consumer.lookupUserFunction(pid, addr); + } + System.out.println(f); + } + } + consumer.close(); + } catch (Exception e) { + e.printStackTrace(); + System.exit(1); + } + } +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/src/TestMaxConsumers.java b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/src/TestMaxConsumers.java new file mode 100644 index 000000000000..50eeac23b7a1 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/src/TestMaxConsumers.java @@ -0,0 +1,97 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * ident "%Z%%M% %I% %E% SMI" + */ + +import org.opensolaris.os.dtrace.*; + +/** + * Regression for 6506495 -DJAVA_DTRACE_MAX_CONSUMERS=N for any N < 8 + * is treated as if it were 8. + */ +public class TestMaxConsumers { + static final String MAX_CONSUMERS_PROPERTY_NAME = + "JAVA_DTRACE_MAX_CONSUMERS"; + + static Integer + getIntegerProperty(String name) + { + Integer value = null; + String property = System.getProperty(name); + if (property != null && property.length() != 0) { + try { + value = Integer.parseInt(property); + } catch (NumberFormatException e) { + e.printStackTrace(); + } + } + return value; + } + + public static void + main(String[] args) + { + Integer property = getIntegerProperty(MAX_CONSUMERS_PROPERTY_NAME); + int max = (property == null ? 0 : property); + int n = (property == null ? 11 : (max < 1 ? 1 : max)); + + Consumer[] consumers = new Consumer[n]; + try { + for (int i = 0; i < n; ++i) { + consumers[i] = new LocalConsumer(); + consumers[i].open(); + } + for (int i = 0; i < n; ++i) { + consumers[i].close(); + } + for (int i = 0; i < n; ++i) { + consumers[i] = new LocalConsumer(); + consumers[i].open(); + } + } catch (Exception e) { + e.printStackTrace(); + System.exit(1); + } + + try { + Consumer consumer = new LocalConsumer(); + consumer.open(); + if (max > 0) { + System.out.println("Error: " + (max + 1) + " > " + + MAX_CONSUMERS_PROPERTY_NAME); + } else { + System.out.println("Success"); + } + consumer.close(); + } catch (Exception e) { + System.out.println("Success"); + } finally { + for (int i = 0; i < n; ++i) { + consumers[i].close(); + } + } + } +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/src/TestMultiAggPrinta.java b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/src/TestMultiAggPrinta.java new file mode 100644 index 000000000000..facdf7fad364 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/java_api/src/TestMultiAggPrinta.java @@ -0,0 +1,144 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * ident "%Z%%M% %I% %E% SMI" + */ + +import java.io.File; +import java.io.IOException; +import java.util.List; +import org.opensolaris.os.dtrace.*; + +/** + * Regression for multi-aggregation printa() corner cases. + */ +public class TestMultiAggPrinta { + static int exitStatus; + + // Gets a string representation of the given PrintaRecord minus the + // timestamp of the aggregate snapshot, so that the output is + // comparable across multiple test runs. + static String + printaRecordString(PrintaRecord rec) + { + StringBuffer buf = new StringBuffer(); + buf.append(PrintaRecord.class.getName()); + buf.append("[aggregations = "); + buf.append(rec.getAggregations()); + buf.append(", formattedStrings = "); + buf.append(rec.getFormattedStrings()); + buf.append(", tuples = "); + buf.append(rec.getTuples()); + buf.append(", output = "); + buf.append(rec.getOutput()); + buf.append(']'); + return buf.toString(); + } + + static String + probeDataString(ProbeData data) + { + StringBuffer buf = new StringBuffer(); + buf.append(ProbeData.class.getName()); + buf.append("[epid = "); + buf.append(data.getEnabledProbeID()); + // Do not include cpu, since it can change across test runs + buf.append(", enabledProbeDescription = "); + buf.append(data.getEnabledProbeDescription()); + buf.append(", flow = "); + buf.append(data.getFlow()); + buf.append(", records = "); + + List records = data.getRecords(); + Record record; + Object value; + buf.append('['); + for (int i = 0; i < records.size(); ++i) { + if (i > 0) { + buf.append(", "); + } + record = records.get(i); + if (record instanceof ValueRecord) { + value = ((ValueRecord)record).getValue(); + if (value instanceof String) { + buf.append("\""); + buf.append((String)value); + buf.append("\""); + } else { + buf.append(record); + } + } else if (record instanceof PrintaRecord) { + PrintaRecord printa = (PrintaRecord)record; + buf.append(printaRecordString(printa)); + } else { + buf.append(record); + } + } + buf.append(']'); + return buf.toString(); + } + + public static void + main(String[] args) + { + if (args.length != 1) { + System.err.println("usage: java TestMultiAggPrinta