1*5478Sjhaslam# 2*5478Sjhaslam# CDDL HEADER START 3*5478Sjhaslam# 4*5478Sjhaslam# The contents of this file are subject to the terms of the 5*5478Sjhaslam# Common Development and Distribution License (the "License"). 6*5478Sjhaslam# You may not use this file except in compliance with the License. 7*5478Sjhaslam# 8*5478Sjhaslam# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*5478Sjhaslam# or http://www.opensolaris.org/os/licensing. 10*5478Sjhaslam# See the License for the specific language governing permissions 11*5478Sjhaslam# and limitations under the License. 12*5478Sjhaslam# 13*5478Sjhaslam# When distributing Covered Code, include this CDDL HEADER in each 14*5478Sjhaslam# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*5478Sjhaslam# If applicable, add the following below this CDDL HEADER, with the 16*5478Sjhaslam# fields enclosed by brackets "[]" replaced with your own identifying 17*5478Sjhaslam# information: Portions Copyright [yyyy] [name of copyright owner] 18*5478Sjhaslam# 19*5478Sjhaslam# CDDL HEADER END 20*5478Sjhaslam# 21*5478Sjhaslam 22*5478Sjhaslam# 23*5478Sjhaslam# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24*5478Sjhaslam# Use is subject to license terms. 25*5478Sjhaslam# 26*5478Sjhaslam# ident "%Z%%M% %I% %E% SMI" 27*5478Sjhaslam 28*5478Sjhaslam# 29*5478Sjhaslam# This test verifies that we can generate the correct ordering for 30*5478Sjhaslam# a given dependency specification. All files either have a dependency 31*5478Sjhaslam# on another file or are the dependent of another file. In this way we 32*5478Sjhaslam# guarantee consistent ordering as no nodes in the dependency graph will 33*5478Sjhaslam# be isolated. 34*5478Sjhaslam# 35*5478Sjhaslam 36*5478Sjhaslamif [ $# != 1 ]; then 37*5478Sjhaslam echo expected one argument: '<'dtrace-path'>' 38*5478Sjhaslam exit 2 39*5478Sjhaslamfi 40*5478Sjhaslam 41*5478Sjhaslamtmpfile=/tmp/libdeporder.$$ 42*5478Sjhaslamlibdir=${TMPDIR:-/tmp}/libdep.$$ 43*5478Sjhaslamdtrace=$1 44*5478Sjhaslam 45*5478Sjhaslamsetup_libs() 46*5478Sjhaslam{ 47*5478Sjhaslam mkdir $libdir 48*5478Sjhaslam cat > $libdir/liba.$$.d <<EOF 49*5478Sjhaslam#pragma D depends_on library libd.$$.d 50*5478SjhaslamEOF 51*5478Sjhaslam cat > $libdir/libb.$$.d <<EOF 52*5478SjhaslamEOF 53*5478Sjhaslam cat > $libdir/libc.$$.d <<EOF 54*5478Sjhaslam#pragma D depends_on library libe.$$.d 55*5478SjhaslamEOF 56*5478Sjhaslam cat > $libdir/libd.$$.d <<EOF 57*5478Sjhaslam#pragma D depends_on library libb.$$.d 58*5478SjhaslamEOF 59*5478Sjhaslam cat > $libdir/libe.$$.d <<EOF 60*5478Sjhaslam#pragma D depends_on library liba.$$.d 61*5478SjhaslamEOF 62*5478Sjhaslam} 63*5478Sjhaslam 64*5478Sjhaslam 65*5478Sjhaslamsetup_libs 66*5478Sjhaslam 67*5478SjhaslamDTRACE_DEBUG=1 $dtrace -L$libdir -e >$tmpfile 2>&1 68*5478Sjhaslam 69*5478Sjhaslamperl /dev/stdin $tmpfile <<EOF 70*5478Sjhaslam 71*5478Sjhaslam @order = qw(libc libe liba libd libb); 72*5478Sjhaslam 73*5478Sjhaslam while (<>) { 74*5478Sjhaslam if (\$_ =~ /lib[a-e]\.[0-9]+.d/) { 75*5478Sjhaslam \$pos = length \$_; 76*5478Sjhaslam for (\$i=0; \$i<=1;\$i++) { 77*5478Sjhaslam \$pos = rindex(\$_, "/", \$pos); 78*5478Sjhaslam \$pos--; 79*5478Sjhaslam } 80*5478Sjhaslam 81*5478Sjhaslam push(@new, substr(\$_, \$pos+2, 4)); 82*5478Sjhaslam next; 83*5478Sjhaslam } 84*5478Sjhaslam next; 85*5478Sjhaslam } 86*5478Sjhaslam 87*5478Sjhaslam exit 1 if @new != @order; 88*5478Sjhaslam 89*5478Sjhaslam while (@new) { 90*5478Sjhaslam exit 1 if pop(@new) ne pop(@order); 91*5478Sjhaslam } 92*5478Sjhaslam 93*5478Sjhaslam exit 0; 94*5478SjhaslamEOF 95*5478Sjhaslam 96*5478Sjhaslam 97*5478Sjhaslamstatus=$? 98*5478Sjhaslamrm -rf $libdir 99*5478Sjhaslamrm $tmpfile 100*5478Sjhaslamreturn $status 101