1/*
2 * CDDL HEADER START
3 *
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.
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24 * Use is subject to license terms.
25 */
26
27/*
28 * Copyright (c) 2012 by Delphix. All rights reserved.
29 */
30
31/*
32 * ASSERTION:
33 * Verify the behavior of variations in bufsize.
34 *
35 * SECTION: Speculative Tracing/Options and Tuning;
36 *	    Options and Tunables/bufsize
37 *
38 * NOTES: This test behaves differently depending on the values
39 * assigned to bufsize.
40 * 1. 0 > bufsize.
41 * 2. 0 == bufsize.
42 * 3. 0 < bufsize <= 7
43 * 4. 8 <= bufsize <= 31
44 * 5. 32 <= bufsize <= 47
45 * 6. 48 <= bufsize <= 71
46 * 7. 72 <= bufsize
47 */
48
49#pragma D option quiet
50#pragma D option bufsize=4
51
52BEGIN
53{
54	self->speculateFlag = 0;
55	self->commitFlag = 0;
56	self->spec = speculation();
57	printf("Speculative buffer ID: %d\n", self->spec);
58}
59
60BEGIN
61{
62	speculate(self->spec);
63	printf("Lots of data\n");
64	printf("Has to be crammed into this buffer\n");
65	printf("Until it overflows\n");
66	printf("And causes flops\n");
67	self->speculateFlag++;
68
69}
70
71BEGIN
72/1 <= self->speculateFlag/
73{
74	commit(self->spec);
75	self->commitFlag++;
76}
77
78BEGIN
79/1 <= self->commitFlag/
80{
81	printf("Statement was executed\n");
82	exit(0);
83}
84
85BEGIN
86/1 > self->commitFlag/
87{
88	printf("Statement wasn't executed\n");
89	exit(1);
90}
91