e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal#!/bin/ksh -p
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal#
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal# CDDL HEADER START
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal#
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal# This file and its contents are supplied under the terms of the
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal# Common Development and Distribution License ("CDDL"), version 1.0.
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal# You may only use this file in accordance with the terms of version
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal# 1.0 of the CDDL.
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal#
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal# A full copy of the text of the CDDL should have accompanied this
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal# source. A copy of the CDDL is also available via the Internet at
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal# http://www.illumos.org/license/CDDL.
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal#
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal# CDDL HEADER END
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal#
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal#
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal# Copyright (c) 2012 by Delphix. All rights reserved.
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal#
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal############################################################################
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal# ASSERTION:
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal# temporal option causes output to be sorted
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal#
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal# SECTION: Pragma
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal#
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal# NOTES: The temporal option has no effect on a single-CPU system, so
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal# this needs to be run on a multi-CPU system to effectively test the
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal# temporal option.
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal#
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal############################################################################
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalif [ $# != 1 ]; then
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal echo expected one argument: '<'dtrace-path'>'
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal exit 2
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalfi
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhaldtrace=$1
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalfile=/tmp/out.$$
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalrm -f $file
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal$dtrace -o $file -c 'sleep 3' -s /dev/stdin <<EOF
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal #pragma D option quiet
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal #pragma D option temporal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal BEGIN
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal {
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal @lines = count();
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal printf("0 begin\n");
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal }
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal END
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal {
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal /* Bump @lines every time we print a line. */
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal @lines = count();
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal printf("%u end\n", timestamp);
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal @lines = count();
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal printa("99999999999999999 lines %@u\n", @lines);
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal }
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal profile-97hz
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal {
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal @lines = count();
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal printf("%u\n", timestamp);
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal }
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. LeventhalEOF
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalstatus=$?
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalif [ "$status" -ne 0 ]; then
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal echo $tst: dtrace failed
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal exit $status
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalfi
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal# dtrace outputs a blank line at the end, which will sort to the beginning,
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal# so use head to remove the blank line.
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalhead -n -1 $file > $file.2
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalsort -n $file.2 | diff $file.2 -
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalstatus=$?
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalif [ "$status" -ne 0 ]; then
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal echo $tst: output is not sorted
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal exit $status
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalfi
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalhead -n 1 $file.2 | grep begin >/dev/null
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalstatus=$?
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalif [ "$status" -ne 0 ]; then
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal echo $tst: begin probe did not fire
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal exit $status
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalfi
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhaltail -n 2 $file.2 | grep end >/dev/null
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalstatus=$?
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalif [ "$status" -ne 0 ]; then
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal echo $tst: end probe did not fire
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal exit $status
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalfi
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalif [ $(tail -n 1 $file.2 | cut -f3 -d ' ') -ne \
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal $(wc -l $file.2) ]; then
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal echo $tst: incorrect number of lines output
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal exit 1
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalfi
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhalexit $status