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 /* 13 * Copyright 2025 Oxide Computer Company 14 */ 15 16 #ifndef _LIBKTEST_H 17 #define _LIBKTEST_H 18 19 #include <stdbool.h> 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 typedef struct ktest_hdl ktest_hdl_t; 26 typedef struct ktest_list_iter ktest_list_iter_t; 27 28 typedef struct ktest_entry { 29 const char *ke_module; 30 const char *ke_suite; 31 const char *ke_test; 32 bool ke_requires_input; 33 } ktest_entry_t; 34 35 typedef struct ktest_run_req { 36 const char *krq_module; 37 const char *krq_suite; 38 const char *krq_test; 39 uchar_t *krq_input; 40 size_t krq_input_len; 41 } ktest_run_req_t; 42 43 typedef enum ktest_code { 44 KTEST_CODE_NONE, 45 KTEST_CODE_PASS, 46 KTEST_CODE_FAIL, 47 KTEST_CODE_SKIP, 48 KTEST_CODE_ERROR 49 } ktest_code_t; 50 51 typedef struct ktest_run_result { 52 ktest_code_t krr_code; 53 char *krr_msg; 54 uint_t krr_line; 55 } ktest_run_result_t; 56 57 extern ktest_hdl_t *ktest_init(void); 58 extern void ktest_fini(ktest_hdl_t *); 59 60 extern ktest_list_iter_t *ktest_list(ktest_hdl_t *); 61 extern void ktest_list_free(ktest_list_iter_t *); 62 extern bool ktest_list_next(ktest_list_iter_t *, ktest_entry_t *); 63 extern void ktest_list_reset(ktest_list_iter_t *); 64 65 extern bool ktest_run(ktest_hdl_t *, const ktest_run_req_t *, 66 ktest_run_result_t *); 67 68 extern const char *ktest_code_name(ktest_code_t); 69 70 extern bool ktest_mod_load(const char *); 71 extern bool ktest_mod_load_all(void); 72 extern void ktest_mod_unload(const char *); 73 extern bool ktest_mod_unload_all(void); 74 75 extern size_t ktest_max_input_size(void); 76 77 78 #ifdef __cplusplus 79 } 80 #endif 81 82 #endif /* _LIBKTEST_H */ 83