4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
26 * ident "%Z%%M% %I% %E% SMI"
30 import org.opensolaris.os.dtrace.*;
33 * Regression test verifies that ProbeData instances sort as expected
34 * with multiple enabled probe IDs and multiple records including byte
35 * array (sorted as unsigned bytes), stand-alone ufunc() action, and
38 public class TestProbeData {
39 public static final String PROGRAM =
40 "pid$target::fN:entry\n" +
42 " tracemem(copyin(arg1, 6), 6);\n" +
44 " trace((int)arg2);\n" +
47 "pid$target::fN2:entry\n" +
49 " tracemem(copyin(arg1, 6), 6);\n" +
51 " trace((int)arg2);\n" +
55 getString(ProbeData p)
57 StringBuilder buf = new StringBuilder();
58 buf.append("[probe ");
59 buf.append(p.getEnabledProbeID());
61 ProbeDescription d = p.getEnabledProbeDescription();
62 buf.append("pid$target");
64 buf.append(d.getModule());
66 buf.append(d.getFunction());
68 buf.append(d.getName());
70 buf.append(p.getRecords());
72 return buf.toString();
78 if (args.length != 1) {
79 System.err.println("usage: java TestProbedata <command>");
83 String command = args[0];
84 final Consumer consumer = new LocalConsumer();
85 final List <ProbeData> list = new ArrayList <ProbeData> ();
86 consumer.addConsumerListener(new ConsumerAdapter() {
87 public void dataReceived(DataEvent e) {
88 list.add(e.getProbeData());
90 public void consumerStopped(ConsumerEvent e) {
91 Collections.sort(list);
92 for (ProbeData p : list) {
93 System.out.println(getString(p));
102 consumer.createProcess(command);
103 consumer.compile(PROGRAM);
106 } catch (DTraceException e) {