]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.usym.ksh
dtrace: Add the 'oformat' libdtrace option
[FreeBSD/FreeBSD.git] / cddl / contrib / opensolaris / cmd / dtrace / test / tst / common / oformat / tst.usym.ksh
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
17 bname=`basename $0`
18 dtraceout=/tmp/dtrace.$bname
19
20 script()
21 {
22         $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__
23 BEGIN
24 {
25         usym(0);
26         exit(0);
27 }
28 __EOF__
29 }
30
31 if [ $# != 1 ]; then
32         echo expected one argument: '<'dtrace-path'>'
33         exit 2
34 fi
35
36 dtrace=$1
37
38 script json
39 jq . $dtraceout.json
40
41 if [ $? != 0 ]; then
42         echo $bname: failed to produce valid JSON. see $dtraceout.json
43         exit 1
44 fi
45
46 script xml
47 xmllint $dtraceout.xml
48
49 if [ $? != 0 ]; then
50         echo $bname: failed to produce valid XML. see $dtraceout.xml
51         exit 1
52 fi
53
54 rm $dtraceout.json
55 rm $dtraceout.xml
56
57 exit 0