[bind10-dev] Tool to audit parameters of messages?
Stephen Morris
stephen at isc.org
Wed Dec 7 12:20:49 UTC 2011
On 06/12/2011 21:14, Shane Kerr wrote:
> Jinmei,
>
> On Tue, 2011-12-06 at 11:32 -0800, JINMEI Tatuya / 神明達哉 wrote:
>> At Tue, 06 Dec 2011 13:45:38 +0100,
>
>>> I submitted the attached bug report yesterday, and I was
>>> thinking, do we need a tool to check for such mismatched
>>> parameters?
>>>
>>> LIBXFRIN_DIFFERENT_TTL multiple data with different TTLs (600,
>>> 3600) on %3/%4. Adjusting 3600 -> 600.
>>>
>>> Clearly we're missing %3 and %4 on our invocation.
Unless we actually inspect the message being output, the only way to
detect a missing parameter will be to parse the source code: that will
be relatively difficult. So:
> Hm... I think perhaps comparing our number of unique log
> identifiers with the number we produce from our tests may also be
> an interesting measure of coverage...
... is an excellent idea, both from the point of view of coverage and,
using the "grep" command on the output
>>> % B10_LOGGER_DESTINATION=stdout make check |& grep
>>> '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]'|grep '%'
>>> 2011-12-06 11:27:04.231 INFO [bind10.test] LOG_INPUT_OPEN_FAIL
>>> unable to open message file %1 for input: %2 2011-12-06
>>> 11:28:05.972 INFO [bind10.boss] BIND10_SOCKET_GET requesting
>>> socket [%1]:%2 of type %3 from the creator
... to identify missing parameters.
On a related point, the logging code does identify cases where there
is a missing place holder in the message, e.g. the message is
% EXAMPLE can't access %2
... and it is called with LOG_ERROR(logger,
EXAMPLE).arg("par1").arg("par2")
Here, %1 is missing and the code will append the string:
@@Missing placeholder %1 for 'par1'@@
to the message being output. Although it does act as a check, it is
proving a bit restrictive. I've come across a couple of places where
it would be natural to call a general function, passing to it a
message ID and a set of parameters. Within the function I would like
a call of the form:
LOG_DEBUG(logger, level, code).arg("example.com").arg(rcode)....
... and the have logging code use parameters based on what is in the
message text, e.g.
% RCODE error in response to query for %1, rcode received was %2
% EMPTY answer and authority sections were empty in response to query
for %1
:
Stephen
More information about the bind10-dev
mailing list