• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Description: Helpers for tests.
4  */
5 #ifndef LIBURING_HELPERS_H
6 #define LIBURING_HELPERS_H
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 #include "liburing.h"
13 
14 enum t_setup_ret {
15 	T_SETUP_OK	= 0,
16 	T_SETUP_SKIP,
17 };
18 
19 /*
20  * Helper for allocating memory in tests.
21  */
22 void *t_malloc(size_t size);
23 
24 
25 /*
26  * Helper for allocating size bytes aligned on a boundary.
27  */
28 void t_posix_memalign(void **memptr, size_t alignment, size_t size);
29 
30 
31 /*
32  * Helper for allocating space for an array of nmemb elements
33  * with size bytes for each element.
34  */
35 void *t_calloc(size_t nmemb, size_t size);
36 
37 
38 /*
39  * Helper for creating file and write @size byte buf with 0xaa value in the file.
40  */
41 void t_create_file(const char *file, size_t size);
42 
43 /*
44  * Helper for creating @buf_num number of iovec
45  * with @buf_size bytes buffer of each iovec.
46  */
47 struct iovec *t_create_buffers(size_t buf_num, size_t buf_size);
48 
49 /*
50  * Helper for setting up a ring and checking for user privs
51  */
52 enum t_setup_ret t_create_ring_params(int depth, struct io_uring *ring,
53 				      struct io_uring_params *p);
54 enum t_setup_ret t_create_ring(int depth, struct io_uring *ring,
55 			       unsigned int flags);
56 
57 #ifdef __cplusplus
58 }
59 #endif
60 
61 #endif
62