diff options
author | Paul Osmialowski <p.osmialowsk@samsung.com> | 2015-09-23 18:04:13 +0200 |
---|---|---|
committer | Seung-Woo Kim <sw0312.kim@samsung.com> | 2016-12-14 13:49:16 +0900 |
commit | 9a573c97650e1c909651da6d94713ac4edaba025 (patch) | |
tree | a8bd3cfeed6129412daed0318d1e3967f82c9cee /samples | |
parent | a6b3b517a1b5ce5faab04d2a4ba1dc05a9e8fa7a (diff) |
kmsg: selftests
This patch adds selftests framework and four test scenarios for kmsg.
The framework shape and code was inspired by similar selftests framework
for kdbus.
Change-Id: I4453105186c90430dcdb59d592392fbac05b42f5
Signed-off-by: Paul Osmialowski <p.osmialowsk@samsung.com>
Diffstat (limited to 'samples')
-rw-r--r-- | samples/kmsg/kmsg-api.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/samples/kmsg/kmsg-api.h b/samples/kmsg/kmsg-api.h new file mode 100644 index 000000000000..9004acdc526d --- /dev/null +++ b/samples/kmsg/kmsg-api.h @@ -0,0 +1,44 @@ +#ifndef KMSG_API_H +#define KMSG_API_H + +#include <stdint.h> +#include <errno.h> +#include <sys/ioctl.h> +#include <linux/kmsg_ioctl.h> + +static inline int kmsg_cmd_buffer_add(int fd, struct kmsg_cmd_buffer_add *cmd) +{ + int ret = ioctl(fd, KMSG_CMD_BUFFER_ADD, cmd); + + return (ret < 0) ? (errno > 0 ? -errno : -EINVAL) : 0; +} + +static inline int kmsg_cmd_buffer_del(int fd, int *minor) +{ + int ret = ioctl(fd, KMSG_CMD_BUFFER_DEL, minor); + + return (ret < 0) ? (errno > 0 ? -errno : -EINVAL) : 0; +} + +static inline int kmsg_cmd_get_buf_size(int fd, uint32_t *size) +{ + int ret = ioctl(fd, KMSG_CMD_GET_BUF_SIZE, size); + + return (ret < 0) ? (errno > 0 ? -errno : -EINVAL) : 0; +} + +static inline int kmsg_cmd_get_read_size_max(int fd, uint32_t *max_size) +{ + int ret = ioctl(fd, KMSG_CMD_GET_READ_SIZE_MAX, max_size); + + return (ret < 0) ? (errno > 0 ? -errno : -EINVAL) : 0; +} + +static inline int kmsg_cmd_clear(int fd) +{ + int ret = ioctl(fd, KMSG_CMD_CLEAR); + + return (ret < 0) ? (errno > 0 ? -errno : -EINVAL) : 0; +} + +#endif /* KMSG_API_H */ |