Dtrace as a testing tool?

Is anyone out there using Dtrace as a testing tool during the development cycle? While Dtrace is a great debugging/analysis tool, I am wondering if developers are using it as a part of their unit or regression testing.

For example, it seems to me that I can use assertions of some sort (with more context built up than just the entry point) to throw some sort of error condition and have that assertion be defined outside the context of the application in a Dtrace script. In this case, the error condition will be outside the context of the app as well. Might not be the best example, but just thinking out loud.

Comments:

Yep. Patch System Test use it as part of testing patches to make sure they can be applied with "patchadd -R" correctly. This is necessary for diskless client and live upgrade technology.
Before Dtrace we used an interposition library to catch all the open, creat, link and kill calls. Then parsed the arguments given to the commands to ensure that they were allowed. For example to check that a prepatch script was not modifying files on the running root filesystem when it should be altering the alternate root patch given by the -R argument to patchadd.
With solaris 10, this interposition library can be replaced by dtrace.
#!/usr/sbin/dtrace -qs

int x;
BEGIN{
x=-1;
}

/\* The process that we are interested in \*/
proc:::create
/execname == "patchadd" || execname == "patchrm"/
{
        x=pid;
        self->called_proc_create = 1;
}

syscall::open\*:entry,
syscall::creat\*:entry,
syscall::link:entry,
syscall::symlink:entry
/progenyof(x) && self->called_proc_create/
{
     self->path = copyinstr(arg0);
     printf("%s:%s:%s:%s\\n", probefunc, self->path, cwd, execname);
}

syscall::kill:entry
/progenyof(x) && self->called_proc_create/
{
        printf("%s:%d:%s:%s\\n", probefunc, arg0, execname,execname);
}

pid$target::exit:entry
{
        printf("return code is: %d\\n", arg0);
}
I don't think this is multithread safe, but its still an improvemnt on the interposition library, that we still use for testing patches on earlier OS's. The biggest problem with the library approach was that at several points the environment was cleared, and so our LD_PRELOAD was ignored. To get around this we had to catch the calls to for example exec("/sbin/sh") and call /bin/sh instead with LD_PRELOAD reset. This is not an issue with Dtrace.
The above Dtrace will catch every call to open() etc. so another script is used to parse the output to check for any problems. I'm sure there are improvements that can be made to the Dtrace script to remove more of the checking in the parsing script.

Posted by Albert White on June 09, 2005 at 09:28 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

John Clingan-Oracle

Search

Archives
« September 2015
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today