On Fri, Jun 24, 2011 at 6:14 AM, John Baldwin <j...@freebsd.org> wrote: > On Friday, June 24, 2011 3:23:11 am Sebastian Huber wrote: >> Hello, >> >> exists there some unit tests for FreeBSD kernel APIs, e.g. mutex(9), >> condvar(9), etc.? >> >> Have a nice day! > > Hmm, I have a kernel module that does some tests, but it is not in the tree. > One of the issues is that many of the tests you want to do for some of these > APIs involve timing. For rwlocks, for example, I used KTR traces and used > a kernel module that forked 4 threads to all compete over a single lock. I > then verified via KTR traces that every branch was taken (and made liberal > use of KASSERT()s which caught a few edge cases I had missed initially).
At $WORK we have a generic TEST_THREAD interface which allows for calling essentially random kernel code (whatever a dev codes up) with arguments. At the shell one types "test_thread foobar(12345, \"string\")" or whatever args. The test_thread syscall looks in the set of registered functions for foobar, and passes off a string with (12345, \"string\") to the function. Each function is responsible for parsing its own arguments. The args for the test_thread function pointer are the $WORK equivalent of and input sbuf and and output sbuf, which is copyout'd to the calling binary. If there's interest I can clean up the patch a little to show proof-of-concept that builds without all the $WORK gorp. We use this for a few things: unit-testing kernel code, hand-editing of filesystem data to recover customer sites from kernel bugs (sometimes this is possible), etc. Cheers, matthew _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"