diff options
author | Dmitry V. Levin <ldv@altlinux.org> | 2017-07-03 15:14:54 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2017-07-03 15:14:54 +0000 |
commit | 005c67a900e69fc016d62ce15da346b0def48f64 (patch) | |
tree | e9b143fd58147e15edcaa1b790539d18a23525ff | |
parent | 7d465949e4cf707753d4352e34a5c97632bb2b0c (diff) | |
download | strace-005c67a900e69fc016d62ce15da346b0def48f64.tar.gz |
tests: move DEFAULT_STRLEN macro to tests.h
* tests/tests.h [!DEFAULT_STRLEN] (DEFAULT_STRLEN): New macro.
* tests/mincore.c (DEFAULT_STRLEN): Remove.
* tests/mmsg_name.c: Likewise.
* tests/msg_control.c: Likewise.
* tests/netlink_protocol.c: Likewise.
* tests/nlattr.c: Likewise.
* tests/nlattr_inet_diag_msg.c: Likewise.
* tests/nlattr_netlink_diag_msg.c: Likewise.
* tests/nlattr_unix_diag_msg.c: Likewise.
* tests/printstr.c: Likewise.
* tests/xattr.c: Likewise.
* tests/execve.c: Likewise.
(main): Initialize str_a and str_b arrays at run time.
* tests/execveat.c: Likewise.
Suggested-by: JingPiao Chen <chenjingpiao@gmail.com>
-rw-r--r-- | tests/execve.c | 11 | ||||
-rw-r--r-- | tests/execveat.c | 11 | ||||
-rw-r--r-- | tests/mincore.c | 2 | ||||
-rw-r--r-- | tests/mmsg_name.c | 2 | ||||
-rw-r--r-- | tests/msg_control.c | 2 | ||||
-rw-r--r-- | tests/netlink_protocol.c | 1 | ||||
-rw-r--r-- | tests/nlattr.c | 1 | ||||
-rw-r--r-- | tests/nlattr_inet_diag_msg.c | 1 | ||||
-rw-r--r-- | tests/nlattr_netlink_diag_msg.c | 1 | ||||
-rw-r--r-- | tests/nlattr_unix_diag_msg.c | 1 | ||||
-rw-r--r-- | tests/printstr.c | 2 | ||||
-rw-r--r-- | tests/tests.h | 5 | ||||
-rw-r--r-- | tests/xattr.c | 2 |
13 files changed, 21 insertions, 21 deletions
diff --git a/tests/execve.c b/tests/execve.c index c558dd3b2..da3bc5200 100644 --- a/tests/execve.c +++ b/tests/execve.c @@ -127,9 +127,14 @@ main(void) #endif ); - char str_a[] = "012345678901234567890123456789012"; - char str_b[] = "_abcdefghijklmnopqrstuvwxyz()[]{}"; -#define DEFAULT_STRLEN ((unsigned int) sizeof(str_a) - 2) + char *const str_a = tail_alloc(DEFAULT_STRLEN + 2); + fill_memory_ex(str_a, DEFAULT_STRLEN + 1, '0', 10); + str_a[DEFAULT_STRLEN + 1] = '\0'; + + char *const str_b = tail_alloc(DEFAULT_STRLEN + 2); + fill_memory_ex(str_b, DEFAULT_STRLEN + 1, '_', 32); + str_b[DEFAULT_STRLEN + 1] = '\0'; + char **const a = tail_alloc(sizeof(*a) * (DEFAULT_STRLEN + 2)); char **const b = tail_alloc(sizeof(*b) * (DEFAULT_STRLEN + 2)); unsigned int i; diff --git a/tests/execveat.c b/tests/execveat.c index 8ffc4d588..566a59f9e 100644 --- a/tests/execveat.c +++ b/tests/execveat.c @@ -133,9 +133,14 @@ main(void) #endif errno2name()); - char str_a[] = "012345678901234567890123456789012"; - char str_b[] = "_abcdefghijklmnopqrstuvwxyz()[]{}"; -#define DEFAULT_STRLEN ((unsigned int) sizeof(str_a) - 2) + char *const str_a = tail_alloc(DEFAULT_STRLEN + 2); + fill_memory_ex(str_a, DEFAULT_STRLEN + 1, '0', 10); + str_a[DEFAULT_STRLEN + 1] = '\0'; + + char *const str_b = tail_alloc(DEFAULT_STRLEN + 2); + fill_memory_ex(str_b, DEFAULT_STRLEN + 1, '_', 32); + str_b[DEFAULT_STRLEN + 1] = '\0'; + char **const a = tail_alloc(sizeof(*a) * (DEFAULT_STRLEN + 2)); char **const b = tail_alloc(sizeof(*b) * (DEFAULT_STRLEN + 2)); unsigned int i; diff --git a/tests/mincore.c b/tests/mincore.c index ea2b49e38..0ede687d6 100644 --- a/tests/mincore.c +++ b/tests/mincore.c @@ -29,8 +29,6 @@ #include <stdio.h> #include <sys/mman.h> -#define DEFAULT_STRLEN 32 - static void print_mincore(const unsigned int pages, void *const addr, const size_t size, unsigned char *const vec) diff --git a/tests/mmsg_name.c b/tests/mmsg_name.c index ac8dcde7e..ad5a482d4 100644 --- a/tests/mmsg_name.c +++ b/tests/mmsg_name.c @@ -40,8 +40,6 @@ #include "msghdr.h" -#define DEFAULT_STRLEN 32 - #define IOV_MAX1 (IOV_MAX + 1) #ifndef TEST_NAME diff --git a/tests/msg_control.c b/tests/msg_control.c index 5b6b25a5d..b63f2d04e 100644 --- a/tests/msg_control.c +++ b/tests/msg_control.c @@ -63,8 +63,6 @@ get_cmsghdr(void *const page, const size_t len) return page - CMSG_ALIGN(len); } -#define DEFAULT_STRLEN 32 - static void print_fds(const struct cmsghdr *const cmsg, const size_t cmsg_len) { diff --git a/tests/netlink_protocol.c b/tests/netlink_protocol.c index d0479805e..f09dd9a96 100644 --- a/tests/netlink_protocol.c +++ b/tests/netlink_protocol.c @@ -169,7 +169,6 @@ send_query(const int fd) (unsigned) sizeof(*reqs), sprintrc(rc)); /* abbreviated output */ -# define DEFAULT_STRLEN 32 # define ABBREV_LEN (DEFAULT_STRLEN + 1) const unsigned int msg_len = sizeof(struct nlmsghdr) * ABBREV_LEN; struct nlmsghdr *const msgs = tail_alloc(msg_len); diff --git a/tests/nlattr.c b/tests/nlattr.c index 15a0ad1fb..7361eced0 100644 --- a/tests/nlattr.c +++ b/tests/nlattr.c @@ -210,7 +210,6 @@ test_nlattr(const int fd) fd, msg_len, nla->nla_len, msg_len, sprintrc(rc)); /* abbreviated output */ -#define DEFAULT_STRLEN 32 #define ABBREV_LEN (DEFAULT_STRLEN + 1) msg_len = NLA_HDRLEN * ABBREV_LEN + NLMSG_SPACE(sizeof(msg->udm)); msg = tail_memdup(&c_msg, msg_len); diff --git a/tests/nlattr_inet_diag_msg.c b/tests/nlattr_inet_diag_msg.c index 33397c787..306b86654 100644 --- a/tests/nlattr_inet_diag_msg.c +++ b/tests/nlattr_inet_diag_msg.c @@ -96,7 +96,6 @@ main(void) const unsigned int hdrlen = sizeof(struct inet_diag_msg); void *const nlh0 = tail_alloc(NLMSG_SPACE(hdrlen)); -#define DEFAULT_STRLEN 32 static char pattern[DEFAULT_STRLEN]; fill_memory_ex(pattern, sizeof(pattern), 'a', 'z' - 'a' + 1); diff --git a/tests/nlattr_netlink_diag_msg.c b/tests/nlattr_netlink_diag_msg.c index a7f7e58e6..37e3a0127 100644 --- a/tests/nlattr_netlink_diag_msg.c +++ b/tests/nlattr_netlink_diag_msg.c @@ -80,7 +80,6 @@ main(void) const unsigned int hdrlen = sizeof(struct netlink_diag_msg); void *const nlh0 = tail_alloc(NLMSG_SPACE(hdrlen)); -#define DEFAULT_STRLEN 32 static char pattern[DEFAULT_STRLEN]; fill_memory_ex(pattern, sizeof(pattern), 'a', 'z' - 'a' + 1); diff --git a/tests/nlattr_unix_diag_msg.c b/tests/nlattr_unix_diag_msg.c index 59444c458..a11328b19 100644 --- a/tests/nlattr_unix_diag_msg.c +++ b/tests/nlattr_unix_diag_msg.c @@ -79,7 +79,6 @@ main(void) const unsigned int hdrlen = sizeof(struct unix_diag_msg); void *const nlh0 = tail_alloc(NLMSG_SPACE(hdrlen)); -#define DEFAULT_STRLEN 32 static char pattern[DEFAULT_STRLEN]; fill_memory_ex(pattern, sizeof(pattern), 'a', 'z' - 'a' + 1); diff --git a/tests/printstr.c b/tests/printstr.c index 356ae2eca..8e2268135 100644 --- a/tests/printstr.c +++ b/tests/printstr.c @@ -34,8 +34,6 @@ #include <unistd.h> #include <sys/uio.h> -#define DEFAULT_STRLEN 32 - int main(void) { diff --git a/tests/tests.h b/tests/tests.h index 00d10eaec..094f36508 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -51,6 +51,11 @@ # define VERBOSE 0 #endif +#ifndef DEFAULT_STRLEN +/* Default maximum # of bytes printed in printstr et al. */ +# define DEFAULT_STRLEN 32 +#endif + /* Cached sysconf(_SC_PAGESIZE). */ size_t get_page_size(void); diff --git a/tests/xattr.c b/tests/xattr.c index a772eced6..03b4270aa 100644 --- a/tests/xattr.c +++ b/tests/xattr.c @@ -36,8 +36,6 @@ # define XATTR_SIZE_MAX 65536 # endif -#define DEFAULT_STRLEN 32 - int main(void) { |