Print this page
XXX Remove nawk(1)
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/dtrace/test/tst/common/funcs/tst.badfreopen.ksh
+++ new/usr/src/cmd/dtrace/test/tst/common/funcs/tst.badfreopen.ksh
1 1 #
2 2 # CDDL HEADER START
3 3 #
4 4 # The contents of this file are subject to the terms of the
5 5 # Common Development and Distribution License (the "License").
6 6 # You may not use this file except in compliance with the License.
7 7 #
8 8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 # or http://www.opensolaris.org/os/licensing.
10 10 # See the License for the specific language governing permissions
11 11 # and limitations under the License.
12 12 #
13 13 # When distributing Covered Code, include this CDDL HEADER in each
14 14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 # If applicable, add the following below this CDDL HEADER, with the
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
16 16 # fields enclosed by brackets "[]" replaced with your own identifying
17 17 # information: Portions Copyright [yyyy] [name of copyright owner]
18 18 #
19 19 # CDDL HEADER END
20 20 #
21 21
22 22 #
23 23 # Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 24 # Use is subject to license terms.
25 25 #
26 -#ident "%Z%%M% %I% %E% SMI"
27 26
28 27 script()
29 28 {
30 29 $dtrace -wq -o $tmpfile -s /dev/stdin 2> $errfile <<EOF
31 30 BEGIN
32 31 {
33 32 /*
34 33 * All of these should fail...
35 34 */
36 35 freopen("..");
37 36 freopen("%s", ".");
38 37 freopen("%c%c", '.', '.');
39 38 freopen("%c", '.');
40 39
41 40 /*
42 41 * ...so stdout should still be open here.
43 42 */
44 43 printf("%d", ++i);
45 44
46 45 freopen("%s%s", ".", ".");
47 46 freopen("%s%s", ".", ".");
48 47
49 48 printf("%d", ++i);
50 49 }
51 50
52 51 BEGIN
53 52 /i == 2/
54 53 {
55 54 /*
56 55 * ...and here.
57 56 */
58 57 printf("%d\n", ++i);
59 58 exit(0);
60 59 }
61 60
62 61 BEGIN
63 62 {
64 63 exit(1);
65 64 }
66 65 EOF
67 66 }
68 67
69 68 if [ $# != 1 ]; then
70 69 echo expected one argument: '<'dtrace-path'>'
71 70 exit 2
72 71 fi
73 72
74 73 dtrace=$1
75 74 tmpfile=/tmp/tst.badfreopen.$$
76 75 errfile=/tmp/tst.badfreopen.$$.stderr
77 76
78 77 script
79 78 status=$?
↓ open down ↓ |
43 lines elided |
↑ open up ↑ |
80 79
81 80 if [ "$status" -eq 0 ]; then
82 81 i=`cat $tmpfile`
83 82
84 83 if [[ $i != "123" ]]; then
85 84 echo "$0: unexpected contents in $tmpfile: " \
86 85 "expected 123, found $i"
87 86 status=100
88 87 fi
89 88
90 - i=`wc -l $errfile | nawk '{ print $1 }'`
89 + i=`wc -l $errfile | /usr/xpg4/bin/awk '{ print $1 }'`
91 90
92 91 if [ "$i" -lt 6 ]; then
93 92 echo "$0: expected at least 6 lines of stderr, found $i lines"
94 93 status=101
95 94 fi
96 95 else
97 96 cat $errfile > /dev/fd/2
98 97 fi
99 98
100 99 rm $tmpfile $errfile
101 100
102 101 exit $status
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX