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.*;
30 import java.util.NoSuchElementException;
33 * Regression for 6426129 abort() after close() throws
34 * NoSuchElementException.
36 public class TestAbort {
37 static boolean aborted = false;
42 Consumer consumer = new LocalConsumer();
44 // Test for deadlock (bug 6419880)
47 consumer.compile("syscall:::entry { @[execname] = count(); } " +
48 "tick-101ms { printa(@); }");
52 Thread.currentThread().sleep(1000);
53 } catch (InterruptedException e) {
58 } catch (DTraceException e) {
63 consumer = new LocalConsumer();
65 // Should be able to abort an unopened consumer
68 consumer.addConsumerListener(new ConsumerAdapter() {
69 public void consumerStopped(ConsumerEvent e) {
75 consumer.compile("syscall:::entry { @[execname] = count(); } " +
76 "tick-101ms { printa(@); }");
80 Thread.currentThread().sleep(1000);
81 } catch (InterruptedException e) {
86 throw new IllegalStateException("consumer not aborted");
89 } catch (Exception e) {
94 consumer = new LocalConsumer();
96 // Should be safe to call abort() in any state
101 consumer.compile("syscall:::entry { @[execname] = count(); } " +
102 "tick-101ms { printa(@); }");
109 // Should be safe to call after close()
112 } catch (NoSuchElementException e) {
116 } catch (Exception e) {
121 consumer = new LocalConsumer();
123 // Tests that close() throws expected exception when called on
124 // synchronized consumer.
127 consumer.compile("syscall:::entry { @[execname] = count(); } " +
128 "tick-101ms { printa(@); }");
132 Thread.currentThread().sleep(1000);
133 } catch (InterruptedException e) {
138 synchronized (consumer) {
141 } catch (IllegalThreadStateException e) {
144 System.out.println("Successful");
146 } catch (NoSuchElementException x) {
151 } catch (DTraceException e) {
155 System.err.println("Failed");