Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 309a29b5965a0b2f36b3e245213eb43300a89ac2 59 lines 1.7 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 */ 2 3#ifndef __COREDUMP_TEST_H 4#define __COREDUMP_TEST_H 5 6#include <stdbool.h> 7#include <sys/types.h> 8#include <linux/coredump.h> 9 10#include "../kselftest_harness.h" 11#include "../pidfd/pidfd.h" 12 13#ifndef PAGE_SIZE 14#define PAGE_SIZE 4096 15#endif 16 17#define NUM_THREAD_SPAWN 128 18 19/* Coredump fixture */ 20FIXTURE(coredump) 21{ 22 char original_core_pattern[256]; 23 pid_t pid_coredump_server; 24 int fd_tmpfs_detached; 25}; 26 27/* Shared helper function declarations */ 28void *do_nothing(void *arg); 29void crashing_child(void); 30int create_detached_tmpfs(void); 31int create_and_listen_unix_socket(const char *path); 32bool set_core_pattern(const char *pattern); 33int get_peer_pidfd(int fd); 34bool get_pidfd_info(int fd_peer_pidfd, struct pidfd_info *info); 35 36/* Inline helper that uses harness types */ 37static inline void wait_and_check_coredump_server(pid_t pid_coredump_server, 38 struct __test_metadata *const _metadata, 39 FIXTURE_DATA(coredump) *self) 40{ 41 int status; 42 waitpid(pid_coredump_server, &status, 0); 43 self->pid_coredump_server = -ESRCH; 44 ASSERT_TRUE(WIFEXITED(status)); 45 ASSERT_EQ(WEXITSTATUS(status), 0); 46} 47 48/* Protocol helper function declarations */ 49ssize_t recv_marker(int fd); 50bool read_marker(int fd, enum coredump_mark mark); 51bool read_coredump_req(int fd, struct coredump_req *req); 52bool send_coredump_ack(int fd, const struct coredump_req *req, 53 __u64 mask, size_t size_ack); 54bool check_coredump_req(const struct coredump_req *req, size_t min_size, 55 __u64 required_mask); 56int open_coredump_tmpfile(int fd_tmpfs_detached); 57void process_coredump_worker(int fd_coredump, int fd_peer_pidfd, int fd_core_file); 58 59#endif /* __COREDUMP_TEST_H */