Date: Mon, 3 Mar 2014 12:32:40 -0500 From: Julio Merino <jmmv@freebsd.org> To: "R. Tyler Croy" <tyler@monkeypox.org> Cc: "freebsd-testing@freebsd.org" <freebsd-testing@freebsd.org> Subject: Re: atf-c for kernel function unit testing Message-ID: <CAFY7cWCMS1tP_7RnhgU=yJMrPz-k-_zzK3Y9knZ0%2BQk0a5mD=g@mail.gmail.com> In-Reply-To: <20140303165226.GK85115@kiwi> References: <20140303165226.GK85115@kiwi>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Mar 3, 2014 at 11:52 AM, R. Tyler Croy <tyler@monkeypox.org> wrote: > > I'm wondering if anybody's explored using atf-c for adding unit tests to kernel > level functions or driver code. We do this extensively in NetBSD: we have a mechanism (rump) to build unmodified kernel-level code as user-space binaries and we later use atf to unit-test the code in controlled tiny environments. (You'd think about this as super-lightweight virtualization of the kernel.) Achieving this for any non-trivial kernel-level code is hard however, but I believe that this approach has huge benefits. For example: we are able to unit-test all file system and networking code in user-space without any chances of crashing the system; there is also the benefit of being able to control the test environment fully without relying on any state of the running kernel. For more details see: http://en.wikipedia.org/wiki/Anykernel http://wiki.netbsd.org/rumpkernel/ If the code you are interested in testing can easily be built without ties to the kernel, you can relatively easily do the above. (In fact, we used to do this in NetBSD for some tiny areas of the code before we got rump.) At some point I also pondered the idea to write an interface and a kernel module to allow writing unit tests within the kernel. This might be interesting for some special cases (like testing live hardware maybe) but it's a very fragile setup that should not be pursued if other safer solutions suffice.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFY7cWCMS1tP_7RnhgU=yJMrPz-k-_zzK3Y9knZ0%2BQk0a5mD=g>