| 1 |
|
| 2 |
|
| 3 |
|
| 4 | #ifndef __TESTING_HELPERS_H
|
| 5 | #define __TESTING_HELPERS_H
|
| 6 |
|
| 7 | #include <stdbool.h>
|
| 8 | #include <bpf/bpf.h>
|
| 9 | #include <bpf/libbpf.h>
|
| 10 | #include <time.h>
|
| 11 |
|
| 12 | #define __TO_STR(x) #x
|
| 13 | #define TO_STR(x) __TO_STR(x)
|
| 14 |
|
| 15 | int parse_num_list(const char *s, bool **set, int *set_len);
|
| 16 | __u32 link_info_prog_id(const struct bpf_link *link, struct bpf_link_info *info);
|
| 17 | int bpf_prog_test_load(const char *file, enum bpf_prog_type type,
|
| 18 | struct bpf_object **pobj, int *prog_fd);
|
| 19 | int bpf_test_load_program(enum bpf_prog_type type, const struct bpf_insn *insns,
|
| 20 | size_t insns_cnt, const char *license,
|
| 21 | __u32 kern_version, char *log_buf,
|
| 22 | size_t log_buf_sz);
|
| 23 |
|
| 24 | |
| 25 | * below function is exported for testing in prog_test test
|
| 26 |
|
| 27 | struct test_filter_set;
|
| 28 | int parse_test_list(const char *s,
|
| 29 | struct test_filter_set *test_set,
|
| 30 | bool is_glob_pattern);
|
| 31 | int parse_test_list_file(const char *path,
|
| 32 | struct test_filter_set *test_set,
|
| 33 | bool is_glob_pattern);
|
| 34 |
|
| 35 | __u64 read_perf_max_sample_freq(void);
|
| 36 | int load_bpf_testmod(bool verbose);
|
| 37 | int unload_bpf_testmod(bool verbose);
|
| 38 | int kern_sync_rcu(void);
|
| 39 |
|
| 40 | int uffd_block_page(void *fault_addr);
|
| 41 | int finit_module(int fd, const char *param_values, int flags);
|
| 42 | int delete_module(const char *name, int flags);
|
| 43 | int load_module(const char *path, bool verbose);
|
| 44 | int load_module_params(const char *path, const char *param_values, bool verbose);
|
| 45 | int try_unload_module(const char *name, int retries, bool verbose);
|
| 46 | int unload_module(const char *name, bool verbose);
|
| 47 |
|
| 48 | static inline __u64 get_time_ns(void)
|
| 49 | {
|
| 50 | struct timespec t;
|
| 51 |
|
| 52 | clock_gettime(CLOCK_MONOTONIC, &t);
|
| 53 |
|
| 54 | return (u64)t.tv_sec * 1000000000 + t.tv_nsec;
|
| 55 | }
|
| 56 |
|
| 57 | struct bpf_insn;
|
| 58 | |
| 59 | * e.g. verifier.c:convert_ctx_access() is done.
|
| 60 |
|
| 61 | int get_xlated_program(int fd_prog, struct bpf_insn **buf, __u32 *cnt);
|
| 62 | int testing_prog_flags(void);
|
| 63 | bool is_jit_enabled(void);
|
| 64 | int stack_mprotect(void);
|
| 65 |
|
| 66 | #endif
|