I'll be submitting a patch shortly to add basic unit tests to PolicyKit. In preparation for adding netgroup support, I'm adding tests for the normal cases of: PolkitUnixUser, PolkitUnixGroup, PolkitIdentity, PolkitBackendLocalAuthority, and PolkitBackendLocalAuthorizationStore. Tests use glib's test framework: http://developer.gnome.org/glib/2.30/glib-Testing.html Tests should run when 'make check' is called, and should cause 'make check' to fail if any tests fail. Unit tests link against libraries built for each part of Policy Kit in ./src, and do import private headers. Future integration tests should only use public interfaces.
Created attachment 54449 [details] [review] Added netgroup support, added MockLibc support for mocking NSS calls in unit tests, expanded previous unit tests to include new mock users/groups. This patch relies on 'policykit-unittest.patch' from bug #43608. There are a few issues I ran into implementing netgroups: 1. Netgroups can't support glob syntax like other identities do in *.pkla files. 2. A netgroup with a wildcard entry like (,,), which means any user/host/domain, will be ignored in the admin identities list. 3. I use git submodules to include the MockLibc source code, but I'm not sure if that's what we should stick with. I can include code Since I'm using submodules, the first commit with the submodule needs to run 'git submodule add' to put special metadata in the repo which can't happen via patch AFAIK. For eaxmple: cd PolicyKit patch -p1 < ~/policykit-unittest.patch patch -p1 < ~/policykit-netgroup.patch git submodule add -b v1 https://code.google.com/p/mocklibc/ noinst/mocklibc
Created attachment 54451 [details] [review] Basic unittest support and a few tests Please ignore the previous comment/attachment. I got the two bug numbers mixed up. Adds basic unit tests for: PolkitIdentity, PolkitUnixUser, PolkitUnixGroup, PolkitBackendLocalAuthorizationStore, and PolkitBackendLocalAuthority.
Patch looks great, I've committed it here http://cgit.freedesktop.org/PolicyKit/commit/?id=15d2e90a54009efb31300d8b59292d71ce98a5b2 Thanks!
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.