xref: /illumos-gate/usr/src/man/man9f/ktest_get_input.9f (revision 068cf9dc70b00292d5e5ff1ab17f1b046215d6f6)
1.\"
2.\" This file and its contents are supplied under the terms of the
3.\" Common Development and Distribution License ("CDDL"), version 1.0.
4.\" You may only use this file in accordance with the terms of version
5.\" 1.0 of the CDDL.
6.\"
7.\" A full copy of the text of the CDDL should have accompanied this
8.\" source.  A copy of the CDDL is also available via the Internet at
9.\" http://www.illumos.org/license/CDDL.
10.\"
11.\"
12.\" Copyright 2023 Oxide Computer Company
13.\"
14.Dd February 15, 2023
15.Dt KTEST_GET_INPUT 9F
16.Os
17.Sh NAME
18.Nm ktest_get_input
19.Nd get the input stream
20.Sh SYNOPSIS
21.In sys/ktest.h
22.Ft void
23.Fo ktest_get_input
24.Fa "const ktest_ctx_hdl_t *ctx"
25.Fa "uchar_t **bytes"
26.Fa "size_t *len"
27.Fc
28.Sh INTERFACE LEVEL
29.Sy Volatile -
30This interface is still evolving in illumos.
31API and ABI stability is not guaranteed.
32.Sh PARAMETERS
33.Bl -tag -width Fa
34.It Fa ctx
35A handle to the test context.
36This handle is passed as argument to the test function by the ktest facility.
37.It Fa bytes
38A return parameter used to provide the caller with a pointer to the
39bytes of the input stream.
40.It Fa len
41A return parameter used to provide the caller with the number of bytes
42in the input stream.
43.El
44.Sh DESCRIPTION
45The
46.Fn ktest_get_input
47function is used to get a handle to the input stream passed to the
48test along with its length.
49.Pp
50This function panics when called on a context with no input stream.
51.Sh EXAMPLES
52This examples shows a test that verifies all bytes in the input stream
53are lowercase ASCII.
54.Bd -literal
55void
56is_lower_ascii_test(ktest_ctx_hdl_t *ctx)
57{
58	uchar_t *bytes = NULL;
59	size_t len = 0;
60
61	ktest_get_input(ctx, &bytes, &len);
62
63	for (size_t i = 0; i < len; i++) {
64		KT_ASSERT3U(bytes[i], >=, 'a', ctx);
65		KT_ASSERT3U(bytes[i], <=, 'z', ctx);
66	}
67
68	KT_PASS(ctx);
69}
70.Ed
71