[kea-dev] How to properly test callouts?

Francis Dupont fdupont at isc.org
Wed Nov 5 19:08:32 UTC 2014


> There is a good example of the hooks library, that we have
> implemented for our needs, in the source code. It is located in
> src/hooks/dhcp/user_chk. It comes along with the suitable
> Makefile.am which builds it as a shared library.

=> in fact it is a loadable module, not a shared library even on
systems using ELF they look the same (but not on OS X for instance).

>  It also has a bunch of unit tests for individual C++ classes and
> methods. I think it will be best for you to start from there.

=> unfortunately the unit tests don't load the module:
 - in old code the module source files are compiled in

 - in current (master / #3629) code the module is linked with the unit tests

 - in future (#3631 fix) code the module source files are collected
  into a convenience archive which is linked with both the module
  and the unit tests (the idea of the archive is to compile these files
  once)

So there is currently no test code which loads the module the way
it is supposed to be loaded, i.e., via dlopen(). Note there is a
ticket (#3633) still opened about this mess (it was for an issue
introduced by #3629, fixed by #3631 but very related).

Regards

Francis Dupont <fdupont at isc.org>

PS: I wrote a lot of PKCS#11 code which is explicitely specified to
be a module, both because there is no choice on Windows (loadable module ==
dynamically linked shared object == DLL) and because it makes very easy
to restrict the entry points to a strictly limited list.
PPS: there are unit tests loading modules but in another place:
src/lib/hooks/test


More information about the kea-dev mailing list