xref: /freebsd/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.stack.ksh (revision 93f27766a7e1af009c5b1e4ca538632857c91aa1)
1#!/usr/bin/ksh
2#
3# This file and its contents are supplied under the terms of the
4# Common Development and Distribution License ("CDDL"), version 1.0.
5# You may only use this file in accordance with the terms of version
6# 1.0 of the CDDL.
7#
8# A full copy of the text of the CDDL should have accompanied this
9# source.  A copy of the CDDL is also available via the Internet at
10# http://www.illumos.org/license/CDDL.
11#
12
13#
14# Copyright (c) 2023 Domagoj Stolfa
15#
16
17bname=`basename $0`
18dtraceout=/tmp/dtrace.$bname
19
20script()
21{
22	$dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__
23syscall:::entry
24{
25        stack();
26}
27
28tick-1s
29{
30        exit(0);
31}
32__EOF__
33}
34
35if [ $# != 1 ]; then
36	echo expected one argument: '<'dtrace-path'>'
37	exit 2
38fi
39
40dtrace=$1
41
42script json
43jq . $dtraceout.json
44
45if [ $? != 0 ]; then
46	echo $bname: failed to produce valid JSON. see $dtraceout.json
47	exit 1
48fi
49
50script xml
51xmllint $dtraceout.xml
52
53if [ $? != 0 ]; then
54	echo $bname: failed to produce valid XML. see $dtraceout.xml
55	exit 1
56fi
57
58rm $dtraceout.json
59rm $dtraceout.xml
60
61exit 0
62