xref: /illumos-gate/usr/src/cmd/dtrace/test/tst/i86xpv/xdt/tst.schedargs.ksh (revision 66e150d7d3c0cb2de3c45c74612784ffd3e73de6)
1#
2# CDDL HEADER START
3#
4# The contents of this file are subject to the terms of the
5# Common Development and Distribution License (the "License").
6# You may not use this file except in compliance with the License.
7#
8# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9# or http://www.opensolaris.org/os/licensing.
10# See the License for the specific language governing permissions
11# and limitations under the License.
12#
13# When distributing Covered Code, include this CDDL HEADER in each
14# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15# If applicable, add the following below this CDDL HEADER, with the
16# fields enclosed by brackets "[]" replaced with your own identifying
17# information: Portions Copyright [yyyy] [name of copyright owner]
18#
19# CDDL HEADER END
20#
21
22#
23# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24# Use is subject to license terms.
25#
26# ident	"%Z%%M%	%I%	%E% SMI"
27#
28
29#
30# ASSERTION: Sched probe arguments should be valid.
31#
32
33if [ $# != 1 ]; then
34	echo expected one argument: '<'dtrace-path'>'
35	exit 2
36fi
37
38#
39# do not fail test in a domU
40#
41if [ ! -c /dev/xen/privcmd ]; then
42	exit 0
43fi
44
45dtrace=$1
46outf=/tmp/sched.args.$$
47
48script()
49{
50	$dtrace -c '/usr/bin/sleep 10' -o $outf -qs /dev/stdin <<EOF
51	xdt:sched::off-cpu,
52	xdt:sched::on-cpu,
53	xdt:sched::block,
54	xdt:sched::sleep,
55	xdt:sched::wake,
56	xdt:sched::yield
57	{
58		/* print domid vcpu pcpu probename */
59		printf("%d %d %d %s\n", arg1, arg2, arg0, probename);
60	}
61EOF
62}
63
64validate()
65{
66	/usr/bin/nawk '
67	BEGIN {
68		while (("/usr/sbin/xm vcpu-list" | getline)) {
69			if ($1 != "Name") {
70				domid = $2
71				vcpu = $3
72
73				vcpumap[domid, vcpu] = 1
74
75				split($7, affinity, ",")
76				for (i in affinity) {
77					if (split(affinity[i], p, "-") > 1) {
78						for (pcpu = p[1]; pcpu <= p[2];\
79						    pcpu++) {
80							cpumap[domid, vcpu,
81							    pcpu] = 1
82						}
83					} else {
84						cpumap[domid, vcpu,
85						    affinity[i]] = 1
86					}
87				}
88			}
89		}
90	}
91
92	/^$/ { next }
93
94	/wake/ {
95		if (vcpumap[$1, $2]) {
96			next
97		} else {
98			print "error: " $0
99			exit 1
100		}
101	}
102
103	{
104		if (cpumap[$1, $2, "any"] || cpumap[$1, $2, $3]) {
105			next
106		} else {
107			print "error: " $0
108			exit 1
109		}
110	}
111	' $outf
112}
113
114script
115status=$?
116
117if [ $status == 0 ]; then
118	validate
119	status=$?
120fi
121
122rm $outf
123exit $status
124