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"
29 import org.opensolaris.os.dtrace.*;
32 * Prove that enable() handles multiple programs, recognizing programs
33 * that are already enabled and programs that were compiled by another
36 public class TestEnable {
48 Consumer consumer = new LocalConsumer();
52 Program p0 = consumer.compile("dtrace:::BEGIN");
53 Program p1 = consumer.compile("syscall:::entry");
54 Program p2 = consumer.compile("dtrace:::END");
59 System.err.println("go() illegal, not all programs " +
62 } catch (IllegalStateException e) {
63 System.out.println(e);
64 } catch (Exception e) {
70 System.err.println("enable() illegal, some programs " +
71 "already enabled (p0, p1)");
73 } catch (IllegalStateException e) {
74 System.out.println(e);
75 } catch (Exception e) {
81 System.err.println("cannot enable a program that " +
82 "has already been enabled (p0)");
84 } catch (IllegalStateException e) {
85 System.out.println(e);
86 } catch (Exception e) {
91 Program p3 = consumer.compile("syscall:::return");
94 System.err.println("go() illegal, not all programs " +
95 "enabled (p0, p1, p2)");
97 } catch (IllegalStateException e) {
98 System.out.println(e);
99 } catch (Exception e) {
105 System.err.println("enable() illegal, some programs " +
106 "already enabled (p0, p1, p2)");
108 } catch (IllegalStateException e) {
109 System.out.println(e);
110 } catch (Exception e) {
114 // Try to fool the consumer with a program compiled by
116 Consumer consumer2 = new LocalConsumer();
118 Program p3x = consumer2.compile("syscall:::return");
120 consumer.enable(p3x);
121 System.err.println("cannot enable program compiled " +
122 "by another consumer");
124 } catch (IllegalArgumentException e) {
125 System.out.println(e);
126 } catch (Exception e) {
136 // Enable all compiled programs at once
137 consumer = new LocalConsumer();
139 consumer.compile("dtrace:::BEGIN");
140 consumer.compile("syscall:::entry");
141 consumer.compile("dtrace:::END");
146 } catch (DTraceException e) {