KTEST_GET_INPUT(9F) Kernel Functions for Drivers KTEST_GET_INPUT(9F)

ktest_get_inputget the input stream

#include <sys/ktest.h>

void
ktest_get_input(const ktest_ctx_hdl_t *ctx, uchar_t **bytes, size_t *len);

This interface is still evolving in illumos. API and ABI stability is not guaranteed.

ctx
A handle to the test context. This handle is passed as argument to the test function by the ktest facility.
bytes
A return parameter used to provide the caller with a pointer to the bytes of the input stream.
len
A return parameter used to provide the caller with the number of bytes in the input stream.

The () function is used to get a handle to the input stream passed to the test along with its length.

This function panics when called on a context with no input stream.

This examples shows a test that verifies all bytes in the input stream are lowercase ASCII.

void
is_lower_ascii_test(ktest_ctx_hdl_t *ctx)
{
	uchar_t *bytes = NULL;
	size_t len = 0;

	ktest_get_input(ctx, &bytes, &len);

	for (size_t i = 0; i < len; i++) {
		KT_ASSERT3U(bytes[i], >=, 'a', ctx);
		KT_ASSERT3U(bytes[i], <=, 'z', ctx);
	}

	KT_PASS(ctx);
}
February 15, 2023 OmniOS