There is already a regression test in src/tools/regression for gethosty*() and friends. It's main purpose is to check the correctness of these functions in the multithreaded environment. There is also a need in the test, which would check the correctness of these functions' results itself. I see several possible ways:
Checks for these databases will be done in these ways:
The idea of this kind of testing is that the nsswitch-query results should be generally the same after the system upgrade (if we don't edit user database, or services file, of course). The test procedure can be very simple: we make a set of nsswitch-queries (with get**ent() and then with get**byname() and get**byid()) and store them in the file (we can use cached's marshalling functions for that). When the test is done next time, it does the same queries in the same order and compares their results to the ones, that are already stored.
The main purpose of such a test is to check the compatibility of different versions of the system. For example, we can take FreeBSD6-STABLE, run the first stage of the test, then upgrade to CURRENT and run the second stage of the test. The test will show all the compatibility issues between versions of nsswitch-dependant functions.