9512fe850e98fdd448c638ca63fdd92a8a510255ahl/*
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * CDDL HEADER START
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * The contents of this file are subject to the terms of the
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * Common Development and Distribution License (the "License").
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * You may not use this file except in compliance with the License.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * or http://www.opensolaris.org/os/licensing.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * See the License for the specific language governing permissions
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * and limitations under the License.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * When distributing Covered Code, include this CDDL HEADER in each
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * If applicable, add the following below this CDDL HEADER, with the
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * fields enclosed by brackets "[]" replaced with your own identifying
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * information: Portions Copyright [yyyy] [name of copyright owner]
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * CDDL HEADER END
9512fe850e98fdd448c638ca63fdd92a8a510255ahl */
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl/*
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * Use is subject to license terms.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl */
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal/*
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * Copyright (c) 2012 by Delphix. All rights reserved.
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal */
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl/*
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * ASSERTION:
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * Positive test for ring buffer policy.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * SECTION: Buffers and Buffering/ring Policy;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * Buffers and Buffering/Buffer Sizes;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * Options and Tunables/bufsize;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * Options and Tunables/bufpolicy
9512fe850e98fdd448c638ca63fdd92a8a510255ahl */
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl/*
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * We make some regrettable assumptions about the implementation in this
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * test. First, we assume that each entry for the printf() of an int
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * takes _exactly_ 16 bytes (4 bytes for the EPID, 8 bytes for the
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * timestamp, 4 bytes for the payload). Second, we assume that by
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * allocating storage for n + 1 records, we will get exactly n. Here is
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * why: the final predicate that evaluates to false will reserve space
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * that it won't use. This act of reservation will advance the wrapped
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * offset. That record won't be subsequently used, but the wrapped
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * offset has advanced. (And in this case, that old record is clobbered
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * by the exit() anyway.) Thirdly: we rely on t_cpu/cpu_id. Finally:
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * we rely on being able to run on the CPU that we first ran on.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl */
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#pragma D option bufpolicy=ring
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal#pragma D option bufsize=80
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#pragma D option quiet
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlint n;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlBEGIN
9512fe850e98fdd448c638ca63fdd92a8a510255ahl{
9512fe850e98fdd448c638ca63fdd92a8a510255ahl cpuid = -1;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl}
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahltick-10msec
9512fe850e98fdd448c638ca63fdd92a8a510255ahl/cpuid == -1/
9512fe850e98fdd448c638ca63fdd92a8a510255ahl{
9512fe850e98fdd448c638ca63fdd92a8a510255ahl cpuid = curthread->t_cpu->cpu_id;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl}
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahltick-10msec
9512fe850e98fdd448c638ca63fdd92a8a510255ahl/curthread->t_cpu->cpu_id == cpuid && n < 100/
9512fe850e98fdd448c638ca63fdd92a8a510255ahl{
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("%d\n", n++);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl}
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahltick-10msec
9512fe850e98fdd448c638ca63fdd92a8a510255ahl/n == 100/
9512fe850e98fdd448c638ca63fdd92a8a510255ahl{
9512fe850e98fdd448c638ca63fdd92a8a510255ahl exit(0);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl}