diff options
Diffstat (limited to 'cmd/dtrace/test/tst/common')
77 files changed, 3526 insertions, 46 deletions
diff --git a/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.stddevtoofew.d b/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.stddevtoofew.d new file mode 100644 index 000000000000..262040f1b820 --- /dev/null +++ b/cmd/dtrace/test/tst/common/aggs/err.D_AGG_SCALAR.stddevtoofew.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 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * ASSERTION: + * stddev() should not accept a non-scalar value + * + * SECTION: Aggregations/Aggregations + * + */ + +#pragma D option quiet + +BEGIN +{ + @a[pid] = stddev(probefunc); +} + diff --git a/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.stddevnoarg.d b/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.stddevnoarg.d new file mode 100644 index 000000000000..2952cf50c6d2 --- /dev/null +++ b/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.stddevnoarg.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 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * ASSERTION: + * stddev() should not accept a call with no arguments + * + * SECTION: Aggregations/Aggregations + * + */ + +#pragma D option quiet + +BEGIN +{ + @a[1] = stddev(); +} + diff --git a/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.stddevtoomany.d b/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.stddevtoomany.d new file mode 100644 index 000000000000..c42e9628ce48 --- /dev/null +++ b/cmd/dtrace/test/tst/common/aggs/err.D_PROTO_LEN.stddevtoomany.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 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * ASSERTION: + * stddev() should not have more than one argument + * + * SECTION: Aggregations/Aggregations + * + */ + +#pragma D option quiet + +BEGIN +{ + @a[1] = stddev(1, 2); +} + diff --git a/cmd/dtrace/test/tst/common/aggs/tst.clearstddev.d b/cmd/dtrace/test/tst/common/aggs/tst.clearstddev.d new file mode 100644 index 000000000000..af3ecd56a7fd --- /dev/null +++ b/cmd/dtrace/test/tst/common/aggs/tst.clearstddev.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 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * ASSERTION: + * Positive stddev() test + * + * SECTION: Aggregations/Aggregations + * + * NOTES: + * Verifies that printing a clear()'d aggregation with an stddev() + * aggregation function doesn't cause problems. + * + */ + +#pragma D option quiet + +tick-10ms +/i++ < 5/ +{ + @a = stddev(timestamp); +} + +tick-10ms +/i == 5/ +{ + exit(2); +} + +END +{ + clear(@a); + exit(0); +} diff --git a/cmd/dtrace/test/tst/common/aggs/tst.clearstddev.d.out b/cmd/dtrace/test/tst/common/aggs/tst.clearstddev.d.out new file mode 100644 index 000000000000..8d23188fd1f0 --- /dev/null +++ b/cmd/dtrace/test/tst/common/aggs/tst.clearstddev.d.out @@ -0,0 +1,2 @@ + + 0 diff --git a/cmd/dtrace/test/tst/common/aggs/tst.multiaggs1.d b/cmd/dtrace/test/tst/common/aggs/tst.multiaggs1.d index 80cffd4c9694..c65fb529e062 100644 --- a/cmd/dtrace/test/tst/common/aggs/tst.multiaggs1.d +++ b/cmd/dtrace/test/tst/common/aggs/tst.multiaggs1.d @@ -20,15 +20,13 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 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. + * Multiple aggregates can be used within the same D script. * * SECTION: Aggregations/Aggregations * @@ -52,9 +50,11 @@ tick-10ms @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); + @f[pid] = stddev(new_time); + @g[timestamp] = max(new_time); + @h[timestamp] = quantize(new_time); + @i[timestamp] = lquantize(new_time, 0, 10000, 1000); + time_1 = time_2; i++; } diff --git a/cmd/dtrace/test/tst/common/aggs/tst.multiaggs2.d b/cmd/dtrace/test/tst/common/aggs/tst.multiaggs2.d index 21c05b8e844b..b34d73fa8b84 100644 --- a/cmd/dtrace/test/tst/common/aggs/tst.multiaggs2.d +++ b/cmd/dtrace/test/tst/common/aggs/tst.multiaggs2.d @@ -20,18 +20,16 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 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 + * Test multiple aggregations and the default output order * * SECTION: Aggregations/Aggregations; - * Aggregations/Output + * Aggregations/Output * */ @@ -51,6 +49,7 @@ tick-10ms @d = max(i); @e = quantize(i); @f = lquantize(i, 0, 1000, 100); + @g = stddev(i); i += 100; } diff --git a/cmd/dtrace/test/tst/common/aggs/tst.multiaggs2.d.out b/cmd/dtrace/test/tst/common/aggs/tst.multiaggs2.d.out index 2e84e08ead16..579f78dd9bed 100644 --- a/cmd/dtrace/test/tst/common/aggs/tst.multiaggs2.d.out +++ b/cmd/dtrace/test/tst/common/aggs/tst.multiaggs2.d.out @@ -34,3 +34,4 @@ 900 |@@@@ 1 >= 1000 | 0 + 287 diff --git a/cmd/dtrace/test/tst/common/aggs/tst.multiaggs3.d b/cmd/dtrace/test/tst/common/aggs/tst.multiaggs3.d index 0685c0dac059..21d2fa9e2d69 100644 --- a/cmd/dtrace/test/tst/common/aggs/tst.multiaggs3.d +++ b/cmd/dtrace/test/tst/common/aggs/tst.multiaggs3.d @@ -20,19 +20,17 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 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. + * Test multiple aggregations and overriding default order with + * printa() statements. * * SECTION: Aggregations/Aggregations; - * Aggregations/Output + * Aggregations/Output * * NOTES: This is a simple verifiable test. * @@ -55,6 +53,7 @@ tick-10ms @e = max(i); @f = quantize(i); @g = lquantize(i, 0, 1000, 100); + @h = stddev(i); i += 100; } @@ -62,6 +61,7 @@ tick-10ms tick-10ms /i == 1000/ { + printa("%@d\n", @h); printa("%@d\n", @g); printa("%@d\n", @f); printa("%@d\n", @e); diff --git a/cmd/dtrace/test/tst/common/aggs/tst.multiaggs3.d.out b/cmd/dtrace/test/tst/common/aggs/tst.multiaggs3.d.out index b0c49a33d3e6..ab976601b2af 100644 --- a/cmd/dtrace/test/tst/common/aggs/tst.multiaggs3.d.out +++ b/cmd/dtrace/test/tst/common/aggs/tst.multiaggs3.d.out @@ -1,3 +1,4 @@ +287 value ------------- Distribution ------------- count < 0 | 0 diff --git a/cmd/dtrace/test/tst/common/aggs/tst.stddev.d b/cmd/dtrace/test/tst/common/aggs/tst.stddev.d index 11e99d390553..041b82070f84 100644 --- a/cmd/dtrace/test/tst/common/aggs/tst.stddev.d +++ b/cmd/dtrace/test/tst/common/aggs/tst.stddev.d @@ -20,20 +20,19 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - - /* * ASSERTION: - * Positive stddev() test + * Positive stddev() test * * SECTION: Aggregations/Aggregations * * NOTES: This is a simple verifiable positive test of the stddev() function. + * printa() for one aggregation, default printing behavior for the other + * so that we exercise both code paths. */ #pragma D option quiet @@ -60,5 +59,6 @@ BEGIN @b = stddev(-5000000700); @b = stddev(-5000000800); @b = stddev(-5000000900); + printa("%@d\n", @a); exit(0); } diff --git a/cmd/dtrace/test/tst/common/aggs/tst.stddev.d.out b/cmd/dtrace/test/tst/common/aggs/tst.stddev.d.out index cec6074081e1..0c02852e452f 100644 --- a/cmd/dtrace/test/tst/common/aggs/tst.stddev.d.out +++ b/cmd/dtrace/test/tst/common/aggs/tst.stddev.d.out @@ -1,3 +1,3 @@ +287 287 - 287 diff --git a/cmd/dtrace/test/tst/common/cpc/err.D_PDESC_ZERO.lowfrequency.d b/cmd/dtrace/test/tst/common/cpc/err.D_PDESC_ZERO.lowfrequency.d new file mode 100644 index 000000000000..1015a251cfeb --- /dev/null +++ b/cmd/dtrace/test/tst/common/cpc/err.D_PDESC_ZERO.lowfrequency.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 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Test to check that attempting to enable a valid event with a frequency + * lower than the default platform limit will fail. + * + * This test will fail if: + * 1) The system under test does not define the 'PAPI_tot_ins' event. + * 2) The 'dcpc-min-overflow' variable in dcpc.conf has been modified. + */ + +#pragma D option quiet + +BEGIN +{ + exit(0); +} + +cpc:::PAPI_tot_ins-all-100 +{ +} diff --git a/cmd/dtrace/test/tst/common/cpc/err.D_PDESC_ZERO.malformedoverflow.d b/cmd/dtrace/test/tst/common/cpc/err.D_PDESC_ZERO.malformedoverflow.d new file mode 100644 index 000000000000..f9b780942fab --- /dev/null +++ b/cmd/dtrace/test/tst/common/cpc/err.D_PDESC_ZERO.malformedoverflow.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 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Tests that specifying an overflow value containing extraneous characters + * (only digits are allowed) will fail. + */ + +BEGIN +{ + exit(0); +} + +cpc:::PAPI_tot_ins-all-10000bonehead +{ + @[probename] = count(); +} diff --git a/cmd/dtrace/test/tst/common/cpc/err.D_PDESC_ZERO.nonexistentevent.d b/cmd/dtrace/test/tst/common/cpc/err.D_PDESC_ZERO.nonexistentevent.d new file mode 100644 index 000000000000..73f9575fbe6b --- /dev/null +++ b/cmd/dtrace/test/tst/common/cpc/err.D_PDESC_ZERO.nonexistentevent.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 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Tests that attempting to enable a probe containing a non existent event + * will fail. + */ + +BEGIN +{ + exit(0); +} + +cpc:::PAPI_cpc_bad-all-10000 +{ + @[probename] = count(); +} diff --git a/cmd/dtrace/test/tst/common/cpc/err.cpcvscpustatpart1.ksh b/cmd/dtrace/test/tst/common/cpc/err.cpcvscpustatpart1.ksh new file mode 100644 index 000000000000..767d493a76b7 --- /dev/null +++ b/cmd/dtrace/test/tst/common/cpc/err.cpcvscpustatpart1.ksh @@ -0,0 +1,78 @@ +#!/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 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + + +# +# This tests that cpustat(1) should fail to start if the cpc provider +# is already calling the shots. +# +# This script will fail if: +# 1) The system under test does not define the 'PAPI_tot_ins' +# generic event. + +script() +{ + $dtrace -o $dtraceout -s /dev/stdin <<EOF + #pragma D option bufsize=128k + + cpc:::PAPI_tot_ins-all-10000 + { + @[probename] = count(); + } +EOF +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +dtraceout=/tmp/dtrace.out.$$ +script 2>/dev/null & +timeout=15 + +# +# Sleep while the above script fires into life. To guard against dtrace dying +# and us sleeping forever we allow 15 secs for this to happen. This should be +# enough for even the slowest systems. +# +while [ ! -f $dtraceout ]; do + sleep 1 + timeout=$(($timeout-1)) + if [ $timeout -eq 0 ]; then + echo "dtrace failed to start. Exiting." + exit 1 + fi +done + +cpustat -c PAPI_tot_ins 1 5 +status=$? + +rm $dtraceout + +exit $status diff --git a/cmd/dtrace/test/tst/common/cpc/err.cpcvscpustatpart2.ksh b/cmd/dtrace/test/tst/common/cpc/err.cpcvscpustatpart2.ksh new file mode 100644 index 000000000000..584469c3fe9c --- /dev/null +++ b/cmd/dtrace/test/tst/common/cpc/err.cpcvscpustatpart2.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 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + + +# +# This tests that enablings from the cpc provider will fail if cpustat(1) is +# already master of the universe. +# +# This script will fail if: +# 1) The system under test does not define the 'PAPI_tot_ins' +# generic event. + +script() +{ + $dtrace -s /dev/stdin <<EOF + #pragma D option bufsize=128k + + BEGIN + { + exit(0); + } + + cpc:::PAPI_tot_ins-all-10000 + { + @[probename] = count(); + } +EOF +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +dtraceout=/tmp/dtrace.out.$$ + +cpustat -c PAPI_tot_ins 1 20 & +pid=$! +sleep 5 +script 2>/dev/null + +status=$? + +kill $pid +exit $status diff --git a/cmd/dtrace/test/tst/common/cpc/err.cputrackfailtostart.ksh b/cmd/dtrace/test/tst/common/cpc/err.cputrackfailtostart.ksh new file mode 100644 index 000000000000..f62b83d5714b --- /dev/null +++ b/cmd/dtrace/test/tst/common/cpc/err.cputrackfailtostart.ksh @@ -0,0 +1,77 @@ +#!/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 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. + +# +# This script ensures that cputrack(1M) will fail to start when the cpc +# provider has active enablings. +# +# The script will fail if: +# 1) The system under test does not define the 'PAPI_tot_ins' event. +# + +script() +{ + $dtrace -o $dtraceout -s /dev/stdin <<EOF + #pragma D option bufsize=128k + + cpc:::PAPI_tot_ins-all-10000 + { + @[probename] = count(); + } +EOF +} + + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +dtraceout=/tmp/dtrace.out.$$ +script 2>/dev/null & +timeout=15 + +# +# Sleep while the above script fires into life. To guard against dtrace dying +# and us sleeping forever we allow 15 secs for this to happen. This should be +# enough for even the slowest systems. +# +while [ ! -f $dtraceout ]; do + sleep 1 + timeout=$(($timeout-1)) + if [ $timeout -eq 0 ]; then + echo "dtrace failed to start. Exiting." + exit 1 + fi +done + +cputrack -c PAPI_tot_ins sleep 10 +status=$? + +rm $dtraceout + +exit $status diff --git a/cmd/dtrace/test/tst/common/cpc/err.cputrackterminates.ksh b/cmd/dtrace/test/tst/common/cpc/err.cputrackterminates.ksh new file mode 100644 index 000000000000..58d1e798f10e --- /dev/null +++ b/cmd/dtrace/test/tst/common/cpc/err.cputrackterminates.ksh @@ -0,0 +1,70 @@ +#!/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 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. + +# +# This script ensures that cputrack(1) will terminate when the cpc provider +# kicks into life. +# +# The script will fail if: +# 1) The system under test does not define the 'PAPI_tot_ins' event. +# + +script() +{ + $dtrace -s /dev/stdin <<EOF + #pragma D option bufsize=128k + + cpc:::PAPI_tot_ins-all-10000 + { + @[probename] = count(); + } + + tick-1s + /n++ > 10/ + { + exit(0); + } +EOF +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +cputrack -c PAPI_tot_ins sleep 20 & +cputrack_pid=$! +sleep 5 +script 2>/dev/null & + +wait $cputrack_pid +status=$? + +rm $dtraceout + +exit $status diff --git a/cmd/dtrace/test/tst/common/cpc/err.toomanyenablings.d b/cmd/dtrace/test/tst/common/cpc/err.toomanyenablings.d new file mode 100644 index 000000000000..a50bd71ae6ae --- /dev/null +++ b/cmd/dtrace/test/tst/common/cpc/err.toomanyenablings.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 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Test to check that attempting to enable too many probes will fail. + * + * This test will fail if: + * 1) We ever execute on a platform which is capable of programming 10 + * 'PAPI_tot_ins' events simultaneously (which no current platforms are + * capable of doing). + * 2) The system under test does not define the 'PAPI_tot_ins' event. + */ + +#pragma D option quiet + +BEGIN +{ + exit(0); +} + +cpc:::PAPI_tot_ins-all-10000, +cpc:::PAPI_tot_ins-all-10001, +cpc:::PAPI_tot_ins-all-10002, +cpc:::PAPI_tot_ins-all-10003, +cpc:::PAPI_tot_ins-all-10004, +cpc:::PAPI_tot_ins-all-10005, +cpc:::PAPI_tot_ins-all-10006, +cpc:::PAPI_tot_ins-all-10007, +cpc:::PAPI_tot_ins-all-10008, +cpc:::PAPI_tot_ins-all-10009 +{ +} diff --git a/cmd/dtrace/test/tst/common/cpc/tst.allcpus.ksh b/cmd/dtrace/test/tst/common/cpc/tst.allcpus.ksh new file mode 100644 index 000000000000..7f026c9ebca7 --- /dev/null +++ b/cmd/dtrace/test/tst/common/cpc/tst.allcpus.ksh @@ -0,0 +1,107 @@ +#!/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 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# This script verifies that we can fire a probe on each CPU that is in +# an online state. +# +# The script will fail if: +# 1) The system under test does not define the 'PAPI_tot_ins' event. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +numproc=`psrinfo | tail -1 | cut -f1` +cpu=0 +dtraceout=/var/tmp/dtrace.out.$$ +scriptout=/var/tmp/script.out.$$ + +spin() +{ + while [ 1 ]; do + : + done +} + +script() +{ + $dtrace -o $dtraceout -s /dev/stdin <<EOF + #pragma D option bufsize=128k + #pragma D option quiet + + cpc:::PAPI_tot_ins-user-10000 + /cpus[cpu] != 1/ + { + cpus[cpu] = 1; + @a[cpu] = count(); + } + + tick-1s + /n++ > 10/ + { + printa(@a); + exit(0); + } +EOF +} + +echo "" > $scriptout +while [ $cpu -le $numproc ] +do + if [ "`psrinfo -s $cpu 2> /dev/null`" -eq 1 ]; then + printf "%9d %16d\n" $cpu 1 >> $scriptout + spin & + allpids[$cpu]=$! + pbind -b $cpu $! + fi + cpu=$(($cpu+1)) +done +echo "" >> $scriptout + +script + +diff $dtraceout $scriptout >/dev/null 2>&1 +status=$? + +# kill off the spinner processes +cpu=0 +while [ $cpu -le $numproc ] +do + if [ "`psrinfo -s $cpu 2> /dev/null`" -eq 1 ]; then + kill ${allpids[$cpu]} + fi + cpu=$(($cpu+1)) +done + +rm $dtraceout +rm $scriptout + +exit $status diff --git a/cmd/dtrace/test/tst/common/cpc/tst.genericevent.d b/cmd/dtrace/test/tst/common/cpc/tst.genericevent.d new file mode 100644 index 000000000000..7ebf844e9cbe --- /dev/null +++ b/cmd/dtrace/test/tst/common/cpc/tst.genericevent.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 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Test that we can successfully enable a probe using a generic event. + * Currently, all platforms implement 'PAPI_tot_ins' so we'll use that. + * Note that this test will fail if the system under test does not + * implement that event. + * + * This test will fail if: + * 1) The system under test does not define the 'PAPI_tot_ins' event. + */ + +#pragma D option quiet +#pragma D option bufsize=128k + +cpc:::PAPI_tot_ins-all-10000 +{ + @[probename] = count(); +} + +tick-1s +/n++ > 10/ +{ + exit(0); +} diff --git a/cmd/dtrace/test/tst/common/cpc/tst.platformevent.ksh b/cmd/dtrace/test/tst/common/cpc/tst.platformevent.ksh new file mode 100644 index 000000000000..96d1ab8c6a71 --- /dev/null +++ b/cmd/dtrace/test/tst/common/cpc/tst.platformevent.ksh @@ -0,0 +1,81 @@ +#!/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 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# This script ensures that we can enable a probe which specifies a platform +# specific event. +# + +if [ $# != 1 ]; then + print -u2 "expected one argument: <dtrace-path>" + exit 2 +fi + +dtrace=$1 + +get_event() +{ + perl /dev/stdin /dev/stdout << EOF + open CPUSTAT, '/usr/sbin/cpustat -h |' + or die "Couldn't run cpustat: \$!\n"; + while (<CPUSTAT>) { + if (/(\s+)event\[*[0-9]-*[0-9]*\]*:/ && !/PAPI/) { + @a = split(/ /, \$_); + \$event = \$a[\$#a-1]; + } + } + + close CPUSTAT; + print "\$event\n"; +EOF +} + +script() +{ + $dtrace -s /dev/stdin << EOD + #pragma D option quiet + #pragma D option bufsize=128k + + cpc:::$1-all-10000 + { + @[probename] = count(); + } + + tick-1s + /n++ > 5/ + { + exit(0); + } +EOD +} + +event=$(get_event) +script $event + +status=$? + +exit $status diff --git a/cmd/dtrace/test/tst/common/ip/get.ipv4remote.pl b/cmd/dtrace/test/tst/common/ip/get.ipv4remote.pl new file mode 100755 index 000000000000..fb41255473e6 --- /dev/null +++ b/cmd/dtrace/test/tst/common/ip/get.ipv4remote.pl @@ -0,0 +1,104 @@ +#!/usr/bin/perl -w +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL 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" + +# +# get.ipv4remote.pl [tcpport] +# +# Find an IPv4 reachable remote host using both ifconfig(1M) and ping(1M). +# If a tcpport is specified, return a host that is also listening on this +# TCP port. Print the local address and the remote address, or an +# error message if no suitable remote host was found. Exit status is 0 if +# a host was found. +# + +use strict; +use IO::Socket; + +my $MAXHOSTS = 32; # max hosts to port scan +my $TIMEOUT = 3; # connection timeout +my $tcpport = @ARGV == 1 ? $ARGV[0] : 0; + +# +# Determine local IP address +# +my $local = ""; +my $remote = ""; +my %Broadcast; +my $up; +open IFCONFIG, '/usr/sbin/ifconfig -a |' or die "Couldn't run ifconfig: $!\n"; +while (<IFCONFIG>) { + next if /^lo/; + + # "UP" is always printed first (see print_flags() in ifconfig.c): + $up = 1 if /^[a-z].*<UP,/; + $up = 0 if /^[a-z].*<,/; + + # assume output is "inet X ... broadcast Z": + if (/inet (\S+) .* broadcast (\S+)/) { + my ($addr, $bcast) = ($1, $2); + $Broadcast{$addr} = $bcast; + $local = $addr if $up and $local eq ""; + $up = 0; + } +} +close IFCONFIG; +die "Could not determine local IP address" if $local eq ""; + +# +# Find the first remote host that responds to an icmp echo, +# which isn't a local address. +# +open PING, "/usr/sbin/ping -ns $Broadcast{$local} 56 $MAXHOSTS |" or + die "Couldn't run ping: $!\n"; +while (<PING>) { + if (/bytes from (.*): / and not defined $Broadcast{$1}) { + my $addr = $1; + + if ($tcpport != 0) { + # + # Test TCP + # + my $socket = IO::Socket::INET->new( + Proto => "tcp", + PeerAddr => $addr, + PeerPort => $tcpport, + Timeout => $TIMEOUT, + ); + next unless $socket; + close $socket; + } + + $remote = $addr; + last; + } +} +close PING; +die "Can't find a remote host for testing: No suitable response from " . + "$Broadcast{$local}\n" if $remote eq ""; + +print "$local $remote\n"; diff --git a/cmd/dtrace/test/tst/common/ip/get.ipv6remote.pl b/cmd/dtrace/test/tst/common/ip/get.ipv6remote.pl new file mode 100755 index 000000000000..051ab8c3c32c --- /dev/null +++ b/cmd/dtrace/test/tst/common/ip/get.ipv6remote.pl @@ -0,0 +1,88 @@ +#!/usr/bin/perl -w +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL 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" + +# +# get.ipv6remote.pl +# +# Find an IPv6 reachable remote host using both ifconfig(1M) and ping(1M). +# Print the local address and the remote address, or print nothing if either +# no IPv6 interfaces or remote hosts were found. (Remote IPv6 testing is +# considered optional, and so not finding another IPv6 host is not an error +# state we need to log.) Exit status is 0 if a host was found. +# + +use strict; +use IO::Socket; + +my $MAXHOSTS = 32; # max hosts to scan +my $TIMEOUT = 3; # connection timeout +my $MULTICAST = "FF02::1"; # IPv6 multicast address + +# +# Determine local IP address +# +my $local = ""; +my $remote = ""; +my %Local; +my $up; +open IFCONFIG, '/usr/sbin/ifconfig -a inet6 |' + or die "Couldn't run ifconfig: $!\n"; +while (<IFCONFIG>) { + next if /^lo/; + + # "UP" is always printed first (see print_flags() in ifconfig.c): + $up = 1 if /^[a-z].*<UP,/; + $up = 0 if /^[a-z].*<,/; + + # assume output is "inet6 ...": + if (m:inet6 (\S+)/:) { + my $addr = $1; + $Local{$addr} = 1; + $local = $addr if $up and $local eq ""; + $up = 0; + } +} +close IFCONFIG; +exit 1 if $local eq ""; + +# +# Find the first remote host that responds to an icmp echo, +# which isn't a local address. +# +open PING, "/usr/sbin/ping -ns -A inet6 $MULTICAST 56 $MAXHOSTS |" or + die "Couldn't run ping: $!\n"; +while (<PING>) { + if (/bytes from (.*): / and not defined $Local{$1}) { + $remote = $1; + last; + } +} +close PING; +exit 2 if $remote eq ""; + +print "$local $remote\n"; diff --git a/cmd/dtrace/test/tst/common/ip/tst.ipv4localicmp.ksh b/cmd/dtrace/test/tst/common/ip/tst.ipv4localicmp.ksh new file mode 100755 index 000000000000..0965040e62e8 --- /dev/null +++ b/cmd/dtrace/test/tst/common/ip/tst.ipv4localicmp.ksh @@ -0,0 +1,70 @@ +#!/usr/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 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#pragma ident "%Z%%M% %I% %E% SMI" + +# +# Test ip:::{send,receive} of IPv4 ICMP to a local address. +# +# This may fail due to: +# +# 1. A change to the ip stack breaking expected probe behavior, +# which is the reason we are testing. +# 2. The lo0 interface missing or not up. +# 3. Unrelated ICMP on lo0 traced by accident. +# + +if (( $# != 1 )); then + print -u2 "expected one argument: <dtrace-path>" + exit 2 +fi + +dtrace=$1 +local=127.0.0.1 + +$dtrace -c "/usr/sbin/ping $local 3" -qs /dev/stdin <<EOF | sort -n +ip:::send +/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" && + args[4]->ipv4_protocol == IPPROTO_ICMP/ +{ + printf("1 ip:::send ("); + printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength); + printf("args[4]: %d %d %d %d %d)\n", + args[4]->ipv4_ver, args[4]->ipv4_length, args[4]->ipv4_flags, + args[4]->ipv4_offset, args[4]->ipv4_ttl); +} + +ip:::receive +/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" && + args[4]->ipv4_protocol == IPPROTO_ICMP/ +{ + printf("2 ip:::receive ("); + printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength); + printf("args[4]: %d %d %d %d %d)\n", + args[4]->ipv4_ver, args[4]->ipv4_length, args[4]->ipv4_flags, + args[4]->ipv4_offset, args[4]->ipv4_ttl); +} +EOF diff --git a/cmd/dtrace/test/tst/common/ip/tst.ipv4localicmp.ksh.out b/cmd/dtrace/test/tst/common/ip/tst.ipv4localicmp.ksh.out new file mode 100644 index 000000000000..41d6e0c8ad41 --- /dev/null +++ b/cmd/dtrace/test/tst/common/ip/tst.ipv4localicmp.ksh.out @@ -0,0 +1,6 @@ + +1 ip:::send (args[2]: 4 64, args[4]: 4 84 0 0 255) +1 ip:::send (args[2]: 4 64, args[4]: 4 84 0 0 255) +2 ip:::receive (args[2]: 4 64, args[4]: 4 84 0 0 255) +2 ip:::receive (args[2]: 4 64, args[4]: 4 84 0 0 255) +127.0.0.1 is alive diff --git a/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh b/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh new file mode 100755 index 000000000000..6fa8c35bf3b3 --- /dev/null +++ b/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh @@ -0,0 +1,125 @@ +#!/usr/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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +# + +# +# Test {ip,tcp}:::{send,receive} of IPv4 TCP to local host. +# +# This may fail due to: +# +# 1. A change to the ip stack breaking expected probe behavior, +# which is the reason we are testing. +# 2. The lo0 interface missing or not up. +# 3. The local ssh service is not online. +# 4. An unlikely race causes the unlocked global send/receive +# variables to be corrupted. +# +# This test performs a TCP connection and checks that at least the +# following packet counts were traced: +# +# 3 x ip:::send (2 during the TCP handshake, then a FIN) +# 3 x tcp:::send (2 during the TCP handshake, then a FIN) +# 2 x ip:::receive (1 during the TCP handshake, then the FIN ACK) +# 2 x tcp:::receive (1 during the TCP handshake, then the FIN ACK) + +# The actual count tested is 5 each way, since we are tracing both +# source and destination events. +# +# For this test to work, we are assuming that the TCP handshake and +# TCP close will enter the IP code path and not use tcp fusion. +# + +if (( $# != 1 )); then + print -u2 "expected one argument: <dtrace-path>" + exit 2 +fi + +dtrace=$1 +local=127.0.0.1 +tcpport=22 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > test.pl <<-EOPERL + use IO::Socket; + my \$s = IO::Socket::INET->new( + Proto => "tcp", + PeerAddr => "$local", + PeerPort => $tcpport, + Timeout => 3); + die "Could not connect to host $local port $tcpport" unless \$s; + close \$s; +EOPERL + +$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE +BEGIN +{ + ipsend = tcpsend = ipreceive = tcpreceive = 0; +} + +ip:::send +/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" && + args[4]->ipv4_protocol == IPPROTO_TCP/ +{ + ipsend++; +} + +tcp:::send +/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local"/ +{ + tcpsend++; +} + +ip:::receive +/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" && + args[4]->ipv4_protocol == IPPROTO_TCP/ +{ + ipreceive++; +} + +tcp:::receive +/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local"/ +{ + tcpreceive++; +} + +END +{ + printf("Minimum TCP events seen\n\n"); + printf("ip:::send - %s\n", ipsend >= 5 ? "yes" : "no"); + printf("ip:::receive - %s\n", ipreceive >= 5 ? "yes" : "no"); + printf("tcp:::send - %s\n", tcpsend >= 5 ? "yes" : "no"); + printf("tcp:::receive - %s\n", tcpreceive >= 5 ? "yes" : "no"); +} +EODTRACE + +status=$? + +cd / +/usr/bin/rm -rf $DIR + +exit $status diff --git a/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh.out b/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh.out new file mode 100644 index 000000000000..2a85b98b6b7d --- /dev/null +++ b/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh.out @@ -0,0 +1,7 @@ +Minimum TCP events seen + +ip:::send - yes +ip:::receive - yes +tcp:::send - yes +tcp:::receive - yes + diff --git a/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh b/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh new file mode 100755 index 000000000000..fa8f7acfc7ac --- /dev/null +++ b/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh @@ -0,0 +1,93 @@ +#!/usr/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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +# + +# +# Test ip:::{send,receive} of IPv4 UDP to a local address. +# +# This may fail due to: +# +# 1. A change to the ip stack breaking expected probe behavior, +# which is the reason we are testing. +# 2. No physical network interface is plumbed and up. +# 3. No other hosts on this subnet are reachable and listening on rpcbind. +# 4. An unlikely race causes the unlocked global send/receive +# variables to be corrupted. +# +# This test sends a UDP message using ping and checks that at least the +# following counts were traced: +# +# 1 x ip:::send (UDP sent to ping's base UDP port) +# 1 x udp:::send (UDP sent to ping's base UDP port) +# 1 x ip:::receive (UDP received) +# +# No udp:::receive event is expected as the response ping -U elicits is +# an ICMP PORT_UNREACHABLE response rather than a UDP packet, and locally +# the echo request UDP packet only reaches IP, so the udp:::receive probe +# is not triggered by it. +# + +if (( $# != 1 )); then + print -u2 "expected one argument: <dtrace-path>" + exit 2 +fi + +dtrace=$1 +local=127.0.0.1 + +$dtrace -c "/usr/sbin/ping -U $local" -qs /dev/stdin <<EOF | grep -v 'is alive' +BEGIN +{ + ipsend = udpsend = ipreceive = 0; +} + +ip:::send +/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" && + args[4]->ipv4_protocol == IPPROTO_UDP/ +{ + ipsend++; +} + +udp:::send +/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local"/ +{ + udpsend++; +} + +ip:::receive +/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" && + args[4]->ipv4_protocol == IPPROTO_UDP/ +{ + ipreceive++; +} + +END +{ + printf("Minimum UDP events seen\n\n"); + printf("ip:::send - %s\n", ipsend >= 1 ? "yes" : "no"); + printf("ip:::receive - %s\n", ipreceive >= 1 ? "yes" : "no"); + printf("udp:::send - %s\n", udpsend >= 1 ? "yes" : "no"); +} +EOF diff --git a/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh.out b/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh.out new file mode 100644 index 000000000000..bca55327ef57 --- /dev/null +++ b/cmd/dtrace/test/tst/common/ip/tst.ipv4localudp.ksh.out @@ -0,0 +1,6 @@ +Minimum UDP events seen + +ip:::send - yes +ip:::receive - yes +udp:::send - yes + diff --git a/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteicmp.ksh b/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteicmp.ksh new file mode 100755 index 000000000000..efe0d30fa9db --- /dev/null +++ b/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteicmp.ksh @@ -0,0 +1,81 @@ +#!/usr/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 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#pragma ident "%Z%%M% %I% %E% SMI" + +# +# Test ip:::{send,receive} of IPv4 ICMP to a remote host. +# +# This may fail due to: +# +# 1. A change to the ip stack breaking expected probe behavior, +# which is the reason we are testing. +# 2. No physical network interface is plumbed and up. +# 3. No other hosts on this subnet are reachable. +# 4. An unrelated ICMP between these hosts was traced by accident. +# + +if (( $# != 1 )); then + print -u2 "expected one argument: <dtrace-path>" + exit 2 +fi + +dtrace=$1 +getaddr=./get.ipv4remote.pl + +if [[ ! -x $getaddr ]]; then + print -u2 "could not find or execute sub program: $getaddr" + exit 3 +fi +$getaddr | read source dest +if (( $? != 0 )); then + exit 4 +fi + +$dtrace -c "/usr/sbin/ping $dest 3" -qs /dev/stdin <<EOF | \ + grep -v 'is alive' | sort -n +ip:::send +/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" && + args[4]->ipv4_protocol == IPPROTO_ICMP/ +{ + printf("1 ip:::send ("); + printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength); + printf("args[4]: %d %d %d %d %d)\n", + args[4]->ipv4_ver, args[4]->ipv4_length, args[4]->ipv4_flags, + args[4]->ipv4_offset, args[4]->ipv4_ttl); +} + +ip:::receive +/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" && + args[4]->ipv4_protocol == IPPROTO_ICMP/ +{ + printf("2 ip:::receive ("); + printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength); + printf("args[4]: %d %d %d %d %d)\n", + args[4]->ipv4_ver, args[4]->ipv4_length, args[4]->ipv4_flags, + args[4]->ipv4_offset, args[4]->ipv4_ttl); +} +EOF diff --git a/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteicmp.ksh.out b/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteicmp.ksh.out new file mode 100644 index 000000000000..b5915f8db477 --- /dev/null +++ b/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteicmp.ksh.out @@ -0,0 +1,3 @@ + +1 ip:::send (args[2]: 4 64, args[4]: 4 84 0 0 255) +2 ip:::receive (args[2]: 4 64, args[4]: 4 84 4 0 255) diff --git a/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh b/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh new file mode 100755 index 000000000000..89a0cdb95eea --- /dev/null +++ b/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh @@ -0,0 +1,128 @@ +#!/usr/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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +# + +# +# Test {tcp,ip}:::{send,receive} of IPv4 TCP to a remote host. +# +# This may fail due to: +# +# 1. A change to the ip stack breaking expected probe behavior, +# which is the reason we are testing. +# 2. No physical network interface is plumbed and up. +# 3. No other hosts on this subnet are reachable and listening on ssh. +# 4. An unlikely race causes the unlocked global send/receive +# variables to be corrupted. +# +# This test performs a TCP connection and checks that at least the +# following packet counts were traced: +# +# 3 x ip:::send (2 during the TCP handshake, then a FIN) +# 3 x tcp:::send (2 during the TCP handshake, then a FIN) +# 2 x ip:::receive (1 during the TCP handshake, then the FIN ACK) +# 2 x tcp:::receive (1 during the TCP handshake, then the FIN ACK) +# + +if (( $# != 1 )); then + print -u2 "expected one argument: <dtrace-path>" + exit 2 +fi + +dtrace=$1 +getaddr=./get.ipv4remote.pl +tcpport=22 +DIR=/var/tmp/dtest.$$ + +if [[ ! -x $getaddr ]]; then + print -u2 "could not find or execute sub program: $getaddr" + exit 3 +fi +$getaddr $tcpport | read source dest +if (( $? != 0 )); then + exit 4 +fi + +mkdir $DIR +cd $DIR + +cat > test.pl <<-EOPERL + use IO::Socket; + my \$s = IO::Socket::INET->new( + Proto => "tcp", + PeerAddr => "$dest", + PeerPort => $tcpport, + Timeout => 3); + die "Could not connect to host $dest port $tcpport" unless \$s; + close \$s; +EOPERL + +$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE +BEGIN +{ + ipsend = tcpsend = ipreceive = tcpreceive = 0; +} + +ip:::send +/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" && + args[4]->ipv4_protocol == IPPROTO_TCP/ +{ + ipsend++; +} + +tcp:::send +/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest"/ +{ + tcpsend++; +} + +ip:::receive +/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" && + args[4]->ipv4_protocol == IPPROTO_TCP/ +{ + ipreceive++; +} + +tcp:::receive +/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source"/ +{ + tcpreceive++; +} + +END +{ + printf("Minimum TCP events seen\n\n"); + printf("ip:::send - %s\n", ipsend >= 3 ? "yes" : "no"); + printf("ip:::receive - %s\n", ipreceive >= 2 ? "yes" : "no"); + printf("tcp:::send - %s\n", tcpsend >= 3 ? "yes" : "no"); + printf("tcp:::receive - %s\n", tcpreceive >= 2 ? "yes" : "no"); +} +EODTRACE + +status=$? + +cd / +/usr/bin/rm -rf $DIR + +exit $? diff --git a/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh.out b/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh.out new file mode 100644 index 000000000000..2a85b98b6b7d --- /dev/null +++ b/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh.out @@ -0,0 +1,7 @@ +Minimum TCP events seen + +ip:::send - yes +ip:::receive - yes +tcp:::send - yes +tcp:::receive - yes + diff --git a/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh b/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh new file mode 100755 index 000000000000..b0893c816145 --- /dev/null +++ b/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh @@ -0,0 +1,88 @@ +#!/usr/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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +# + +# +# Test {udp,ip}:::{send,receive} of IPv4 UDP to a remote host. +# +# This may fail due to: +# +# 1. A change to the ip stack breaking expected probe behavior, +# which is the reason we are testing. +# 2. No physical network interface is plumbed and up. +# 3. No other hosts on this subnet are reachable and listening on rpcbind. +# 4. An unlikely race causes the unlocked global send/receive +# variables to be corrupted. +# +# This test sends a UDP message using ping and checks that at least the +# following counts were traced: +# +# 1 x ip:::send (UDP sent to ping's base UDP port) +# 1 x udp:::send (UDP sent to ping's base UDP port) +# + +if (( $# != 1 )); then + print -u2 "expected one argument: <dtrace-path>" + exit 2 +fi + +dtrace=$1 +getaddr=./get.ipv4remote.pl + +if [[ ! -x $getaddr ]]; then + print -u2 "could not find or execute sub program: $getaddr" + exit 3 +fi +$getaddr | read source dest +if (( $? != 0 )); then + exit 4 +fi + +$dtrace -c "/usr/sbin/ping -U $dest" -qs /dev/stdin <<EOF | grep -v 'is alive' +BEGIN +{ + ipsend = udpsend = 0; +} + +ip:::send +/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" && + args[4]->ipv4_protocol == IPPROTO_UDP/ +{ + ipsend++; +} + +udp:::send +/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest"/ +{ + udpsend++; +} + +END +{ + printf("Minimum UDP events seen\n\n"); + printf("ip:::send - %s\n", ipsend >= 1 ? "yes" : "no"); + printf("udp:::send - %s\n", udpsend >= 1 ? "yes" : "no"); +} +EOF diff --git a/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh.out b/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh.out new file mode 100644 index 000000000000..bdbbe1fd6562 --- /dev/null +++ b/cmd/dtrace/test/tst/common/ip/tst.ipv4remoteudp.ksh.out @@ -0,0 +1,5 @@ +Minimum UDP events seen + +ip:::send - yes +udp:::send - yes + diff --git a/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh b/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh new file mode 100755 index 000000000000..5912ee7c8e43 --- /dev/null +++ b/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh @@ -0,0 +1,82 @@ +#!/usr/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 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#pragma ident "%Z%%M% %I% %E% SMI" + +# +# Test ip:::{send,receive} of IPv6 ICMP to a local address. This creates a +# temporary lo0/inet6 interface if one doesn't already exist. +# +# This may fail due to: +# +# 1. A change to the ip stack breaking expected probe behavior, +# which is the reason we are testing. +# 2. Unrelated ICMPv6 on lo0 traced by accident. +# + +if (( $# != 1 )); then + print -u2 "expected one argument: <dtrace-path>" + exit 2 +fi + +dtrace=$1 +local=::1 + +if ! ifconfig lo0 inet6 > /dev/null 2>&1; then + if ! ifconfig lo0 inet6 plumb up; then + print -u2 "could not plumb lo0 inet6 for testing" + exit 3 + fi + removeinet6=1 +else + removeinet6=0 +fi + +$dtrace -c "/usr/sbin/ping -A inet6 $local 3" -qs /dev/stdin <<EOF | sort -n +ip:::send +/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" && + args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/ +{ + printf("1 ip:::send ("); + printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength); + printf("args[5]: %d %d %d)\n", + args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen); +} + +ip:::receive +/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" && + args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/ +{ + printf("2 ip:::receive ("); + printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength); + printf("args[5]: %d %d %d)\n", + args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen); +} +EOF + +if (( removeinet6 )); then + ifconfig lo0 inet6 unplumb +fi diff --git a/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh.out b/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh.out new file mode 100644 index 000000000000..529d251fa06e --- /dev/null +++ b/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh.out @@ -0,0 +1,6 @@ + +::1 is alive +1 ip:::send (args[2]: 6 64, args[5]: 6 0 64) +1 ip:::send (args[2]: 6 64, args[5]: 6 0 64) +2 ip:::receive (args[2]: 6 64, args[5]: 6 0 64) +2 ip:::receive (args[2]: 6 64, args[5]: 6 0 64) diff --git a/cmd/dtrace/test/tst/common/ip/tst.ipv6remoteicmp.ksh b/cmd/dtrace/test/tst/common/ip/tst.ipv6remoteicmp.ksh new file mode 100755 index 000000000000..b94b78439757 --- /dev/null +++ b/cmd/dtrace/test/tst/common/ip/tst.ipv6remoteicmp.ksh @@ -0,0 +1,88 @@ +#!/usr/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 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#pragma ident "%Z%%M% %I% %E% SMI" + +# +# Test ip:::{send,receive} of IPv6 ICMP to a remote host. This test is +# skipped if there are no physical interfaces configured with IPv6, or no +# other IPv6 hosts are reachable. +# +# This may fail due to: +# +# 1. A change to the ip stack breaking expected probe behavior, +# which is the reason we are testing. +# 2. An unrelated ICMPv6 between these hosts was traced by accident. +# + +if (( $# != 1 )); then + print -u2 "expected one argument: <dtrace-path>" + exit 2 +fi + +dtrace=$1 +getaddr=./get.ipv6remote.pl + +if [[ ! -x $getaddr ]]; then + print -u2 "could not find or execute sub program: $getaddr" + exit 3 +fi +$getaddr | read source dest +if (( $? != 0 )); then + print -nu2 "Could not find a local IPv6 interface and a remote IPv6 " + print -u2 "host. Aborting test.\n" + print -nu2 "For this test to continue, a \"ping -ns -A inet6 FF02::1\" " + print -u2 "must respond with a\nremote IPv6 host." + exit 3 +fi + +# +# Shake loose any ICMPv6 Neighbor advertisement messages before tracing. +# +/usr/sbin/ping $dest 3 > /dev/null 2>&1 + +$dtrace -c "/usr/sbin/ping $dest 3" -qs /dev/stdin <<EOF | \ + grep -v 'is alive' | sort -n +ip:::send +/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" && + args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/ +{ + printf("1 ip:::send ("); + printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength); + printf("args[5]: %d %d %d)\n", + args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen); +} + +ip:::receive +/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" && + args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/ +{ + printf("2 ip:::receive ("); + printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength); + printf("args[5]: %d %d %d)\n", + args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen); +} +EOF diff --git a/cmd/dtrace/test/tst/common/ip/tst.ipv6remoteicmp.ksh.out b/cmd/dtrace/test/tst/common/ip/tst.ipv6remoteicmp.ksh.out new file mode 100644 index 000000000000..1ddcd07b367e --- /dev/null +++ b/cmd/dtrace/test/tst/common/ip/tst.ipv6remoteicmp.ksh.out @@ -0,0 +1,3 @@ + +1 ip:::send (args[2]: 6 64, args[5]: 6 0 64) +2 ip:::receive (args[2]: 6 64, args[5]: 6 0 64) diff --git a/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh b/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh new file mode 100644 index 000000000000..8a65ce6f8d66 --- /dev/null +++ b/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh @@ -0,0 +1,182 @@ +#!/usr/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 (c) 2010, Oracle and/or its affiliates. All rights reserved. +# + +# +# Test tcp:::state-change and tcp:::{send,receive} by connecting to +# the local ssh service and sending a test message. This should result +# in a "Protocol mismatch" response and a close of the connection. +# A number of state transition events along with tcp fusion send and +# receive events for the message should result. +# +# This may fail due to: +# +# 1. A change to the ip stack breaking expected probe behavior, +# which is the reason we are testing. +# 2. The lo0 interface missing or not up. +# 3. The local ssh service is not online. +# 4. An unlikely race causes the unlocked global send/receive +# variables to be corrupted. +# +# This test performs a TCP connection to the ssh service (port 22) and +# checks that at least the following packet counts were traced: +# +# 3 x ip:::send (2 during the TCP handshake, then a FIN) +# 4 x tcp:::send (2 during the TCP handshake, 1 message then a FIN) +# 2 x ip:::receive (1 during the TCP handshake, then the FIN ACK) +# 3 x tcp:::receive (1 during the TCP handshake, 1 message then the FIN ACK) +# +# The actual ip count tested is 5 each way, since we are tracing both +# source and destination events. The actual tcp count tested is 7 +# each way, since the TCP fusion send/receive events will not reach IP. +# +# For this test to work, we are assuming that the TCP handshake and +# TCP close will enter the IP code path and not use tcp fusion. +# + +if (( $# != 1 )); then + print -u2 "expected one argument: <dtrace-path>" + exit 2 +fi + +dtrace=$1 +local=127.0.0.1 +tcpport=22 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > test.pl <<-EOPERL + use IO::Socket; + my \$s = IO::Socket::INET->new( + Proto => "tcp", + PeerAddr => "$local", + PeerPort => $tcpport, + Timeout => 3); + die "Could not connect to host $local port $tcpport" unless \$s; + print \$s "testing state machine transitions"; + close \$s; +EOPERL + +$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE +BEGIN +{ + ipsend = tcpsend = ipreceive = tcpreceive = 0; + connreq = connest = connaccept = 0; +} + +ip:::send +/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" && + args[4]->ipv4_protocol == IPPROTO_TCP/ +{ + ipsend++; +} + +tcp:::send +/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" && + (args[4]->tcp_sport == $tcpport || args[4]->tcp_dport == $tcpport)/ +{ + tcpsend++; +} + +ip:::receive +/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" && + args[4]->ipv4_protocol == IPPROTO_TCP/ +{ + ipreceive++; +} + +tcp:::receive +/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" && + (args[4]->tcp_sport == $tcpport || args[4]->tcp_dport == $tcpport)/ +{ + tcpreceive++; +} + +tcp:::state-change +{ + state_event[args[3]->tcps_state]++; +} + +tcp:::connect-request +/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" && + args[4]->tcp_dport == $tcpport/ +{ + connreq++; +} + +tcp:::connect-established +/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" && + args[4]->tcp_sport == $tcpport/ +{ + connest++; +} + +tcp:::accept-established +/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" && + args[4]->tcp_dport == $tcpport/ +{ + connaccept++; +} + +END +{ + printf("Minimum TCP events seen\n\n"); + printf("ip:::send - %s\n", ipsend >= 5 ? "yes" : "no"); + printf("ip:::receive - %s\n", ipreceive >= 5 ? "yes" : "no"); + printf("tcp:::send - %s\n", tcpsend >= 7 ? "yes" : "no"); + printf("tcp:::receive - %s\n", tcpreceive >= 7 ? "yes" : "no"); + printf("tcp:::state-change to syn-sent - %s\n", + state_event[TCP_STATE_SYN_SENT] >=1 ? "yes" : "no"); + printf("tcp:::state-change to syn-received - %s\n", + state_event[TCP_STATE_SYN_RECEIVED] >=1 ? "yes" : "no"); + printf("tcp:::state-change to established - %s\n", + state_event[TCP_STATE_ESTABLISHED] >= 2 ? "yes" : "no"); + printf("tcp:::state-change to fin-wait-1 - %s\n", + state_event[TCP_STATE_FIN_WAIT_1] >= 1 ? "yes" : "no"); + printf("tcp:::state-change to close-wait - %s\n", + state_event[TCP_STATE_CLOSE_WAIT] >= 1 ? "yes" : "no"); + printf("tcp:::state-change to fin-wait-2 - %s\n", + state_event[TCP_STATE_FIN_WAIT_2] >= 1 ? "yes" : "no"); + printf("tcp:::state-change to last-ack - %s\n", + state_event[TCP_STATE_LAST_ACK] >= 1 ? "yes" : "no"); + printf("tcp:::state-change to time-wait - %s\n", + state_event[TCP_STATE_TIME_WAIT] >= 1 ? "yes" : "no"); + printf("tcp:::connect-request - %s\n", + connreq >=1 ? "yes" : "no"); + printf("tcp:::connect-established - %s\n", + connest >=1 ? "yes" : "no"); + printf("tcp:::accept-established - %s\n", + connaccept >=1 ? "yes" : "no"); +} +EODTRACE + +status=$? + +cd / +/usr/bin/rm -rf $DIR + +exit $status diff --git a/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh.out b/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh.out new file mode 100644 index 000000000000..ea1c27e5020c --- /dev/null +++ b/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh.out @@ -0,0 +1,18 @@ +Minimum TCP events seen + +ip:::send - yes +ip:::receive - yes +tcp:::send - yes +tcp:::receive - yes +tcp:::state-change to syn-sent - yes +tcp:::state-change to syn-received - yes +tcp:::state-change to established - yes +tcp:::state-change to fin-wait-1 - yes +tcp:::state-change to close-wait - yes +tcp:::state-change to fin-wait-2 - yes +tcp:::state-change to last-ack - yes +tcp:::state-change to time-wait - yes +tcp:::connect-request - yes +tcp:::connect-established - yes +tcp:::accept-established - yes + diff --git a/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh b/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh new file mode 100644 index 000000000000..b6b9545d4e20 --- /dev/null +++ b/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh @@ -0,0 +1,172 @@ +#!/usr/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 (c) 2010, Oracle and/or its affiliates. All rights reserved. +# + +# +# Test tcp:::state-change and tcp:::{send,receive} by connecting to +# the remote ssh service and sending a test message. This should result +# in a "Protocol mismatch" response and a close of the connection. +# A number of state transition events along with tcp send and receive +# events for the message should result. +# +# This may fail due to: +# +# 1. A change to the ip stack breaking expected probe behavior, +# which is the reason we are testing. +# 2. The lo0 interface missing or not up. +# 3. The remote ssh service is not online. +# 4. An unlikely race causes the unlocked global send/receive +# variables to be corrupted. +# +# This test performs a TCP connection to the ssh service (port 22) and +# checks that at least the following packet counts were traced: +# +# 4 x ip:::send (2 during the TCP handshake, the message, then a FIN) +# 4 x tcp:::send (2 during the TCP handshake, the messages, then a FIN) +# 3 x ip:::receive (1 during the TCP handshake, the response, then the FIN ACK) +# 3 x tcp:::receive (1 during the TCP handshake, the response, then the FIN ACK) +# +# For this test to work, we are assuming that the TCP handshake and +# TCP close will enter the IP code path and not use tcp fusion. +# + +if (( $# != 1 )); then + print -u2 "expected one argument: <dtrace-path>" + exit 2 +fi + +dtrace=$1 +getaddr=./get.ipv4remote.pl +tcpport=22 +DIR=/var/tmp/dtest.$$ + +if [[ ! -x $getaddr ]]; then + print -u2 "could not find or execute sub program: $getaddr" + exit 3 +fi +$getaddr $tcpport | read source dest +if (( $? != 0 )); then + exit 4 +fi + +mkdir $DIR +cd $DIR + +cat > test.pl <<-EOPERL + use IO::Socket; + my \$s = IO::Socket::INET->new( + Proto => "tcp", + PeerAddr => "$dest", + PeerPort => $tcpport, + Timeout => 3); + die "Could not connect to host $dest port $tcpport" unless \$s; + print \$s "testing state machine transitions"; + close \$s; +EOPERL + +$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE +BEGIN +{ + ipsend = tcpsend = ipreceive = tcpreceive = 0; + connreq = connest = 0; +} + +ip:::send +/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" && + args[4]->ipv4_protocol == IPPROTO_TCP/ +{ + ipsend++; +} + +tcp:::send +/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" && + args[4]->tcp_dport == $tcpport/ +{ + tcpsend++; +} + +ip:::receive +/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" && + args[4]->ipv4_protocol == IPPROTO_TCP/ +{ + ipreceive++; +} + +tcp:::receive +/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" && + args[4]->tcp_sport == $tcpport/ +{ + tcpreceive++; +} + +tcp:::state-change +{ + state_event[args[3]->tcps_state]++; +} + +tcp:::connect-request +/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" && + args[4]->tcp_dport == $tcpport/ +{ + connreq++; +} + +tcp:::connect-established +/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" && + args[4]->tcp_sport == $tcpport/ +{ + connest++; +} + +END +{ + printf("Minimum TCP events seen\n\n"); + printf("ip:::send - %s\n", ipsend >= 4 ? "yes" : "no"); + printf("ip:::receive - %s\n", ipreceive >= 3 ? "yes" : "no"); + printf("tcp:::send - %s\n", tcpsend >= 4 ? "yes" : "no"); + printf("tcp:::receive - %s\n", tcpreceive >= 3 ? "yes" : "no"); + printf("tcp:::state-change to syn-sent - %s\n", + state_event[TCP_STATE_SYN_SENT] >=1 ? "yes" : "no"); + printf("tcp:::state-change to established - %s\n", + state_event[TCP_STATE_ESTABLISHED] >= 1 ? "yes" : "no"); + printf("tcp:::state-change to fin-wait-1 - %s\n", + state_event[TCP_STATE_FIN_WAIT_1] >= 1 ? "yes" : "no"); + printf("tcp:::state-change to fin-wait-2 - %s\n", + state_event[TCP_STATE_FIN_WAIT_2] >= 1 ? "yes" : "no"); + printf("tcp:::state-change to time-wait - %s\n", + state_event[TCP_STATE_TIME_WAIT] >= 1 ? "yes" : "no"); + printf("tcp:::connect-request - %s\n", + connreq >=1 ? "yes" : "no"); + printf("tcp:::connect-established - %s\n", + connest >=1 ? "yes" : "no"); +} +EODTRACE + +status=$? + +cd / +/usr/bin/rm -rf $DIR + +exit $status diff --git a/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh.out b/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh.out new file mode 100644 index 000000000000..27388fba65dc --- /dev/null +++ b/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh.out @@ -0,0 +1,15 @@ +Minimum TCP events seen + +ip:::send - yes +ip:::receive - yes +tcp:::send - yes +tcp:::receive - yes +tcp:::state-change to syn-sent - yes +tcp:::state-change to established - yes +tcp:::state-change to fin-wait-1 - yes +tcp:::state-change to close-wait - yes +tcp:::state-change to fin-wait-2 - yes +tcp:::state-change to time-wait - yes +tcp:::connect-request - yes +tcp:::connect-established - yes + diff --git a/cmd/dtrace/test/tst/common/java_api/src/TestFunctionLookup.java b/cmd/dtrace/test/tst/common/java_api/src/TestFunctionLookup.java index 3488903c19ea..2bc43ea6f1ce 100644 --- a/cmd/dtrace/test/tst/common/java_api/src/TestFunctionLookup.java +++ b/cmd/dtrace/test/tst/common/java_api/src/TestFunctionLookup.java @@ -20,10 +20,8 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. - * - * ident "%Z%%M% %I% %E% SMI" */ import org.opensolaris.os.dtrace.*; @@ -70,7 +68,7 @@ public class TestFunctionLookup { long addr = (Long)address; f = consumer.lookupKernelFunction(addr); } - if (f.equals("genunix`setrun")) { + if (f.equals("genunix`cv_wakeup")) { System.out.println(f); done = true; } diff --git a/cmd/dtrace/test/tst/common/java_api/src/TestGetAggregate.java b/cmd/dtrace/test/tst/common/java_api/src/TestGetAggregate.java new file mode 100644 index 000000000000..e02df8582417 --- /dev/null +++ b/cmd/dtrace/test/tst/common/java_api/src/TestGetAggregate.java @@ -0,0 +1,252 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL 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. + */ + +import org.opensolaris.os.dtrace.*; +import java.util.*; + +/** + * Assert getAggregate() can explicitly specify the anonymous aggregation. + */ +public class TestGetAggregate { + static final String programString = + "profile:::tick-50ms" + + "{" + + " @ = count();" + + " @a = count();" + + "}"; + + static final String ANONYMOUS_AGGREGATION = ""; + static final int TICK = 50; + static final int EXPECTED_TICKS = 3; + static final int INTERVALS = 4; + + static void + testIncluded(Consumer consumer, String ... aggregationNames) + throws DTraceException, InterruptedException + { + Aggregate aggregate; + Set <String> included = new HashSet <String> (); + int n = 1; + + for (String name : aggregationNames) { + included.add(name); + } + + // Wait up to a full second to obtain aggregate data. Without a + // time limit, we'll loop forever if no aggregation was + // successfully included. + do { + Thread.sleep(TICK); + aggregate = consumer.getAggregate(included, null); + } while (aggregate.asMap().isEmpty() && n++ < (1000 / TICK)); + + for (String name : included) { + if (aggregate.getAggregation(name) == null) { + throw new IllegalStateException("@" + name + + " was explicitly included but did not appear " + + "in the aggregate"); + } + } + for (Aggregation a : aggregate.getAggregations()) { + if (!included.contains(a.getName())) { + throw new IllegalStateException("@" + a.getName() + + " was not explicitly included but appeared " + + "in the aggregate anyway"); + } + } + + if (!consumer.isRunning()) { + throw new IllegalStateException("consumer exited"); + } + } + + static void + testCleared(Consumer consumer, String ... aggregationNames) + throws DTraceException, InterruptedException + { + Aggregate aggregate; + AggregationRecord rec; + long value; + Long firstValue; + int n = 1; + Map <String, Long> firstValues = new HashMap <String, Long> (); + Set <String> cleared = new HashSet <String> (); + + for (String name : aggregationNames) { + cleared.add(name); + } + + do { + Thread.sleep(TICK); + aggregate = consumer.getAggregate(null, cleared); + } while (aggregate.asMap().isEmpty() && n++ < (1000 / TICK)); + n = 1; + + do { + Thread.sleep(TICK * EXPECTED_TICKS); + aggregate = consumer.getAggregate(null, cleared); + + for (Aggregation a : aggregate.getAggregations()) { + if (!firstValues.containsKey(a.getName())) { + rec = a.getRecord(Tuple.EMPTY); + value = rec.getValue().getValue().longValue(); + firstValues.put(a.getName(), value); + } + } + } while (consumer.isRunning() && n++ < INTERVALS); + + for (Aggregation a : aggregate.getAggregations()) { + rec = a.getRecord(Tuple.EMPTY); + value = rec.getValue().getValue().longValue(); + firstValue = firstValues.get(a.getName()); + + if (cleared.contains(a.getName())) { + // last value should be about the same as first value + if (value > (firstValue * 2)) { + throw new IllegalStateException( + "@" + a.getName() + " should have " + + "been cleared but instead grew from " + + firstValue + " to " + value); + } + } else { + // last value should be about (INTERVALS * firstValue) + if (value < (firstValue * 2)) { + throw new IllegalStateException( + "@" + a.getName() + " should have " + + "accumulated a running total but " + + "instead went from " + + firstValue + " to " + value); + } + } + } + + if (!consumer.isRunning()) { + throw new IllegalStateException("consumer exited"); + } + } + + static Integer includedStatus; + static Integer clearedStatus; + + static void + startIncludedTest() + { + final Consumer consumer = new LocalConsumer(); + consumer.addConsumerListener(new ConsumerAdapter() { + public void consumerStarted(ConsumerEvent e) { + new Thread(new Runnable() { + public void run() { + try { + testIncluded(consumer, ANONYMOUS_AGGREGATION); + includedStatus = 0; + } catch (Exception e) { + includedStatus = 1; + e.printStackTrace(); + } finally { + consumer.abort(); + } + } + }).start(); + } + }); + + try { + consumer.open(); + consumer.setOption(Option.aggrate, Option.millis(TICK)); + consumer.compile(programString); + consumer.enable(); + consumer.go(); + } catch (Exception e) { + includedStatus = 1; + e.printStackTrace(); + } + } + + static void + startClearedTest() + { + final Consumer consumer = new LocalConsumer(); + consumer.addConsumerListener(new ConsumerAdapter() { + public void consumerStarted(ConsumerEvent e) { + new Thread(new Runnable() { + public void run() { + try { + testCleared(consumer, ANONYMOUS_AGGREGATION); + clearedStatus = 0; + } catch (Exception e) { + clearedStatus = 1; + e.printStackTrace(); + } finally { + consumer.abort(); + } + } + }).start(); + } + }); + + try { + consumer.open(); + consumer.setOption(Option.aggrate, Option.millis(TICK)); + consumer.compile(programString); + consumer.enable(); + consumer.go(); + } catch (Exception e) { + clearedStatus = 1; + e.printStackTrace(); + } + } + + public static void + main(String[] args) + { + startIncludedTest(); + + do { + try { + Thread.sleep(TICK); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } while (includedStatus == null); + + startClearedTest(); + + do { + try { + Thread.sleep(TICK); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } while (clearedStatus == null); + + if (includedStatus != 0 || clearedStatus != 0) { + System.out.println("Failure"); + System.exit(1); + } + + System.out.println("Success"); + } +} diff --git a/cmd/dtrace/test/tst/common/java_api/tst.FunctionLookup.ksh.out b/cmd/dtrace/test/tst/common/java_api/tst.FunctionLookup.ksh.out index 400064d8eaba..d42e9b59b6e1 100644 --- a/cmd/dtrace/test/tst/common/java_api/tst.FunctionLookup.ksh.out +++ b/cmd/dtrace/test/tst/common/java_api/tst.FunctionLookup.ksh.out @@ -1,3 +1,3 @@ -genunix`setrun +genunix`cv_wakeup 3 tst.FunctionLookup.exe`f1 diff --git a/cmd/dtrace/test/tst/common/java_api/tst.GetAggregate.ksh b/cmd/dtrace/test/tst/common/java_api/tst.GetAggregate.ksh new file mode 100644 index 000000000000..2fdd5a9eac44 --- /dev/null +++ b/cmd/dtrace/test/tst/common/java_api/tst.GetAggregate.ksh @@ -0,0 +1,36 @@ +#!/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 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +############################################################################ +# ASSERTION: +# getAggregate() can explicitly specify the anonymous aggregation +# +# SECTION: Java API +# +############################################################################ + +java -cp test.jar TestGetAggregate diff --git a/cmd/dtrace/test/tst/common/misc/tst.macroglob.ksh b/cmd/dtrace/test/tst/common/misc/tst.macroglob.ksh new file mode 100644 index 000000000000..a5114f4917e5 --- /dev/null +++ b/cmd/dtrace/test/tst/common/misc/tst.macroglob.ksh @@ -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 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -ln 'syscall::*$1:entry' read | awk '{print $(NF-1),$NF}' | sort +$dtrace -ln 'syscall::$1*:entry' read | awk '{print $(NF-1),$NF}' | sort +$dtrace -ln 'syscall::re$1*:entry' ad | awk '{print $(NF-1),$NF}' | sort +$dtrace -ln 'syscall::$1l*:entry' read | awk '{print $(NF-1),$NF}' | sort +$dtrace -ln 'syscall::p$1[0-9][0-9]:entry' read | awk '{print $(NF-1),$NF}' | \ + sort + +exit $status diff --git a/cmd/dtrace/test/tst/common/misc/tst.macroglob.ksh.out b/cmd/dtrace/test/tst/common/misc/tst.macroglob.ksh.out new file mode 100644 index 000000000000..8a9ac6d96c5a --- /dev/null +++ b/cmd/dtrace/test/tst/common/misc/tst.macroglob.ksh.out @@ -0,0 +1,15 @@ +FUNCTION NAME +pread entry +read entry +FUNCTION NAME +read entry +readlink entry +readv entry +FUNCTION NAME +read entry +readlink entry +readv entry +FUNCTION NAME +readlink entry +FUNCTION NAME +pread64 entry diff --git a/cmd/dtrace/test/tst/common/pid/err.D_PDESC_ZERO.badlib.exe b/cmd/dtrace/test/tst/common/pid/err.D_PDESC_ZERO.badlib.exe new file mode 100644 index 000000000000..595db1de33da --- /dev/null +++ b/cmd/dtrace/test/tst/common/pid/err.D_PDESC_ZERO.badlib.exe @@ -0,0 +1,29 @@ +#!/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" + +sleep 1000000 diff --git a/cmd/dtrace/test/tst/common/pid/err.D_PROC_CREATEFAIL.many.exe b/cmd/dtrace/test/tst/common/pid/err.D_PROC_CREATEFAIL.many.exe new file mode 100644 index 000000000000..25b4ff143dad --- /dev/null +++ b/cmd/dtrace/test/tst/common/pid/err.D_PROC_CREATEFAIL.many.exe @@ -0,0 +1,29 @@ +#!/bin/bash +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: 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" + +sleep 1000000 diff --git a/cmd/dtrace/test/tst/common/pid/err.D_PROC_FUNC.badfunc.exe b/cmd/dtrace/test/tst/common/pid/err.D_PROC_FUNC.badfunc.exe new file mode 100644 index 000000000000..595db1de33da --- /dev/null +++ b/cmd/dtrace/test/tst/common/pid/err.D_PROC_FUNC.badfunc.exe @@ -0,0 +1,29 @@ +#!/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" + +sleep 1000000 diff --git a/cmd/dtrace/test/tst/common/pid/err.D_PROC_LIB.libdash.exe b/cmd/dtrace/test/tst/common/pid/err.D_PROC_LIB.libdash.exe new file mode 100644 index 000000000000..595db1de33da --- /dev/null +++ b/cmd/dtrace/test/tst/common/pid/err.D_PROC_LIB.libdash.exe @@ -0,0 +1,29 @@ +#!/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" + +sleep 1000000 diff --git a/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.alldash.exe b/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.alldash.exe new file mode 100644 index 000000000000..595db1de33da --- /dev/null +++ b/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.alldash.exe @@ -0,0 +1,29 @@ +#!/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" + +sleep 1000000 diff --git a/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.badname.exe b/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.badname.exe new file mode 100644 index 000000000000..595db1de33da --- /dev/null +++ b/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.badname.exe @@ -0,0 +1,29 @@ +#!/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" + +sleep 1000000 diff --git a/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.globdash.exe b/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.globdash.exe new file mode 100644 index 000000000000..595db1de33da --- /dev/null +++ b/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.globdash.exe @@ -0,0 +1,29 @@ +#!/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" + +sleep 1000000 diff --git a/cmd/dtrace/test/tst/common/pid/err.D_PROC_OFF.toobig.exe b/cmd/dtrace/test/tst/common/pid/err.D_PROC_OFF.toobig.exe new file mode 100644 index 000000000000..595db1de33da --- /dev/null +++ b/cmd/dtrace/test/tst/common/pid/err.D_PROC_OFF.toobig.exe @@ -0,0 +1,29 @@ +#!/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" + +sleep 1000000 diff --git a/cmd/dtrace/test/tst/common/pid/tst.coverage.exe b/cmd/dtrace/test/tst/common/pid/tst.coverage.exe new file mode 100644 index 000000000000..07e84583e74c --- /dev/null +++ b/cmd/dtrace/test/tst/common/pid/tst.coverage.exe @@ -0,0 +1,29 @@ +#!/usr/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" + +while true; do env > /dev/null; done diff --git a/cmd/dtrace/test/tst/common/pid/tst.emptystack.exe b/cmd/dtrace/test/tst/common/pid/tst.emptystack.exe new file mode 100644 index 000000000000..a8bc8cb351e9 --- /dev/null +++ b/cmd/dtrace/test/tst/common/pid/tst.emptystack.exe @@ -0,0 +1,29 @@ +#!/usr/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" + +exec find / > /dev/null 2>&1 diff --git a/cmd/dtrace/test/tst/common/pid/tst.killonerror.ksh b/cmd/dtrace/test/tst/common/pid/tst.killonerror.ksh new file mode 100644 index 000000000000..587878c3fc2a --- /dev/null +++ b/cmd/dtrace/test/tst/common/pid/tst.killonerror.ksh @@ -0,0 +1,41 @@ +#!/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 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +# +# Make sure we kill a process if the dtrace(1M) command fails. +# + +rc=`$dtrace -c date -n jarod 2>/dev/null | /usr/bin/wc -l` + +exit $rc diff --git a/cmd/dtrace/test/tst/common/pid/tst.probemod.ksh b/cmd/dtrace/test/tst/common/pid/tst.probemod.ksh index 2565b503d154..326fd1ab9f83 100644 --- a/cmd/dtrace/test/tst/common/pid/tst.probemod.ksh +++ b/cmd/dtrace/test/tst/common/pid/tst.probemod.ksh @@ -21,11 +21,9 @@ # # -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# ident "%Z%%M% %I% %E% SMI" -# if [ $# != 1 ]; then echo expected one argument: '<'dtrace-path'>' @@ -40,7 +38,7 @@ dtrace=$1 # (and therefore 'libc' and 'libc.so') as it's definitely there. # -for lib in libc libc.so libc.so.1; do +for lib in libc libc.so libc.so.1 'lib[c]*'; do sleep 60 & pid=$! dtrace -n "pid$pid:$lib::entry" -n 'tick-2s{exit(0);}' diff --git a/cmd/dtrace/test/tst/common/plockstat/tst.available.exe b/cmd/dtrace/test/tst/common/plockstat/tst.available.exe new file mode 100644 index 000000000000..221e8b1d7434 --- /dev/null +++ b/cmd/dtrace/test/tst/common/plockstat/tst.available.exe @@ -0,0 +1,29 @@ +#!/usr/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" + +sleep 100000000 diff --git a/cmd/dtrace/test/tst/common/plockstat/tst.libmap.exe b/cmd/dtrace/test/tst/common/plockstat/tst.libmap.exe new file mode 100644 index 000000000000..221e8b1d7434 --- /dev/null +++ b/cmd/dtrace/test/tst/common/plockstat/tst.libmap.exe @@ -0,0 +1,29 @@ +#!/usr/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" + +sleep 100000000 diff --git a/cmd/dtrace/test/tst/common/printa/tst.basics.d b/cmd/dtrace/test/tst/common/printa/tst.basics.d index e7de2d389abf..f5353870808d 100644 --- a/cmd/dtrace/test/tst/common/printa/tst.basics.d +++ b/cmd/dtrace/test/tst/common/printa/tst.basics.d @@ -20,15 +20,13 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * ASSERTION: - * Test the basic formatting of all the supported kinds of aggregations. + * Test the basic formatting of all the supported kinds of aggregations. * * SECTION: Output Formatting/printa() * @@ -45,6 +43,7 @@ BEGIN @e = min(1); @f = sum(1); @g = quantize(1); + @h = stddev(1); printa("@a = %@u\n", @a); printa("@b = %@u\n", @b); @@ -53,6 +52,7 @@ BEGIN printa("@e = %@u\n", @e); printa("@f = %@u\n", @f); printa("@g = %@d\n", @g); + printa("@h = %@d\n", @h); exit(0); } diff --git a/cmd/dtrace/test/tst/common/printa/tst.basics.d.out b/cmd/dtrace/test/tst/common/printa/tst.basics.d.out index a3d46a982a95..ddad2134d1af 100644 --- a/cmd/dtrace/test/tst/common/printa/tst.basics.d.out +++ b/cmd/dtrace/test/tst/common/printa/tst.basics.d.out @@ -15,4 +15,5 @@ 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 2 | 0 +@h = 0 diff --git a/cmd/dtrace/test/tst/common/printa/tst.largeusersym.ksh b/cmd/dtrace/test/tst/common/printa/tst.largeusersym.ksh new file mode 100644 index 000000000000..ed375fdbf9b4 --- /dev/null +++ b/cmd/dtrace/test/tst/common/printa/tst.largeusersym.ksh @@ -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 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > test.c <<EOF +void +thequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydog(void) +{ + while (1) + ; +} + +int +main(int argc, char *argv[]) +{ + thequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydog(); +} +EOF + +cc -o test test.c +if [ $? -ne 0 ]; then + print -u2 "failed to compile test.c" + exit 1 +fi + +script() +{ + $dtrace -c ./test -qs /dev/stdin <<EOF + profile:::profile-1001hz + /pid == \$target/ + { + @[arg1] = count(); + } + + tick-1s + /n++ > 10/ + { + printa("%A %@d\n", @); + exit(0); + } +EOF +} + +script +status=$? + +cd / +/usr/bin/rm -rf $DIR + +exit $status diff --git a/cmd/dtrace/test/tst/common/printf/tst.str.d b/cmd/dtrace/test/tst/common/printf/tst.str.d index 483473344a54..a74041393ebf 100644 --- a/cmd/dtrace/test/tst/common/printf/tst.str.d +++ b/cmd/dtrace/test/tst/common/printf/tst.str.d @@ -20,12 +20,10 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * ASSERTION: * Test printf() with a simple string argument. @@ -38,6 +36,6 @@ BEGIN { - printf("rootfs = %s", `rootfs.bo_fstype); + printf("sysname = %s", `utsname.sysname); exit(0); } diff --git a/cmd/dtrace/test/tst/common/printf/tst.str.d.out b/cmd/dtrace/test/tst/common/printf/tst.str.d.out index b425586425ea..ba3198176ecc 100644 --- a/cmd/dtrace/test/tst/common/printf/tst.str.d.out +++ b/cmd/dtrace/test/tst/common/printf/tst.str.d.out @@ -1 +1 @@ -rootfs = ufs +sysname = SunOS diff --git a/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.c b/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.c new file mode 100644 index 000000000000..07635502a9db --- /dev/null +++ b/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.c @@ -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 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <unistd.h> +#include <sys/uadmin.h> + +int +main(int argc, char **argv) +{ + while (1) { + if (uadmin(A_SDTTEST, 0, 0) < 0) { + perror("uadmin"); + return (1); + } + + sleep(1); + } + + return (0); +} diff --git a/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.d b/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.d new file mode 100644 index 000000000000..0523de0951ed --- /dev/null +++ b/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.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 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Verify that argN (1..7) variables are properly remapped. + */ + +BEGIN +{ + /* Timeout after 5 seconds */ + timeout = timestamp + 5000000000; + ignore = $1; +} + +ERROR +{ + printf("sdt:::test failed.\n"); + exit(1); +} + +sdt:::test +/arg0 != 1 || arg1 != 2 || arg2 != 3 || arg3 != 4 || arg4 != 5 || arg5 != 6 || + arg6 != 7/ +{ + printf("sdt arg mismatch\n\n"); + printf("args are : %d, %d, %d, %d, %d, %d, %d\n", arg0, arg1, arg2, + arg3, arg4, arg5, arg6); + printf("should be : 1, 2, 3, 4, 5, 6, 7\n"); + exit(1); +} + +sdt:::test +{ + exit(0); +} + +profile:::tick-1 +/timestamp > timeout/ +{ + trace("test timed out"); + exit(1); +} diff --git a/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithStddev.d b/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithStddev.d new file mode 100644 index 000000000000..22953c2a55f4 --- /dev/null +++ b/cmd/dtrace/test/tst/common/speculation/err.D_AGG_SPEC.SpeculateWithStddev.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 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * ASSERTION: + * Aggregating actions may never be speculative. + * + * SECTION: Speculative Tracing/Using a Speculation + * + */ +#pragma D option quiet + +BEGIN +{ + i = 0; +} + +profile:::tick-1sec +/i < 1/ +{ + var = speculation(); + speculate(var); + printf("Speculation ID: %d", var); + @sdev["speculate"] = stddev(i); + i++; +} + +profile:::tick-1sec +/1 == i/ +{ + exit(0); +} + +ERROR +{ + exit(0); +} + +END +{ + exit(0); +} diff --git a/cmd/dtrace/test/tst/common/sysevent/tst.post_chan.c b/cmd/dtrace/test/tst/common/sysevent/tst.post_chan.c index 8394716af173..4a452a7ad2de 100644 --- a/cmd/dtrace/test/tst/common/sysevent/tst.post_chan.c +++ b/cmd/dtrace/test/tst/common/sysevent/tst.post_chan.c @@ -19,12 +19,10 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <libsysevent.h> #include <stdio.h> @@ -42,7 +40,7 @@ main(int argc, char **argv) for (;;) { if (sysevent_evc_publish(ch, "class_dtest", "subclass_dtest", "vendor_dtest", "publisher_dtest", NULL, EVCH_SLEEP) != 0) { - sysevent_evc_unbind(ch); + (void) sysevent_evc_unbind(ch); (void) fprintf(stderr, "failed to publisth sysevent\n"); return (1); } diff --git a/cmd/dtrace/test/tst/common/usdt/tst.corruptenv.ksh b/cmd/dtrace/test/tst/common/usdt/tst.corruptenv.ksh new file mode 100644 index 000000000000..68dbb03456cc --- /dev/null +++ b/cmd/dtrace/test/tst/common/usdt/tst.corruptenv.ksh @@ -0,0 +1,107 @@ +#!/usr/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 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# This test verifies that a program that corrupts its own environment +# without inducing a crash does not crash solely due to drti.o's use of +# getenv(3C). +# + +PATH=/usr/bin:/usr/sbin:$PATH + +if (( $# != 1 )); then + print -u2 'expected one argument: <dtrace-path>' + exit 2 +fi + +# +# jdtrace does not implement the -h option that is required to generate +# C header files. +# +if [[ "$1" == */jdtrace ]]; then + exit 0 +fi + +dtrace="$1" +startdir="$PWD" +dir=$(mktemp -td drtiXXXXXX) +if (( $? != 0 )); then + print -u2 'Could not create safe temporary directory' + exit 2 +fi + +cd "$dir" + +cat > Makefile <<EOF +all: main + +main: main.o prov.o + \$(CC) -o main main.o prov.o + +main.o: main.c prov.h + \$(CC) -c main.c + +prov.h: prov.d + $dtrace -h -s prov.d + +prov.o: prov.d main.o + $dtrace -G -32 -s prov.d main.o +EOF + +cat > prov.d <<EOF +provider tester { + probe entry(); +}; +EOF + +cat > main.c <<EOF +#include <stdlib.h> +#include <sys/sdt.h> +#include "prov.h" + +int +main(int argc, char **argv, char **envp) +{ + envp[0] = (char*)0xff; + TESTER_ENTRY(); + return 0; +} +EOF + +make > /dev/null +status=$? +if (( $status != 0 )) ; then + print -u2 "failed to build" +else + ./main + status=$? +fi + +cd "$startdir" +rm -rf "$dir" + +exit $status diff --git a/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh b/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh new file mode 100644 index 000000000000..340164847bfb --- /dev/null +++ b/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh @@ -0,0 +1,113 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL 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" + +# +# This test is primarily intended to verify a fix for SPARC, but there's no +# harm in running it on other platforms. Here, we verify that is-enabled +# probes don't interfere with return values from previously invoked functions. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > prov.d <<EOF +provider test_prov { + probe go(); +}; +EOF + +$dtrace -h -s prov.d +if [ $? -ne 0 ]; then + print -u2 "failed to generate header file" + exit 1 +fi + +cat > test.c <<EOF +#include <stdio.h> +#include "prov.h" + +int +foo(void) +{ + return (24); +} + +int +main(int argc, char **argv) +{ + int a = foo(); + if (TEST_PROV_GO_ENABLED()) { + TEST_PROV_GO(); + } + (void) printf("%d %d %d\n", a, a, a); + + return (0); +} +EOF + +cc -c -xO2 test.c +if [ $? -ne 0 ]; then + print -u2 "failed to compile test.c" + exit 1 +fi +$dtrace -G -32 -s prov.d test.o +if [ $? -ne 0 ]; then + print -u2 "failed to create DOF" + exit 1 +fi +cc -o test test.o prov.o +if [ $? -ne 0 ]; then + print -u2 "failed to link final executable" + exit 1 +fi + +script() +{ + ./test + + $dtrace -c ./test -qs /dev/stdin <<EOF + test_prov\$target::: + { + } +EOF +} + +script +status=$? + +cd / +/usr/bin/rm -rf $DIR + +exit $status diff --git a/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh.out b/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh.out new file mode 100644 index 000000000000..563d68fd312b --- /dev/null +++ b/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh.out @@ -0,0 +1,3 @@ +24 24 24 +24 24 24 + |