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

NAME


ktest_get_input - get the input stream

SYNOPSIS


#include <sys/ktest.h>

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

INTERFACE LEVEL


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

PARAMETERS


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.

DESCRIPTION


The ktest_get_input() 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.

EXAMPLES


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);
}

illumos February 15, 2023 illumos

tribblix@gmail.com :: GitHub :: Privacy