MFC r244280 (by pjd):
sbuf_trim() cannot be used on sbuf with drain function set.
This fixes panic when listing sysctls on INVARIANTS-enabled kernel while
having wbwd loaded.

This panic was not fatal, at worst one additional space was printed.

Also sbuf_trim() makes some sense even if drain function is set. The drain
function is called only when buffer is to be expanded. So we could still trim
existing buffer before drain is called. In this case it worked just fine - the
trailing space was correctly trimmed.
MFC r256082 (by decke)

Rename internal function test() to avoid name clashes with common
macros. This fixes ports like mysql 5.6 which has an internal macro
called test.

Discussed with:	theraven