Port most of the DTrace tests to FreeBSD.

Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Rui Paulo 2010-08-21 11:04:38 +00:00
parent 9329096b80
commit b2db760808
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=211545
83 changed files with 171 additions and 93 deletions

View File

@ -43,7 +43,7 @@ $USAGE = "Usage: $PNAME [-abfghjlnqs] [-d dir] [-i isa] "
@dtrace_argv = ();
$ksh_path = '/bin/sh';
$ksh_path = '/usr/local/bin/ksh';
@files = ();
%exceptions = ();

View File

@ -26,7 +26,6 @@
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/dtrace.h>
#define INTFUNC(x) \
BEGIN \

View File

@ -39,13 +39,13 @@ BEGIN
}
BEGIN
/b[curthread->t_did] == 0/
/b[curthread->td_flags] == 0/
{
exit(0);
}
BEGIN
{
printf("value should be 0; value is %x!", b[curthread->t_did]);
printf("value should be 0; value is %x!", b[curthread->td_flags]);
exit(1);
}

View File

@ -78,5 +78,5 @@ if [ "$status" -ne 0 ]; then
exit $status
fi
/usr/bin/rm -f $tempfile
/bin/rm -f $tempfile
exit 0

View File

@ -44,7 +44,7 @@ fi
dtrace=$1
$dtrace -qwm unix'{chill(15); printf("Done chilling"); exit(0);}'
$dtrace -qwm kernel'{chill(15); printf("Done chilling"); exit(0);}'
status=$?
if [ "$status" -ne 0 ]; then

View File

@ -69,5 +69,5 @@ if [ ! -a "d.out" ]; then
exit 1
fi
/usr/bin/rm -f "d.out"
/bin/rm -f "d.out"
exit 0

View File

@ -70,5 +70,5 @@ if [ ! -a "outputFile" ]; then
exit 1
fi
/usr/bin/rm -f "outputFile"
/bin/rm -f "outputFile"
exit 0

View File

