====== Developing DTrace on FreeBSD ======
While the Illumos project continues to work on DTrace there is much to be done to enhance this code on %%FreeBSD%%. This page includes information about how to develop DTrace code on %%FreeBSD%% natively, including how to add new providers as well as proper testing procedures.
===== Where Your Files Should Reside =====
===== Updating Makefiles =====
===== Testing Your Changes =====
DTrace comes with an extensive test suite that has been integrated into the %%FreeBSD%% source tree.
All of the tests reside in: ''%%src/cddl/contrib/opensolaris/cmd/dtrace/test/tst/%%''
The perl script that runs the tests resides in: ''%%src/cddl/contrib/opensolaris/cmd/dtrace/test/cmd/scripts/dtest.pl%%''
To run the test suite you can execute a single file:
sudo ./dtest.pl ../../tst/common/enum/tst.EnumValAssign.d
/usr/sbin/dtrace
testing ../../tst/common/enum/tst.EnumValAssign.d ... [19597]
Each test runs in it's own process and the number in brackets is the process ID.
If a test fails a directory is created named failed.#### and the test suite tells you the test that failed and where to find the failure. For example, if you forget to run the test with root privileges that's a silly user error, but here is what you'll see:
./dtest.pl ../../tst/common/enum/tst.EnumValAssign.d
/usr/sbin/dtrace
testing ../../tst/common/enum/tst.EnumValAssign.d ... [19604]
ERROR: tst.EnumValAssign.d returned 1 instead of 0; details in failure.6
and in the ''%%failure.6%%'' directory you will find several files: ''%%19604.err%%'' ''%%19604.out%%'' ''%%README%%'' and ''%%tst.EnumValAssign.d%%''
The last file in the list is just a copy of the D script that was executed and failed.
The README shows the error line generated by the test script itself:
ERROR: ../../tst/common/enum/tst.EnumValAssign.d returned 1 instead of 0
which doesn't tell us what really went wrong, that, in this case, is in the ''%%.err%%'' file:
dtrace: failed to initialize dtrace: DTrace requires additional privileges
Since the test generated no real output, other than error output, the ''%%.out%%'' file is empty.
----
{{tag>Dtrace HowTo}}