tst.pidprint.ksh revision 285830
1139749Simp#! /usr/bin/ksh 2136467Ssimokawa# 3136467Ssimokawa# 4136467Ssimokawa# This file and its contents are supplied under the terms of the 5136467Ssimokawa# Common Development and Distribution License ("CDDL"), version 1.0. 6136467Ssimokawa# You may only use this file in accordance with the terms of version 7136467Ssimokawa# 1.0 of the CDDL. 8136467Ssimokawa# 9136467Ssimokawa# A full copy of the text of the CDDL should have accompanied this 10136467Ssimokawa# source. A copy of the CDDL is also available via the Internet at 11136467Ssimokawa# http://www.illumos.org/license/CDDL. 12136467Ssimokawa# 13136467Ssimokawa 14136467Ssimokawa# 15136467Ssimokawa# Copyright (c) 2013 Joyent, Inc. All rights reserved. 16136467Ssimokawa# 17136467Ssimokawa 18136467Ssimokawa# 19136467Ssimokawa# Use print() on userland CTF types and verify we get the data we expect. 20136467Ssimokawa# 21136467Ssimokawa 22136467Ssimokawaif [ $# != 1 ]; then 23136467Ssimokawa echo expected one argument: '<'dtrace-path'>' 24136467Ssimokawa exit 2 25136467Ssimokawafi 26136467Ssimokawa 27136467Ssimokawadtrace=$1 28136467Ssimokawat="final_fantasy_info_t" 29136467Ssimokawaexe="tst.printtype.exe" 30136467Ssimokawa 31136467Ssimokawaelfdump "./$exe" | grep -q '.SUNW_ctf' 32136467Ssimokawaif [[ $? -ne 0 ]]; then 33136467Ssimokawa echo "CTF does not exist in $exe, that's a bug" >&2 34136467Ssimokawa exit 1 35136467Ssimokawafi 36136467Ssimokawa 37136467Ssimokawa./$exe & 38136467Ssimokawapid=$! 39136467Ssimokawa 40136467Ssimokawa$dtrace -qs /dev/stdin <<EOF 41136467Ssimokawapid$pid::ff_getgameid:entry 42136467Ssimokawa/next == 0/ 43136467Ssimokawa{ 44136467Ssimokawa print(*args[0]); 45136467Ssimokawa printf("\n"); 46136467Ssimokawa next = 1; 47136467Ssimokawa} 48136467Ssimokawa 49136467Ssimokawapid$pid::ff_getpartysize:entry 50136467Ssimokawa/next == 1/ 51164033Srwatson{ 52136467Ssimokawa print(*args[0]); 53136467Ssimokawa printf("\n"); 54136467Ssimokawa next = 2; 55136467Ssimokawa} 56136467Ssimokawa 57136467Ssimokawapid$pid::ff_getsummons:entry 58136467Ssimokawa/next == 2/ 59136467Ssimokawa{ 60136467Ssimokawa print(*args[0]); 61136467Ssimokawa printf("\n"); 62136467Ssimokawa exit(0); 63136467Ssimokawa} 64136467SsimokawaEOF 65136467Ssimokawarc=$? 66136467Ssimokawa 67136467Ssimokawakill -9 $pid 68136467Ssimokawa 69136467Ssimokawaexit $rc 70136467Ssimokawa