@ -43,7 +43,6 @@ script()
{
$dtrace -CH -s /dev/stdin <<EOF
#include <stdio.h>
BEGIN
{

View File

@ -34,7 +34,7 @@
*
*/
lockstat:genunix:mutex_enter:adaptive-acquire
lockstat:kernel:mtx_lock:adaptive-acquire
{
mutex_owned();
exit(1);

View File

@ -34,7 +34,7 @@
*
*/
lockstat:genunix:mutex_enter:adaptive-acquire
lockstat:kernel:mtx_lock:adaptive-acquire
{
mutex_owned((kmutex_t *)arg0, 99);
exit(1);

View File

@ -36,7 +36,7 @@
*/
lockstat:genunix:mutex_enter:adaptive-acquire
lockstat:kernel:mtx_lock:adaptive-acquire
{
mutex_type_adaptive();
exit(1);

View File

@ -35,7 +35,7 @@
*/
lockstat:genunix:mutex_enter:adaptive-acquire
lockstat:kernel:mtx_lock:adaptive-acquire
{
mutex_type_adaptive((kmutex_t *)arg0, 99);
exit(1);

View File

@ -80,7 +80,7 @@ BEGIN
i++;
end = j = k = 0;
printf("#!/usr/perl5/bin/perl\n\nBEGIN {\n");
printf("#!/usr/bin/perl\n\nBEGIN {\n");
}
tick-1ms

View File

@ -50,7 +50,7 @@ my $local = "";
my $remote = "";
my %Broadcast;
my $up;
open IFCONFIG, '/usr/sbin/ifconfig -a |' or die "Couldn't run ifconfig: $!\n";
open IFCONFIG, '/sbin/ifconfig -a |' or die "Couldn't run ifconfig: $!\n";
while (<IFCONFIG>) {
next if /^lo/;
@ -73,7 +73,7 @@ die "Could not determine local IP address" if $local eq "";
# Find the first remote host that responds to an icmp echo,
# which isn't a local address.
#
open PING, "/usr/sbin/ping -ns $Broadcast{$local} 56 $MAXHOSTS |" or
open PING, "/sbin/ping -ns $Broadcast{$local} 56 $MAXHOSTS |" or
die "Couldn't run ping: $!\n";
while (<PING>) {
if (/bytes from (.*): / and not defined $Broadcast{$1}) {

View File

@ -50,7 +50,7 @@ my $local = "";
my $remote = "";
my %Local;
my $up;
open IFCONFIG, '/usr/sbin/ifconfig -a inet6 |'
open IFCONFIG, '/sbin/ifconfig -a inet6 |'
or die "Couldn't run ifconfig: $!\n";
while (<IFCONFIG>) {
next if /^lo/;
@ -74,7 +74,7 @@ exit 1 if $local eq "";
# Find the first remote host that responds to an icmp echo,
# which isn't a local address.
#
open PING, "/usr/sbin/ping -ns -A inet6 $MULTICAST 56 $MAXHOSTS |" or
open PING, "/sbin/ping -ns -A inet6 $MULTICAST 56 $MAXHOSTS |" or
die "Couldn't run ping: $!\n";
while (<PING>) {
if (/bytes from (.*): / and not defined $Local{$1}) {

View File

@ -45,7 +45,7 @@ fi
dtrace=$1
local=127.0.0.1
$dtrace -c "/usr/sbin/ping $local 3" -qs /dev/stdin <<EOF | sort -n
$dtrace -c "/sbin/ping $local 3" -qs /dev/stdin <<EOF | sort -n
ip:::send
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
args[4]->ipv4_protocol == IPPROTO_ICMP/

View File

@ -120,6 +120,6 @@ EODTRACE
status=$?
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status

View File

@ -57,7 +57,7 @@ fi
dtrace=$1
local=127.0.0.1
$dtrace -c "/usr/sbin/ping -U $local" -qs /dev/stdin <<EOF | grep -v 'is alive'
$dtrace -c "/sbin/ping -U $local" -qs /dev/stdin <<EOF | grep -v 'is alive'
BEGIN
{
ipsend = udpsend = ipreceive = 0;

View File

@ -55,7 +55,7 @@ if (( $? != 0 )); then
exit 4
fi
$dtrace -c "/usr/sbin/ping $dest 3" -qs /dev/stdin <<EOF | \
$dtrace -c "/sbin/ping $dest 3" -qs /dev/stdin <<EOF | \
grep -v 'is alive' | sort -n
ip:::send
/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&

View File

@ -123,6 +123,6 @@ EODTRACE
status=$?
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $?

View File

@ -60,7 +60,7 @@ if (( $? != 0 )); then
exit 4
fi
$dtrace -c "/usr/sbin/ping -U $dest" -qs /dev/stdin <<EOF | grep -v 'is alive'
$dtrace -c "/sbin/ping -U $dest" -qs /dev/stdin <<EOF | grep -v 'is alive'
BEGIN
{
ipsend = udpsend = 0;

View File

@ -55,7 +55,7 @@ else
removeinet6=0
fi
$dtrace -c "/usr/sbin/ping -A inet6 $local 3" -qs /dev/stdin <<EOF | sort -n
$dtrace -c "/sbin/ping -A inet6 $local 3" -qs /dev/stdin <<EOF | sort -n
ip:::send
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/

View File

@ -62,9 +62,9 @@ fi
#
# Shake loose any ICMPv6 Neighbor advertisement messages before tracing.
#
/usr/sbin/ping $dest 3 > /dev/null 2>&1
/sbin/ping $dest 3 > /dev/null 2>&1
$dtrace -c "/usr/sbin/ping $dest 3" -qs /dev/stdin <<EOF | \
$dtrace -c "/sbin/ping $dest 3" -qs /dev/stdin <<EOF | \
grep -v 'is alive' | sort -n
ip:::send
/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&

View File

@ -177,6 +177,6 @@ EODTRACE
status=$?
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status

View File

@ -167,6 +167,6 @@ EODTRACE
status=$?
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status

View File

@ -31,7 +31,7 @@ if [ $# != 1 ]; then
fi
dtrace=$1
CC=/usr/sfw/bin/gcc
CC=/usr/bin/gcc
CFLAGS=
doit()

View File

@ -39,7 +39,7 @@ dtrace=$1
# LD_NOEXEC_64 variable prevents nm from re-execing itself.
#
LD_NOEXEC_64=tomeeisrad $dtrace -F -s /dev/stdin -c \
'/usr/ccs/bin/nm /bin/ls' stat <<EOF
'/usr/bin/nm /bin/ls' stat <<EOF
pid\$target::\$1:entry
{

View File

@ -56,7 +56,7 @@ main(int argc, char **argv)
while (waiting(&a) == 0)
continue;
(void) forkall();
(void) fork();
(void) go();
return (0);

View File

@ -28,13 +28,14 @@
#include <spawn.h>
#include <signal.h>
#include <stdio.h>
void
go(void)
{
pid_t pid;
(void) posix_spawn(&pid, "/usr/bin/ls", NULL, NULL, NULL, NULL);
(void) posix_spawn(&pid, "/bin/ls", NULL, NULL, NULL, NULL);
(void) waitpid(pid, NULL, 0);
}

View File

@ -88,6 +88,6 @@ script
status=$?
cd /tmp
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status

View File

@ -126,6 +126,6 @@ script
status=$?
cd /tmp
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status

View File

@ -97,6 +97,6 @@ script
status=$?
cd /tmp
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status

View File

@ -149,6 +149,6 @@ script
status=$?
cd /tmp
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status

View File

@ -78,6 +78,6 @@ script
status=$?
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status

View File

@ -33,7 +33,7 @@ fi
dtrace=$1
# The output files assumes the timezone is US/Pacific
TZ=US/Pacific
export TZ=America/Los_Angeles
$dtrace -s /dev/stdin <<EOF
#pragma D option quiet

View File

@ -33,7 +33,7 @@ fi
dtrace=$1
# The output files assumes the timezone is US/Pacific
TZ=US/Pacific
export TZ=America/Los_Angeles
$dtrace -s /dev/stdin <<EOF
#pragma D option quiet

View File

@ -33,7 +33,7 @@ fi
dtrace=$1
# The output files assumes the timezone is US/Pacific
TZ=US/Pacific
export TZ=America/Los_Angeles
$dtrace -s /dev/stdin <<EOF
#pragma D option quiet

View File

@ -38,6 +38,6 @@
BEGIN
{
printf("symbol = %a", &`kmem_flags);
printf("symbol = %a", &`kmem_alloc);
exit(0);
}

View File

@ -1 +1 @@
symbol = genunix`kmem_flags
symbol = kernel`kmem_alloc

View File

@ -41,7 +41,7 @@ script()
self->exec = 1;
}
proc:::exec_success
proc:::exec-success
/self->exec/
{
exit(0);

View File

@ -42,7 +42,7 @@ script()
self->exec = 1;
}
proc:::exec_failure
proc:::exec-failure
/self->exec && args[0] == ENOENT/
{
exit(0);

View File

@ -45,7 +45,7 @@ script()
self->exec = 1;
}
proc:::exec_failure
proc:::exec-failure
/self->exec/
{
exit(0);

View File

@ -28,13 +28,13 @@
#pragma D option destructive
proc:::signal_send
proc:::signal-send
/args[1]->p_pid == $1 && args[2] == SIGUSR1/
{
sent = 1;
}
proc:::signal_clear
proc:::signal-clear
/pid == $1 && args[0] == SIGUSR1 && sent/
{
exit(0);

View File

@ -70,11 +70,11 @@ fi
grep "D_MACRO_UNUSED" /var/tmp/err.$$.txt >/dev/null 2>&1
if [ $? -ne 0 ]; then
print -u2 "Expected error D_MACRO_UNUSED not returned"
/usr/bin/rm -f /var/tmp/err.$$.txt
/bin/rm -f /var/tmp/err.$$.txt
exit 1
fi
/usr/bin/rm -f $dfilename
/usr/bin/rm -f /var/tmp/err.$$.txt
/bin/rm -f $dfilename
/bin/rm -f /var/tmp/err.$$.txt
exit 0

View File

@ -42,7 +42,7 @@ fi
dtrace=$1
bname=`/bin/basename $0`
bname=`/usr/bin/basename $0`
dfilename=/var/tmp/$bname.$$
@ -85,6 +85,6 @@ if [[ ${outarray[0]} != 1 || ${outarray[1]} != 2 || ${outarray[2]} != 3 || \
exit 1
fi
/usr/bin/rm -f $dfilename
/bin/rm -f $dfilename
exit 0

View File

@ -43,7 +43,7 @@ if [ $# != 1 ]; then
fi
dtrace=$1
bname=`/bin/basename $0`
bname=`/usr/bin/basename $0`
dfilename=/var/tmp/$bname.$$.d
## Create .d file
@ -70,14 +70,14 @@ EOF
#chmod 555 the .d file
chmod 555 $dfilename >/dev/null 2>&1
if [ &? -ne 0 ]; then
if [ $? -ne 0 ]; then
print -u2 "chmod $dfilename failed"
exit 1
fi
#Get the groupid of the calling process using ps
groupid=`ps -o pid,gid | grep "$$ " | awk '{print $2}' 2>/dev/null`
groupid=`ps -o pid,pgid | grep "$$ " | awk '{print $2}' 2>/dev/null`
if [ $? -ne 0 ]; then
print -u2 "unable to get uid of the current process with pid = $$"
exit 1
@ -93,5 +93,5 @@ fi
#Cleanup leftovers
/usr/bin/rm -f $dfilename
/bin/rm -f $dfilename
exit 0

View File

@ -82,5 +82,5 @@ if [ $? -ne 0 ]; then
exit 1
fi
#/usr/bin/rm -f $dfilename
#/bin/rm -f $dfilename
exit 0

View File

@ -82,5 +82,5 @@ if [ $? -ne 0 ]; then
exit 1
fi
#/usr/bin/rm -f $dfilename
#/bin/rm -f $dfilename
exit 0

View File

@ -82,5 +82,5 @@ if [ $? -ne 0 ]; then
exit 1
fi
#/usr/bin/rm -f $dfilename
#/bin/rm -f $dfilename
exit 0

View File

@ -82,5 +82,5 @@ if [ $? -ne 0 ]; then
exit 1
fi
#/usr/bin/rm -f $dfilename
#/bin/rm -f $dfilename
exit 0

View File

@ -82,5 +82,5 @@ if [ $? -ne 0 ]; then
exit 1
fi
#/usr/bin/rm -f $dfilename
#/bin/rm -f $dfilename
exit 0

View File

@ -74,5 +74,5 @@ if [ "$output" != "this is test" ]; then
exit 1
fi
/usr/bin/rm -f $dfilename
/bin/rm -f $dfilename
exit 0

View File

@ -82,5 +82,5 @@ if [ $? -ne 0 ]; then
exit 1
fi
#/usr/bin/rm -f $dfilename
#/bin/rm -f $dfilename
exit 0

View File

@ -82,5 +82,5 @@ if [ $? -ne 0 ]; then
exit 1
fi
#/usr/bin/rm -f $dfilename
#/bin/rm -f $dfilename
exit 0

View File

@ -27,11 +27,16 @@
#pragma ident "%Z%%M% %I% %E% SMI"
#include <unistd.h>
#ifndef __FreeBSD__
#include <sys/uadmin.h>
#endif
int
main(int argc, char **argv)
{
#ifdef __FreeBSD__
return (1);
#else
while (1) {
if (uadmin(A_SDTTEST, 0, 0) < 0) {
perror("uadmin");
@ -42,4 +47,5 @@ main(int argc, char **argv)
}
return (0);
#endif
}

View File

@ -0,0 +1,13 @@
all: main
main: main.o prov.o
$(CC) -o main main.o prov.o
main.o: main.c prov.h
$(CC) -c main.c
prov.h: prov.d
/usr/sbin/dtrace -h -s prov.d
prov.o: prov.d main.o
/usr/sbin/dtrace -G -32 -s prov.d main.o

View File

@ -0,0 +1,11 @@
#include <stdlib.h>
#include <sys/sdt.h>
#include "prov.h"
int
main(int argc, char **argv, char **envp)
{
envp[0] = (char*)0xff;
TESTER_ENTRY();
return 0;
}

View File

@ -0,0 +1,3 @@
provider tester {
probe entry();
};

View File

@ -0,0 +1,46 @@
/*
* Generated by dtrace(1M).
*/
#ifndef _PROV_H
#define _PROV_H
#include <unistd.h>
#ifdef __cplusplus
extern "C" {
#endif
#if _DTRACE_VERSION
#define TESTER_ENTRY() \
__dtrace_tester___entry()
#ifndef __sparc
#define TESTER_ENTRY_ENABLED() \
__dtraceenabled_tester___entry()
#else
#define TESTER_ENTRY_ENABLED() \
__dtraceenabled_tester___entry(0)
#endif
extern void __dtrace_tester___entry(void);
#ifndef __sparc
extern int __dtraceenabled_tester___entry(void);
#else
extern int __dtraceenabled_tester___entry(long);
#endif
#else
#define TESTER_ENTRY()
#define TESTER_ENTRY_ENABLED() (0)
#endif
#ifdef __cplusplus
}
#endif
#endif /* _PROV_H */

View File

@ -79,6 +79,6 @@ if [ $? -eq 0 ]; then
fi
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit 0

View File

@ -125,7 +125,7 @@ main(int argc, char **argv)
}
EOF
/usr/ccs/bin/make > /dev/null
/usr/bin/make > /dev/null
if [ $? -ne 0 ]; then
print -u2 "failed to build"
exit 1
@ -154,6 +154,6 @@ script 2>&1
status=$?
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status

View File

@ -136,7 +136,7 @@ main(int argc, char **argv)
}
EOF
/usr/ccs/bin/make > /dev/null
/usr/bin/make > /dev/null
if [ $? -ne 0 ]; then
print -u2 "failed to build"
exit 1
@ -155,6 +155,6 @@ script
status=$?
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status

View File

@ -131,7 +131,7 @@ main(int argc, char **argv)
}
EOF
/usr/ccs/bin/make > /dev/null
/usr/bin/make > /dev/null
if [ $? -ne 0 ]; then
print -u2 "failed to build"
exit 1
@ -165,6 +165,6 @@ script
status=$?
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status

View File

@ -101,6 +101,6 @@ if [ $? -eq 0 ]; then
fi
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit 0

View File

@ -91,6 +91,6 @@ script
status=$?
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status

View File

@ -108,6 +108,6 @@ script
status=$?
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status

View File

@ -113,6 +113,6 @@ script | cut -c5-
status=$?
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status

View File

@ -100,6 +100,6 @@ script
status=$?
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status

View File

@ -91,6 +91,6 @@ script
status=$?
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status

View File

@ -95,6 +95,6 @@ else
fi
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status

View File

@ -82,4 +82,4 @@ if [ $? -ne 0 ]; then
fi
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR

View File

@ -56,6 +56,6 @@ fi
status=$?
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status

View File

@ -79,4 +79,4 @@ if [ $? -ne 0 ]; then
fi
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR

View File

@ -81,4 +81,4 @@ if [ $? -ne 0 ]; then
fi
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR

View File

@ -94,6 +94,6 @@ script
status=$?
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status

View File

@ -85,6 +85,6 @@ fi
status=$?
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status

View File

@ -79,4 +79,4 @@ if [ $? -ne 0 ]; then
fi
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR

View File

@ -93,6 +93,6 @@ script
status=$?
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status

View File

@ -93,6 +93,6 @@ script
status=$?
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status

View File

@ -103,6 +103,6 @@ script
status=$?
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status

View File

@ -91,6 +91,6 @@ script
status=$?
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status

View File

@ -38,7 +38,7 @@ fi
dtrace=$1
$dtrace -qs /dev/stdin -c "/usr/bin/echo" <<EOF
$dtrace -qs /dev/stdin -c "/bin/echo" <<EOF
pid\$target:ld.so.1:calloc:entry
{
self->calloc = 1;

View File

@ -76,7 +76,7 @@ provider test {
};
EOF
/usr/ccs/bin/as -xregsym=no -P -D_ASM -o test.o test.s
/usr/bin/as -xregsym=no -P -D_ASM -o test.o test.s
if [ $? -ne 0 ]; then
print -u2 "failed to compile test.s"
exit 1
@ -127,6 +127,6 @@ EOF
status=$?
cd /
/usr/bin/rm -rf $DIR
/bin/rm -rf $DIR
exit $status