1239385Smm#!/bin/ksh -p 2239385Smm# 3239385Smm# CDDL HEADER START 4239385Smm# 5239385Smm# This file and its contents are supplied under the terms of the 6239385Smm# Common Development and Distribution License ("CDDL"), version 1.0. 7239385Smm# You may only use this file in accordance with the terms of version 8239385Smm# 1.0 of the CDDL. 9239385Smm# 10239385Smm# A full copy of the text of the CDDL should have accompanied this 11239385Smm# source. A copy of the CDDL is also available via the Internet at 12239385Smm# http://www.illumos.org/license/CDDL. 13239385Smm# 14239385Smm# CDDL HEADER END 15239385Smm# 16239385Smm 17239385Smm# 18239385Smm# Copyright (c) 2012 by Delphix. All rights reserved. 19239385Smm# 20239385Smm 21239385Smm############################################################################ 22239385Smm# ASSERTION: 23239385Smm# temporal option causes output to be sorted 24239385Smm# 25239385Smm# SECTION: Pragma 26239385Smm# 27239385Smm# NOTES: The temporal option has no effect on a single-CPU system, so 28239385Smm# this needs to be run on a multi-CPU system to effectively test the 29239385Smm# temporal option. 30239385Smm# 31239385Smm############################################################################ 32239385Smm 33239385Smmif [ $# != 1 ]; then 34239385Smm echo expected one argument: '<'dtrace-path'>' 35239385Smm exit 2 36239385Smmfi 37239385Smm 38239385Smmdtrace=$1 39239385Smmfile=/tmp/out.$$ 40239385Smm 41239385Smmrm -f $file 42239385Smm 43239385Smm$dtrace -o $file -c 'sleep 3' -s /dev/stdin <<EOF 44239385Smm #pragma D option quiet 45239385Smm #pragma D option temporal 46239385Smm 47239385Smm BEGIN 48239385Smm { 49239385Smm @lines = count(); 50239385Smm printf("0 begin\n"); 51239385Smm } 52239385Smm 53239385Smm END 54239385Smm { 55239385Smm /* Bump @lines every time we print a line. */ 56239385Smm @lines = count(); 57239385Smm printf("%u end\n", timestamp); 58239385Smm @lines = count(); 59239385Smm printa("99999999999999999 lines %@u\n", @lines); 60239385Smm } 61239385Smm 62239385Smm profile-97hz 63239385Smm { 64239385Smm @lines = count(); 65239385Smm printf("%u\n", timestamp); 66239385Smm } 67239385SmmEOF 68239385Smm 69239385Smmstatus=$? 70239385Smmif [ "$status" -ne 0 ]; then 71239385Smm echo $tst: dtrace failed 72239385Smm exit $status 73239385Smmfi 74239385Smm 75239385Smm# dtrace outputs a blank line at the end, which will sort to the beginning, 76250575Smarkj# so use sed to remove the blank line. 77250575Smarkjsed '$d' $file > $file.2 78239385Smm 79239385Smmsort -n $file.2 | diff $file.2 - 80239385Smmstatus=$? 81239385Smmif [ "$status" -ne 0 ]; then 82239385Smm echo $tst: output is not sorted 83239385Smm exit $status 84239385Smmfi 85239385Smm 86239385Smmhead -n 1 $file.2 | grep begin >/dev/null 87239385Smmstatus=$? 88239385Smmif [ "$status" -ne 0 ]; then 89239385Smm echo $tst: begin probe did not fire 90239385Smm exit $status 91239385Smmfi 92239385Smm 93239385Smmtail -n 2 $file.2 | grep end >/dev/null 94239385Smmstatus=$? 95239385Smmif [ "$status" -ne 0 ]; then 96239385Smm echo $tst: end probe did not fire 97239385Smm exit $status 98239385Smmfi 99239385Smm 100239385Smmif [ $(tail -n 1 $file.2 | cut -f3 -d ' ') -ne \ 101239385Smm $(wc -l $file.2) ]; then 102239385Smm echo $tst: incorrect number of lines output 103239385Smm exit 1 104239385Smmfi 105239385Smm 106239385Smmexit $status 107