diff options
author | Adrian Reber <areber@redhat.com> | 2021-07-19 10:28:38 +0300 |
---|---|---|
committer | Andrei Vagin <avagin@gmail.com> | 2021-09-03 20:31:00 +0300 |
commit | 93dd984ca0ee0e31a5650f64328222e748152bcb (patch) | |
tree | 024483c121704ec8d106c9bf596441b51e51a67c /test/zdtm | |
parent | 1e26f170caa8b2c26f5d09a78ffe9fdea70d38d0 (diff) |
Run 'make indent' on all C files
Acked-by: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Adrian Reber <areber@redhat.com>
Diffstat (limited to 'test/zdtm')
357 files changed, 3688 insertions, 4318 deletions
diff --git a/test/zdtm/lib/bpfmap_zdtm.c b/test/zdtm/lib/bpfmap_zdtm.c index 73a79b3f5..7fe1ed182 100644 --- a/test/zdtm/lib/bpfmap_zdtm.c +++ b/test/zdtm/lib/bpfmap_zdtm.c @@ -39,13 +39,13 @@ int parse_bpfmap_fdinfo(int fd, struct bpfmap_fdinfo_obj *obj, uint32_t expected continue; } if (fdinfo_field(str, "map_flags")) { - if (sscanf(str, "map_flags: %"PRIx32"", &obj->map_flags) != 1) + if (sscanf(str, "map_flags: %" PRIx32 "", &obj->map_flags) != 1) goto parse_err; met++; continue; } if (fdinfo_field(str, "memlock")) { - if (sscanf(str, "memlock: %"PRIu64"", &obj->memlock) != 1) + if (sscanf(str, "memlock: %" PRIu64 "", &obj->memlock) != 1) goto parse_err; met++; continue; @@ -86,17 +86,11 @@ int cmp_bpf_map_info(struct bpf_map_info *old, struct bpf_map_info *new) * the new BPF map created by CRIU (during restore) will have a different * map id than the old one */ - if ((old->type != new->type) || - (old->key_size != new->key_size) || - (old->value_size != new->value_size) || - (old->max_entries != new->max_entries) || - (old->map_flags != new->map_flags) || - (old->ifindex != new->ifindex) || - (old->netns_dev != new->netns_dev) || - (old->netns_ino != new->netns_ino) || - (old->btf_id != new->btf_id) || - (old->btf_key_type_id != new->btf_key_type_id) || - (old->btf_value_type_id != new->btf_value_type_id)) + if ((old->type != new->type) || (old->key_size != new->key_size) || (old->value_size != new->value_size) || + (old->max_entries != new->max_entries) || (old->map_flags != new->map_flags) || + (old->ifindex != new->ifindex) || (old->netns_dev != new->netns_dev) || + (old->netns_ino != new->netns_ino) || (old->btf_id != new->btf_id) || + (old->btf_key_type_id != new->btf_key_type_id) || (old->btf_value_type_id != new->btf_value_type_id)) return -1; if (strcmp(old->name, new->name) != 0) @@ -113,13 +107,9 @@ int cmp_bpfmap_fdinfo(struct bpfmap_fdinfo_obj *old, struct bpfmap_fdinfo_obj *n * the new BPF map created by CRIU (during restore) will have a different map * id than the old one */ - if ((old->map_type != new->map_type) || - (old->key_size != new->key_size) || - (old->value_size != new->value_size) || - (old->max_entries != new->max_entries) || - (old->map_flags != new->map_flags) || - (old->memlock != new->memlock) || - (old->frozen != new->frozen)) + if ((old->map_type != new->map_type) || (old->key_size != new->key_size) || + (old->value_size != new->value_size) || (old->max_entries != new->max_entries) || + (old->map_flags != new->map_flags) || (old->memlock != new->memlock) || (old->frozen != new->frozen)) return -1; return 0; diff --git a/test/zdtm/lib/datagen.c b/test/zdtm/lib/datagen.c index 83fbea285..1561820c7 100644 --- a/test/zdtm/lib/datagen.c +++ b/test/zdtm/lib/datagen.c @@ -120,10 +120,7 @@ int datachk(const uint8_t *buffer, unsigned length, uint32_t *crc) for (; length-- > 4; buffer++) *crc = crc32_le8(*crc, *buffer); - read_crc = buffer[0] | - buffer[1] << 8 | - buffer[2] << 16 | - buffer[3] << 24; + read_crc = buffer[0] | buffer[1] << 8 | buffer[2] << 16 | buffer[3] << 24; if (read_crc != *crc) { test_msg("Read: %x, Expected: %x\n", read_crc, *crc); return 1; diff --git a/test/zdtm/lib/fs.c b/test/zdtm/lib/fs.c index e82011ec8..7b8be5f9f 100644 --- a/test/zdtm/lib/fs.c +++ b/test/zdtm/lib/fs.c @@ -54,10 +54,7 @@ mnt_info_t *get_cwd_mnt_info(void) while (fgets(str, sizeof(str), f)) { char *hyphen = strchr(str, '-'); - ret = sscanf(str, "%i %i %u:%u %s %s", - &mnt_id, &parent_mnt_id, - &kmaj, &kmin, - root, mountpoint); + ret = sscanf(str, "%i %i %u:%u %s %s", &mnt_id, &parent_mnt_id, &kmaj, &kmin, root, mountpoint); if (ret != 6 || !hyphen) goto err; ret = sscanf(hyphen + 1, " %ms", &fsname); @@ -110,8 +107,7 @@ int get_cwd_check_perm(char **result) "failed for uid:%d,gid:%d, error: %d(%s). " "Bit 'x' should be set in all path components of " "this directory\n", - cwd, getuid(), getgid(), errno, strerror(errno) - ); + cwd, getuid(), getgid(), errno, strerror(errno)); return -1; } diff --git a/test/zdtm/lib/groups.c b/test/zdtm/lib/groups.c index 83b0938a4..8aa744147 100644 --- a/test/zdtm/lib/groups.c +++ b/test/zdtm/lib/groups.c @@ -4,8 +4,8 @@ #include "zdtmtst.h" -const char *test_doc = "Group starter"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Group starter"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; int main(int argc, char **argv) { diff --git a/test/zdtm/lib/lock.c b/test/zdtm/lib/lock.c index 3c3691d98..d47fc736f 100644 --- a/test/zdtm/lib/lock.c +++ b/test/zdtm/lib/lock.c @@ -8,7 +8,7 @@ #include "zdtmtst.h" -#define TASK_WAITER_INITIAL 0x0fffff +#define TASK_WAITER_INITIAL 0x0fffff static long sys_gettid(void) { @@ -34,8 +34,10 @@ void task_waiter_fini(task_waiter_t *t) void task_waiter_wait4(task_waiter_t *t, unsigned int lockid) { - struct timespec req = { .tv_nsec = TASK_WAITER_INITIAL, }; - struct timespec rem = { }; + struct timespec req = { + .tv_nsec = TASK_WAITER_INITIAL, + }; + struct timespec rem = {}; unsigned int v; for (;;) { diff --git a/test/zdtm/lib/msg.c b/test/zdtm/lib/msg.c index fe0994077..1cf92e3e0 100644 --- a/test/zdtm/lib/msg.c +++ b/test/zdtm/lib/msg.c @@ -50,8 +50,7 @@ void test_msg(const char *format, ...) gettimeofday(&tv, NULL); tm = localtime(&tv.tv_sec); if (tm == NULL) { - fprintf(stderr, "ERROR in %s: localtime() failed: %m\n", - __func__); + fprintf(stderr, "ERROR in %s: localtime() failed: %m\n", __func__); } else { off += strftime(buf, sizeof(buf), "%H:%M:%S", tm); } diff --git a/test/zdtm/lib/ns.c b/test/zdtm/lib/ns.c index 0054a3040..6f6cccc99 100644 --- a/test/zdtm/lib/ns.c +++ b/test/zdtm/lib/ns.c @@ -41,7 +41,7 @@ static int prepare_mntns(void) * under them. So we need to create another mount for the * new root. */ - if (mount(root, root, NULL, MS_SLAVE , NULL)) { + if (mount(root, root, NULL, MS_SLAVE, NULL)) { fprintf(stderr, "Can't bind-mount root: %m\n"); return -1; } @@ -54,8 +54,7 @@ static int prepare_mntns(void) criu_path = getenv("ZDTM_CRIU"); if (criu_path) { snprintf(path, sizeof(path), "%s%s", root, criu_path); - if (mount(criu_path, path, NULL, MS_BIND, NULL) || - mount(NULL, path, NULL, MS_PRIVATE, NULL)) { + if (mount(criu_path, path, NULL, MS_BIND, NULL) || mount(NULL, path, NULL, MS_PRIVATE, NULL)) { pr_perror("Unable to mount %s", path); return -1; } @@ -87,7 +86,7 @@ static int prepare_mntns(void) return -1; } - if (mount("./old", "./old", NULL, MS_SLAVE | MS_REC , NULL)) { + if (mount("./old", "./old", NULL, MS_SLAVE | MS_REC, NULL)) { fprintf(stderr, "Can't bind-mount root: %m\n"); return -1; } @@ -159,7 +158,7 @@ static int prepare_namespaces(void) return 0; } -#define NS_STACK_SIZE 4096 +#define NS_STACK_SIZE 4096 /* All arguments should be above stack, because it grows down */ struct ns_exec_args { @@ -191,13 +190,11 @@ static void ns_sig_hand(int signo) if (futex_get(&sig_received)) return; futex_set_and_wake(&sig_received, signo); - len = snprintf(buf, sizeof(buf), - "All test processes exited\n"); + len = snprintf(buf, sizeof(buf), "All test processes exited\n"); } else { - len = snprintf(buf, sizeof(buf), - "wait() failed: %m\n"); + len = snprintf(buf, sizeof(buf), "wait() failed: %m\n"); } - goto write_out; + goto write_out; } if (status) fprintf(stderr, "%d return %d\n", pid, status); @@ -210,7 +207,7 @@ write_out: } #ifndef CLONE_NEWTIME -#define CLONE_NEWTIME 0x00000080 /* New time namespace */ +#define CLONE_NEWTIME 0x00000080 /* New time namespace */ #endif static inline int _settime(clockid_t clk_id, time_t offset) @@ -245,7 +242,7 @@ static inline int _settime(clockid_t clk_id, time_t offset) #define STATUS_FD 255 static int ns_exec(void *_arg) { - struct ns_exec_args *args = (struct ns_exec_args *) _arg; + struct ns_exec_args *args = (struct ns_exec_args *)_arg; char buf[4096]; int ret; @@ -304,8 +301,8 @@ static int create_timens(void) int ns_init(int argc, char **argv) { struct sigaction sa = { - .sa_handler = ns_sig_hand, - .sa_flags = SA_RESTART, + .sa_handler = ns_sig_hand, + .sa_flags = SA_RESTART, }; int ret, fd, status_pipe = STATUS_FD; char buf[128], *x; @@ -372,7 +369,7 @@ int ns_init(int argc, char **argv) break; if (pid < 0) { fprintf(stderr, "waitpid() failed: %m\n"); - exit (1); + exit(1); } if (status) fprintf(stderr, "%d return %d\n", pid, status); @@ -426,7 +423,6 @@ int ns_init(int argc, char **argv) waitpid(pid, NULL, 0); } - exit(1); } @@ -449,8 +445,7 @@ void ns_create(int argc, char **argv) exit(1); } - flags = CLONE_NEWPID | CLONE_NEWNS | CLONE_NEWUTS | - CLONE_NEWNET | CLONE_NEWIPC | SIGCHLD; + flags = CLONE_NEWPID | CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWNET | CLONE_NEWIPC | SIGCHLD; if (getenv("ZDTM_USERNS")) flags |= CLONE_NEWUSER; @@ -521,4 +516,3 @@ void ns_create(int argc, char **argv) exit(0); } - diff --git a/test/zdtm/lib/parseargs.c b/test/zdtm/lib/parseargs.c index d8aa4ed63..156f5a46c 100644 --- a/test/zdtm/lib/parseargs.c +++ b/test/zdtm/lib/parseargs.c @@ -20,17 +20,12 @@ void __push_opt(struct long_opt *opt) int parse_opt_bool(char *param, void *arg) { - if (param == NULL || - !strcmp(param, "on") || - !strcmp(param, "yes") || - !strcmp(param, "true")) { - * (int *) arg = 1; + if (param == NULL || !strcmp(param, "on") || !strcmp(param, "yes") || !strcmp(param, "true")) { + *(int *)arg = 1; return 0; } - if (!strcmp(param, "off") || - !strcmp(param, "no") || - !strcmp(param, "false")) { - * (int *) arg = 0; + if (!strcmp(param, "off") || !strcmp(param, "no") || !strcmp(param, "false")) { + *(int *)arg = 0; return 0; } return -EINVAL; @@ -41,7 +36,7 @@ int parse_opt_int(char *param, void *arg) char *tail; if (param == NULL || param[0] == '\0') return -EINVAL; - * (int *) arg = strtol(param, &tail, 0); + *(int *)arg = strtol(param, &tail, 0); if (tail[0] != '\0') return -EINVAL; return 0; @@ -52,7 +47,7 @@ int parse_opt_uint(char *param, void *arg) char *tail; if (param == NULL || param[0] == '\0') return -EINVAL; - * (unsigned int *) arg = strtoul(param, &tail, 0); + *(unsigned int *)arg = strtoul(param, &tail, 0); if (tail[0] != '\0') return -EINVAL; return 0; @@ -63,7 +58,7 @@ int parse_opt_long(char *param, void *arg) char *tail; if (param == NULL || param[0] == '\0') return -EINVAL; - * (long *) arg = strtol(param, &tail, 0); + *(long *)arg = strtol(param, &tail, 0); if (tail[0] != '\0') return -EINVAL; return 0; @@ -74,7 +69,7 @@ int parse_opt_ulong(char *param, void *arg) char *tail; if (param == NULL || param[0] == '\0') return -EINVAL; - * (unsigned long *) arg = strtoul(param, &tail, 0); + *(unsigned long *)arg = strtoul(param, &tail, 0); if (tail[0] != '\0') return -EINVAL; return 0; @@ -84,7 +79,7 @@ int parse_opt_string(char *param, void *arg) { if (param == NULL || param[0] == '\0') return -EINVAL; - * (char **) arg = param; + *(char **)arg = param; return 0; } @@ -97,8 +92,7 @@ static void printopt(const struct long_opt *opt) cbracket = "]"; } - fprintf(stderr, " %s--%s=%s%s\t%s\n", - obracket, opt->name, opt->type, cbracket, opt->doc); + fprintf(stderr, " %s--%s=%s%s\t%s\n", obracket, opt->name, opt->type, cbracket, opt->doc); } static void helpexit(void) @@ -113,8 +107,8 @@ static void helpexit(void) exit(1); } -const char __attribute__((weak)) *test_doc; -const char __attribute__((weak)) *test_author; +const char __attribute__((weak)) * test_doc; +const char __attribute__((weak)) * test_author; static void prdoc(void) { @@ -124,7 +118,7 @@ static void prdoc(void) fprintf(stderr, "Author: %s\n", test_author); } -void parseargs(int argc, char ** argv) +void parseargs(int argc, char **argv) { int i; struct long_opt *opt; @@ -148,10 +142,9 @@ void parseargs(int argc, char ** argv) if (opt->parse_opt(value, opt->value)) { fprintf(stderr, "%s: failed to parse\n", argv[i]); helpexit(); - } - else + } else /* -1 marks fulfilled requirement */ - opt->is_required = - opt->is_required; + opt->is_required = -opt->is_required; break; } diff --git a/test/zdtm/lib/tcp.c b/test/zdtm/lib/tcp.c index 623994bf8..cbd87521b 100644 --- a/test/zdtm/lib/tcp.c +++ b/test/zdtm/lib/tcp.c @@ -1,6 +1,6 @@ #include <string.h> #include <sys/socket.h> -#include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */ +#include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */ #include "zdtmtst.h" @@ -25,11 +25,11 @@ int tcp_init_server_with_opts(int family, int *port, struct zdtm_tcp_opts *opts) int sock; int yes = 1, ret; - memset(&addr,0,sizeof(addr)); + memset(&addr, 0, sizeof(addr)); if (family == AF_INET) { addr.v4.sin_family = family; inet_pton(family, "0.0.0.0", &(addr.v4.sin_addr)); - } else if (family == AF_INET6){ + } else if (family == AF_INET6) { addr.v6.sin6_family = family; inet_pton(family, "::0", &(addr.v6.sin6_addr)); } else @@ -41,14 +41,12 @@ int tcp_init_server_with_opts(int family, int *port, struct zdtm_tcp_opts *opts) return -1; } - if (opts->reuseport && - setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof(int)) == -1) { + if (opts->reuseport && setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof(int)) == -1) { pr_perror("setsockopt(SO_REUSEPORT) failed"); return -1; } - if (opts->reuseaddr && - setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) { + if (opts->reuseaddr && setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) { pr_perror("setsockopt(SO_REUSEATTR) failed"); return -1; } @@ -59,7 +57,7 @@ int tcp_init_server_with_opts(int family, int *port, struct zdtm_tcp_opts *opts) else if (family == AF_INET6) addr.v6.sin6_port = htons(*port); - ret = bind(sock, (struct sockaddr *) &addr, sizeof(addr)); + ret = bind(sock, (struct sockaddr *)&addr, sizeof(addr)); /* criu doesn't restore sock opts, so we need this hack */ if (ret == -1 && errno == EADDRINUSE) { @@ -88,10 +86,10 @@ int tcp_accept_server(int sock) int sock2; socklen_t addrlen; #ifdef DEBUG - test_msg ("Waiting for connection..........\n"); + test_msg("Waiting for connection..........\n"); #endif addrlen = sizeof(maddr); - sock2 = accept(sock,(struct sockaddr *) &maddr, &addrlen); + sock2 = accept(sock, (struct sockaddr *)&maddr, &addrlen); if (sock2 == -1) { pr_perror("accept() failed"); @@ -99,7 +97,7 @@ int tcp_accept_server(int sock) } #ifdef DEBUG - test_msg ("Connection!!\n"); + test_msg("Connection!!\n"); #endif return sock2; } @@ -123,15 +121,15 @@ int tcp_init_client_with_fd(int sock, int family, char *servIP, unsigned short s /* Construct the server address structure */ memset(&servAddr, 0, sizeof(servAddr)); if (family == AF_INET) { - servAddr.v4.sin_family = AF_INET; - servAddr.v4.sin_port = htons(servPort); + servAddr.v4.sin_family = AF_INET; + servAddr.v4.sin_port = htons(servPort); inet_pton(AF_INET, servIP, &servAddr.v4.sin_addr); } else { - servAddr.v6.sin6_family = AF_INET6; - servAddr.v6.sin6_port = htons(servPort); + servAddr.v6.sin6_family = AF_INET6; + servAddr.v6.sin6_port = htons(servPort); inet_pton(AF_INET6, servIP, &servAddr.v6.sin6_addr); } - if (connect(sock, (struct sockaddr *) &servAddr, sizeof(servAddr)) < 0) { + if (connect(sock, (struct sockaddr *)&servAddr, sizeof(servAddr)) < 0) { pr_perror("can't connect to server"); return -1; } diff --git a/test/zdtm/lib/test.c b/test/zdtm/lib/test.c index e848091c1..81da81eba 100644 --- a/test/zdtm/lib/test.c +++ b/test/zdtm/lib/test.c @@ -22,7 +22,7 @@ futex_t sig_received; static struct { futex_t stage; -} *test_shared_state; +} * test_shared_state; enum { TEST_INIT_STAGE = 0, @@ -74,8 +74,7 @@ static void test_fini(void) static void setup_outfile(void) { if (!access(outfile, F_OK) || errno != ENOENT) { - fprintf(stderr, "Output file %s appears to exist, aborting\n", - outfile); + fprintf(stderr, "Output file %s appears to exist, aborting\n", outfile); exit(1); } @@ -214,8 +213,8 @@ void test_init(int argc, char **argv) pid_t pid; char *val; struct sigaction sa = { - .sa_handler = sig_hand, - .sa_flags = SA_RESTART, + .sa_handler = sig_hand, + .sa_flags = SA_RESTART, }; sigemptyset(&sa.sa_mask); @@ -302,7 +301,7 @@ void test_init(int argc, char **argv) } parent = 1; - if (pid) { /* parent will exit when the child is ready */ + if (pid) { /* parent will exit when the child is ready */ futex_wait_while(&test_shared_state->stage, TEST_INIT_STAGE); if (futex_get(&test_shared_state->stage) == TEST_FAIL_STAGE) { @@ -343,7 +342,7 @@ void test_init(int argc, char **argv) exit(1); } - srand48(time(NULL)); /* just in case we need it */ + srand48(time(NULL)); /* just in case we need it */ } void test_daemon(void) @@ -398,12 +397,11 @@ int test_wait_pre_dump_ack(void) return 0; } -pid_t sys_clone_unified(unsigned long flags, void *child_stack, void *parent_tid, - void *child_tid, unsigned long newtls) +pid_t sys_clone_unified(unsigned long flags, void *child_stack, void *parent_tid, void *child_tid, unsigned long newtls) { #ifdef __x86_64__ return (pid_t)syscall(__NR_clone, flags, child_stack, parent_tid, child_tid, newtls); -#elif (__i386__ || __arm__ || __aarch64__ ||__powerpc64__ || __mips__) +#elif (__i386__ || __arm__ || __aarch64__ || __powerpc64__ || __mips__) return (pid_t)syscall(__NR_clone, flags, child_stack, parent_tid, newtls, child_tid); #elif __s390x__ return (pid_t)syscall(__NR_clone, child_stack, flags, parent_tid, child_tid, newtls); diff --git a/test/zdtm/lib/unix.c b/test/zdtm/lib/unix.c index c36846cad..49773dedd 100644 --- a/test/zdtm/lib/unix.c +++ b/test/zdtm/lib/unix.c @@ -16,4 +16,3 @@ int unix_fill_sock_name(struct sockaddr_un *name, char *relFilename) ssprintf(name->sun_path, "%s/%s", cwd, relFilename); return 0; } - diff --git a/test/zdtm/static/aio00.c b/test/zdtm/static/aio00.c index 93ca7aabb..7e7b9978d 100644 --- a/test/zdtm/static/aio00.c +++ b/test/zdtm/static/aio00.c @@ -5,8 +5,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that plain io_setup works"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check that plain io_setup works"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; int main(int argc, char **argv) { diff --git a/test/zdtm/static/aio01.c b/test/zdtm/static/aio01.c index fda7572a1..ed45192b9 100644 --- a/test/zdtm/static/aio01.c +++ b/test/zdtm/static/aio01.c @@ -10,20 +10,20 @@ #include "zdtmtst.h" -const char *test_doc = "Check head and tail restore correct"; -const char *test_author = "Kirill Tkhai <ktkhai@virtuozzo.com>"; +const char *test_doc = "Check head and tail restore correct"; +const char *test_author = "Kirill Tkhai <ktkhai@virtuozzo.com>"; struct aio_ring { - unsigned id; /* kernel internal index number */ - unsigned nr; /* number of io_events */ - unsigned head; /* Written to by userland or under ring_lock + unsigned id; /* kernel internal index number */ + unsigned nr; /* number of io_events */ + unsigned head; /* Written to by userland or under ring_lock * mutex by aio_read_events_ring(). */ - unsigned tail; - unsigned magic; - unsigned compat_features; - unsigned incompat_features; - unsigned header_length; /* size of aio_ring */ - struct io_event io_events[0]; + unsigned tail; + unsigned magic; + unsigned compat_features; + unsigned incompat_features; + unsigned header_length; /* size of aio_ring */ + struct io_event io_events[0]; }; /* 128 bytes + ring size */ int main(int argc, char **argv) diff --git a/test/zdtm/static/apparmor.c b/test/zdtm/static/apparmor.c index a06589815..713ffaa46 100644 --- a/test/zdtm/static/apparmor.c +++ b/test/zdtm/static/apparmor.c @@ -10,8 +10,8 @@ #include <signal.h> #include "zdtmtst.h" -const char *test_doc = "Check that an apparmor profile is restored"; -const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; +const char *test_doc = "Check that an apparmor profile is restored"; +const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; #define PROFILE "criu_test" diff --git a/test/zdtm/static/arm-neon00.c b/test/zdtm/static/arm-neon00.c index c58218a11..43e1d4ca3 100644 --- a/test/zdtm/static/arm-neon00.c +++ b/test/zdtm/static/arm-neon00.c @@ -3,14 +3,13 @@ #include "zdtmtst.h" -const char *test_doc = "Initialize VFP registers before a migration,\n" - "check the VFP state is the same after a restore."; -const char *test_author = "Alexander Karatshov <alekskartashov@parallels.com>"; - +const char *test_doc = "Initialize VFP registers before a migration,\n" + "check the VFP state is the same after a restore."; +const char *test_author = "Alexander Karatshov <alekskartashov@parallels.com>"; #ifdef __arm__ -int main(int argc, char ** argv) +int main(int argc, char **argv) { int a, b, c, y1, y2; @@ -19,18 +18,17 @@ int main(int argc, char ** argv) a = rand() % 100; b = rand() % 100; c = rand() % 100; - y1 = a + b*c; + y1 = a + b * c; test_init(argc, argv); - asm ( - ".fpu neon \n" - "vmov.32 d0[0], %0 \n" - "vmov.32 d1[0], %1 \n" - "vmov.32 d2[0], %2 \n" - ".fpu softvfp \n" - : : "r"(a), "r"(b), "r"(c) - ); + asm(".fpu neon \n" + "vmov.32 d0[0], %0 \n" + "vmov.32 d1[0], %1 \n" + "vmov.32 d2[0], %2 \n" + ".fpu softvfp \n" + : + : "r"(a), "r"(b), "r"(c)); test_msg("Preparing to wait...\n"); @@ -39,14 +37,12 @@ int main(int argc, char ** argv) test_msg("Restored.\n"); - asm ( - ".fpu neon \n" - "vmul.I32 d3, d1, d2 \n" - "vadd.I32 d4, d0, d3 \n" - "vmov.32 %0, d4[0] \n" - ".fpu softvfp \n" - : "=r"(y2) - ); + asm(".fpu neon \n" + "vmul.I32 d3, d1, d2 \n" + "vadd.I32 d4, d0, d3 \n" + "vmov.32 %0, d4[0] \n" + ".fpu softvfp \n" + : "=r"(y2)); if (y1 != y2) fail("VFP restoration failed: result = %d, expected = %d (a = %d, b = %d, c = %d)", y2, y1, a, b, c); diff --git a/test/zdtm/static/autofs.c b/test/zdtm/static/autofs.c index 6d261677b..2d6078627 100644 --- a/test/zdtm/static/autofs.c +++ b/test/zdtm/static/autofs.c @@ -20,14 +20,14 @@ #include "auto_dev-ioctl.h" const char *test_doc = "Autofs (v5) migration test"; -const char *test_author = "Stanislav Kinsburskii <stanislav.kinsburskiy@virtuozzo.com>"; +const char *test_author = "Stanislav Kinsburskii <stanislav.kinsburskiy@virtuozzo.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); -#define AUTOFS_DEV "/dev/autofs" +#define AUTOFS_DEV "/dev/autofs" -#define INDIRECT_MNT_DIR "mnt" +#define INDIRECT_MNT_DIR "mnt" int autofs_dev; task_waiter_t t; @@ -53,7 +53,7 @@ static char *xvstrcat(char *str, const char *fmt, va_list args) if (ret >= delta) { /* NOTE: vsnprintf returns the amount of bytes * * to allocate. */ - delta = ret +1; + delta = ret + 1; str = new; ret = 0; } @@ -187,53 +187,45 @@ static int check_fd(struct autofs_params *p) if (st.st_dev != p->fd_stat.st_dev) { skip("%s: st_dev differs: %llu != %llu " - "(waiting for \"device namespaces\")", p->mountpoint, - (long long unsigned)st.st_dev, - (long long unsigned)p->fd_stat.st_dev); -// ret++; + "(waiting for \"device namespaces\")", + p->mountpoint, (long long unsigned)st.st_dev, (long long unsigned)p->fd_stat.st_dev); + // ret++; } if (st.st_mode != p->fd_stat.st_mode) { - pr_err("%s: st_mode differs: 0%o != 0%o\n", p->mountpoint, - st.st_mode, p->fd_stat.st_mode); + pr_err("%s: st_mode differs: 0%o != 0%o\n", p->mountpoint, st.st_mode, p->fd_stat.st_mode); ret++; } if (st.st_nlink != p->fd_stat.st_nlink) { - pr_err("%s: st_nlink differs: %ld != %ld\n", p->mountpoint, - (long)st.st_nlink, (long)p->fd_stat.st_nlink); + pr_err("%s: st_nlink differs: %ld != %ld\n", p->mountpoint, (long)st.st_nlink, + (long)p->fd_stat.st_nlink); ret++; } if (st.st_uid != p->fd_stat.st_uid) { - pr_err("%s: st_uid differs: %u != %u\n", p->mountpoint, - st.st_uid, p->fd_stat.st_uid); + pr_err("%s: st_uid differs: %u != %u\n", p->mountpoint, st.st_uid, p->fd_stat.st_uid); ret++; } if (st.st_gid != p->fd_stat.st_gid) { - pr_err("%s: st_gid differs: %u != %u\n", p->mountpoint, - st.st_gid, p->fd_stat.st_gid); + pr_err("%s: st_gid differs: %u != %u\n", p->mountpoint, st.st_gid, p->fd_stat.st_gid); ret++; } if (st.st_rdev != p->fd_stat.st_rdev) { - pr_err("%s: st_rdev differs: %lld != %lld\n", p->mountpoint, - (long long)st.st_rdev, - (long long)p->fd_stat.st_rdev); + pr_err("%s: st_rdev differs: %lld != %lld\n", p->mountpoint, (long long)st.st_rdev, + (long long)p->fd_stat.st_rdev); ret++; } if (st.st_size != p->fd_stat.st_size) { - pr_err("%s: st_size differs: %lld != %lld\n", p->mountpoint, - (long long)st.st_size, - (long long)p->fd_stat.st_size); + pr_err("%s: st_size differs: %lld != %lld\n", p->mountpoint, (long long)st.st_size, + (long long)p->fd_stat.st_size); ret++; } if (st.st_blksize != p->fd_stat.st_blksize) { - pr_err("%s: st_blksize differs %lld != %lld:\n", p->mountpoint, - (long long)st.st_blksize, - (long long)p->fd_stat.st_blksize); + pr_err("%s: st_blksize differs %lld != %lld:\n", p->mountpoint, (long long)st.st_blksize, + (long long)p->fd_stat.st_blksize); ret++; } if (st.st_blocks != p->fd_stat.st_blocks) { - pr_err("%s: st_blocks differs: %lld != %lld\n", p->mountpoint, - (long long)st.st_blocks, - (long long)p->fd_stat.st_blocks); + pr_err("%s: st_blocks differs: %lld != %lld\n", p->mountpoint, (long long)st.st_blocks, + (long long)p->fd_stat.st_blocks); ret++; } @@ -247,8 +239,7 @@ static int check_automount(struct autofs_params *p) err = check_fd(p); if (err) { - pr_err("%s: opened file descriptor wasn't migrated properly\n", - p->mountpoint); + pr_err("%s: opened file descriptor wasn't migrated properly\n", p->mountpoint); return err; } @@ -283,8 +274,7 @@ static int check_automount(struct autofs_params *p) } if (close(p->fd)) { - pr_perror("%s: failed to close fd %d", mountpoint, - p->fd); + pr_perror("%s: failed to close fd %d", mountpoint, p->fd); return -errno; } @@ -335,11 +325,10 @@ out: return ret; } -static int autofs_report_result(int token, int devid, const char *mountpoint, - int result) +static int autofs_report_result(int token, int devid, const char *mountpoint, int result) { int ioctl_fd; - struct autofs_dev_ioctl param; + struct autofs_dev_ioctl param; int err; ioctl_fd = autofs_open_mount(devid, mountpoint); @@ -378,28 +367,24 @@ static int mount_tmpfs(const char *mountpoint) return 0; if (mount("autofs_test", mountpoint, "tmpfs", 0, "size=1M") < 0) { - pr_perror("failed to mount tmpfs to %s", - mountpoint); + pr_perror("failed to mount tmpfs to %s", mountpoint); return -errno; } return 0; } -static int autofs_mount_direct(const char *mountpoint, - const struct autofs_v5_packet *packet) +static int autofs_mount_direct(const char *mountpoint, const struct autofs_v5_packet *packet) { int err; const char *direct_mnt = mountpoint; err = mount_tmpfs(direct_mnt); if (err) - pr_err("%d: failed to mount direct autofs mountpoint\n", - getpid()); + pr_err("%d: failed to mount direct autofs mountpoint\n", getpid()); return err; } -static int autofs_mount_indirect(const char *mountpoint, - const struct autofs_v5_packet *packet) +static int autofs_mount_indirect(const char *mountpoint, const struct autofs_v5_packet *packet) { char *indirect_mnt; int err; @@ -417,40 +402,34 @@ static int autofs_mount_indirect(const char *mountpoint, err = mount_tmpfs(indirect_mnt); if (err) - pr_err("%d: failed to mount indirect autofs mountpoint\n", - getpid()); + pr_err("%d: failed to mount indirect autofs mountpoint\n", getpid()); return err; - } -static int automountd_serve(const char *mountpoint, struct autofs_params *p, - const union autofs_v5_packet_union *packet) +static int automountd_serve(const char *mountpoint, struct autofs_params *p, const union autofs_v5_packet_union *packet) { const struct autofs_v5_packet *v5_packet = &packet->v5_packet; int err, res; switch (packet->hdr.type) { - case autofs_ptype_missing_indirect: - res = autofs_mount_indirect(mountpoint, v5_packet); - break; - case autofs_ptype_missing_direct: - res = autofs_mount_direct(mountpoint, v5_packet); - break; - case autofs_ptype_expire_indirect: - pr_err("%d: expire request for indirect mount %s?\n", - getpid(), v5_packet->name); - return -EINVAL; - case autofs_ptype_expire_direct: - pr_err("%d: expire request for direct mount?\n", - getpid()); - return -EINVAL; - default: - pr_err("unknown request type: %d\n", packet->hdr.type); - return -EINVAL; + case autofs_ptype_missing_indirect: + res = autofs_mount_indirect(mountpoint, v5_packet); + break; + case autofs_ptype_missing_direct: + res = autofs_mount_direct(mountpoint, v5_packet); + break; + case autofs_ptype_expire_indirect: + pr_err("%d: expire request for indirect mount %s?\n", getpid(), v5_packet->name); + return -EINVAL; + case autofs_ptype_expire_direct: + pr_err("%d: expire request for direct mount?\n", getpid()); + return -EINVAL; + default: + pr_err("unknown request type: %d\n", packet->hdr.type); + return -EINVAL; } - err = autofs_report_result(v5_packet->wait_queue_token, v5_packet->dev, - mountpoint, res); + err = autofs_report_result(v5_packet->wait_queue_token, v5_packet->dev, mountpoint, res); if (err) return err; return res; @@ -481,8 +460,7 @@ static int automountd_loop(int pipe, const char *mountpoint, struct autofs_param continue; } if (bytes != psize) { - pr_err("read less than expected: %zd < %zd\n", - bytes, psize); + pr_err("read less than expected: %zd < %zd\n", bytes, psize); return -EINVAL; } err = automountd_serve(mountpoint, param, packet); @@ -522,22 +500,21 @@ static int automountd(struct autofs_params *p, int control_fd) } switch (p->type) { - case AUTOFS_TYPE_DIRECT: - type = "direct"; - break; - case AUTOFS_TYPE_INDIRECT: - type = "indirect"; - break; - case AUTOFS_TYPE_OFFSET: - type = "offset"; - break; - default: - pr_err("unknown autofs type: %d\n", p->type); - return -EINVAL; + case AUTOFS_TYPE_DIRECT: + type = "direct"; + break; + case AUTOFS_TYPE_INDIRECT: + type = "indirect"; + break; + case AUTOFS_TYPE_OFFSET: + type = "offset"; + break; + default: + pr_err("unknown autofs type: %d\n", p->type); + return -EINVAL; } - options = xsprintf("fd=%d,pgrp=%d,minproto=5,maxproto=5,%s", - pipes[1], getpgrp(), type); + options = xsprintf("fd=%d,pgrp=%d,minproto=5,maxproto=5,%s", pipes[1], getpgrp(), type); if (!options) { pr_err("failed to allocate autofs options\n"); goto err; @@ -550,8 +527,7 @@ static int automountd(struct autofs_params *p, int control_fd) } if (mount("autofs_test", autofs_path, "autofs", 0, options) < 0) { - pr_perror("failed to mount autofs with options \"%s\"", - options); + pr_perror("failed to mount autofs with options \"%s\"", options); goto err; } @@ -589,12 +565,12 @@ static int start_automounter(struct autofs_params *p) pid = test_fork(); switch (pid) { - case -1: - pr_perror("failed to fork"); - return -1; - case 0: - close(control_fd[0]); - exit(automountd(p, control_fd[1])); + case -1: + pr_perror("failed to fork"); + return -1; + case 0: + close(control_fd[0]); + exit(automountd(p, control_fd[1])); } task_waiter_wait4(&t, pid); p->pid = pid; @@ -608,8 +584,7 @@ static int start_automounter(struct autofs_params *p) return -errno; } if (bytes != sizeof(ret)) { - pr_err("received less than expected: %zu. Child %d died?\n", - bytes, p->pid); + pr_err("received less than expected: %zu. Child %d died?\n", bytes, p->pid); return -EINVAL; } return ret; @@ -657,8 +632,7 @@ static int reap_catatonic(struct autofs_params *p) err = umount_fs(mountpoint, AUTOFS_SUPER_MAGIC); if (!err) { if (rmdir(mountpoint) < 0) { - skip("failed to remove %s directory: %s\n", mountpoint, - strerror(errno)); + skip("failed to remove %s directory: %s\n", mountpoint, strerror(errno)); err = -errno; } } @@ -732,40 +706,34 @@ static int create_catatonic(struct autofs_params *p) static void test_exit(void) { if (rmdir(dirname) < 0) - skip("failed to remove %s directory: %s\n", dirname, - strerror(errno)); + skip("failed to remove %s directory: %s\n", dirname, strerror(errno)); } -typedef enum { - AUTOFS_START, - AUTOFS_SETUP, - AUTOFS_CHECK, - AUTOFS_STOP -} autfs_test_action; +typedef enum { AUTOFS_START, AUTOFS_SETUP, AUTOFS_CHECK, AUTOFS_STOP } autfs_test_action; static int test_action(autfs_test_action act, struct autofs_params *p) { int ret = 0; - while(p->mountpoint) { - int (*action)(struct autofs_params *p); + while (p->mountpoint) { + int (*action)(struct autofs_params * p); switch (act) { - case AUTOFS_START: - action = p->create; - break; - case AUTOFS_SETUP: - action = p->setup; - break; - case AUTOFS_CHECK: - action = p->check; - break; - case AUTOFS_STOP: - action = p->reap; - break; - default: - pr_err("unknown action: %d\n", act); - return -1; + case AUTOFS_START: + action = p->create; + break; + case AUTOFS_SETUP: + action = p->setup; + break; + case AUTOFS_CHECK: + action = p->check; + break; + case AUTOFS_STOP: + action = p->reap; + break; + default: + pr_err("unknown action: %d\n", act); + return -1; } if (action && action(p)) @@ -793,8 +761,7 @@ static void direct_exit(void) return; if (rmdir(mountpoint) < 0) - skip("failed to remove %s directory: %s\n", mountpoint, - strerror(errno)); + skip("failed to remove %s directory: %s\n", mountpoint, strerror(errno)); } static void indirect_exit(void) @@ -822,8 +789,7 @@ static void indirect_exit(void) return; if (rmdir(mountpoint) < 0) - skip("failed to remove %s directory: %s\n", mountpoint, - strerror(errno)); + skip("failed to remove %s directory: %s\n", mountpoint, strerror(errno)); } enum autofs_tests { @@ -940,4 +906,3 @@ err: pass(); return 0; } - diff --git a/test/zdtm/static/bind-mount.c b/test/zdtm/static/bind-mount.c index 06c5cf173..fed51c59b 100644 --- a/test/zdtm/static/bind-mount.c +++ b/test/zdtm/static/bind-mount.c @@ -8,8 +8,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check bind-mounts"; -const char *test_author = "Pavel Emelianov <avagin@parallels.com>"; +const char *test_doc = "Check bind-mounts"; +const char *test_author = "Pavel Emelianov <avagin@parallels.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); diff --git a/test/zdtm/static/binfmt_misc.c b/test/zdtm/static/binfmt_misc.c index 553cc1795..036eb9fe9 100644 --- a/test/zdtm/static/binfmt_misc.c +++ b/test/zdtm/static/binfmt_misc.c @@ -9,13 +9,13 @@ #include "zdtmtst.h" -const char *test_doc = "Check that binfmt_misc entries remain registered"; -const char *test_author = "Kirill Tkhai <ktkhai@odin.com"; +const char *test_doc = "Check that binfmt_misc entries remain registered"; +const char *test_author = "Kirill Tkhai <ktkhai@odin.com"; -#define MAX_REG_STR 256 -#define MAX_MAGIC 16 +#define MAX_REG_STR 256 +#define MAX_MAGIC 16 #define MAX_MAGIC_OFFSET 128 /* Max magic+offset */ -#define MAX_EXTENSION 128 +#define MAX_EXTENSION 128 char *dirname = "binfmt_misc.dir"; TEST_OPTION(dirname, string, "binfmt_misc mount directory name", 1); @@ -31,7 +31,7 @@ void create_magic_pattern(char *buf, const char *name) int i, magic, mask, offset; magic = rand() % (MAX_MAGIC + 1); - mask = (rand() % 2) ? magic : 0; + mask = (rand() % 2) ? magic : 0; offset = MAX_MAGIC_OFFSET - magic; offset = rand() % (offset + 1); @@ -83,7 +83,7 @@ int dump_content(const char *path, char **dump) return -1; } - len = read(fd, p, PAGE_SIZE-1); + len = read(fd, p, PAGE_SIZE - 1); close(fd); if (len <= 0) { fail("read"); @@ -98,7 +98,7 @@ int dump_content(const char *path, char **dump) int main(int argc, char **argv) { char buf[MAX_REG_STR + 1]; - char path[PATH_MAX*2 + 1]; + char path[PATH_MAX * 2 + 1]; char *dump[2]; int i, fd, len; @@ -118,7 +118,10 @@ int main(int argc, char **argv) } /* Register binfmt_entries */ - sprintf(path, "%s/" "register", dirname); + sprintf(path, + "%s/" + "register", + dirname); fd = open(path, O_WRONLY); if (fd < 0) { fail("open"); @@ -152,7 +155,7 @@ int main(int argc, char **argv) close(fd); /* Dump files content */ - for (i = 0; i < 2; i ++) { + for (i = 0; i < 2; i++) { sprintf(path, "%s/%s", dirname, NAME[i]); if (dump_content(path, &dump[i])) exit(1); @@ -162,7 +165,7 @@ int main(int argc, char **argv) test_waitsig(); /* Check */ - for (i = 0; i < 2; i ++) { + for (i = 0; i < 2; i++) { char *tmp; sprintf(path, "%s/%s", dirname, NAME[i]); diff --git a/test/zdtm/static/bpf_array.c b/test/zdtm/static/bpf_array.c index ca7796bdf..ec74a3e3b 100644 --- a/test/zdtm/static/bpf_array.c +++ b/test/zdtm/static/bpf_array.c @@ -5,17 +5,14 @@ #include "zdtmtst.h" #include "bpfmap_zdtm.h" -const char *test_doc = "Check that data and meta-data for BPF_MAP_TYPE_ARRAY" - "is correctly restored"; -const char *test_author = "Abhishek Vijeev <abhishek.vijeev@gmail.com>"; +const char *test_doc = "Check that data and meta-data for BPF_MAP_TYPE_ARRAY" + "is correctly restored"; +const char *test_author = "Abhishek Vijeev <abhishek.vijeev@gmail.com>"; static int map_batch_update(int map_fd, uint32_t max_entries, int *keys, int *values) { int i, ret; - DECLARE_LIBBPF_OPTS(bpf_map_batch_opts, opts, - .elem_flags = 0, - .flags = 0, - ); + DECLARE_LIBBPF_OPTS(bpf_map_batch_opts, opts, .elem_flags = 0, .flags = 0, ); for (i = 0; i < max_entries; i++) { keys[i] = i; @@ -72,17 +69,11 @@ int main(int argc, char **argv) .max_entries = max_entries, .map_flags = BPF_F_NUMA_NODE, }; - DECLARE_LIBBPF_OPTS(bpf_map_batch_opts, opts, - .elem_flags = 0, - .flags = 0, - ); - - keys = mmap(NULL, max_entries * sizeof(int), - PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); - values = mmap(NULL, max_entries * sizeof(int), - PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); - visited = mmap(NULL, max_entries * sizeof(int), - PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); + DECLARE_LIBBPF_OPTS(bpf_map_batch_opts, opts, .elem_flags = 0, .flags = 0, ); + + keys = mmap(NULL, max_entries * sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); + values = mmap(NULL, max_entries * sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); + visited = mmap(NULL, max_entries * sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); if ((keys == MAP_FAILED) || (values == MAP_FAILED) || (visited == MAP_FAILED)) { pr_perror("Can't mmap()"); diff --git a/test/zdtm/static/bpf_hash.c b/test/zdtm/static/bpf_hash.c index 4054140b8..612f69665 100644 --- a/test/zdtm/static/bpf_hash.c +++ b/test/zdtm/static/bpf_hash.c @@ -5,17 +5,14 @@ #include "zdtmtst.h" #include "bpfmap_zdtm.h" -const char *test_doc = "Check that data and meta-data for BPF_MAP_TYPE_HASH" - "is correctly restored"; -const char *test_author = "Abhishek Vijeev <abhishek.vijeev@gmail.com>"; +const char *test_doc = "Check that data and meta-data for BPF_MAP_TYPE_HASH" + "is correctly restored"; +const char *test_author = "Abhishek Vijeev <abhishek.vijeev@gmail.com>"; static int map_batch_update(int map_fd, uint32_t max_entries, int *keys, int *values) { int ret; - DECLARE_LIBBPF_OPTS(bpf_map_batch_opts, opts, - .elem_flags = 0, - .flags = 0, - ); + DECLARE_LIBBPF_OPTS(bpf_map_batch_opts, opts, .elem_flags = 0, .flags = 0, ); for (int i = 0; i < max_entries; i++) { keys[i] = i + 1; @@ -34,7 +31,6 @@ static int map_batch_verify(int *visited, uint32_t max_entries, int *keys, int * { memset(visited, 0, max_entries * sizeof(*visited)); for (int i = 0; i < max_entries; i++) { - if (keys[i] + 1 != values[i]) { pr_err("Key/value checking error: i=%d, key=%d, value=%d\n", i, keys[i], values[i]); return -1; @@ -71,17 +67,11 @@ int main(int argc, char **argv) .max_entries = max_entries, .map_flags = BPF_F_NO_PREALLOC | BPF_F_NUMA_NODE, }; - DECLARE_LIBBPF_OPTS(bpf_map_batch_opts, opts, - .elem_flags = 0, - .flags = 0, - ); - - keys = mmap(NULL, max_entries * sizeof(int), - PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); - values = mmap(NULL, max_entries * sizeof(int), - PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); - visited = mmap(NULL, max_entries * sizeof(int), - PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); + DECLARE_LIBBPF_OPTS(bpf_map_batch_opts, opts, .elem_flags = 0, .flags = 0, ); + + keys = mmap(NULL, max_entries * sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); + values = mmap(NULL, max_entries * sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); + visited = mmap(NULL, max_entries * sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); if ((keys == MAP_FAILED) || (values == MAP_FAILED) || (visited == MAP_FAILED)) { pr_perror("Can't mmap()"); diff --git a/test/zdtm/static/bridge.c b/test/zdtm/static/bridge.c index 983c262af..03084a296 100644 --- a/test/zdtm/static/bridge.c +++ b/test/zdtm/static/bridge.c @@ -12,8 +12,8 @@ #include <net/if.h> #include "zdtmtst.h" -const char *test_doc = "check that empty bridges are c/r'd correctly"; -const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; +const char *test_doc = "check that empty bridges are c/r'd correctly"; +const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; #define BRIDGE_NAME "zdtmbr0" @@ -72,7 +72,7 @@ int main(int argc, char **argv) } addr.sin6_scope_id = if_nametoindex(BRIDGE_NAME); - if (bind(sk, (struct sockaddr*)&addr, sizeof(addr)) < 0) { + if (bind(sk, (struct sockaddr *)&addr, sizeof(addr)) < 0) { fail("can't bind"); goto out; } diff --git a/test/zdtm/static/busyloop00.c b/test/zdtm/static/busyloop00.c index e9a065cf7..399516933 100644 --- a/test/zdtm/static/busyloop00.c +++ b/test/zdtm/static/busyloop00.c @@ -1,9 +1,9 @@ #include "zdtmtst.h" -const char *test_doc = "Run busy loop while migrating"; -const char *test_author = "Roman Kagan <rkagan@parallels.com>"; +const char *test_doc = "Run busy loop while migrating"; +const char *test_author = "Roman Kagan <rkagan@parallels.com>"; -int main(int argc, char ** argv) +int main(int argc, char **argv) { test_init(argc, argv); diff --git a/test/zdtm/static/caps00.c b/test/zdtm/static/caps00.c index 7a256c08a..d652c7626 100644 --- a/test/zdtm/static/caps00.c +++ b/test/zdtm/static/caps00.c @@ -6,8 +6,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that aps are preserved"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check that aps are preserved"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; struct cap_hdr { unsigned int version; @@ -15,15 +15,15 @@ struct cap_hdr { }; struct cap_data { - unsigned int eff; - unsigned int prm; - unsigned int inh; + unsigned int eff; + unsigned int prm; + unsigned int inh; }; -#define _LINUX_CAPABILITY_VERSION_3 0x20080522 -#define _LINUX_CAPABILITY_U32S_3 2 -#define CAP_CHOWN 0 -#define CAP_DAC_OVERRIDE 1 +#define _LINUX_CAPABILITY_VERSION_3 0x20080522 +#define _LINUX_CAPABILITY_U32S_3 2 +#define CAP_CHOWN 0 +#define CAP_DAC_OVERRIDE 1 int capget(struct cap_hdr *hdrp, struct cap_data *datap); int capset(struct cap_hdr *hdrp, const struct cap_data *datap); @@ -131,12 +131,12 @@ int main(int argc, char **argv) } if (prctl(PR_CAPBSET_READ, CAP_SETPCAP, 0, 0, 0) != 0) { - res='5'; + res = '5'; goto bad; } res = '0'; -bad: + bad: write(result_pipe[1], &res, 1); if (res != '0') { @@ -163,12 +163,10 @@ bad: else { read(result_pipe[0], data, sizeof(data)); read(result_pipe[0], data_2, sizeof(data_2)); - test_msg("{eff,prm,inh}[]={%08x,%08x,%08x}, {%08x,%08x,%08x}\n", - data[0].eff, data[0].prm, data[0].inh, - data[1].eff, data[1].prm, data[1].inh); - test_msg("{eff,prm,inh}[]={%08x,%08x,%08x}, {%08x,%08x,%08x}\n", - data_2[0].eff, data_2[0].prm, data_2[0].inh, - data_2[1].eff, data_2[1].prm, data_2[1].inh); + test_msg("{eff,prm,inh}[]={%08x,%08x,%08x}, {%08x,%08x,%08x}\n", data[0].eff, data[0].prm, data[0].inh, + data[1].eff, data[1].prm, data[1].inh); + test_msg("{eff,prm,inh}[]={%08x,%08x,%08x}, {%08x,%08x,%08x}\n", data_2[0].eff, data_2[0].prm, + data_2[0].inh, data_2[1].eff, data_2[1].prm, data_2[1].inh); fail("Fail: %c", res); } close(result_pipe[0]); diff --git a/test/zdtm/static/cgroup00.c b/test/zdtm/static/cgroup00.c index ee14d1fd3..2ed106094 100644 --- a/test/zdtm/static/cgroup00.c +++ b/test/zdtm/static/cgroup00.c @@ -7,14 +7,14 @@ #include <stdlib.h> #include "zdtmtst.h" -const char *test_doc = "Check that cgroups layout is preserved"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check that cgroups layout is preserved"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; char *dirname; TEST_OPTION(dirname, string, "cgroup directory name", 1); static const char *cgname = "zdtmtst"; -#define SUBNAME "subcg00" -#define SUBNAME2 SUBNAME"/subsubcg" +#define SUBNAME "subcg00" +#define SUBNAME2 SUBNAME "/subsubcg" static int cg_move(char *name) { diff --git a/test/zdtm/static/cgroup01.c b/test/zdtm/static/cgroup01.c index f0d00f209..bc8515264 100644 --- a/test/zdtm/static/cgroup01.c +++ b/test/zdtm/static/cgroup01.c @@ -6,8 +6,8 @@ #include <sys/mount.h> #include "zdtmtst.h" -const char *test_doc = "Check that empty cgroups are preserved"; -const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; +const char *test_doc = "Check that empty cgroups are preserved"; +const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; char *dirname; TEST_OPTION(dirname, string, "cgroup directory name", 1); diff --git a/test/zdtm/static/cgroup02.c b/test/zdtm/static/cgroup02.c index 67cc73d9e..6229a8a08 100644 --- a/test/zdtm/static/cgroup02.c +++ b/test/zdtm/static/cgroup02.c @@ -8,8 +8,8 @@ #include <sys/mount.h> #include "zdtmtst.h" -const char *test_doc = "Check that empty cgroups are preserved"; -const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; +const char *test_doc = "Check that empty cgroups are preserved"; +const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; char *dirname; TEST_OPTION(dirname, string, "cgroup directory name", 1); @@ -160,7 +160,6 @@ int main(int argc, char **argv) pass(); ret = 0; - out_close: fclose(cgf); out_umount: diff --git a/test/zdtm/static/cgroup03.c b/test/zdtm/static/cgroup03.c index 757f0c3b4..78b8b5bee 100644 --- a/test/zdtm/static/cgroup03.c +++ b/test/zdtm/static/cgroup03.c @@ -9,8 +9,8 @@ #include <limits.h> #include "zdtmtst.h" -const char *test_doc = "Check that global cgroup settings (+perms) are restored"; -const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; +const char *test_doc = "Check that global cgroup settings (+perms) are restored"; +const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; char *dirname; TEST_OPTION(dirname, string, "cgroup directory name", 1); @@ -137,7 +137,6 @@ int main(int argc, char **argv) if (chownmod(path, O_RDWR) < 0) goto out_umount; - sprintf(path, "%s/%s/test/cgroup.procs", dirname, cgname); if (chownmod(path, O_RDWR) < 0) goto out_umount; diff --git a/test/zdtm/static/cgroup04.c b/test/zdtm/static/cgroup04.c index 8ec0cff37..5a424be12 100644 --- a/test/zdtm/static/cgroup04.c +++ b/test/zdtm/static/cgroup04.c @@ -10,10 +10,10 @@ #include <limits.h> #include "zdtmtst.h" -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -const char *test_doc = "Check that some cgroups properties in kernel controllers are preserved"; -const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; +const char *test_doc = "Check that some cgroups properties in kernel controllers are preserved"; +const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; char *dirname; TEST_OPTION(dirname, string, "cgroup directory name", 1); @@ -116,17 +116,8 @@ int main(int argc, char **argv) struct stat sb; char *dev_allow[] = { - "c *:* m", - "b *:* m", - "c 1:3 rwm", - "c 1:5 rwm", - "c 1:7 rwm", - "c 5:0 rwm", - "c 5:2 rwm", - "c 1:8 rwm", - "c 1:9 rwm", - "c 136:* rwm", - "c 10:229 rwm", + "c *:* m", "b *:* m", "c 1:3 rwm", "c 1:5 rwm", "c 1:7 rwm", "c 5:0 rwm", + "c 5:2 rwm", "c 1:8 rwm", "c 1:9 rwm", "c 136:* rwm", "c 10:229 rwm", }; test_init(argc, argv); diff --git a/test/zdtm/static/cgroup_ifpriomap.c b/test/zdtm/static/cgroup_ifpriomap.c index 24ed44f14..5f07d495b 100644 --- a/test/zdtm/static/cgroup_ifpriomap.c +++ b/test/zdtm/static/cgroup_ifpriomap.c @@ -10,20 +10,20 @@ #include "zdtmtst.h" -const char *test_doc = "Check preserving multiline cgroup controller's property net_prio/net_prio.ifpriomap"; -const char *test_author = "Dmitry Safonov <dsafonov@virtuozzo.com>"; +const char *test_doc = "Check preserving multiline cgroup controller's property net_prio/net_prio.ifpriomap"; +const char *test_author = "Dmitry Safonov <dsafonov@virtuozzo.com>"; char *dirname; TEST_OPTION(dirname, string, "cgroup directory name", 1); static const char *cgname = "zdtmtst"; -#define BUF_SZ 1024 -#define PRIOMAPS_SZ 40 +#define BUF_SZ 1024 +#define PRIOMAPS_SZ 40 struct ifpriomap_t { - char *ifname; - uint32_t prio; + char *ifname; + uint32_t prio; }; struct ifpriomap_t maps[PRIOMAPS_SZ], new_maps[PRIOMAPS_SZ]; @@ -165,8 +165,7 @@ static int write_map(const char *path, struct ifpriomap_t *out, size_t out_sz) if (!p->ifname) break; - snprintf(buf, BUF_SZ, "%s %lu", - p->ifname, (unsigned long)p->prio); + snprintf(buf, BUF_SZ, "%s %lu", p->ifname, (unsigned long)p->prio); written = write(fd, buf, strlen(buf)); if (written < 0) { @@ -216,10 +215,8 @@ static int compare_maps(void) if (strcmp(a->ifname, b->ifname) == 0) { if (a->prio != b->prio) { - pr_err("`%s' prio: %lu != %lu\n", - a->ifname, - (unsigned long)a->prio, - (unsigned long)b->prio); + pr_err("`%s' prio: %lu != %lu\n", a->ifname, (unsigned long)a->prio, + (unsigned long)b->prio); return -1; } } @@ -296,11 +293,11 @@ static int get_controller_name(char **name) if (strstr(*name, "net_prio")) { /* erasing ':' delimiter */ - (*name)[len-1] = '\0'; + (*name)[len - 1] = '\0'; ret = 0; goto out_close; } - } while(1); + } while (1); /* self/cgroup has no mount for net_prio - try to map it */ *name = "net_prio"; @@ -328,8 +325,7 @@ int main(int argc, char **argv) if (mount_cg(controller_name) < 0) return -1; - sprintf(path, "%s/%s/%s/net_prio.ifpriomap", - dirname, controller_name, cgname); + sprintf(path, "%s/%s/%s/net_prio.ifpriomap", dirname, controller_name, cgname); if (read_map(path, maps, PRIOMAPS_SZ)) goto out_umount; diff --git a/test/zdtm/static/cgroup_stray.c b/test/zdtm/static/cgroup_stray.c index a068378ec..0c0ed93cf 100644 --- a/test/zdtm/static/cgroup_stray.c +++ b/test/zdtm/static/cgroup_stray.c @@ -13,8 +13,8 @@ #include <limits.h> #include "zdtmtst.h" -const char *test_doc = "Check that stray cgroups are c/r'd correctly"; -const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; +const char *test_doc = "Check that stray cgroups are c/r'd correctly"; +const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; char *dirname; TEST_OPTION(dirname, string, "cgroup directory name", 1); @@ -76,7 +76,8 @@ static int add_to_cg(const char *controller, const char *path) return 0; } -static bool pid_in_cgroup(pid_t pid, const char *controller, const char *path) { +static bool pid_in_cgroup(pid_t pid, const char *controller, const char *path) +{ char buf[2048]; FILE *f; bool ret = false; @@ -92,7 +93,7 @@ static bool pid_in_cgroup(pid_t pid, const char *controller, const char *path) { char *pos, *pid_controller, *pid_path; /* chop off trailing \n */ - buf[strlen(buf)-1] = '\0'; + buf[strlen(buf) - 1] = '\0'; /* skip hierarchy no. */ pos = strstr(buf, ":"); @@ -113,12 +114,13 @@ static bool pid_in_cgroup(pid_t pid, const char *controller, const char *path) { pos++; pid_path = pos; -test_msg("comparing %s and %s\n", controller, pid_controller); + test_msg("comparing %s and %s\n", controller, pid_controller); if (strcmp(controller, pid_controller)) continue; if (strcmp(path, pid_path)) - pr_err("task not in right cg for controller %s expected %s, got %s\n", controller, path, pid_path); + pr_err("task not in right cg for controller %s expected %s, got %s\n", controller, path, + pid_path); else ret = true; diff --git a/test/zdtm/static/cgroupns.c b/test/zdtm/static/cgroupns.c index 68b86b44b..8974f1607 100644 --- a/test/zdtm/static/cgroupns.c +++ b/test/zdtm/static/cgroupns.c @@ -14,11 +14,11 @@ #include "zdtmtst.h" #ifndef CLONE_NEWCGROUP -#define CLONE_NEWCGROUP 0x02000000 +#define CLONE_NEWCGROUP 0x02000000 #endif -const char *test_doc = "Check that cgroup NS is correctly handled."; -const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; +const char *test_doc = "Check that cgroup NS is correctly handled."; +const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; /* we need dirname before test_init() here */ char *dirname = "cgroupns.test"; @@ -74,7 +74,8 @@ err_rd: return -1; } -static bool pid_in_cgroup(pid_t pid, const char *controller, const char *path) { +static bool pid_in_cgroup(pid_t pid, const char *controller, const char *path) +{ char buf[2048]; FILE *f; bool ret = false; @@ -90,7 +91,7 @@ static bool pid_in_cgroup(pid_t pid, const char *controller, const char *path) { char *pos, *pid_controller, *pid_path; /* chop off trailing \n */ - buf[strlen(buf)-1] = '\0'; + buf[strlen(buf) - 1] = '\0'; /* skip hierarchy no. */ pos = strstr(buf, ":"); @@ -115,7 +116,8 @@ static bool pid_in_cgroup(pid_t pid, const char *controller, const char *path) { continue; if (strcmp(path, pid_path)) - pr_err("task not in right cg for controller %s expected %s, got %s\n", controller, path, pid_path); + pr_err("task not in right cg for controller %s expected %s, got %s\n", controller, path, + pid_path); else ret = true; diff --git a/test/zdtm/static/child_opened_proc.c b/test/zdtm/static/child_opened_proc.c index 2a1fa8c79..2125cd264 100644 --- a/test/zdtm/static/child_opened_proc.c +++ b/test/zdtm/static/child_opened_proc.c @@ -9,10 +9,10 @@ #include "zdtmtst.h" -const char *test_doc = "Check that tree prior to files opening"; -const char *test_author = "Stanislav Kinsbursky <skinsbursky@paralles.com"; +const char *test_doc = "Check that tree prior to files opening"; +const char *test_author = "Stanislav Kinsbursky <skinsbursky@paralles.com"; -int main(int argc, char ** argv) +int main(int argc, char **argv) { int pid, err = 0; int proc_fd; diff --git a/test/zdtm/static/child_subreaper.c b/test/zdtm/static/child_subreaper.c index 4a27569fc..34d8c7411 100644 --- a/test/zdtm/static/child_subreaper.c +++ b/test/zdtm/static/child_subreaper.c @@ -3,8 +3,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that child subreaper attribute is restored"; -const char *test_author = "MichaÅ‚ CÅ‚apiÅ„ski <mclapinski@google.com>"; +const char *test_doc = "Check that child subreaper attribute is restored"; +const char *test_author = "MichaÅ‚ CÅ‚apiÅ„ski <mclapinski@google.com>"; int main(int argc, char **argv) { diff --git a/test/zdtm/static/child_subreaper_and_reparent.c b/test/zdtm/static/child_subreaper_and_reparent.c index e3955d3d9..ba03517ba 100644 --- a/test/zdtm/static/child_subreaper_and_reparent.c +++ b/test/zdtm/static/child_subreaper_and_reparent.c @@ -8,8 +8,8 @@ #include "zdtmtst.h" #include "lock.h" -const char *test_doc = "Check that child subreaper does not affect reparenting"; -const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; +const char *test_doc = "Check that child subreaper does not affect reparenting"; +const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; enum { TEST_FORK, @@ -23,7 +23,7 @@ struct shared { futex_t fstate; int parent_before_cr; int parent_after_cr; -} *sh; +} * sh; int orphan(void) { diff --git a/test/zdtm/static/child_subreaper_existing_child.c b/test/zdtm/static/child_subreaper_existing_child.c index bc0047480..4805aa41d 100644 --- a/test/zdtm/static/child_subreaper_existing_child.c +++ b/test/zdtm/static/child_subreaper_existing_child.c @@ -7,8 +7,8 @@ #include "zdtmtst.h" #include "lock.h" -const char *test_doc = "Check that property is restored for existing children"; -const char *test_author = "MichaÅ‚ CÅ‚apiÅ„ski <mclapinski@google.com>"; +const char *test_doc = "Check that property is restored for existing children"; +const char *test_author = "MichaÅ‚ CÅ‚apiÅ„ski <mclapinski@google.com>"; enum { TEST_FORK, @@ -21,8 +21,7 @@ enum { struct shared { futex_t fstate; int ppid_after_reparent; -} *sh; - +} * sh; int orphan(void) { diff --git a/test/zdtm/static/chroot-file.c b/test/zdtm/static/chroot-file.c index 94f584213..d8c0846c7 100644 --- a/test/zdtm/static/chroot-file.c +++ b/test/zdtm/static/chroot-file.c @@ -8,15 +8,15 @@ #include "zdtmtst.h" -const char *test_doc = "Check that out-of-root file survives"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check that out-of-root file survives"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); char *filename; TEST_OPTION(filename, string, "file name", 1); -#define MSG "out-file-contents" +#define MSG "out-file-contents" static int make_file(char *name) { @@ -46,14 +46,14 @@ static int check_file(int fd) return 0; } -#define SUCCESS 0 -#define ERR_PIPES (char)0x7f +#define SUCCESS 0 +#define ERR_PIPES (char)0x7f /* bitmap of errors */ -#define ERR_IN_FILE 1 -#define ERR_ROOT 2 -#define ERR_DIR 4 -#define ERR_CHDIR 8 -#define ERR_ROOT2 4 +#define ERR_IN_FILE 1 +#define ERR_ROOT 2 +#define ERR_DIR 4 +#define ERR_CHDIR 8 +#define ERR_ROOT2 4 int main(int argc, char **argv) { diff --git a/test/zdtm/static/chroot.c b/test/zdtm/static/chroot.c index 439a8e7dc..861cbab3f 100644 --- a/test/zdtm/static/chroot.c +++ b/test/zdtm/static/chroot.c @@ -8,8 +8,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that root didn't change"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check that root didn't change"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); @@ -17,7 +17,7 @@ char *filename; TEST_OPTION(filename, string, "file name", 1); static char *filepath; -#define MSG "chroot-file-contents" +#define MSG "chroot-file-contents" static int make_file(char *name) { @@ -47,14 +47,14 @@ static int check_file(int fd) return 0; } -#define SUCCESS 0 -#define ERR_PIPES (char)0x7f +#define SUCCESS 0 +#define ERR_PIPES (char)0x7f /* bitmap of errors */ -#define ERR_IN_FILE 1 -#define ERR_ROOT 2 -#define ERR_DIR 4 -#define ERR_OPEN 2 -#define ERR_FILE2 4 +#define ERR_IN_FILE 1 +#define ERR_ROOT 2 +#define ERR_DIR 4 +#define ERR_OPEN 2 +#define ERR_FILE2 4 int main(int argc, char **argv) { diff --git a/test/zdtm/static/clean_mntns.c b/test/zdtm/static/clean_mntns.c index 762894611..c529afd11 100644 --- a/test/zdtm/static/clean_mntns.c +++ b/test/zdtm/static/clean_mntns.c @@ -4,8 +4,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that clean mntns works"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check that clean mntns works"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; int main(int argc, char **argv) { diff --git a/test/zdtm/static/clone_fs.c b/test/zdtm/static/clone_fs.c index e368aff99..78edf8095 100644 --- a/test/zdtm/static/clone_fs.c +++ b/test/zdtm/static/clone_fs.c @@ -4,7 +4,7 @@ #include "zdtmtst.h" -const char *test_doc = "Check that shared FS is migrated properly"; +const char *test_doc = "Check that shared FS is migrated properly"; const char *test_author = "Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>"; enum kcmp_type { @@ -26,28 +26,27 @@ static int kcmp(int type, pid_t pid1, pid_t pid2, unsigned long idx1, unsigned l ret = syscall(SYS_kcmp, pid1, pid2, type, idx1, idx2); switch (ret) { - case 0: - break; - case 1: - case 2: - test_msg("FS for pids %d and %d doesn't match: %d\n", pid1, pid2, ret); - break; - case -1: - pr_err("kcmp (type: %d, pid1: %d, pid2: %d, " - "idx1: %ld, idx2: %ld) failed: %d\n", - type, pid1, pid2, idx1, idx2, errno); - break; - default: - pr_err("kcmp (type: %d, pid1: %d, pid2: %d, " - "idx1: %ld, idx2: %ld) returned %d\n", - type, pid1, pid2, idx1, idx2, ret); - break; + case 0: + break; + case 1: + case 2: + test_msg("FS for pids %d and %d doesn't match: %d\n", pid1, pid2, ret); + break; + case -1: + pr_err("kcmp (type: %d, pid1: %d, pid2: %d, " + "idx1: %ld, idx2: %ld) failed: %d\n", + type, pid1, pid2, idx1, idx2, errno); + break; + default: + pr_err("kcmp (type: %d, pid1: %d, pid2: %d, " + "idx1: %ld, idx2: %ld) returned %d\n", + type, pid1, pid2, idx1, idx2, ret); + break; } return ret; } -#define gettid(code) \ - syscall(__NR_gettid) +#define gettid(code) syscall(__NR_gettid) static pthread_mutex_t init_lock; static pthread_mutex_t exit_lock; @@ -68,7 +67,7 @@ int main(int argc, char **argv) int ret; pthread_t th; - test_init(argc, argv); + test_init(argc, argv); pthread_mutex_init(&init_lock, NULL); pthread_mutex_lock(&init_lock); diff --git a/test/zdtm/static/cmdlinenv00.c b/test/zdtm/static/cmdlinenv00.c index 8fffcb3e0..fc2f0a7dc 100644 --- a/test/zdtm/static/cmdlinenv00.c +++ b/test/zdtm/static/cmdlinenv00.c @@ -10,8 +10,8 @@ #include "zdtmtst.h" -const char *test_doc = "Test that env/cmdline/auxv restored well\n"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org"; +const char *test_doc = "Test that env/cmdline/auxv restored well\n"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org"; static char *arg1, *arg2, *arg3; @@ -60,7 +60,7 @@ static int cmp_auxv(const void *auxv_orig, const void *auxv, size_t size) while (size > 0) { if (*new != *old) return -1; - new++; + new ++; old++; size -= sizeof(*new); } @@ -76,12 +76,12 @@ int main(int argc, char *argv[]) char auxv_orig[1024]; char auxv[1024]; - memset(cmdline_orig, 0, sizeof(cmdline_orig)); - memset(cmdline, 0, sizeof(cmdline)); - memset(env_orig, 0, sizeof(env_orig)); - memset(env, 0, sizeof(env)); - memset(auxv_orig, 0, sizeof(auxv_orig)); - memset(auxv, 0, sizeof(auxv)); + memset(cmdline_orig, 0, sizeof(cmdline_orig)); + memset(cmdline, 0, sizeof(cmdline)); + memset(env_orig, 0, sizeof(env_orig)); + memset(env, 0, sizeof(env)); + memset(auxv_orig, 0, sizeof(auxv_orig)); + memset(auxv, 0, sizeof(auxv)); test_init(argc, argv); diff --git a/test/zdtm/static/config_inotify_irmap.c b/test/zdtm/static/config_inotify_irmap.c index 3cbeba7d3..94585491a 100644 --- a/test/zdtm/static/config_inotify_irmap.c +++ b/test/zdtm/static/config_inotify_irmap.c @@ -20,16 +20,19 @@ * refer to the original test case and it's author. */ -const char *test_doc = "Default configuration files usage"; -const char *test_author = "Veronika Kabatova <vkabatov@redhat.com>"; +const char *test_doc = "Default configuration files usage"; +const char *test_author = "Veronika Kabatova <vkabatov@redhat.com>"; -#define TDIR "/etc" -char test_files[2][128] = {TDIR"/zdtm-test", TDIR"/zdtm-test1",}; -#define CONFIG_PATH "../../zdtm_test_config.conf" +#define TDIR "/etc" +char test_files[2][128] = { + TDIR "/zdtm-test", + TDIR "/zdtm-test1", +}; +#define CONFIG_PATH "../../zdtm_test_config.conf" #define BUFF_SIZE ((sizeof(struct inotify_event) + PATH_MAX)) -int main (int argc, char *argv[]) +int main(int argc, char *argv[]) { FILE *configfile; char buf[BUFF_SIZE]; diff --git a/test/zdtm/static/console.c b/test/zdtm/static/console.c index 026eacb2e..d40332acd 100644 --- a/test/zdtm/static/console.c +++ b/test/zdtm/static/console.c @@ -10,20 +10,20 @@ #include "zdtmtst.h" -const char *test_doc = "Check c/r for console device"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; +const char *test_doc = "Check c/r for console device"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; char *filename; TEST_OPTION(filename, string, "file name", 1); -int main(int argc, char ** argv) +int main(int argc, char **argv) { struct stat st1, st2; int fd; test_init(argc, argv); - if (mknod(filename, S_IFCHR | S_IRUSR | S_IWUSR, makedev(5,1))) { + if (mknod(filename, S_IFCHR | S_IRUSR | S_IWUSR, makedev(5, 1))) { pr_perror("Can't create console %s", filename); return 1; } @@ -48,9 +48,7 @@ int main(int argc, char ** argv) } if (st1.st_rdev != st2.st_rdev) { - fail("Console rdev mismatch %x != %x on %s", - (int)st1.st_rdev, (int)st2.st_rdev, - filename); + fail("Console rdev mismatch %x != %x on %s", (int)st1.st_rdev, (int)st2.st_rdev, filename); return 1; } diff --git a/test/zdtm/static/cow00.c b/test/zdtm/static/cow00.c index 92446a16c..cb0c6733e 100644 --- a/test/zdtm/static/cow00.c +++ b/test/zdtm/static/cow00.c @@ -10,13 +10,13 @@ #include "zdtmtst.h" -const char *test_doc = "Check that cow memory are restored"; -const char *test_author = "Andrey Vagin <avagin@parallels.com"; +const char *test_doc = "Check that cow memory are restored"; +const char *test_author = "Andrey Vagin <avagin@parallels.com"; static int is_cow(void *addr, pid_t p1, pid_t p2) { char buf[PATH_MAX]; - unsigned long pfn = (unsigned long) addr / PAGE_SIZE; + unsigned long pfn = (unsigned long)addr / PAGE_SIZE; uint64_t map1, map2; int fd1, fd2, ret, i; @@ -63,7 +63,7 @@ static int is_cow(void *addr, pid_t p1, pid_t p2) return map1 == map2; } -int main(int argc, char ** argv) +int main(int argc, char **argv) { void *addr; pid_t pid; diff --git a/test/zdtm/static/cow01.c b/test/zdtm/static/cow01.c index ce5745831..268f49e2a 100644 --- a/test/zdtm/static/cow01.c +++ b/test/zdtm/static/cow01.c @@ -13,8 +13,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that cow memory are restored"; -const char *test_author = "Andrey Vagin <avagin@parallels.com"; +const char *test_doc = "Check that cow memory are restored"; +const char *test_author = "Andrey Vagin <avagin@parallels.com"; char *filename; TEST_OPTION(filename, string, "file name", 1); @@ -22,20 +22,19 @@ TEST_OPTION(filename, string, "file name", 1); struct test_case { union { struct { - uint8_t b_f_write:1; /* before fork */ - uint8_t b_f_read:1; - uint8_t a_f_write_child:1; /* after fork */ - uint8_t a_f_write_parent:1; - uint8_t a_f_read_child:1; - uint8_t a_f_read_parent:1; -#define TEST_CASES (2 << 6) + uint8_t b_f_write : 1; /* before fork */ + uint8_t b_f_read : 1; + uint8_t a_f_write_child : 1; /* after fork */ + uint8_t a_f_write_parent : 1; + uint8_t a_f_read_child : 1; + uint8_t a_f_read_parent : 1; +#define TEST_CASES (2 << 6) }; uint8_t num; }; uint32_t crc_parent; uint32_t crc_child; - }; struct test_cases { @@ -57,27 +56,28 @@ static pid_t child_pid; * file, etc.). A return code of 1 means failure, it means criu was not able * to checkpoint and/or restore the process properly. */ -#define EXECUTE_ACTION(func, fd) ({ \ - int __ret = 0; \ - __ret |= func(&sep_tcs, fd); \ - __ret |= func(&cow_tcs, fd); \ - __ret |= func(&cow_gd_tcs, fd); \ - __ret |= func(&file_tcs, fd); \ - __ret; \ -}) - -struct test_cases cow_tcs = {.init = init_cow, .tname = "cow_tcs"}, - sep_tcs = {.init = init_sep, .tname = "sep_tcs"}, - file_tcs = {.init = init_file, .tname = "file_tcs"}, - cow_gd_tcs = {.init = init_cow_gd, .tname = "cow_gd_tcs"}; +#define EXECUTE_ACTION(func, fd) \ + ({ \ + int __ret = 0; \ + __ret |= func(&sep_tcs, fd); \ + __ret |= func(&cow_tcs, fd); \ + __ret |= func(&cow_gd_tcs, fd); \ + __ret |= func(&file_tcs, fd); \ + __ret; \ + }) + +struct test_cases cow_tcs = { .init = init_cow, .tname = "cow_tcs" }, + sep_tcs = { .init = init_sep, .tname = "sep_tcs" }, + file_tcs = { .init = init_file, .tname = "file_tcs" }, + cow_gd_tcs = { .init = init_cow_gd, .tname = "cow_gd_tcs" }; uint32_t zero_crc = ~1; -static int is_cow(void *addr, pid_t pid_child, pid_t pid_parent, - uint64_t *map_child_ret, uint64_t *map_parent_ret, int fd) +static int is_cow(void *addr, pid_t pid_child, pid_t pid_parent, uint64_t *map_child_ret, uint64_t *map_parent_ret, + int fd) { char buf[PATH_MAX]; - unsigned long pfn = (unsigned long) addr / PAGE_SIZE; + unsigned long pfn = (unsigned long)addr / PAGE_SIZE; uint64_t map_child, map_parent; int fd_child, fd_parent, ret, i; off_t lseek_ret; @@ -104,30 +104,26 @@ static int is_cow(void *addr, pid_t pid_child, pid_t pid_parent, void **p = addr; lseek_ret = lseek(fd_child, pfn * sizeof(map_child), SEEK_SET); - if (lseek_ret == (off_t) -1) { - pr_perror("Unable to seek child pagemap to virtual addr %#08lx", - pfn * PAGE_SIZE); + if (lseek_ret == (off_t)-1) { + pr_perror("Unable to seek child pagemap to virtual addr %#08lx", pfn * PAGE_SIZE); return -1; } lseek_ret = lseek(fd_parent, pfn * sizeof(map_parent), SEEK_SET); - if (lseek_ret == (off_t) -1) { - pr_perror("Unable to seek parent pagemap to virtual addr %#08lx", - pfn * PAGE_SIZE); + if (lseek_ret == (off_t)-1) { + pr_perror("Unable to seek parent pagemap to virtual addr %#08lx", pfn * PAGE_SIZE); return -1; } ret = read(fd_child, &map_child, sizeof(map_child)); if (ret != sizeof(map_child)) { - pr_perror("Unable to read child pagemap at virtual addr %#08lx", - pfn * PAGE_SIZE); + pr_perror("Unable to read child pagemap at virtual addr %#08lx", pfn * PAGE_SIZE); return -1; } ret = read(fd_parent, &map_parent, sizeof(map_parent)); if (ret != sizeof(map_parent)) { - pr_perror("Unable to read parent pagemap at virtual addr %#08lx", - pfn * PAGE_SIZE); + pr_perror("Unable to read parent pagemap at virtual addr %#08lx", pfn * PAGE_SIZE); return -1; } @@ -192,8 +188,8 @@ static int child_check(struct test_cases *test_cases, int fd) datasum(addr + i * PAGE_SIZE, PAGE_SIZE, &crc); if (crc != tc->crc_child) { errno = 0; - fail("%s[%#x]: %p child data mismatch (expected [%04x] got [%04x])", - test_cases->tname, i, addr + i * PAGE_SIZE, tc->crc_child, crc); + fail("%s[%#x]: %p child data mismatch (expected [%04x] got [%04x])", test_cases->tname, i, + addr + i * PAGE_SIZE, tc->crc_child, crc); ret |= 1; } } @@ -266,29 +262,25 @@ static int parent_check(struct test_cases *test_cases, int fd) datasum(addr + i * PAGE_SIZE, PAGE_SIZE, &crc); if (crc != tc->crc_parent) { errno = 0; - fail("%s[%#x]: %p parent data mismatch (expected [%04x] got [%04x])", - test_cases->tname, i, addr + i * PAGE_SIZE, tc->crc_parent, crc); + fail("%s[%#x]: %p parent data mismatch (expected [%04x] got [%04x])", test_cases->tname, i, + addr + i * PAGE_SIZE, tc->crc_parent, crc); ret |= 1; } if (test_cases == &sep_tcs) continue; - if (!tc->a_f_write_child && - !tc->a_f_write_parent && - tc->b_f_write) { + if (!tc->a_f_write_child && !tc->a_f_write_parent && tc->b_f_write) { uint64_t map_child, map_parent; int is_cow_ret; - is_cow_ret = is_cow(addr + i * PAGE_SIZE, child_pid, getpid(), - &map_child, &map_parent, fd); + is_cow_ret = is_cow(addr + i * PAGE_SIZE, child_pid, getpid(), &map_child, &map_parent, fd); ret |= is_cow_ret; if (is_cow_ret == 1) { errno = 0; fail("%s[%#x]: %p is not COW-ed (pagemap of " - "child=[%"PRIx64"], parent=[%"PRIx64"])", - test_cases->tname, i, addr + i * PAGE_SIZE, - map_child, map_parent); + "child=[%" PRIx64 "], parent=[%" PRIx64 "])", + test_cases->tname, i, addr + i * PAGE_SIZE, map_child, map_parent); } } } @@ -301,9 +293,7 @@ static int __init_cow(struct test_cases *tcs, int flags) int i; void *addr; - addr = mmap(NULL, PAGE_SIZE * (TEST_CASES + 2), - PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + addr = mmap(NULL, PAGE_SIZE * (TEST_CASES + 2), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (addr == MAP_FAILED) { pr_perror("Can't allocate memory"); return -1; @@ -314,12 +304,11 @@ static int __init_cow(struct test_cases *tcs, int flags) * In parent cow-ed and coinciding regions can be merged, but * in child they cannot be, so COW will not be restored. FIXME */ - mmap(addr, PAGE_SIZE, PROT_NONE, - MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); + mmap(addr, PAGE_SIZE, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); addr += PAGE_SIZE; tcs->addr = addr; - mmap(addr + PAGE_SIZE * TEST_CASES, PAGE_SIZE, PROT_NONE, - MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED | flags, -1, 0); + mmap(addr + PAGE_SIZE * TEST_CASES, PAGE_SIZE, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED | flags, -1, + 0); test_msg("addr[%s]=%p\n", tcs->tname, tcs->addr); for (i = 0; i < TEST_CASES; i++) { @@ -345,9 +334,7 @@ static int init_sep(struct test_cases *tcs) { int i; - tcs->addr = mmap(NULL, PAGE_SIZE * TEST_CASES, - PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + tcs->addr = mmap(NULL, PAGE_SIZE * TEST_CASES, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (tcs->addr == MAP_FAILED) { pr_perror("Can't allocate memory"); return -1; @@ -389,9 +376,7 @@ static int init_file(struct test_cases *tcs) tc->crc_child = crc; } - tcs->addr = mmap(NULL, PAGE_SIZE * TEST_CASES, - PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_FILE, fd, 0); + tcs->addr = mmap(NULL, PAGE_SIZE * TEST_CASES, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FILE, fd, 0); if (tcs->addr == MAP_FAILED) { pr_perror("Can't allocate memory"); return -1; @@ -407,9 +392,8 @@ static int child(task_waiter_t *child_waiter, int fd) { int ret = 0; - sep_tcs.addr = mmap(sep_tcs.addr, PAGE_SIZE * TEST_CASES, - PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); + sep_tcs.addr = mmap(sep_tcs.addr, PAGE_SIZE * TEST_CASES, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); if (sep_tcs.addr == MAP_FAILED) { pr_perror("Can't allocate memory"); return -1; @@ -445,7 +429,7 @@ static int child(task_waiter_t *child_waiter, int fd) return (ret < 0) ? 2 : (ret != 0); } -int main(int argc, char ** argv) +int main(int argc, char **argv) { uint8_t zero_page[PAGE_SIZE]; int status = -1, ret = 0; diff --git a/test/zdtm/static/cr_veth.c b/test/zdtm/static/cr_veth.c index bc5c0cbd4..f09d52797 100644 --- a/test/zdtm/static/cr_veth.c +++ b/test/zdtm/static/cr_veth.c @@ -13,8 +13,8 @@ #include <net/if.h> #include "zdtmtst.h" -const char *test_doc = "check that veth C/R-s right"; -const char *test_author = "Pavel Emelyanov <xemul@virtuozzo.com>"; +const char *test_doc = "check that veth C/R-s right"; +const char *test_author = "Pavel Emelyanov <xemul@virtuozzo.com>"; #define IF_NAME "zdtmvthc0" diff --git a/test/zdtm/static/cr_veth02.c b/test/zdtm/static/cr_veth02.c index 9e75906c0..5075e062d 100644 --- a/test/zdtm/static/cr_veth02.c +++ b/test/zdtm/static/cr_veth02.c @@ -4,8 +4,8 @@ #include "zdtmtst.h" -const char *test_doc = "Restore with precreated veth devices."; -const char *test_author = "Andrei Vagin <avagin@gmail.com>"; +const char *test_doc = "Restore with precreated veth devices."; +const char *test_author = "Andrei Vagin <avagin@gmail.com>"; #define IF_NAME "zdtmvthc0" diff --git a/test/zdtm/static/criu-rtc.c b/test/zdtm/static/criu-rtc.c index 8ffb0cd08..9626a6dcc 100644 --- a/test/zdtm/static/criu-rtc.c +++ b/test/zdtm/static/criu-rtc.c @@ -37,8 +37,7 @@ int cr_plugin_dump_file(int fd, int id) return -1; } - if (major(st.st_rdev) != major(st_rtc.st_rdev) || - minor(st.st_rdev) != 0) + if (major(st.st_rdev) != major(st_rtc.st_rdev) || minor(st.st_rdev) != 0) return -ENOTSUP; if (ioctl(fd, RTC_IRQP_READ, &irqp) == -1) { @@ -61,7 +60,7 @@ int cr_plugin_dump_file(int fd, int id) criu_rtc__pack(&e, buf); - ret = write(img_fd, buf, len); + ret = write(img_fd, buf, len); if (ret != len) { pr_perror("Unable to write in %s", img_path); close(img_fd); diff --git a/test/zdtm/static/cwd00.c b/test/zdtm/static/cwd00.c index d75fa6a4e..c05174d63 100644 --- a/test/zdtm/static/cwd00.c +++ b/test/zdtm/static/cwd00.c @@ -8,8 +8,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that cwd didn't change"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check that cwd didn't change"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); diff --git a/test/zdtm/static/cwd01.c b/test/zdtm/static/cwd01.c index b04032c1c..9d457e9c8 100644 --- a/test/zdtm/static/cwd01.c +++ b/test/zdtm/static/cwd01.c @@ -8,11 +8,10 @@ #include <sys/types.h> #include <fcntl.h> - #include "zdtmtst.h" -const char *test_doc = "Check that removed cwd works"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check that removed cwd works"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); diff --git a/test/zdtm/static/cwd02.c b/test/zdtm/static/cwd02.c index 0d4b276e5..916625b7b 100644 --- a/test/zdtm/static/cwd02.c +++ b/test/zdtm/static/cwd02.c @@ -8,8 +8,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that removed and opened cwd are kept"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check that removed and opened cwd are kept"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); @@ -72,8 +72,7 @@ int main(int argc, char **argv) goto cleanup; } - if (stf.st_ino != std.st_ino || - stf.st_dev != std.st_dev) { + if (stf.st_ino != std.st_ino || stf.st_dev != std.st_dev) { fail("cwd and opened fd are not the same"); goto cleanup; } diff --git a/test/zdtm/static/del_standalone_un.c b/test/zdtm/static/del_standalone_un.c index f1a7a30f6..c9fa84870 100644 --- a/test/zdtm/static/del_standalone_un.c +++ b/test/zdtm/static/del_standalone_un.c @@ -10,8 +10,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that deleted unix sockets are restored correctly"; -const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; +const char *test_doc = "Check that deleted unix sockets are restored correctly"; +const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); @@ -26,7 +26,7 @@ static int bind_and_listen(struct sockaddr_un *addr) return -1; } - if (bind(sk, (struct sockaddr *) addr, sizeof(*addr))) { + if (bind(sk, (struct sockaddr *)addr, sizeof(*addr))) { fail("bind %s", addr->sun_path); close(sk); return -1; diff --git a/test/zdtm/static/deleted_dev.c b/test/zdtm/static/deleted_dev.c index a850338d9..1819a8886 100644 --- a/test/zdtm/static/deleted_dev.c +++ b/test/zdtm/static/deleted_dev.c @@ -8,9 +8,9 @@ #include "zdtmtst.h" -const char *test_doc = "Check that we can migrate with a device special file " - "open and unlinked before migration"; -const char *test_author = "Roman Kagan <rkagan@parallels.com>"; +const char *test_doc = "Check that we can migrate with a device special file " + "open and unlinked before migration"; +const char *test_author = "Roman Kagan <rkagan@parallels.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); @@ -51,10 +51,8 @@ int main(int argc, char **argv) if (st.st_mode != mode || st.st_rdev != dev) { fail("%s is no longer the device file we had", filename); - test_msg("mode %x want %x, dev %llx want %llx\n", - st.st_mode, mode, - (long long unsigned)st.st_rdev, - (long long unsigned)dev); + test_msg("mode %x want %x, dev %llx want %llx\n", st.st_mode, mode, (long long unsigned)st.st_rdev, + (long long unsigned)dev); goto out; } diff --git a/test/zdtm/static/deleted_unix_sock.c b/test/zdtm/static/deleted_unix_sock.c index b8856b6fd..342e6586f 100644 --- a/test/zdtm/static/deleted_unix_sock.c +++ b/test/zdtm/static/deleted_unix_sock.c @@ -9,10 +9,10 @@ #include "zdtmtst.h" -const char *test_doc = "Create a unix socket, and destroy it before " - "migration; check that the child can write to it " - "and the parent can read from it after migration"; -const char *test_author = "Roman Kagan <rkagan@parallels.com>"; +const char *test_doc = "Create a unix socket, and destroy it before " + "migration; check that the child can write to it " + "and the parent can read from it after migration"; +const char *test_author = "Roman Kagan <rkagan@parallels.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); @@ -31,7 +31,7 @@ static int setup_srv_sock(void) return -1; } - if (bind(sock, (struct sockaddr *) &name, SUN_LEN(&name)) < 0) { + if (bind(sock, (struct sockaddr *)&name, SUN_LEN(&name)) < 0) { pr_perror("can't bind to socket \"%s\"", filename); goto err; } @@ -59,7 +59,7 @@ static int setup_clnt_sock(void) if (sock < 0) return -1; - if (connect(sock, (struct sockaddr *) &name, SUN_LEN(&name)) < 0) + if (connect(sock, (struct sockaddr *)&name, SUN_LEN(&name)) < 0) goto err; return sock; @@ -68,7 +68,7 @@ err: return -1; } -int main(int argc, char ** argv) +int main(int argc, char **argv) { int sock, acc_sock, ret; pid_t pid; @@ -87,7 +87,7 @@ int main(int argc, char ** argv) exit(1); } - if (pid == 0) { /* child writes to the unlinked socket and returns */ + if (pid == 0) { /* child writes to the unlinked socket and returns */ close(sock); sock = setup_clnt_sock(); @@ -157,7 +157,6 @@ int main(int argc, char ** argv) goto out; } - if (close(sock)) { fail("close failed"); goto out; diff --git a/test/zdtm/static/different_creds.c b/test/zdtm/static/different_creds.c index 44a87c43d..34c5bc648 100644 --- a/test/zdtm/static/different_creds.c +++ b/test/zdtm/static/different_creds.c @@ -11,51 +11,51 @@ #include "zdtmtst.h" -const char *test_doc = "Check that threads with different creds aren't checkpointed"; -const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; +const char *test_doc = "Check that threads with different creds aren't checkpointed"; +const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; void *drop_caps_and_wait(void *arg) { - int fd = *((int *) arg), i; + int fd = *((int *)arg), i; void *retcode = (void *)0xdeadbeaf; cap_t caps; char c; typedef struct cap_set { - cap_flag_value_t val; - cap_flag_value_t new; - cap_flag_t flag; - cap_value_t bit; + cap_flag_value_t val; + cap_flag_value_t new; + cap_flag_t flag; + cap_value_t bit; } cap_set_t; cap_set_t src[] = { { - .val = CAP_CLEAR, - .flag = CAP_EFFECTIVE, - .bit = CAP_CHOWN, + .val = CAP_CLEAR, + .flag = CAP_EFFECTIVE, + .bit = CAP_CHOWN, }, { - .val = CAP_SET, - .flag = CAP_EFFECTIVE, - .bit = CAP_DAC_OVERRIDE, + .val = CAP_SET, + .flag = CAP_EFFECTIVE, + .bit = CAP_DAC_OVERRIDE, }, { - .val = CAP_CLEAR, - .flag = CAP_INHERITABLE, - .bit = CAP_SETPCAP, + .val = CAP_CLEAR, + .flag = CAP_INHERITABLE, + .bit = CAP_SETPCAP, }, { - .val = CAP_SET, - .flag = CAP_INHERITABLE, - .bit = CAP_NET_BIND_SERVICE, + .val = CAP_SET, + .flag = CAP_INHERITABLE, + .bit = CAP_NET_BIND_SERVICE, }, }; - caps = cap_get_proc(); - if (!caps) { - pr_perror("cap_get_proc"); - return NULL; - } + caps = cap_get_proc(); + if (!caps) { + pr_perror("cap_get_proc"); + return NULL; + } for (i = 0; i < ARRAY_SIZE(src); i++) { if (cap_set_flag(caps, src[i].flag, 1, &src[i].bit, src[i].val) < 0) { @@ -64,10 +64,10 @@ void *drop_caps_and_wait(void *arg) } } - if (cap_set_proc(caps) < 0) { - pr_perror("cap_set_proc"); - goto die; - } + if (cap_set_proc(caps) < 0) { + pr_perror("cap_set_proc"); + goto die; + } if (write(fd, "a", 1) != 1) { pr_perror("Unable to send a status"); @@ -93,11 +93,11 @@ void *drop_caps_and_wait(void *arg) retcode = NULL; die: - cap_free(caps); + cap_free(caps); return retcode; } -int main(int argc, char ** argv) +int main(int argc, char **argv) { int pipefd[2]; pthread_t thr; diff --git a/test/zdtm/static/dumpable01.c b/test/zdtm/static/dumpable01.c index e5dfc9ab7..73ca17073 100644 --- a/test/zdtm/static/dumpable01.c +++ b/test/zdtm/static/dumpable01.c @@ -5,7 +5,7 @@ #include "zdtmtst.h" -const char *test_doc = "Check dumpable flag handling (dumpable case)"; +const char *test_doc = "Check dumpable flag handling (dumpable case)"; const char *test_author = "Filipe Brandenburger <filbranden@google.com>"; int main(int argc, char **argv) diff --git a/test/zdtm/static/dumpable02.c b/test/zdtm/static/dumpable02.c index cbcd5ba66..6c7df45db 100644 --- a/test/zdtm/static/dumpable02.c +++ b/test/zdtm/static/dumpable02.c @@ -10,10 +10,11 @@ #include "zdtmtst.h" -const char *test_doc = "Check dumpable flag handling (non-dumpable case)"; +const char *test_doc = "Check dumpable flag handling (non-dumpable case)"; const char *test_author = "Filipe Brandenburger <filbranden@google.com>"; -int dumpable_server(void) { +int dumpable_server(void) +{ char buf[256]; int ret; @@ -27,7 +28,8 @@ int dumpable_server(void) { return 0; } -int get_dumpable_from_pipes(int pipe_input, int pipe_output) { +int get_dumpable_from_pipes(int pipe_input, int pipe_output) +{ char buf[256]; int len; long value; @@ -57,7 +59,6 @@ int get_dumpable_from_pipes(int pipe_input, int pipe_output) { return (int)value; } - int main(int argc, char **argv) { int pipe_input[2]; @@ -156,7 +157,8 @@ int main(int argc, char **argv) close(pipe_output[1]); save_dumpable = get_dumpable_from_pipes(pipe_input[1], pipe_output[0]); - if (save_dumpable < 0) return 1; + if (save_dumpable < 0) + return 1; #ifdef DEBUG test_msg("DEBUG: before dump: dumpable=%d\n", save_dumpable); #endif @@ -166,7 +168,8 @@ int main(int argc, char **argv) test_waitsig(); dumpable = get_dumpable_from_pipes(pipe_input[1], pipe_output[0]); - if (dumpable < 0) return 1; + if (dumpable < 0) + return 1; #ifdef DEBUG test_msg("DEBUG: after restore: dumpable=%d\n", dumpable); #endif @@ -188,18 +191,15 @@ int main(int argc, char **argv) } errno = 0; if (waited != pid) { - pr_err("waited pid %d did not match child pid %d\n", - waited, pid); + pr_err("waited pid %d did not match child pid %d\n", waited, pid); return 1; } if (!WIFEXITED(status)) { - pr_err("child dumpable server returned abnormally with status=%d\n", - status); + pr_err("child dumpable server returned abnormally with status=%d\n", status); return 1; } if (WEXITSTATUS(status) != 0) { - pr_err("child dumpable server returned rc=%d\n", - WEXITSTATUS(status)); + pr_err("child dumpable server returned rc=%d\n", WEXITSTATUS(status)); return 1; } diff --git a/test/zdtm/static/env00.c b/test/zdtm/static/env00.c index 5ee995b93..a966c0418 100644 --- a/test/zdtm/static/env00.c +++ b/test/zdtm/static/env00.c @@ -4,8 +4,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that environment didn't change"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check that environment didn't change"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; char *envname; TEST_OPTION(envname, string, "environment variable name", 1); diff --git a/test/zdtm/static/epoll.c b/test/zdtm/static/epoll.c index 5acb54094..6909935b9 100644 --- a/test/zdtm/static/epoll.c +++ b/test/zdtm/static/epoll.c @@ -19,10 +19,10 @@ #include "zdtmtst.h" -const char *test_doc = "Check for epoll"; -const char *test_author = "Andrei Vagin <avagin@openvz.org>"; +const char *test_doc = "Check for epoll"; +const char *test_author = "Andrei Vagin <avagin@openvz.org>"; -#define DUPFDNO 999 +#define DUPFDNO 999 int main(int argc, char *argv[]) { @@ -31,7 +31,7 @@ int main(int argc, char *argv[]) int i, ret; struct { - int pipefd[2]; + int pipefd[2]; } pipes[250]; test_init(argc, argv); @@ -108,8 +108,7 @@ int main(int argc, char *argv[]) return 1; } if (ev.data.u64 != i) { - pr_err("ev.fd=%d ev.data.u64=%#llx (%d expected)\n", - ev.data.fd, (long long)ev.data.u64, i); + pr_err("ev.fd=%d ev.data.u64=%#llx (%d expected)\n", ev.data.fd, (long long)ev.data.u64, i); ret |= 1; } @@ -118,8 +117,7 @@ int main(int argc, char *argv[]) return 1; } if (ev.data.u64 != i) { - pr_err("ev.fd=%d ev.data.u64=%#llx (%d expected)\n", - ev.data.fd, (long long)ev.data.u64, i); + pr_err("ev.fd=%d ev.data.u64=%#llx (%d expected)\n", ev.data.fd, (long long)ev.data.u64, i); ret |= 1; } diff --git a/test/zdtm/static/epoll01.c b/test/zdtm/static/epoll01.c index 23d536123..6701dbdff 100644 --- a/test/zdtm/static/epoll01.c +++ b/test/zdtm/static/epoll01.c @@ -19,12 +19,12 @@ #include "zdtmtst.h" -const char *test_doc = "Check another case of epoll: This adds three epoll " - "targets on tfd 702 and then adds two epoll targets " - "on tfd 701. This test is for off calculation in " - "dump_one_eventpoll, the reverse order makes qsort " - "to actually work."; -const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; +const char *test_doc = "Check another case of epoll: This adds three epoll " + "targets on tfd 702 and then adds two epoll targets " + "on tfd 701. This test is for off calculation in " + "dump_one_eventpoll, the reverse order makes qsort " + "to actually work."; +const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; int main(int argc, char *argv[]) { @@ -33,15 +33,11 @@ int main(int argc, char *argv[]) int i, ret; struct { - int pipefd[2]; - int dupfd; - bool close; + int pipefd[2]; + int dupfd; + bool close; } pipes[5] = { - { {}, 702, true }, - { {}, 702, true }, - { {}, 702, false }, - { {}, 701, true }, - { {}, 701, false }, + { {}, 702, true }, { {}, 702, true }, { {}, 702, false }, { {}, 701, true }, { {}, 701, false }, }; test_init(argc, argv); @@ -102,8 +98,7 @@ int main(int argc, char *argv[]) } if (ev.data.u64 != i) { - pr_err("ev.fd=%d ev.data.u64=%#llx (%d expected)\n", - ev.data.fd, (long long)ev.data.u64, i); + pr_err("ev.fd=%d ev.data.u64=%#llx (%d expected)\n", ev.data.fd, (long long)ev.data.u64, i); ret |= 1; } diff --git a/test/zdtm/static/eventfs00.c b/test/zdtm/static/eventfs00.c index 5278777ba..8934f8aca 100644 --- a/test/zdtm/static/eventfs00.c +++ b/test/zdtm/static/eventfs00.c @@ -21,14 +21,14 @@ #include "zdtmtst.h" #ifndef F_SETSIG -#define F_SETSIG 10 /* for sockets. */ -#define F_GETSIG 11 /* for sockets. */ +#define F_SETSIG 10 /* for sockets. */ +#define F_GETSIG 11 /* for sockets. */ #endif -const char *test_doc = "Check for eventfs"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; +const char *test_doc = "Check for eventfs"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; -#define EVENTFD_INITIAL 30 +#define EVENTFD_INITIAL 30 #define EVENTFD_FINAL 90 int main(int argc, char *argv[]) @@ -65,7 +65,7 @@ int main(int argc, char *argv[]) exit(1); } - test_msg("created eventfd with %"PRIu64"\n", v); + test_msg("created eventfd with %" PRIu64 "\n", v); ret = write(efd, &v, sizeof(v)); if (ret != sizeof(v)) { diff --git a/test/zdtm/static/fanotify00.c b/test/zdtm/static/fanotify00.c index 0251e46d4..69ead43e7 100644 --- a/test/zdtm/static/fanotify00.c +++ b/test/zdtm/static/fanotify00.c @@ -17,56 +17,56 @@ #include "zdtmtst.h" #ifdef __x86_64__ -# define __NR_fanotify_init 300 -# define __NR_fanotify_mark 301 +#define __NR_fanotify_init 300 +#define __NR_fanotify_mark 301 #elif defined(__PPC64__) -# define __NR_fanotify_init 323 -# define __NR_fanotify_mark 324 +#define __NR_fanotify_init 323 +#define __NR_fanotify_mark 324 #elif __aarch64__ -# define __NR_fanotify_init 262 -# define __NR_fanotify_mark 263 +#define __NR_fanotify_init 262 +#define __NR_fanotify_mark 263 #elif __s390x__ -# define __NR_fanotify_init 332 -# define __NR_fanotify_mark 333 +#define __NR_fanotify_init 332 +#define __NR_fanotify_mark 333 #else -# define __NR_fanotify_init 338 -# define __NR_fanotify_mark 339 +#define __NR_fanotify_init 338 +#define __NR_fanotify_mark 339 #endif -const char *test_doc = "Check for fanotify delivery"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; +const char *test_doc = "Check for fanotify delivery"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; const char fanotify_path[] = "fanotify-del-after-cr"; #define BUFF_SIZE (8192) struct fanotify_mark_inode { - unsigned long i_ino; - unsigned int s_dev; - unsigned int mflags; - unsigned int mask; - unsigned int ignored_mask; - unsigned int fhandle_bytes; - unsigned int fhandle_type; - unsigned char fhandle[512]; + unsigned long i_ino; + unsigned int s_dev; + unsigned int mflags; + unsigned int mask; + unsigned int ignored_mask; + unsigned int fhandle_bytes; + unsigned int fhandle_type; + unsigned char fhandle[512]; }; struct fanotify_mark_mount { - unsigned int mnt_id; - unsigned int mflags; - unsigned int mask; - unsigned int ignored_mask; + unsigned int mnt_id; + unsigned int mflags; + unsigned int mask; + unsigned int ignored_mask; }; struct fanotify_glob { - unsigned int faflags; - unsigned int evflags; + unsigned int faflags; + unsigned int evflags; }; struct fanotify_obj { - struct fanotify_glob glob; - struct fanotify_mark_inode inode; - struct fanotify_mark_mount mount; + struct fanotify_glob glob; + struct fanotify_mark_inode inode; + struct fanotify_mark_mount mount; }; static int fanotify_init(unsigned int flags, unsigned int event_f_flags) @@ -74,8 +74,7 @@ static int fanotify_init(unsigned int flags, unsigned int event_f_flags) return syscall(__NR_fanotify_init, flags, event_f_flags); } -static int fanotify_mark(int fanotify_fd, unsigned int flags, unsigned long mask, - int dfd, const char *pathname) +static int fanotify_mark(int fanotify_fd, unsigned int flags, unsigned long mask, int dfd, const char *pathname) { #ifdef __i386__ return syscall(__NR_fanotify_mark, fanotify_fd, flags, mask, 0, dfd, pathname); @@ -84,29 +83,25 @@ static int fanotify_mark(int fanotify_fd, unsigned int flags, unsigned long mask #endif } -#define fdinfo_field(str, field) !strncmp(str, field":", sizeof(field)) +#define fdinfo_field(str, field) !strncmp(str, field ":", sizeof(field)) static void show_fanotify_obj(struct fanotify_obj *obj) { test_msg("fanotify obj at %p\n", obj); test_msg(" glob\n"); - test_msg(" faflags: %x evflags: %x\n", - obj->glob.faflags, obj->glob.evflags); + test_msg(" faflags: %x evflags: %x\n", obj->glob.faflags, obj->glob.evflags); test_msg(" inode\n"); test_msg(" i_ino: %lx s_dev: %x mflags: %x " "mask: %x ignored_mask: %x " "fhandle_bytes: %x fhandle_type: %x " "fhandle: %s", - obj->inode.i_ino, obj->inode.s_dev, - obj->inode.mflags, obj->inode.mask, - obj->inode.ignored_mask, obj->inode.fhandle_bytes, - obj->inode.fhandle_type, obj->inode.fhandle); + obj->inode.i_ino, obj->inode.s_dev, obj->inode.mflags, obj->inode.mask, obj->inode.ignored_mask, + obj->inode.fhandle_bytes, obj->inode.fhandle_type, obj->inode.fhandle); test_msg(" mount\n"); - test_msg(" mnt_id: %x mflags: %x mask: %x ignored_mask: %x\n", - obj->mount.mnt_id, obj->mount.mflags, + test_msg(" mnt_id: %x mflags: %x mask: %x ignored_mask: %x\n", obj->mount.mnt_id, obj->mount.mflags, obj->mount.mask, obj->mount.ignored_mask); } @@ -129,20 +124,15 @@ static int cmp_fanotify_obj(struct fanotify_obj *old, struct fanotify_obj *new) * moreover the backend (say PLOOP) may be re-mounted during * c/r, so exclude them. */ - if ((old->glob.faflags != new->glob.faflags) || - (old->glob.evflags != new->glob.evflags) || - (old->inode.i_ino != new->inode.i_ino) || - (old->inode.mflags != new->inode.mflags) || - (old->inode.mask != new->inode.mask) || - (old->inode.ignored_mask != new->inode.ignored_mask)) + if ((old->glob.faflags != new->glob.faflags) || (old->glob.evflags != new->glob.evflags) || + (old->inode.i_ino != new->inode.i_ino) || (old->inode.mflags != new->inode.mflags) || + (old->inode.mask != new->inode.mask) || (old->inode.ignored_mask != new->inode.ignored_mask)) return -1; - if (memcmp(old->inode.fhandle, new->inode.fhandle, - sizeof(new->inode.fhandle))) + if (memcmp(old->inode.fhandle, new->inode.fhandle, sizeof(new->inode.fhandle))) return -2; - if ((old->mount.mflags != new->mount.mflags) || - (old->mount.mask != new->mount.mask) || + if ((old->mount.mflags != new->mount.mflags) || (old->mount.mask != new->mount.mask) || (old->mount.ignored_mask != new->mount.ignored_mask)) return -3; @@ -165,18 +155,15 @@ int parse_fanotify_fdinfo(int fd, struct fanotify_obj *obj, unsigned int expecte while (fgets(str, sizeof(str), f)) { if (fdinfo_field(str, "fanotify flags")) { - ret = sscanf(str, "fanotify flags:%x event-flags:%x", - &obj->glob.faflags, &obj->glob.evflags); + ret = sscanf(str, "fanotify flags:%x event-flags:%x", &obj->glob.faflags, &obj->glob.evflags); if (ret != 2) goto parse_err; met++; continue; } if (fdinfo_field(str, "fanotify mnt_id")) { - ret = sscanf(str, - "fanotify mnt_id:%x mflags:%x mask:%x ignored_mask:%x", - &obj->mount.mnt_id, &obj->mount.mflags, - &obj->mount.mask, &obj->mount.ignored_mask); + ret = sscanf(str, "fanotify mnt_id:%x mflags:%x mask:%x ignored_mask:%x", &obj->mount.mnt_id, + &obj->mount.mflags, &obj->mount.mask, &obj->mount.ignored_mask); if (ret != 4) goto parse_err; met++; @@ -187,9 +174,8 @@ int parse_fanotify_fdinfo(int fd, struct fanotify_obj *obj, unsigned int expecte ret = sscanf(str, "fanotify ino:%lx sdev:%x mflags:%x mask:%x ignored_mask:%x " "fhandle-bytes:%x fhandle-type:%x f_handle: %n", - &obj->inode.i_ino, &obj->inode.s_dev, - &obj->inode.mflags, &obj->inode.mask, &obj->inode.ignored_mask, - &obj->inode.fhandle_bytes, &obj->inode.fhandle_type, + &obj->inode.i_ino, &obj->inode.s_dev, &obj->inode.mflags, &obj->inode.mask, + &obj->inode.ignored_mask, &obj->inode.fhandle_bytes, &obj->inode.fhandle_type, &hoff); if (ret != 7) goto parse_err; @@ -200,8 +186,7 @@ int parse_fanotify_fdinfo(int fd, struct fanotify_obj *obj, unsigned int expecte } if (expected_to_meet != met) { - pr_perror("Expected to meet %d entries but got %d", - expected_to_meet, met); + pr_perror("Expected to meet %d entries but got %d", expected_to_meet, met); return -1; } @@ -212,9 +197,9 @@ parse_err: return -1; } -int main (int argc, char *argv[]) +int main(int argc, char *argv[]) { - struct fanotify_obj old = { }, new = { }; + struct fanotify_obj old = {}, new = {}; int fa_fd, fd, del_after; char buf[BUFF_SIZE]; ssize_t length; @@ -232,8 +217,7 @@ int main (int argc, char *argv[]) } } - fa_fd = fanotify_init(FAN_NONBLOCK | FAN_CLASS_NOTIF | FAN_UNLIMITED_QUEUE, - O_RDONLY | O_LARGEFILE); + fa_fd = fanotify_init(FAN_NONBLOCK | FAN_CLASS_NOTIF | FAN_UNLIMITED_QUEUE, O_RDONLY | O_LARGEFILE); if (fa_fd < 0) { pr_perror("fanotify_init failed"); exit(1); @@ -245,24 +229,19 @@ int main (int argc, char *argv[]) exit(1); } - if (fanotify_mark(fa_fd, FAN_MARK_ADD, - FAN_MODIFY | FAN_ACCESS | FAN_OPEN | FAN_CLOSE, - AT_FDCWD, fanotify_path)) { + if (fanotify_mark(fa_fd, FAN_MARK_ADD, FAN_MODIFY | FAN_ACCESS | FAN_OPEN | FAN_CLOSE, AT_FDCWD, + fanotify_path)) { pr_perror("fanotify_mark failed"); exit(1); } - if (fanotify_mark(fa_fd, FAN_MARK_ADD | FAN_MARK_MOUNT, - FAN_ONDIR | FAN_OPEN | FAN_CLOSE, - AT_FDCWD, "/tmp")) { + if (fanotify_mark(fa_fd, FAN_MARK_ADD | FAN_MARK_MOUNT, FAN_ONDIR | FAN_OPEN | FAN_CLOSE, AT_FDCWD, "/tmp")) { pr_perror("fanotify_mark failed"); exit(1); } - if (fanotify_mark(fa_fd, FAN_MARK_ADD | FAN_MARK_MOUNT | - FAN_MARK_IGNORED_MASK | FAN_MARK_IGNORED_SURV_MODIFY, - FAN_MODIFY | FAN_ACCESS, - AT_FDCWD, "/tmp")) { + if (fanotify_mark(fa_fd, FAN_MARK_ADD | FAN_MARK_MOUNT | FAN_MARK_IGNORED_MASK | FAN_MARK_IGNORED_SURV_MODIFY, + FAN_MODIFY | FAN_ACCESS, AT_FDCWD, "/tmp")) { pr_perror("fanotify_mark failed"); exit(1); } @@ -306,9 +285,8 @@ int main (int argc, char *argv[]) exit(1); } - if (fanotify_mark(fa_fd, FAN_MARK_REMOVE | FAN_MARK_MOUNT, - FAN_ONDIR | FAN_OPEN | FAN_CLOSE, - AT_FDCWD, "/tmp")) { + if (fanotify_mark(fa_fd, FAN_MARK_REMOVE | FAN_MARK_MOUNT, FAN_ONDIR | FAN_OPEN | FAN_CLOSE, AT_FDCWD, + "/tmp")) { pr_perror("fanotify_mark failed"); exit(1); } diff --git a/test/zdtm/static/fd.c b/test/zdtm/static/fd.c index bf27eaf44..9059114be 100644 --- a/test/zdtm/static/fd.c +++ b/test/zdtm/static/fd.c @@ -10,8 +10,8 @@ #include "zdtmtst.h" #include "lock.h" -const char *test_doc = "Check that criu closes up all its descriptors"; -const char *test_author = "Andrew Vagin <avagin@parallels.com>"; +const char *test_doc = "Check that criu closes up all its descriptors"; +const char *test_author = "Andrew Vagin <avagin@parallels.com>"; int main(int argc, char **argv) { @@ -38,7 +38,6 @@ int main(int argc, char **argv) } if (pid == 0) { - d = opendir("/proc/self/fd"); if (d == NULL) return 1; @@ -98,8 +97,7 @@ int main(int argc, char **argv) } if (status != 0) { - fail("%d:%d:%d:%d", WIFEXITED(status), WEXITSTATUS(status), - WIFSIGNALED(status), WTERMSIG(status)); + fail("%d:%d:%d:%d", WIFEXITED(status), WEXITSTATUS(status), WIFSIGNALED(status), WTERMSIG(status)); return 1; } diff --git a/test/zdtm/static/fd01.c b/test/zdtm/static/fd01.c index 4e7875110..3313ac4bd 100644 --- a/test/zdtm/static/fd01.c +++ b/test/zdtm/static/fd01.c @@ -14,8 +14,9 @@ #include "zdtmtst.h" #include "lock.h" -const char *test_doc = "Create file descriptors with different numbers. Check that they do not intersect with service fds"; -const char *test_author = "Kirill Tkhai <ktkhai@virtuozzo.com>"; +const char *test_doc = + "Create file descriptors with different numbers. Check that they do not intersect with service fds"; +const char *test_author = "Kirill Tkhai <ktkhai@virtuozzo.com>"; int main(int argc, char **argv) { @@ -28,7 +29,7 @@ int main(int argc, char **argv) test_init(argc, argv); - futex = mmap(NULL, sizeof(*futex), PROT_WRITE | PROT_READ, MAP_ANONYMOUS|MAP_SHARED, -1, 0); + futex = mmap(NULL, sizeof(*futex), PROT_WRITE | PROT_READ, MAP_ANONYMOUS | MAP_SHARED, -1, 0); if (futex == MAP_FAILED) { fail("mmap"); exit(1); @@ -68,7 +69,6 @@ int main(int argc, char **argv) exit(1); } - for (i = 1; (fd = (1 << i)) < (rlim.rlim_cur >> 1); i++) { FILE *fp = tmpfile(); if (!fp) { diff --git a/test/zdtm/static/fdt_shared.c b/test/zdtm/static/fdt_shared.c index 6ccd25487..1a0d04ac7 100644 --- a/test/zdtm/static/fdt_shared.c +++ b/test/zdtm/static/fdt_shared.c @@ -9,14 +9,14 @@ #include "zdtmtst.h" -const char *test_doc = "Check a shared file descriptor table."; -const char *test_author = "Andrew Vagin <avagin@openvz.org>"; +const char *test_doc = "Check a shared file descriptor table."; +const char *test_author = "Andrew Vagin <avagin@openvz.org>"; char *filename; TEST_OPTION(filename, string, "file name", 1); -#define STACK_SIZE 4096 -#define TEST_FD 128 +#define STACK_SIZE 4096 +#define TEST_FD 128 #define TEST_STRING "Hello World!" #define CHILDREN 4 @@ -50,8 +50,7 @@ static pid_t clone_child(int (*fn)(void *), int flags) char stack[STACK_SIZE] __stack_aligned__; pid_t pid; - pid = clone(fn, stack + STACK_SIZE, - flags | SIGCHLD, NULL); + pid = clone(fn, stack + STACK_SIZE, flags | SIGCHLD, NULL); if (pid == -1) { pr_perror("Unable to clone a new process"); return -1; @@ -134,7 +133,7 @@ static int child(void *_arg) return 0; } -int main(int argc, char ** argv) +int main(int argc, char **argv) { int status; pid_t pid, pid2; diff --git a/test/zdtm/static/fifo-ghost.c b/test/zdtm/static/fifo-ghost.c index f5e11cfa2..cfe28111b 100644 --- a/test/zdtm/static/fifo-ghost.c +++ b/test/zdtm/static/fifo-ghost.c @@ -7,8 +7,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that a ghost fifo with data restored"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; +const char *test_doc = "Check that a ghost fifo with data restored"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; char *filename; TEST_OPTION(filename, string, "file name", 1); diff --git a/test/zdtm/static/fifo-rowo-pair.c b/test/zdtm/static/fifo-rowo-pair.c index 239634381..54054961b 100644 --- a/test/zdtm/static/fifo-rowo-pair.c +++ b/test/zdtm/static/fifo-rowo-pair.c @@ -15,9 +15,9 @@ #include "zdtmtst.h" -const char *test_doc = "Test for fifo ro/wo with " - "fake fifo needed on criu side"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; +const char *test_doc = "Test for fifo ro/wo with " + "fake fifo needed on criu side"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; char *name_master; TEST_OPTION(name_master, string, "master fifo name", 1); @@ -25,13 +25,15 @@ TEST_OPTION(name_master, string, "master fifo name", 1); char *name_slave; TEST_OPTION(name_slave, string, "slave fifo name", 1); -#define TEST_VALUE (00100) +#define TEST_VALUE (00100) -#define exit_shot(pid, code) \ - do { kill(pid, SIGKILL); exit(code); } while (0) +#define exit_shot(pid, code) \ + do { \ + kill(pid, SIGKILL); \ + exit(code); \ + } while (0) -#define exit_shot_parent(code) \ - exit_shot(getppid(), 1) +#define exit_shot_parent(code) exit_shot(getppid(), 1) int main(int argc, char **argv) { diff --git a/test/zdtm/static/fifo.c b/test/zdtm/static/fifo.c index 91a116619..8c627a7cf 100644 --- a/test/zdtm/static/fifo.c +++ b/test/zdtm/static/fifo.c @@ -7,9 +7,9 @@ #include "zdtmtst.h" -const char *test_doc = "Check that we can migrate with a named pipe " - "open"; -const char *test_author = "Roman Kagan <rkagan@parallels.com>"; +const char *test_doc = "Check that we can migrate with a named pipe " + "open"; +const char *test_author = "Roman Kagan <rkagan@parallels.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); diff --git a/test/zdtm/static/fifo_ro.c b/test/zdtm/static/fifo_ro.c index d0d2cc48e..24a12f842 100644 --- a/test/zdtm/static/fifo_ro.c +++ b/test/zdtm/static/fifo_ro.c @@ -7,8 +7,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that a fifo read-only descriptor is restored with data"; -const char *test_author = "Andrew Vagin <avagin@openvz.org>"; +const char *test_doc = "Check that a fifo read-only descriptor is restored with data"; +const char *test_author = "Andrew Vagin <avagin@openvz.org>"; char *filename; TEST_OPTION(filename, string, "file name", 1); diff --git a/test/zdtm/static/fifo_upon_unix_socket00.c b/test/zdtm/static/fifo_upon_unix_socket00.c index f75965fdd..0ef68bb66 100644 --- a/test/zdtm/static/fifo_upon_unix_socket00.c +++ b/test/zdtm/static/fifo_upon_unix_socket00.c @@ -11,8 +11,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that fifo upon ghost socket configuration is restored"; -const char *test_author = "Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>"; +const char *test_doc = "Check that fifo upon ghost socket configuration is restored"; +const char *test_author = "Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>"; char *filename; TEST_OPTION(filename, string, "socket name", 1); @@ -24,8 +24,7 @@ static int fill_sock_name(struct sockaddr_un *name, const char *filename) cwd = get_current_dir_name(); if (strlen(filename) + strlen(cwd) + 1 >= sizeof(name->sun_path)) { - pr_err("Name %s/%s is too long for socket\n", - cwd, filename); + pr_err("Name %s/%s is too long for socket\n", cwd, filename); return -1; } diff --git a/test/zdtm/static/fifo_wronly.c b/test/zdtm/static/fifo_wronly.c index 64502e187..1083549cb 100644 --- a/test/zdtm/static/fifo_wronly.c +++ b/test/zdtm/static/fifo_wronly.c @@ -10,8 +10,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that we can migrate with a named pipe, " - "opened in WRONLY mode"; +const char *test_doc = "Check that we can migrate with a named pipe, " + "opened in WRONLY mode"; #define BUF_SIZE 256 char *filename; TEST_OPTION(filename, string, "file name", 1); @@ -66,7 +66,6 @@ int main(int argc, char **argv) } } else { - fd = open(filename, O_WRONLY); if (fd < 0) { pr_perror("open(%s, O_WRONLY) Failed", filename); @@ -87,8 +86,7 @@ int main(int argc, char **argv) wait(&chret); chret = WEXITSTATUS(chret); if (chret) { - fail("child exited with non-zero code %d (%s)", - chret, strerror(chret)); + fail("child exited with non-zero code %d (%s)", chret, strerror(chret)); return 1; } diff --git a/test/zdtm/static/file_append.c b/test/zdtm/static/file_append.c index 14f18776c..aa93ae186 100644 --- a/test/zdtm/static/file_append.c +++ b/test/zdtm/static/file_append.c @@ -9,8 +9,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check O_APPEND preserved"; -const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; +const char *test_doc = "Check O_APPEND preserved"; +const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); diff --git a/test/zdtm/static/file_attr.c b/test/zdtm/static/file_attr.c index 752c094bf..f8b3d846e 100644 --- a/test/zdtm/static/file_attr.c +++ b/test/zdtm/static/file_attr.c @@ -9,24 +9,27 @@ #include "zdtmtst.h" -const char *test_doc = "Check that attributes and content of an open, " - "written to, and then unlinked file migrate " - "correctly"; -const char *test_author = "Roman Kagan <rkagan@parallels.com>"; +const char *test_doc = "Check that attributes and content of an open, " + "written to, and then unlinked file migrate " + "correctly"; +const char *test_author = "Roman Kagan <rkagan@parallels.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); -#define DEF_PERMS 06604 /* -rwS--Sr--, really esoteric one */ +#define DEF_PERMS 06604 /* -rwS--Sr--, really esoteric one */ unsigned int perms = DEF_PERMS; -TEST_OPTION(perms, uint, "permissions to set on file " - "(default " __stringify(DEF_PERMS) ")", 0); -#define DEF_MTIME 123456 /* another really esoteric one */ +TEST_OPTION(perms, uint, + "permissions to set on file " + "(default " __stringify(DEF_PERMS) ")", + 0); +#define DEF_MTIME 123456 /* another really esoteric one */ unsigned int mtime = DEF_MTIME; -TEST_OPTION(mtime, uint, "mtime to set on file " - "(default " __stringify(DEF_MTIME) ")", 0); +TEST_OPTION(mtime, uint, + "mtime to set on file " + "(default " __stringify(DEF_MTIME) ")", + 0); - -int main(int argc, char ** argv) +int main(int argc, char **argv) { int fd; struct utimbuf ut; @@ -49,7 +52,7 @@ int main(int argc, char ** argv) exit(1); } - ut = (struct utimbuf) { + ut = (struct utimbuf){ .actime = 0, .modtime = mtime, }; diff --git a/test/zdtm/static/file_cloexec.c b/test/zdtm/static/file_cloexec.c index b8eba39e5..6def8174a 100644 --- a/test/zdtm/static/file_cloexec.c +++ b/test/zdtm/static/file_cloexec.c @@ -10,10 +10,14 @@ #include "zdtmtst.h" -const char *test_doc = "Check FD_CLOEXEC flag"; -const char *test_author = "Nicolas Viennot <Nicolas.Viennot@twosigma.com>"; +const char *test_doc = "Check FD_CLOEXEC flag"; +const char *test_author = "Nicolas Viennot <Nicolas.Viennot@twosigma.com>"; -#define err(exitcode, msg, ...) ({ pr_perror(msg, ##__VA_ARGS__); exit(exitcode); }) +#define err(exitcode, msg, ...) \ + ({ \ + pr_perror(msg, ##__VA_ARGS__); \ + exit(exitcode); \ + }) static void assert_fd_flags(int fd, int mask, int value) { diff --git a/test/zdtm/static/file_fown.c b/test/zdtm/static/file_fown.c index af20a3174..eb42a826e 100644 --- a/test/zdtm/static/file_fown.c +++ b/test/zdtm/static/file_fown.c @@ -15,19 +15,19 @@ #include "zdtmtst.h" #ifndef F_SETSIG -#define F_SETSIG 10 /* for sockets. */ -#define F_GETSIG 11 /* for sockets. */ +#define F_SETSIG 10 /* for sockets. */ +#define F_GETSIG 11 /* for sockets. */ #endif -const char *test_doc = "Check for signal delivery on file owners"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; +const char *test_doc = "Check for signal delivery on file owners"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; struct params { - int sigio; - int pipe_flags[2]; - int pipe_pid[2]; - int pipe_sig[2]; -} *shared; + int sigio; + int pipe_flags[2]; + int pipe_pid[2]; + int pipe_sig[2]; +} * shared; static void signal_handler_io(int status) { @@ -55,18 +55,15 @@ static int cmp_pipe_params(struct params *p1, struct params *p2) for (i = 0; i < 2; i++) { if (p1->pipe_flags[i] != p2->pipe_flags[i]) { - fail("pipe flags failed [%d] expected %08o got %08o", - i, p1->pipe_flags[i], p2->pipe_flags[i]); + fail("pipe flags failed [%d] expected %08o got %08o", i, p1->pipe_flags[i], p2->pipe_flags[i]); return -1; } if (p1->pipe_pid[i] != p2->pipe_pid[i]) { - fail("pipe pid failed [%d] expected %d got %d", - i, p1->pipe_pid[i], p2->pipe_pid[i]); + fail("pipe pid failed [%d] expected %d got %d", i, p1->pipe_pid[i], p2->pipe_pid[i]); return -1; } if (p1->pipe_sig[i] != p2->pipe_sig[i]) { - fail("pipe sig failed [%d] expected %d got %d", - i, p1->pipe_sig[i], p2->pipe_sig[i]); + fail("pipe sig failed [%d] expected %d got %d", i, p1->pipe_sig[i], p2->pipe_sig[i]); return -1; } } @@ -76,8 +73,8 @@ static int cmp_pipe_params(struct params *p1, struct params *p2) int main(int argc, char *argv[]) { - struct sigaction saio = { }; - struct params obtained = { }; + struct sigaction saio = {}; + struct params obtained = {}; uid_t ruid, euid, suid; int status, pipes[2]; pid_t pid; @@ -100,8 +97,8 @@ int main(int argc, char *argv[]) exit(1); } - saio.sa_handler = (sig_t)signal_handler_io; - saio.sa_flags = SA_RESTART; + saio.sa_handler = (sig_t)signal_handler_io; + saio.sa_flags = SA_RESTART; if (sigaction(SIGIO, &saio, 0)) { fail("sigaction failed"); exit(1); @@ -112,11 +109,9 @@ int main(int argc, char *argv[]) exit(1); } - if (fcntl(pipes[0], F_SETOWN, getpid()) || - fcntl(pipes[1], F_SETOWN, getpid()) || - fcntl(pipes[0], F_SETSIG, SIGIO) || - fcntl(pipes[1], F_SETSIG, SIGIO) || - fcntl(pipes[0], F_SETFL, fcntl(pipes[0], F_GETFL) | O_ASYNC) || + if (fcntl(pipes[0], F_SETOWN, getpid()) || fcntl(pipes[1], F_SETOWN, getpid()) || + fcntl(pipes[0], F_SETSIG, SIGIO) || fcntl(pipes[1], F_SETSIG, SIGIO) || + fcntl(pipes[0], F_SETFL, fcntl(pipes[0], F_GETFL) | O_ASYNC) || fcntl(pipes[1], F_SETFL, fcntl(pipes[1], F_GETFL) | O_ASYNC)) { fail("fcntl failed"); exit(1); @@ -136,7 +131,7 @@ int main(int argc, char *argv[]) } if (pid == 0) { - struct params p = { }; + struct params p = {}; test_waitsig(); diff --git a/test/zdtm/static/file_lease00.c b/test/zdtm/static/file_lease00.c index 3fd1a0d88..067d8d6ba 100644 --- a/test/zdtm/static/file_lease00.c +++ b/test/zdtm/static/file_lease00.c @@ -62,8 +62,7 @@ int main(int argc, char **argv) pr_err("Can't open files\n"); return -1; } - if (fcntl(fd_rd, F_SETLEASE, F_RDLCK) < 0 || - fcntl(fd_wr, F_SETLEASE, F_WRLCK) < 0) { + if (fcntl(fd_rd, F_SETLEASE, F_RDLCK) < 0 || fcntl(fd_wr, F_SETLEASE, F_WRLCK) < 0) { pr_perror("Can't set leases"); close_files(fd_rd, fd_wr); return -1; diff --git a/test/zdtm/static/file_lease01.c b/test/zdtm/static/file_lease01.c index 6f3dfe60f..bbb2acf34 100644 --- a/test/zdtm/static/file_lease01.c +++ b/test/zdtm/static/file_lease01.c @@ -3,9 +3,9 @@ #include "zdtmtst.h" -#define FD_COUNT 3 -#define FD_LEASED1 0 -#define FD_LEASED2 2 +#define FD_COUNT 3 +#define FD_LEASED1 0 +#define FD_LEASED2 2 #define FD_LEASE_FREE 1 const char *test_doc = "Check that extra leases are not set after c/r"; @@ -63,8 +63,7 @@ int main(int argc, char **argv) return -1; } - if (fcntl(fds[FD_LEASED1], F_SETLEASE, F_RDLCK) < 0 || - fcntl(fds[FD_LEASED2], F_SETLEASE, F_RDLCK) < 0) { + if (fcntl(fds[FD_LEASED1], F_SETLEASE, F_RDLCK) < 0 || fcntl(fds[FD_LEASED2], F_SETLEASE, F_RDLCK) < 0) { pr_err("Can't set leases\n"); close_files(fds); return -1; @@ -85,4 +84,3 @@ int main(int argc, char **argv) close_files(fds); return 0; } - diff --git a/test/zdtm/static/file_lease02.c b/test/zdtm/static/file_lease02.c index 87c56cfd1..c1d3c4594 100644 --- a/test/zdtm/static/file_lease02.c +++ b/test/zdtm/static/file_lease02.c @@ -5,7 +5,7 @@ #include "zdtmtst.h" -#define FD_COUNT 3 +#define FD_COUNT 3 #define BREAK_SIGNUM SIGIO const char *test_doc = "Check c/r of breaking leases"; @@ -111,9 +111,7 @@ int main(int argc, char **argv) act.sa_sigaction = break_sigaction; act.sa_flags = SA_SIGINFO; - if (sigemptyset(&act.sa_mask) || - sigaddset(&act.sa_mask, BREAK_SIGNUM) || - sigaction(BREAK_SIGNUM, &act, NULL)) { + if (sigemptyset(&act.sa_mask) || sigaddset(&act.sa_mask, BREAK_SIGNUM) || sigaction(BREAK_SIGNUM, &act, NULL)) { pr_perror("Can't set signal action"); fail(); return -1; @@ -132,9 +130,8 @@ int main(int argc, char **argv) ret = 0; if (sigaction_error) fail("Ghost signal"); - else if (check_lease_type(fds[0], F_UNLCK) || - check_lease_type(fds[1], F_RDLCK) || - check_lease_type(fds[2], F_UNLCK)) + else if (check_lease_type(fds[0], F_UNLCK) || check_lease_type(fds[1], F_RDLCK) || + check_lease_type(fds[2], F_UNLCK)) fail("Lease type doesn't match"); else pass(); @@ -142,4 +139,3 @@ done: close_files(fds); return ret; } - diff --git a/test/zdtm/static/file_lease03.c b/test/zdtm/static/file_lease03.c index 799c1b1f1..b313c5156 100644 --- a/test/zdtm/static/file_lease03.c +++ b/test/zdtm/static/file_lease03.c @@ -89,9 +89,7 @@ int main(int argc, char **argv) act.sa_sigaction = break_sigaction; act.sa_flags = SA_SIGINFO; - if (sigemptyset(&act.sa_mask) || - sigaddset(&act.sa_mask, BREAK_SIGNUM) || - sigaction(BREAK_SIGNUM, &act, NULL)) { + if (sigemptyset(&act.sa_mask) || sigaddset(&act.sa_mask, BREAK_SIGNUM) || sigaction(BREAK_SIGNUM, &act, NULL)) { pr_perror("Can't set signal action"); return -1; } @@ -143,4 +141,3 @@ done: unlink(filename); return ret; } - diff --git a/test/zdtm/static/file_lease04.c b/test/zdtm/static/file_lease04.c index 4ad9af84f..1c46c24c9 100644 --- a/test/zdtm/static/file_lease04.c +++ b/test/zdtm/static/file_lease04.c @@ -89,9 +89,7 @@ int main(int argc, char **argv) act.sa_sigaction = break_sigaction; act.sa_flags = SA_SIGINFO; - if (sigemptyset(&act.sa_mask) || - sigaddset(&act.sa_mask, BREAK_SIGNUM) || - sigaction(BREAK_SIGNUM, &act, NULL)) { + if (sigemptyset(&act.sa_mask) || sigaddset(&act.sa_mask, BREAK_SIGNUM) || sigaction(BREAK_SIGNUM, &act, NULL)) { pr_perror("Can't set signal action"); return -1; } @@ -129,4 +127,3 @@ done: unlink(filename); return ret; } - diff --git a/test/zdtm/static/file_locks00.c b/test/zdtm/static/file_locks00.c index fa98a31b3..0b5d1313b 100644 --- a/test/zdtm/static/file_locks00.c +++ b/test/zdtm/static/file_locks00.c @@ -10,8 +10,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that posix flocks are restored"; -const char *test_author = "Qiang Huang <h.huangqiang@huawei.com>"; +const char *test_doc = "Check that posix flocks are restored"; +const char *test_author = "Qiang Huang <h.huangqiang@huawei.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); @@ -19,35 +19,32 @@ TEST_OPTION(filename, string, "file name", 1); char file0[PATH_MAX]; char file1[PATH_MAX]; -static int lock_reg(int fd, int cmd, int type, int whence, - off_t offset, off_t len) +static int lock_reg(int fd, int cmd, int type, int whence, off_t offset, off_t len) { struct flock lock; - lock.l_type = type; /* F_RDLCK, F_WRLCK, F_UNLCK */ - lock.l_whence = whence; /* SEEK_SET, SEEK_CUR, SEEK_END */ - lock.l_start = offset; /* byte offset, relative to l_whence */ - lock.l_len = len; /* #bytes (0 means to EOF) */ + lock.l_type = type; /* F_RDLCK, F_WRLCK, F_UNLCK */ + lock.l_whence = whence; /* SEEK_SET, SEEK_CUR, SEEK_END */ + lock.l_start = offset; /* byte offset, relative to l_whence */ + lock.l_len = len; /* #bytes (0 means to EOF) */ errno = 0; return fcntl(fd, cmd, &lock); } -#define set_read_lock(fd, whence, offset, len) \ - lock_reg(fd, F_SETLK, F_RDLCK, whence, offset, len) -#define set_write_lock(fd, whence, offset, len) \ - lock_reg(fd, F_SETLK, F_WRLCK, whence, offset, len) +#define set_read_lock(fd, whence, offset, len) lock_reg(fd, F_SETLK, F_RDLCK, whence, offset, len) +#define set_write_lock(fd, whence, offset, len) lock_reg(fd, F_SETLK, F_WRLCK, whence, offset, len) static int check_read_lock(int fd, int whence, off_t offset, off_t len) { struct flock lock; int ret; - lock.l_type = F_RDLCK; /* F_RDLCK, F_WRLCK, F_UNLCK */ - lock.l_whence = whence; /* SEEK_SET, SEEK_CUR, SEEK_END */ - lock.l_start = offset; /* byte offset, relative to l_whence */ - lock.l_len = len; /* #bytes (0 means to EOF) */ - lock.l_pid = -1; + lock.l_type = F_RDLCK; /* F_RDLCK, F_WRLCK, F_UNLCK */ + lock.l_whence = whence; /* SEEK_SET, SEEK_CUR, SEEK_END */ + lock.l_start = offset; /* byte offset, relative to l_whence */ + lock.l_len = len; /* #bytes (0 means to EOF) */ + lock.l_pid = -1; errno = 0; ret = fcntl(fd, F_GETLK, &lock); @@ -72,11 +69,11 @@ static int check_write_lock(int fd, int whence, off_t offset, off_t len) int ret; pid_t ppid = getppid(); - lock.l_type = F_WRLCK; /* F_RDLCK, F_WRLCK, F_UNLCK */ - lock.l_whence = whence; /* SEEK_SET, SEEK_CUR, SEEK_END */ - lock.l_start = offset; /* byte offset, relative to l_whence */ - lock.l_len = len; /* #bytes (0 means to EOF) */ - lock.l_pid = -1; + lock.l_type = F_WRLCK; /* F_RDLCK, F_WRLCK, F_UNLCK */ + lock.l_whence = whence; /* SEEK_SET, SEEK_CUR, SEEK_END */ + lock.l_start = offset; /* byte offset, relative to l_whence */ + lock.l_len = len; /* #bytes (0 means to EOF) */ + lock.l_pid = -1; errno = 0; ret = fcntl(fd, F_GETLK, &lock); @@ -157,7 +154,7 @@ int main(int argc, char **argv) return -1; } - if (pid == 0) { /* child will check father's file locks */ + if (pid == 0) { /* child will check father's file locks */ test_waitsig(); if (check_file_locks()) { diff --git a/test/zdtm/static/file_locks01.c b/test/zdtm/static/file_locks01.c index a57a5b61b..6c2e54ff4 100644 --- a/test/zdtm/static/file_locks01.c +++ b/test/zdtm/static/file_locks01.c @@ -18,8 +18,8 @@ #define LOCK_READ 64 #endif -const char *test_doc = "Check that flock locks are restored"; -const char *test_author = "Qiang Huang <h.huangqiang@huawei.com>"; +const char *test_doc = "Check that flock locks are restored"; +const char *test_author = "Qiang Huang <h.huangqiang@huawei.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); @@ -78,9 +78,7 @@ static int open_all_files(int *fd_0, int *fd_1, int *fd_2) return 0; } -static int check_file_lock(int fd, char *expected_type, - char *expected_option, - unsigned int expected_dev, +static int check_file_lock(int fd, char *expected_type, char *expected_option, unsigned int expected_dev, unsigned long expected_ino) { char buf[100], fl_flag[16], fl_type[16], fl_option[16]; @@ -90,8 +88,8 @@ static int check_file_lock(int fd, char *expected_type, unsigned long i_no; int maj, min; - test_msg("check_file_lock: (fsname %s) expecting fd %d type %s option %s dev %u ino %lu\n", - m->fsname, fd, expected_type, expected_option, expected_dev, expected_ino); + test_msg("check_file_lock: (fsname %s) expecting fd %d type %s option %s dev %u ino %lu\n", m->fsname, fd, + expected_type, expected_option, expected_dev, expected_ino); snprintf(path, sizeof(path), "/proc/self/fdinfo/%d", fd); fp_locks = fopen(path, "r"); @@ -109,9 +107,8 @@ static int check_file_lock(int fd, char *expected_type, memset(fl_type, 0, sizeof(fl_type)); memset(fl_option, 0, sizeof(fl_option)); - num = sscanf(buf, "%*s %*d:%s %s %s %d %x:%x:%ld %*d %*s", - fl_flag, fl_type, fl_option, &fl_owner, - &maj, &min, &i_no); + num = sscanf(buf, "%*s %*d:%s %s %s %d %x:%x:%ld %*d %*s", fl_flag, fl_type, fl_option, &fl_owner, &maj, + &min, &i_no); if (num < 7) { pr_err("Invalid lock info\n"); break; diff --git a/test/zdtm/static/file_locks02.c b/test/zdtm/static/file_locks02.c index 91d13854a..d2049ebaa 100644 --- a/test/zdtm/static/file_locks02.c +++ b/test/zdtm/static/file_locks02.c @@ -9,22 +9,21 @@ #include "zdtmtst.h" -const char *test_doc = "Check that 'shared' flocks work"; -const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; +const char *test_doc = "Check that 'shared' flocks work"; +const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); -static int check_file_lock(pid_t pid, pid_t child, int fd, char *expected_type, - char *expected_option) +static int check_file_lock(pid_t pid, pid_t child, int fd, char *expected_type, char *expected_option) { char buf[100], fl_flag[16], fl_type[16], fl_option[16]; int found = 0, num, fl_owner; FILE *fp_locks = NULL; char path[PATH_MAX]; - test_msg("check_file_lock: (pid %d child %d) expecting fd %d type %s option %s\n", - pid, child, fd, expected_type, expected_option); + test_msg("check_file_lock: (pid %d child %d) expecting fd %d type %s option %s\n", pid, child, fd, + expected_type, expected_option); snprintf(path, sizeof(path), "/proc/self/fdinfo/%d", fd); fp_locks = fopen(path, "r"); @@ -42,8 +41,7 @@ static int check_file_lock(pid_t pid, pid_t child, int fd, char *expected_type, memset(fl_type, 0, sizeof(fl_type)); memset(fl_option, 0, sizeof(fl_option)); - num = sscanf(buf, "%*s %*d:%s %s %s %d", - fl_flag, fl_type, fl_option, &fl_owner); + num = sscanf(buf, "%*s %*d:%s %s %s %d", fl_flag, fl_type, fl_option, &fl_owner); if (num < 4) { pr_perror("Invalid lock info."); break; diff --git a/test/zdtm/static/file_locks03.c b/test/zdtm/static/file_locks03.c index 19c11dbb6..35ef41a21 100644 --- a/test/zdtm/static/file_locks03.c +++ b/test/zdtm/static/file_locks03.c @@ -9,22 +9,21 @@ #include "zdtmtst.h" -const char *test_doc = "Check that 'inherited' flocks work"; -const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; +const char *test_doc = "Check that 'inherited' flocks work"; +const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); -static int check_file_lock(pid_t pid, pid_t child, int fd, char *expected_type, - char *expected_option) +static int check_file_lock(pid_t pid, pid_t child, int fd, char *expected_type, char *expected_option) { char buf[100], fl_flag[16], fl_type[16], fl_option[16]; int found = 0, num, fl_owner; FILE *fp_locks = NULL; char path[PATH_MAX]; - test_msg("check_file_lock: (pid %d child %d) expecting fd %d type %s option %s\n", - pid, child, fd, expected_type, expected_option); + test_msg("check_file_lock: (pid %d child %d) expecting fd %d type %s option %s\n", pid, child, fd, + expected_type, expected_option); snprintf(path, sizeof(path), "/proc/%d/fdinfo/%d", child, fd); fp_locks = fopen(path, "r"); @@ -42,8 +41,7 @@ static int check_file_lock(pid_t pid, pid_t child, int fd, char *expected_type, memset(fl_type, 0, sizeof(fl_type)); memset(fl_option, 0, sizeof(fl_option)); - num = sscanf(buf, "%*s %*d:%s %s %s %d", - fl_flag, fl_type, fl_option, &fl_owner); + num = sscanf(buf, "%*s %*d:%s %s %s %d", fl_flag, fl_type, fl_option, &fl_owner); if (num < 4) { pr_perror("Invalid lock info."); break; diff --git a/test/zdtm/static/file_locks04.c b/test/zdtm/static/file_locks04.c index 96170d51e..11d224fa7 100644 --- a/test/zdtm/static/file_locks04.c +++ b/test/zdtm/static/file_locks04.c @@ -9,18 +9,18 @@ #include "zdtmtst.h" -const char *test_doc = "Check that 'overlapping' flocks work"; -const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; +const char *test_doc = "Check that 'overlapping' flocks work"; +const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); static int check_file_locks(pid_t child_pid, int fd, int child_fd) { - char path[PATH_MAX]; - FILE *fp_locks = NULL; - char buf[100], fl_flag[16], fl_type[16], fl_option[16]; - int found = 0, num, fl_owner; + char path[PATH_MAX]; + FILE *fp_locks = NULL; + char buf[100], fl_flag[16], fl_type[16], fl_option[16]; + int found = 0, num, fl_owner; sprintf(path, "/proc/%d/fdinfo/%d", child_pid, child_fd); fp_locks = fopen(path, "r"); @@ -34,9 +34,8 @@ static int check_file_locks(pid_t child_pid, int fd, int child_fd) continue; test_msg("c: %s", buf); - num = sscanf(buf, - "%*s %*d:%s %s %s %d %*02x:%*02x:%*d %*d %*s", - fl_flag, fl_type, fl_option, &fl_owner); + num = sscanf(buf, "%*s %*d:%s %s %s %d %*02x:%*02x:%*d %*d %*s", fl_flag, fl_type, fl_option, + &fl_owner); if (num < 4) { pr_perror("Invalid lock info."); @@ -48,9 +47,7 @@ static int check_file_locks(pid_t child_pid, int fd, int child_fd) continue; } - if (!strcmp(fl_flag, "FLOCK") && - !strcmp(fl_type, "ADVISORY") && - !strcmp(fl_option, "WRITE")) + if (!strcmp(fl_flag, "FLOCK") && !strcmp(fl_type, "ADVISORY") && !strcmp(fl_option, "WRITE")) found++; memset(fl_flag, 0, sizeof(fl_flag)); diff --git a/test/zdtm/static/file_locks05.c b/test/zdtm/static/file_locks05.c index e9e56acfe..1972617d5 100644 --- a/test/zdtm/static/file_locks05.c +++ b/test/zdtm/static/file_locks05.c @@ -8,8 +8,8 @@ #include "zdtmtst.h" -const char *test_doc = "Sanity check for criu lock-test quirk"; -const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; +const char *test_doc = "Sanity check for criu lock-test quirk"; +const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); diff --git a/test/zdtm/static/file_locks06.c b/test/zdtm/static/file_locks06.c index 2fb0080c4..ce80113db 100644 --- a/test/zdtm/static/file_locks06.c +++ b/test/zdtm/static/file_locks06.c @@ -5,13 +5,12 @@ #include "ofd_file_locks.h" #include "zdtmtst.h" -const char *test_doc = "Check that OFD lock for the whole file is restored"; +const char *test_doc = "Check that OFD lock for the whole file is restored"; const char *test_author = "Begunkov Pavel <asml.silence@gmail.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); - int init_lock(int *fd, struct flock *lck) { *fd = open(filename, O_RDWR | O_CREAT, 0666); @@ -54,8 +53,7 @@ int main(int argc, char **argv) test_daemon(); test_waitsig(); - if (check_file_lock_restored(getpid(), fd, &lck) || - check_lock_exists(filename, &lck) < 0) + if (check_file_lock_restored(getpid(), fd, &lck) || check_lock_exists(filename, &lck) < 0) fail("OFD file locks check failed"); else pass(); diff --git a/test/zdtm/static/file_locks07.c b/test/zdtm/static/file_locks07.c index 155c1a4a7..0838e35ef 100644 --- a/test/zdtm/static/file_locks07.c +++ b/test/zdtm/static/file_locks07.c @@ -5,19 +5,18 @@ #include "ofd_file_locks.h" #include "zdtmtst.h" -const char *test_doc = "Check that 'overlapping' OFD read locks work"; +const char *test_doc = "Check that 'overlapping' OFD read locks work"; const char *test_author = "Begunkov Pavel <asml.silence@gmail.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); - #define FILE_NUM 4 static int fds[FILE_NUM]; static struct flock lcks[FILE_NUM]; -static short types[] = {F_RDLCK, F_RDLCK, F_RDLCK, F_RDLCK}; -static off_t starts[] = {0, 10, 0, 70}; -static off_t lens[] = {20, 30, 100, 200}; +static short types[] = { F_RDLCK, F_RDLCK, F_RDLCK, F_RDLCK }; +static off_t starts[] = { 0, 10, 0, 70 }; +static off_t lens[] = { 20, 30, 100, 200 }; void fill_lock(struct flock *lock, off_t start, off_t len, short int type) { diff --git a/test/zdtm/static/file_locks08.c b/test/zdtm/static/file_locks08.c index a4fa1feb5..da6c096df 100644 --- a/test/zdtm/static/file_locks08.c +++ b/test/zdtm/static/file_locks08.c @@ -7,13 +7,12 @@ #include "ofd_file_locks.h" #include "zdtmtst.h" -const char *test_doc = "Check that inherited OFD locks work"; +const char *test_doc = "Check that inherited OFD locks work"; const char *test_author = "Begunkov Pavel <asml.silence@gmail.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); - int init_file_lock(int *fd, struct flock *lck) { *fd = open(filename, O_RDWR | O_CREAT, 0666); @@ -62,8 +61,7 @@ int main(int argc, char **argv) pid = fork(); if (pid == 0) { task_waiter_wait4(&tw, getppid()); - if (check_file_lock_restored(getpid(), fd, &lck) || - check_lock_exists(filename, &lck) < 0) + if (check_file_lock_restored(getpid(), fd, &lck) || check_lock_exists(filename, &lck) < 0) ret = -1; exit(ret); } @@ -73,8 +71,7 @@ int main(int argc, char **argv) task_waiter_complete_current(&tw); - if (check_file_lock_restored(getpid(), fd, &lck) || - check_lock_exists(filename, &lck) < 0) + if (check_file_lock_restored(getpid(), fd, &lck) || check_lock_exists(filename, &lck) < 0) fail("OFD file locks check failed"); kill(pid, SIGTERM); diff --git a/test/zdtm/static/file_shared.c b/test/zdtm/static/file_shared.c index 0e78b07e2..9d896c2e2 100644 --- a/test/zdtm/static/file_shared.c +++ b/test/zdtm/static/file_shared.c @@ -7,11 +7,11 @@ #include <stdio.h> #include "zdtmtst.h" -#define OFFSET 1000 +#define OFFSET 1000 #define OFFSET2 500 -const char *test_doc = "Check shared struct file-s"; -const char *test_author = "Andrey Vagin <avagin@openvz.org>"; +const char *test_doc = "Check shared struct file-s"; +const char *test_author = "Andrey Vagin <avagin@openvz.org>"; char *filename; TEST_OPTION(filename, string, "file name", 1); @@ -46,11 +46,11 @@ int main(int argc, char **argv) test_daemon(); test_waitsig(); off = lseek(fd, OFFSET, SEEK_SET); - if (off == (off_t) -1) + if (off == (off_t)-1) return 1; off = lseek(fd3, OFFSET2, SEEK_SET); - if (off == (off_t) -1) + if (off == (off_t)-1) return 1; ret = kill(pid, SIGTERM); diff --git a/test/zdtm/static/fpu00.c b/test/zdtm/static/fpu00.c index 6cc15a2b2..7687639c4 100644 --- a/test/zdtm/static/fpu00.c +++ b/test/zdtm/static/fpu00.c @@ -3,9 +3,9 @@ #include "zdtmtst.h" -const char *test_doc = "Start a calculation, leaving FPU in a certain state,\n" -"before migration, continue after"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Start a calculation, leaving FPU in a certain state,\n" + "before migration, continue after"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; #if defined(__i386__) || defined(__x86_64__) @@ -13,25 +13,20 @@ const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; void start(float a, float b, float c, float d) { - __asm__ volatile ( - "flds %0\n" - "fadds %1\n" - "flds %2\n" - "fadds %3\n" - "fmulp %%st(1)\n" - : - : "m" (a), "m" (b), "m" (c), "m" (d) - ); + __asm__ volatile("flds %0\n" + "fadds %1\n" + "flds %2\n" + "fadds %3\n" + "fmulp %%st(1)\n" + : + : "m"(a), "m"(b), "m"(c), "m"(d)); } float finish(void) { float res; - __asm__ volatile ( - "fstps %0\n" - : "=m" (res) - ); + __asm__ volatile("fstps %0\n" : "=m"(res)); return res; } @@ -56,7 +51,6 @@ void *run_fpu_test(void *unused) c = drand48(); d = drand48(); - start(a, b, c, d); res1 = finish(); @@ -75,7 +69,7 @@ void *run_fpu_test(void *unused) return (void *)(uintptr_t)(res1 != res2); } -int main(int argc, char ** argv) +int main(int argc, char **argv) { test_init(argc, argv); @@ -84,7 +78,6 @@ int main(int argc, char ** argv) return 1; } - #ifdef ZDTM_FPU00_RUN_IN_THREAD /* Check if thread's fpu state is preserved */ { diff --git a/test/zdtm/static/fpu01.c b/test/zdtm/static/fpu01.c index 11c480546..638a1ad8f 100644 --- a/test/zdtm/static/fpu01.c +++ b/test/zdtm/static/fpu01.c @@ -10,8 +10,8 @@ #include "cpuid.h" -const char *test_doc = "Test if FPU data in YMM registers do survive the c/r"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; +const char *test_doc = "Test if FPU data in YMM registers do survive the c/r"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; static int verify_cpu(void) { @@ -45,36 +45,22 @@ static int fpu_test(void) { int ret = 0; - asm volatile("vmovapd %0, %%ymm0 \n" - : - : "m" (*ymm1) - : "memory"); + asm volatile("vmovapd %0, %%ymm0 \n" : : "m"(*ymm1) : "memory"); - asm volatile("vmovapd %0, %%ymm7 \n" - : - : "m" (*ymm2) - : "memory"); + asm volatile("vmovapd %0, %%ymm7 \n" : : "m"(*ymm2) : "memory"); test_daemon(); test_waitsig(); - asm volatile("vmovapd %%ymm0, %0 \n" - : "=m" (*ymm3) - : - : "memory"); + asm volatile("vmovapd %%ymm0, %0 \n" : "=m"(*ymm3) : : "memory"); - asm volatile("vmovapd %%ymm7, %0 \n" - : "=m" (*ymm4) - : - : "memory"); + asm volatile("vmovapd %%ymm7, %0 \n" : "=m"(*ymm4) : : "memory"); if (memcmp(ymm1, ymm3, 32) || memcmp(ymm2, ymm4, 32)) { - test_msg("Data mismatch ('%s' '%s' '%s' '%s')\n", - ymm1, ymm2, ymm3, ymm4); + test_msg("Data mismatch ('%s' '%s' '%s' '%s')\n", ymm1, ymm2, ymm3, ymm4); ret = -1; } else { - test_msg("Data match ('%s' '%s' '%s' '%s')\n", - ymm1, ymm2, ymm3, ymm4); + test_msg("Data match ('%s' '%s' '%s' '%s')\n", ymm1, ymm2, ymm3, ymm4); ret = 0; } diff --git a/test/zdtm/static/fpu02.c b/test/zdtm/static/fpu02.c index 660fc7d59..b201f8081 100644 --- a/test/zdtm/static/fpu02.c +++ b/test/zdtm/static/fpu02.c @@ -10,8 +10,8 @@ #include "cpuid.h" -const char *test_doc = "Test preserve of mxcsr in FPU"; -const char *test_author = "Dmitry Safonov <0x7f454c46@gmail.com>"; +const char *test_doc = "Test preserve of mxcsr in FPU"; +const char *test_author = "Dmitry Safonov <0x7f454c46@gmail.com>"; static int verify_cpu(void) { @@ -36,14 +36,12 @@ static int fpu_test(void) { uint32_t before, after; - asm volatile("stmxcsr %0\n" - : "+m"(before)); + asm volatile("stmxcsr %0\n" : "+m"(before)); test_daemon(); test_waitsig(); - asm volatile("stmxcsr %0\n" - : "+m"(after)); + asm volatile("stmxcsr %0\n" : "+m"(after)); test_msg("before: %x, after: %x\n", before, after); diff --git a/test/zdtm/static/futex-rl.c b/test/zdtm/static/futex-rl.c index a5888a340..e031bfd73 100644 --- a/test/zdtm/static/futex-rl.c +++ b/test/zdtm/static/futex-rl.c @@ -10,12 +10,12 @@ #include "zdtmtst.h" -const char *test_doc = "Check the futex robust list c/r"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; +const char *test_doc = "Check the futex robust list c/r"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; struct args { - task_waiter_t waiter; - int result; + task_waiter_t waiter; + int result; }; static pid_t __gettid(void) diff --git a/test/zdtm/static/futex.c b/test/zdtm/static/futex.c index 5d1f2de86..30bddb3e6 100644 --- a/test/zdtm/static/futex.c +++ b/test/zdtm/static/futex.c @@ -6,8 +6,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check (via pthread/NPTL) that futeces behave through migration"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check (via pthread/NPTL) that futeces behave through migration"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; volatile int kid_passed; @@ -22,12 +22,13 @@ void *thread_fn(void *lock) return NULL; } -#define DEF_NUM_THREADS 10 -#define MAX_NUM_THREADS 50 +#define DEF_NUM_THREADS 10 +#define MAX_NUM_THREADS 50 int num_threads = DEF_NUM_THREADS; -TEST_OPTION(num_threads, int, "number of threads " - "(default " __stringify(DEF_NUM_THREADS) - " maximum " __stringify(MAX_NUM_THREADS) ")", 0); +TEST_OPTION(num_threads, int, + "number of threads " + "(default " __stringify(DEF_NUM_THREADS) " maximum " __stringify(MAX_NUM_THREADS) ")", + 0); int main(int argc, char **argv) { @@ -38,8 +39,7 @@ int main(int argc, char **argv) test_init(argc, argv); if (num_threads > MAX_NUM_THREADS) { - pr_perror("%d threads it too much. max is %d", - num_threads, MAX_NUM_THREADS); + pr_perror("%d threads it too much. max is %d", num_threads, MAX_NUM_THREADS); goto out; } diff --git a/test/zdtm/static/get_smaps_bits.c b/test/zdtm/static/get_smaps_bits.c index 3debaa752..31d0d92b2 100644 --- a/test/zdtm/static/get_smaps_bits.c +++ b/test/zdtm/static/get_smaps_bits.c @@ -3,19 +3,19 @@ #include "zdtmtst.h" #ifndef MAP_HUGETLB -# define MAP_HUGETLB 0x40000 +#define MAP_HUGETLB 0x40000 #endif #ifndef MADV_HUGEPAGE -# define MADV_HUGEPAGE 14 +#define MADV_HUGEPAGE 14 #endif #ifndef MADV_NOHUGEPAGE -# define MADV_NOHUGEPAGE 15 +#define MADV_NOHUGEPAGE 15 #endif #ifndef MADV_DONTDUMP -# define MADV_DONTDUMP 16 +#define MADV_DONTDUMP 16 #endif static void parse_vmflags(char *buf, unsigned long *flags, unsigned long *madv) @@ -66,10 +66,7 @@ static void parse_vmflags(char *buf, unsigned long *flags, unsigned long *madv) #undef _vmflag_match } -#define is_hex_digit(c) \ - (((c) >= '0' && (c) <= '9') || \ - ((c) >= 'a' && (c) <= 'f') || \ - ((c) >= 'A' && (c) <= 'F')) +#define is_hex_digit(c) (((c) >= '0' && (c) <= '9') || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F')) static int is_vma_range_fmt(char *line, unsigned long *start, unsigned long *end) { diff --git a/test/zdtm/static/ghost_holes00.c b/test/zdtm/static/ghost_holes00.c index 214a39141..a87642588 100644 --- a/test/zdtm/static/ghost_holes00.c +++ b/test/zdtm/static/ghost_holes00.c @@ -10,40 +10,40 @@ #include "zdtmtst.h" -const char *test_doc = "Test ghost with one hole in the middle"; +const char *test_doc = "Test ghost with one hole in the middle"; char *filename; TEST_OPTION(filename, string, "file name", 1); /* Buffer that is suitable for hole size */ -#define BUFSIZE 4096 +#define BUFSIZE 4096 static unsigned char buf4k[BUFSIZE]; #ifndef SEEK_DATA -#define SEEK_DATA 3 -#define SEEK_HOLE 4 +#define SEEK_DATA 3 +#define SEEK_HOLE 4 #endif #ifdef HEAD_HOLE -#define HH 1 +#define HH 1 #else -#define HH 0 +#define HH 0 #endif #ifdef TAIL_HOLE -#define TH 1 +#define TH 1 #else -#define TH 0 +#define TH 0 #endif -#define DATA1_BLK (HH) -#define DATA1_OFF (DATA1_BLK * BUFSIZE) -#define DATA2_BLK (HH + 2) -#define DATA2_OFF (DATA2_BLK * BUFSIZE) -#define FILE_BLOCKS (TH + HH + 1 /* mid hole */ + 2 /* data */) -#define FILE_SIZE (FILE_BLOCKS * BUFSIZE) +#define DATA1_BLK (HH) +#define DATA1_OFF (DATA1_BLK * BUFSIZE) +#define DATA2_BLK (HH + 2) +#define DATA2_OFF (DATA2_BLK * BUFSIZE) +#define FILE_BLOCKS (TH + HH + 1 /* mid hole */ + 2 /* data */) +#define FILE_SIZE (FILE_BLOCKS * BUFSIZE) -int main(int argc, char ** argv) +int main(int argc, char **argv) { int fd; struct stat st; diff --git a/test/zdtm/static/ghost_on_rofs.c b/test/zdtm/static/ghost_on_rofs.c index 1a7922320..7fef8a366 100644 --- a/test/zdtm/static/ghost_on_rofs.c +++ b/test/zdtm/static/ghost_on_rofs.c @@ -6,8 +6,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check ghost file on readonly fs mount restores fine"; -const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; +const char *test_doc = "Check ghost file on readonly fs mount restores fine"; +const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; #define GHOST_DATA "Ghost Data" @@ -70,7 +70,7 @@ int main(int argc, char **argv) } ssprintf(ghost_file, "%s/ghost_file", ro_mount); - fd = open(ghost_file, O_CREAT|O_WRONLY, 0600); + fd = open(ghost_file, O_CREAT | O_WRONLY, 0600); if (fd < 0) { pr_perror("open"); return 1; @@ -82,7 +82,7 @@ int main(int argc, char **argv) } ssprintf(ghost_file_bind, "%s/ghost_file_bind", ro_bind_mount); - fd_bind = open(ghost_file_bind, O_CREAT|O_WRONLY, 0600); + fd_bind = open(ghost_file_bind, O_CREAT | O_WRONLY, 0600); if (fd_bind < 0) { pr_perror("open"); return 1; @@ -118,7 +118,7 @@ int main(int argc, char **argv) return 1; } - if (mount(NULL, ro_mount, NULL, MS_RDONLY|MS_REMOUNT|MS_BIND, NULL)) { + if (mount(NULL, ro_mount, NULL, MS_RDONLY | MS_REMOUNT | MS_BIND, NULL)) { pr_perror("mount"); return 1; } @@ -127,7 +127,7 @@ int main(int argc, char **argv) * Need MS_NOSUID flag to check the hunk in do_bind_mount, case of * different flags for mount and it's ->bind */ - if (mount(NULL, ro_bind_mount, NULL, MS_NOSUID|MS_RDONLY|MS_REMOUNT|MS_BIND, NULL)) { + if (mount(NULL, ro_bind_mount, NULL, MS_NOSUID | MS_RDONLY | MS_REMOUNT | MS_BIND, NULL)) { pr_perror("mount"); return 1; } diff --git a/test/zdtm/static/groups.c b/test/zdtm/static/groups.c index 01ec3a12b..1ff5c08fa 100644 --- a/test/zdtm/static/groups.c +++ b/test/zdtm/static/groups.c @@ -8,8 +8,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that supplementary groups are supported"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check that supplementary groups are supported"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; int main(int argc, char **argv) { diff --git a/test/zdtm/static/grow_map.c b/test/zdtm/static/grow_map.c index 089ff7d45..6606f972a 100644 --- a/test/zdtm/static/grow_map.c +++ b/test/zdtm/static/grow_map.c @@ -5,8 +5,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that VMA-s with MAP_GROWSDOWN are restored correctly"; -const char *test_author = "Andrew Vagin <avagin@openvz.org>"; +const char *test_doc = "Check that VMA-s with MAP_GROWSDOWN are restored correctly"; +const char *test_author = "Andrew Vagin <avagin@openvz.org>"; int main(int argc, char **argv) { @@ -21,9 +21,8 @@ int main(int argc, char **argv) } munmap(start_addr, PAGE_SIZE * 10); - fake_grow_down = mmap(start_addr + PAGE_SIZE * 5, PAGE_SIZE, - PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED | MAP_GROWSDOWN, -1, 0); + fake_grow_down = mmap(start_addr + PAGE_SIZE * 5, PAGE_SIZE, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED | MAP_GROWSDOWN, -1, 0); if (fake_grow_down == MAP_FAILED) { pr_perror("Can't mal a new region"); return 1; @@ -34,16 +33,14 @@ int main(int argc, char **argv) *p = 'b'; /* overlap the guard page of fake_grow_down */ - test_addr = mmap(start_addr + PAGE_SIZE * 3, PAGE_SIZE, - PROT_READ | PROT_WRITE, + test_addr = mmap(start_addr + PAGE_SIZE * 3, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); if (test_addr == MAP_FAILED) { pr_perror("Can't mal a new region"); return 1; } - grow_down = mmap(start_addr + PAGE_SIZE * 2, PAGE_SIZE, - PROT_READ | PROT_WRITE, + grow_down = mmap(start_addr + PAGE_SIZE * 2, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED | MAP_GROWSDOWN, -1, 0); if (grow_down == MAP_FAILED) { pr_perror("Can't mal a new region"); diff --git a/test/zdtm/static/grow_map02.c b/test/zdtm/static/grow_map02.c index 0b93714f4..4740947d8 100644 --- a/test/zdtm/static/grow_map02.c +++ b/test/zdtm/static/grow_map02.c @@ -7,24 +7,22 @@ #include "zdtmtst.h" -const char *test_doc = "Check that a few grow-down VMA-s are restored correctly"; -const char *test_author = "Andrew Vagin <avagin@openvz.org>"; +const char *test_doc = "Check that a few grow-down VMA-s are restored correctly"; +const char *test_author = "Andrew Vagin <avagin@openvz.org>"; int main(int argc, char **argv) { char *start_addr, *grow_down; test_init(argc, argv); - start_addr = mmap(NULL, PAGE_SIZE * 10, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + start_addr = mmap(NULL, PAGE_SIZE * 10, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); if (start_addr == MAP_FAILED) { pr_perror("Can't mal a new region"); return 1; } munmap(start_addr, PAGE_SIZE * 10); - grow_down = mmap(start_addr + PAGE_SIZE * 3, PAGE_SIZE * 3, - PROT_READ | PROT_WRITE, + grow_down = mmap(start_addr + PAGE_SIZE * 3, PAGE_SIZE * 3, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED | MAP_GROWSDOWN, -1, 0); if (grow_down == MAP_FAILED) { pr_perror("Can't mal a new region"); @@ -47,8 +45,7 @@ int main(int argc, char **argv) test_daemon(); test_waitsig(); - test_msg("%c %c %c\n", grow_down[0 * PAGE_SIZE], - grow_down[1 * PAGE_SIZE], grow_down[2 * PAGE_SIZE]); + test_msg("%c %c %c\n", grow_down[0 * PAGE_SIZE], grow_down[1 * PAGE_SIZE], grow_down[2 * PAGE_SIZE]); if (grow_down[0 * PAGE_SIZE] != 'x') return 1; diff --git a/test/zdtm/static/grow_map03.c b/test/zdtm/static/grow_map03.c index 6310386a4..d715223af 100644 --- a/test/zdtm/static/grow_map03.c +++ b/test/zdtm/static/grow_map03.c @@ -5,8 +5,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that VMA-s with MAP_GROWSDOWN are restored correctly"; -const char *test_author = "Andrew Vagin <avagin@openvz.org>"; +const char *test_doc = "Check that VMA-s with MAP_GROWSDOWN are restored correctly"; +const char *test_author = "Andrew Vagin <avagin@openvz.org>"; /* * This test case creates two consecutive grows down vmas with a hole @@ -26,8 +26,10 @@ int main(int argc, char **argv) } munmap(start_addr, PAGE_SIZE * 10); - addr1 = mmap(start_addr + PAGE_SIZE * 5, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_GROWSDOWN, -1, 0); - addr2 = mmap(start_addr + PAGE_SIZE * 3, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_GROWSDOWN, -1, 0); + addr1 = mmap(start_addr + PAGE_SIZE * 5, PAGE_SIZE, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE | MAP_GROWSDOWN, -1, 0); + addr2 = mmap(start_addr + PAGE_SIZE * 3, PAGE_SIZE, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE | MAP_GROWSDOWN, -1, 0); test_msg("%p %p\n", addr1, addr2); diff --git a/test/zdtm/static/helper_zombie_child.c b/test/zdtm/static/helper_zombie_child.c index 657d56f27..f4a34e1d0 100644 --- a/test/zdtm/static/helper_zombie_child.c +++ b/test/zdtm/static/helper_zombie_child.c @@ -10,8 +10,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that a zombie with a helper parent is restored"; -const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; +const char *test_doc = "Check that a zombie with a helper parent is restored"; +const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; void setsid_and_fork(int sk) { diff --git a/test/zdtm/static/inotify00.c b/test/zdtm/static/inotify00.c index 635c05047..9b24b55be 100644 --- a/test/zdtm/static/inotify00.c +++ b/test/zdtm/static/inotify00.c @@ -18,44 +18,29 @@ #include "zdtmtst.h" -const char *test_doc = "Check for inotify delivery"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; +const char *test_doc = "Check for inotify delivery"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); -#define TEST_FILE "inotify-removed" -#define TEST_LINK "inotify-hardlink" +#define TEST_FILE "inotify-removed" +#define TEST_LINK "inotify-hardlink" #define BUFF_SIZE ((sizeof(struct inotify_event) + PATH_MAX)) static void decode_event_mask(char *buf, size_t size, unsigned int mask) { static const char *names[32] = { - [ 0] = "IN_ACCESS", - [ 1] = "IN_MODIFY", - [ 2] = "IN_ATTRIB", - [ 3] = "IN_CLOSE_WRITE", - [ 4] = "IN_CLOSE_NOWRITE", - [ 5] = "IN_OPEN", - [ 6] = "IN_MOVED_FROM", - [ 7] = "IN_MOVED_TO", - [ 8] = "IN_CREATE", - [ 9] = "IN_DELETE", - [10] = "IN_DELETE_SELF", - [11] = "IN_MOVE_SELF", - - [13] = "IN_UNMOUNT", - [14] = "IN_Q_OVERFLOW", - [15] = "IN_IGNORED", - - [24] = "IN_ONLYDIR", - [25] = "IN_DONT_FOLLOW", - [26] = "IN_EXCL_UNLINK", - - [29] = "IN_MASK_ADD", - [30] = "IN_ISDIR", - [31] = "IN_ONESHOT", + [0] = "IN_ACCESS", [1] = "IN_MODIFY", [2] = "IN_ATTRIB", [3] = "IN_CLOSE_WRITE", + [4] = "IN_CLOSE_NOWRITE", [5] = "IN_OPEN", [6] = "IN_MOVED_FROM", [7] = "IN_MOVED_TO", + [8] = "IN_CREATE", [9] = "IN_DELETE", [10] = "IN_DELETE_SELF", [11] = "IN_MOVE_SELF", + + [13] = "IN_UNMOUNT", [14] = "IN_Q_OVERFLOW", [15] = "IN_IGNORED", + + [24] = "IN_ONLYDIR", [25] = "IN_DONT_FOLLOW", [26] = "IN_EXCL_UNLINK", + + [29] = "IN_MASK_ADD", [30] = "IN_ISDIR", [31] = "IN_ONESHOT", }; size_t i, j; @@ -95,8 +80,7 @@ static int inotify_read_events(char *prefix, int inotify_fd, unsigned int *expec event = (void *)(buf + off); decode_event_mask(emask, sizeof(emask), event->mask); - test_msg("\t%-16s: event %#10x -> %s\n", - prefix, event->mask, emask); + test_msg("\t%-16s: event %#10x -> %s\n", prefix, event->mask, emask); if (expected) *expected &= ~event->mask; } @@ -107,7 +91,7 @@ out: return ret; } -int main (int argc, char *argv[]) +int main(int argc, char *argv[]) { unsigned int mask = IN_DELETE | IN_CLOSE_WRITE | IN_DELETE_SELF | IN_CREATE; char test_file_path[PATH_MAX]; @@ -122,51 +106,51 @@ int main (int argc, char *argv[]) } #ifdef INOTIFY01 -{ - pid_t pid; - task_waiter_t t; - static char buf[PATH_MAX]; - - task_waiter_init(&t); + { + pid_t pid; + task_waiter_t t; + static char buf[PATH_MAX]; - if (mount(NULL, "/", NULL, MS_PRIVATE | MS_REC, NULL)) { - pr_perror("Unable to remount /"); - return 1; - } - - pid = fork(); - if (pid < 0) { - pr_perror("Can't fork a test process"); - exit(1); - } - if (pid == 0) { - int fd; + task_waiter_init(&t); - prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); - if (unshare(CLONE_NEWNS)) { - pr_perror("Unable to unshare mount namespace"); - exit(1); + if (mount(NULL, "/", NULL, MS_PRIVATE | MS_REC, NULL)) { + pr_perror("Unable to remount /"); + return 1; } - if (mount("zdtm", dirname, "tmpfs", 0, NULL)) { - pr_perror("Unable to mount tmpfs"); + pid = fork(); + if (pid < 0) { + pr_perror("Can't fork a test process"); exit(1); } - fd = open(dirname, O_RDONLY); - if (fd < 0) { - pr_perror("Unable to open %s", dirname); + if (pid == 0) { + int fd; + + prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); + if (unshare(CLONE_NEWNS)) { + pr_perror("Unable to unshare mount namespace"); + exit(1); + } + + if (mount("zdtm", dirname, "tmpfs", 0, NULL)) { + pr_perror("Unable to mount tmpfs"); + exit(1); + } + fd = open(dirname, O_RDONLY); + if (fd < 0) { + pr_perror("Unable to open %s", dirname); + exit(1); + } + dup2(fd, 100); + task_waiter_complete_current(&t); + while (1) + sleep(1000); exit(1); } - dup2(fd, 100); - task_waiter_complete_current(&t); - while (1) - sleep(1000); - exit(1); + task_waiter_wait4(&t, pid); + snprintf(buf, sizeof(buf), "/proc/%d/fd/100", pid); + dirname = buf; } - task_waiter_wait4(&t, pid); - snprintf(buf, sizeof(buf), "/proc/%d/fd/100", pid); - dirname = buf; -} #endif fd = inotify_init1(IN_NONBLOCK); @@ -210,8 +194,7 @@ int main (int argc, char *argv[]) if (emask) { char emask_bits[128]; decode_event_mask(emask_bits, sizeof(emask_bits), emask); - pr_perror("Unhandled events in emask %#x -> %s", - emask, emask_bits); + pr_perror("Unhandled events in emask %#x -> %s", emask, emask_bits); exit(1); } #endif @@ -226,8 +209,7 @@ int main (int argc, char *argv[]) if (emask) { char emask_bits[128]; decode_event_mask(emask_bits, sizeof(emask_bits), emask); - fail("Unhandled events in emask %#x -> %s", - emask, emask_bits); + fail("Unhandled events in emask %#x -> %s", emask, emask_bits); return 1; } @@ -244,8 +226,7 @@ int main (int argc, char *argv[]) if (emask) { char emask_bits[128]; decode_event_mask(emask_bits, sizeof(emask_bits), emask); - fail("Unhandled events in emask %#x -> %s", - emask, emask_bits); + fail("Unhandled events in emask %#x -> %s", emask, emask_bits); return 1; } #endif diff --git a/test/zdtm/static/inotify02.c b/test/zdtm/static/inotify02.c index bedfefac9..44fcdc875 100644 --- a/test/zdtm/static/inotify02.c +++ b/test/zdtm/static/inotify02.c @@ -18,8 +18,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check for inotify file-handles storm"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; +const char *test_doc = "Check for inotify file-handles storm"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); @@ -48,7 +48,7 @@ static int num_of_handles(int fd) return ret; } -int main (int argc, char *argv[]) +int main(int argc, char *argv[]) { const unsigned int mask = IN_DELETE | IN_CLOSE_WRITE | IN_DELETE_SELF | IN_CREATE; const int nr_dirs = 64; diff --git a/test/zdtm/static/inotify04.c b/test/zdtm/static/inotify04.c index fb9293024..96f7b215f 100644 --- a/test/zdtm/static/inotify04.c +++ b/test/zdtm/static/inotify04.c @@ -8,13 +8,13 @@ #include "zdtmtst.h" -const char *test_doc = "Check inotify does not have trash in queue after c/r"; -const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; +const char *test_doc = "Check inotify does not have trash in queue after c/r"; +const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); -#define TEST_FILE "inotify-testfile" +#define TEST_FILE "inotify-testfile" #define BUFF_SIZE ((sizeof(struct inotify_event) + PATH_MAX)) @@ -49,7 +49,7 @@ static int inotify_read_events(int inotify_fd, unsigned int *n) return ret; } -int main (int argc, char *argv[]) +int main(int argc, char *argv[]) { unsigned int mask = IN_ALL_EVENTS; char test_file_path[PATH_MAX]; diff --git a/test/zdtm/static/inotify_irmap.c b/test/zdtm/static/inotify_irmap.c index cf35886e2..f8e35222c 100644 --- a/test/zdtm/static/inotify_irmap.c +++ b/test/zdtm/static/inotify_irmap.c @@ -14,15 +14,15 @@ #include "zdtmtst.h" -const char *test_doc = "Check for irmap"; -const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; +const char *test_doc = "Check for irmap"; +const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; -#define TDIR "/etc" -char test_files[2][128] = {TDIR"/zdtm-test", TDIR"/zdtm-test1"}; +#define TDIR "/etc" +char test_files[2][128] = { TDIR "/zdtm-test", TDIR "/zdtm-test1" }; #define BUFF_SIZE ((sizeof(struct inotify_event) + PATH_MAX)) -int main (int argc, char *argv[]) +int main(int argc, char *argv[]) { char buf[BUFF_SIZE]; int fd, wd, i; diff --git a/test/zdtm/static/inotify_system.c b/test/zdtm/static/inotify_system.c index 3d2355436..487062cab 100644 --- a/test/zdtm/static/inotify_system.c +++ b/test/zdtm/static/inotify_system.c @@ -13,7 +13,7 @@ #include "zdtmtst.h" -const char *test_doc = "Inotify on symlink should be checked"; +const char *test_doc = "Inotify on symlink should be checked"; #ifndef NODEL char filename[] = "file"; char linkname[] = "file.lnk"; @@ -29,34 +29,35 @@ const char *inot_dir = "./inotify.nodel"; #ifndef IN_DONT_FOLLOW /* Missed in SLES 10 header */ -#define IN_DONT_FOLLOW 0x02000000 +#define IN_DONT_FOLLOW 0x02000000 #endif #define EVENT_MAX 1024 /* size of the event structure, not counting name */ -#define EVENT_SIZE (sizeof (struct inotify_event)) +#define EVENT_SIZE (sizeof(struct inotify_event)) /* reasonable guess as to size of 1024 events */ -#define EVENT_BUF_LEN (EVENT_MAX * (EVENT_SIZE + 16)) -#define BUF_SIZE 256 - -#define min_value(a,b) (a<b) ? a : b -#define handle_event(MASK) (MASK == IN_ACCESS) ? "IN_ACCESS" : \ -(MASK == IN_MODIFY) ? "IN_MODIFY" : \ -(MASK == IN_ATTRIB) ? "IN_ATTRIB" : \ -(MASK == IN_CLOSE) ? "IN_CLOSE" : \ -(MASK == IN_CLOSE_WRITE) ? "IN_CLOSE_WRITE" : \ -(MASK == IN_CLOSE_NOWRITE) ? "IN_CLOSE_NOWRITE" : \ -(MASK == IN_OPEN) ? "IN_OPEN" : \ -(MASK == IN_MOVED_FROM) ? "IN_MOVED_FROM" : \ -(MASK == IN_MOVED_TO) ? "IN_MOVED_TO" : \ -(MASK == IN_DELETE) ? "IN_DELETE" : \ -(MASK == IN_CREATE) ? "IN_CREATE" : \ -(MASK == IN_DELETE_SELF) ? "IN_DELETE_SELF" : \ -(MASK == IN_MOVE_SELF) ? "IN_MOVE_SELF" : \ -(MASK == IN_UNMOUNT) ? "IN_UNMOUNT" : \ -(MASK == IN_Q_OVERFLOW) ? "IN_Q_OVERFLOW" : \ -(MASK == IN_IGNORED) ? "IN_IGNORED" : \ -"UNKNOWN" +#define EVENT_BUF_LEN (EVENT_MAX * (EVENT_SIZE + 16)) +#define BUF_SIZE 256 + +#define min_value(a, b) (a < b) ? a : b +#define handle_event(MASK) \ + (MASK == IN_ACCESS) ? "IN_ACCESS" : \ + (MASK == IN_MODIFY) ? "IN_MODIFY" : \ + (MASK == IN_ATTRIB) ? "IN_ATTRIB" : \ + (MASK == IN_CLOSE) ? "IN_CLOSE" : \ + (MASK == IN_CLOSE_WRITE) ? "IN_CLOSE_WRITE" : \ + (MASK == IN_CLOSE_NOWRITE) ? "IN_CLOSE_NOWRITE" : \ + (MASK == IN_OPEN) ? "IN_OPEN" : \ + (MASK == IN_MOVED_FROM) ? "IN_MOVED_FROM" : \ + (MASK == IN_MOVED_TO) ? "IN_MOVED_TO" : \ + (MASK == IN_DELETE) ? "IN_DELETE" : \ + (MASK == IN_CREATE) ? "IN_CREATE" : \ + (MASK == IN_DELETE_SELF) ? "IN_DELETE_SELF" : \ + (MASK == IN_MOVE_SELF) ? "IN_MOVE_SELF" : \ + (MASK == IN_UNMOUNT) ? "IN_UNMOUNT" : \ + (MASK == IN_Q_OVERFLOW) ? "IN_Q_OVERFLOW" : \ + (MASK == IN_IGNORED) ? "IN_IGNORED" : \ + "UNKNOWN" #include <unistd.h> #include <fcntl.h> @@ -68,14 +69,16 @@ typedef struct { int dir; } desc; -void do_wait(void) { +void do_wait(void) +{ test_daemon(); test_waitsig(); } -int createFiles(char *path, char *target, char *link) { +int createFiles(char *path, char *target, char *link) +{ int fd; - fd = open(path,O_CREAT, 0644); + fd = open(path, O_CREAT, 0644); if (fd < 0) { pr_perror("can't open %s", path); return -1; @@ -88,18 +91,19 @@ int createFiles(char *path, char *target, char *link) { return 0; } -int addWatcher(int fd, const char *path) { +int addWatcher(int fd, const char *path) +{ int wd; wd = inotify_add_watch(fd, path, IN_ALL_EVENTS | IN_DONT_FOLLOW); if (wd < 0) { - pr_perror("inotify_add_watch(%d, %s, IN_ALL_EVENTS) failed", - fd, path); + pr_perror("inotify_add_watch(%d, %s, IN_ALL_EVENTS) failed", fd, path); return -1; } return wd; } -int fChmod(char *path) { +int fChmod(char *path) +{ if (chmod(path, 0755) < 0) { pr_perror("chmod(%s, 0755) failed", path); return -1; @@ -107,7 +111,8 @@ int fChmod(char *path) { return 0; } -int fWriteClose(char *path) { +int fWriteClose(char *path) +{ int fd = open(path, O_RDWR | O_CREAT, 0700); if (fd == -1) { pr_perror("open(%s, O_RDWR|O_CREAT, 0700) failed", path); @@ -124,10 +129,11 @@ int fWriteClose(char *path) { return 0; } -int fNoWriteClose(char *path) { +int fNoWriteClose(char *path) +{ char buf[BUF_SIZE]; int fd = open(path, O_RDONLY); - if ( fd < 0 ) { + if (fd < 0) { pr_perror("open(%s, O_RDONLY) failed", path); return -1; } @@ -143,7 +149,8 @@ int fNoWriteClose(char *path) { return 0; } -int fMove(char *from, char *to) { +int fMove(char *from, char *to) +{ if (rename(from, to) == -1) { pr_perror("rename error (from: %s to: %s)", from, to); return -1; @@ -151,8 +158,9 @@ int fMove(char *from, char *to) { return 0; } -desc init_env(const char *dir, char *file_path, char *link_path) { - desc in_desc = {-1, -1, -1, -1}; +desc init_env(const char *dir, char *file_path, char *link_path) +{ + desc in_desc = { -1, -1, -1, -1 }; if (mkdir(dir, 0777) < 0) { pr_perror("mkdir(%s)", dir); return in_desc; @@ -186,7 +194,8 @@ desc init_env(const char *dir, char *file_path, char *link_path) { return in_desc; } -int fDelete(char *path) { +int fDelete(char *path) +{ if (unlink(path) != 0) { pr_perror("unlink(%s)", path); return -1; @@ -194,39 +203,34 @@ int fDelete(char *path) { return 0; } -int fRemDir(const char *target) { - if(rmdir(target)) { +int fRemDir(const char *target) +{ + if (rmdir(target)) { pr_perror("rmdir(%s)", target); return -1; } return 0; } -int test_actions(const char *dir, char *file_path, char *link_path) { - - if ( - fChmod(link_path) == 0 && - fWriteClose(link_path) == 0 && - fNoWriteClose(link_path) == 0 && - fMove(file_path, filename) == 0 && - fMove(filename, file_path) == 0 +int test_actions(const char *dir, char *file_path, char *link_path) +{ + if (fChmod(link_path) == 0 && fWriteClose(link_path) == 0 && fNoWriteClose(link_path) == 0 && + fMove(file_path, filename) == 0 && fMove(filename, file_path) == 0 #ifndef NODEL - && fDelete(file_path) == 0 && - fDelete(link_path) == 0 && - fRemDir(dir) == 0 + && fDelete(file_path) == 0 && fDelete(link_path) == 0 && fRemDir(dir) == 0 #endif - ) - { + ) { return 0; } return -1; } -void dump_events(char *buf, int len) { +void dump_events(char *buf, int len) +{ int marker = 0; struct inotify_event *event; while (marker < len) { - event = (struct inotify_event *) &buf[marker]; + event = (struct inotify_event *)&buf[marker]; test_msg("\t%s (%x mask, %d len", handle_event(event->mask), event->mask, event->len); if (event->len) test_msg(", '%s' name", event->name); @@ -238,88 +242,85 @@ void dump_events(char *buf, int len) { int harmless(int mask) { switch (mask) { - case IN_CLOSE_NOWRITE: - case IN_ATTRIB: - return 1; + case IN_CLOSE_NOWRITE: + case IN_ATTRIB: + return 1; } return 0; } -int errors(int exp_len, int len, char *etalon_buf, char *buf) { - int marker=0; - int error=0; - while (marker < len){ +int errors(int exp_len, int len, char *etalon_buf, char *buf) +{ + int marker = 0; + int error = 0; + while (marker < len) { struct inotify_event *event; struct inotify_event *exp_event; - event = (struct inotify_event *) &buf[marker]; + event = (struct inotify_event *)&buf[marker]; /* It's OK if some additional events are recevived */ if (marker < exp_len) - exp_event = (struct inotify_event *) &etalon_buf[marker]; + exp_event = (struct inotify_event *)&etalon_buf[marker]; else { if (!harmless(event->mask)) { - fail("got unexpected event %s (%x mask)", - handle_event(event->mask), event->mask); + fail("got unexpected event %s (%x mask)", handle_event(event->mask), event->mask); error++; } goto next_event; } if (event->mask != exp_event->mask) { - fail("Handled %s (%x mask), expected %s (%x mask)", - handle_event(event->mask), event->mask, - handle_event(exp_event->mask), - exp_event->mask); - error++; + fail("Handled %s (%x mask), expected %s (%x mask)", handle_event(event->mask), event->mask, + handle_event(exp_event->mask), exp_event->mask); + error++; } if (event->len != exp_event->len) { fail("Incorrect length of field name."); error++; break; } else if (event->len && strncmp(event->name, exp_event->name, event->len)) { - fail("Handled file name %s, expected %s", - event->name, - exp_event->name); - error++; + fail("Handled file name %s, expected %s", event->name, exp_event->name); + error++; } -next_event: + next_event: marker += EVENT_SIZE + event->len; } return error; } -int read_set(int inot_fd, char *event_set) { +int read_set(int inot_fd, char *event_set) +{ int len; if ((len = read(inot_fd, event_set, EVENT_BUF_LEN)) < 0) { - pr_perror("read(%d, buf, %lu) failed", - inot_fd, (unsigned long)EVENT_BUF_LEN); + pr_perror("read(%d, buf, %lu) failed", inot_fd, (unsigned long)EVENT_BUF_LEN); return -1; } return len; } -void common_close(desc *descr) { +void common_close(desc *descr) +{ if (descr->inot > 0) { close(descr->inot); - descr->inot=-1; - descr->file=-1; - descr->dir=-1; - descr->link=-1; + descr->inot = -1; + descr->file = -1; + descr->dir = -1; + descr->link = -1; } } -int get_event_set(char *event_set, int wait) { +int get_event_set(char *event_set, int wait) +{ int len; char link_path[BUF_SIZE]; char file_path[BUF_SIZE]; desc common_desc; common_desc = init_env(inot_dir, file_path, link_path); - if ((common_desc.inot < 0) || (common_desc.file < 0) || \ - (common_desc.dir < 0) || (common_desc.link < 0)) { + if ((common_desc.inot < 0) || (common_desc.file < 0) || (common_desc.dir < 0) || (common_desc.link < 0)) { common_close(&common_desc); return -1; } - if(test_actions(inot_dir, file_path, link_path) < 0) { + if (test_actions(inot_dir, file_path, link_path) < 0) { common_close(&common_desc); return -1; } @@ -329,17 +330,15 @@ int get_event_set(char *event_set, int wait) { len = read_set(common_desc.inot, event_set); common_close(&common_desc); #ifdef NODEL - if (! (fDelete(file_path) == 0 && - fDelete(link_path) == 0 && - fRemDir(inot_dir) == 0)) + if (!(fDelete(file_path) == 0 && fDelete(link_path) == 0 && fRemDir(inot_dir) == 0)) return -1; #endif return len; } -int check(int len, char *event_set, int exp_len, char *etalon_event_set) { - - if ((exp_len < 0) || (len < 0)){ +int check(int len, char *event_set, int exp_len, char *etalon_event_set) +{ + if ((exp_len < 0) || (len < 0)) { fail("Error in preparing event sets."); return -1; } @@ -358,9 +357,9 @@ int check(int len, char *event_set, int exp_len, char *etalon_event_set) { return -1; } -int main(int argc, char ** argv) +int main(int argc, char **argv) { - int exp_len=-1, len=-1; + int exp_len = -1, len = -1; char etalon_event_set[EVENT_BUF_LEN]; char event_set[EVENT_BUF_LEN]; @@ -376,7 +375,7 @@ int main(int argc, char ** argv) } #else -int main(int argc, char ** argv) +int main(int argc, char **argv) { test_init(argc, argv); skip("Inotify not supported."); diff --git a/test/zdtm/static/ipc_namespace.c b/test/zdtm/static/ipc_namespace.c index da400db6c..98241d816 100644 --- a/test/zdtm/static/ipc_namespace.c +++ b/test/zdtm/static/ipc_namespace.c @@ -11,61 +11,61 @@ #include "zdtmtst.h" -#define CLONE_NEWIPC 0x08000000 +#define CLONE_NEWIPC 0x08000000 -extern int msgctl (int __msqid, int __cmd, struct msqid_ds *__buf); -extern int semctl (int __semid, int __semnum, int __cmd, ...); -extern int shmctl (int __shmid, int __cmd, struct shmid_ds *__buf); +extern int msgctl(int __msqid, int __cmd, struct msqid_ds *__buf); +extern int semctl(int __semid, int __semnum, int __cmd, ...); +extern int shmctl(int __shmid, int __cmd, struct shmid_ds *__buf); struct ipc_ids { - int in_use; /* TODO: Check for 0 */ -// unsigned short seq; -// unsigned short seq_max; -// struct rw_semaphore rw_mutex; -// struct idr ipcs_idr; /* TODO */ + int in_use; /* TODO: Check for 0 */ + // unsigned short seq; + // unsigned short seq_max; + // struct rw_semaphore rw_mutex; + // struct idr ipcs_idr; /* TODO */ }; struct ipc_ns { - struct ipc_ids ids[3]; + struct ipc_ids ids[3]; - int sem_ctls[4]; // + - int used_sems; // + + int sem_ctls[4]; // + + int used_sems; // + - int msg_ctlmax; // + - int msg_ctlmnb; // + - int msg_ctlmni; // + - int msg_bytes; // + - int msg_hdrs; // + - int auto_msgmni; // + - int msg_next_id; // + - int sem_next_id; // + - int shm_next_id; // + + int msg_ctlmax; // + + int msg_ctlmnb; // + + int msg_ctlmni; // + + int msg_bytes; // + + int msg_hdrs; // + + int auto_msgmni; // + + int msg_next_id; // + + int sem_next_id; // + + int shm_next_id; // + - size_t shm_ctlmax; - size_t shm_ctlall; - int shm_ctlmni; - int shm_tot; - int shm_rmid_forced; + size_t shm_ctlmax; + size_t shm_ctlall; + int shm_ctlmni; + int shm_tot; + int shm_rmid_forced; -// struct vfsmount *mq_mnt; + // struct vfsmount *mq_mnt; -// unsigned int mq_queues_count; + // unsigned int mq_queues_count; - unsigned int mq_queues_max; /* initialized to DFLT_QUEUESMAX */ - unsigned int mq_msg_max; /* initialized to DFLT_MSGMAX */ - unsigned int mq_msgsize_max; /* initialized to DFLT_MSGSIZEMAX */ - unsigned int mq_msg_default; /* initialized to DFLT_MSG */ - unsigned int mq_msgsize_default; /* initialized to DFLT_MSGSIZE */ + unsigned int mq_queues_max; /* initialized to DFLT_QUEUESMAX */ + unsigned int mq_msg_max; /* initialized to DFLT_MSGMAX */ + unsigned int mq_msgsize_max; /* initialized to DFLT_MSGSIZEMAX */ + unsigned int mq_msg_default; /* initialized to DFLT_MSG */ + unsigned int mq_msgsize_default; /* initialized to DFLT_MSGSIZE */ struct user_ns *user_ns; }; -#define IPC_SEM_IDS 0 -#define IPC_MSG_IDS 1 -#define IPC_SHM_IDS 2 +#define IPC_SEM_IDS 0 +#define IPC_MSG_IDS 1 +#define IPC_SHM_IDS 2 -const char *test_doc = "Check that ipc ns context migrated successfully"; -const char *test_author = "Stanislav Kinsbursky <skinsbursky@parallels.com>"; +const char *test_doc = "Check that ipc ns context migrated successfully"; +const char *test_author = "Stanislav Kinsbursky <skinsbursky@parallels.com>"; struct ipc_ns ipc_before, ipc_after; @@ -111,32 +111,26 @@ static int get_messages_info(struct ipc_ns *ipc) ipc->msg_hdrs = info.msgmap; ipc->ids[IPC_MSG_IDS].in_use = info.msgpool; - if (read_ipc_sysctl("/proc/sys/kernel/auto_msgmni", - &ipc->auto_msgmni, sizeof(ipc->auto_msgmni))) + if (read_ipc_sysctl("/proc/sys/kernel/auto_msgmni", &ipc->auto_msgmni, sizeof(ipc->auto_msgmni))) return -1; - if (read_ipc_sysctl("/proc/sys/kernel/msg_next_id", - &ipc->msg_next_id, sizeof(ipc->msg_next_id))) + if (read_ipc_sysctl("/proc/sys/kernel/msg_next_id", &ipc->msg_next_id, sizeof(ipc->msg_next_id))) return -1; - if (read_ipc_sysctl("/proc/sys/kernel/sem_next_id", - &ipc->sem_next_id, sizeof(ipc->sem_next_id))) + if (read_ipc_sysctl("/proc/sys/kernel/sem_next_id", &ipc->sem_next_id, sizeof(ipc->sem_next_id))) return -1; - if (read_ipc_sysctl("/proc/sys/kernel/shm_next_id", - &ipc->shm_next_id, sizeof(ipc->shm_next_id))) + if (read_ipc_sysctl("/proc/sys/kernel/shm_next_id", &ipc->shm_next_id, sizeof(ipc->shm_next_id))) return -1; - if (read_ipc_sysctl("/proc/sys/fs/mqueue/queues_max", - (int *)&ipc->mq_queues_max, sizeof(ipc->mq_queues_max))) + if (read_ipc_sysctl("/proc/sys/fs/mqueue/queues_max", (int *)&ipc->mq_queues_max, sizeof(ipc->mq_queues_max))) return -1; - if (read_ipc_sysctl("/proc/sys/fs/mqueue/msg_max", - (int *)&ipc->mq_msg_max, sizeof(ipc->mq_msg_max))) + if (read_ipc_sysctl("/proc/sys/fs/mqueue/msg_max", (int *)&ipc->mq_msg_max, sizeof(ipc->mq_msg_max))) return -1; - if (read_ipc_sysctl("/proc/sys/fs/mqueue/msgsize_max", - (int *)&ipc->mq_msgsize_max, sizeof(ipc->mq_msgsize_max))) + if (read_ipc_sysctl("/proc/sys/fs/mqueue/msgsize_max", (int *)&ipc->mq_msgsize_max, + sizeof(ipc->mq_msgsize_max))) return -1; - if (read_ipc_sysctl("/proc/sys/fs/mqueue/msg_default", - (int *)&ipc->mq_msg_default, sizeof(ipc->mq_msg_default))) + if (read_ipc_sysctl("/proc/sys/fs/mqueue/msg_default", (int *)&ipc->mq_msg_default, + sizeof(ipc->mq_msg_default))) return -1; - if (read_ipc_sysctl("/proc/sys/fs/mqueue/msgsize_default", - (int *)&ipc->mq_msgsize_default, sizeof(ipc->mq_msgsize_default))) + if (read_ipc_sysctl("/proc/sys/fs/mqueue/msgsize_default", (int *)&ipc->mq_msgsize_default, + sizeof(ipc->mq_msgsize_default))) return -1; return 0; @@ -185,14 +179,12 @@ static int get_shared_memory_info(struct ipc_ns *ipc) ipc->shm_tot = u.shminfo.shm_tot; ipc->ids[IPC_SHM_IDS].in_use = u.shminfo.used_ids; - if (read_ipc_sysctl("/proc/sys/kernel/shm_rmid_forced", - &ipc->shm_rmid_forced, sizeof(ipc->shm_rmid_forced))) + if (read_ipc_sysctl("/proc/sys/kernel/shm_rmid_forced", &ipc->shm_rmid_forced, sizeof(ipc->shm_rmid_forced))) return -1; return 0; } - int fill_ipc_ns(struct ipc_ns *ipc) { int ret; @@ -238,7 +230,7 @@ static int rand_ipc_sysctl(char *name, unsigned int val) return 0; } -#define MAX_MNI (1<<15) +#define MAX_MNI (1 << 15) static int rand_ipc_sem(void) { @@ -252,8 +244,8 @@ static int rand_ipc_sem(void) pr_perror("Can't open %s", name); return fd; } - sprintf(buf, "%d %d %d %d\n", (unsigned) lrand48(), (unsigned) lrand48(), - (unsigned) lrand48(), (unsigned) lrand48() % MAX_MNI); + sprintf(buf, "%d %d %d %d\n", (unsigned)lrand48(), (unsigned)lrand48(), (unsigned)lrand48(), + (unsigned)lrand48() % MAX_MNI); ret = write(fd, buf, 128); if (ret < 0) { pr_perror("Can't write %s", name); @@ -291,17 +283,18 @@ static int rand_ipc_ns(void) if (!ret) ret = rand_ipc_sysctl("/proc/sys/kernel/shm_rmid_forced", (unsigned)lrand48() & 1); - if (!ret) ret = rand_ipc_sysctl("/proc/sys/fs/mqueue/queues_max", (((unsigned)lrand48()) % 1023) + 1); if (!ret) ret = rand_ipc_sysctl("/proc/sys/fs/mqueue/msg_max", ((unsigned)lrand48() % 65536) + 1); if (!ret) - ret = rand_ipc_sysctl("/proc/sys/fs/mqueue/msgsize_max", ((unsigned)lrand48() & (8192 * 128 - 1)) | 128); + ret = rand_ipc_sysctl("/proc/sys/fs/mqueue/msgsize_max", + ((unsigned)lrand48() & (8192 * 128 - 1)) | 128); if (!ret) ret = rand_ipc_sysctl("/proc/sys/fs/mqueue/msg_default", ((unsigned)lrand48() % 65536) + 1); if (!ret) - ret = rand_ipc_sysctl("/proc/sys/fs/mqueue/msgsize_default", ((unsigned)lrand48() & (8192 * 128 - 1)) | 128); + ret = rand_ipc_sysctl("/proc/sys/fs/mqueue/msgsize_default", + ((unsigned)lrand48() & (8192 * 128 - 1)) | 128); if (ret < 0) pr_err("Failed to randomize ipc namespace tunables\n"); @@ -315,65 +308,45 @@ static void show_ipc_entry(struct ipc_ns *old, struct ipc_ns *new) for (i = 0; i < 3; i++) { if (old->ids[i].in_use != new->ids[i].in_use) - pr_err("ids[%d].in_use differs: %d ---> %d\n", i, - old->ids[i].in_use, new->ids[i].in_use); - + pr_err("ids[%d].in_use differs: %d ---> %d\n", i, old->ids[i].in_use, new->ids[i].in_use); } for (i = 0; i < 4; i++) { if (old->sem_ctls[i] != new->sem_ctls[i]) - pr_err("sem_ctls[%d] differs: %d ---> %d\n", i, - old->sem_ctls[i], new->sem_ctls[i]); - + pr_err("sem_ctls[%d] differs: %d ---> %d\n", i, old->sem_ctls[i], new->sem_ctls[i]); } if (old->msg_ctlmax != new->msg_ctlmax) - pr_err("msg_ctlmax differs: %d ---> %d\n", - old->msg_ctlmax, new->msg_ctlmax); + pr_err("msg_ctlmax differs: %d ---> %d\n", old->msg_ctlmax, new->msg_ctlmax); if (old->msg_ctlmnb != new->msg_ctlmnb) - pr_err("msg_ctlmnb differs: %d ---> %d\n", - old->msg_ctlmnb, new->msg_ctlmnb); + pr_err("msg_ctlmnb differs: %d ---> %d\n", old->msg_ctlmnb, new->msg_ctlmnb); if (old->msg_ctlmni != new->msg_ctlmni) - pr_err("msg_ctlmni differs: %d ---> %d\n", - old->msg_ctlmni, new->msg_ctlmni); + pr_err("msg_ctlmni differs: %d ---> %d\n", old->msg_ctlmni, new->msg_ctlmni); if (old->auto_msgmni != new->auto_msgmni) - pr_err("auto_msgmni differs: %d ---> %d\n", - old->auto_msgmni, new->auto_msgmni); + pr_err("auto_msgmni differs: %d ---> %d\n", old->auto_msgmni, new->auto_msgmni); if (old->msg_next_id != new->msg_next_id) - pr_err("msg_next_id differs: %d ---> %d\n", - old->msg_next_id, new->msg_next_id); + pr_err("msg_next_id differs: %d ---> %d\n", old->msg_next_id, new->msg_next_id); if (old->sem_next_id != new->sem_next_id) - pr_err("sem_next_id differs: %d ---> %d\n", - old->sem_next_id, new->sem_next_id); + pr_err("sem_next_id differs: %d ---> %d\n", old->sem_next_id, new->sem_next_id); if (old->shm_next_id != new->shm_next_id) - pr_err("shm_next_id differs: %d ---> %d\n", - old->shm_next_id, new->shm_next_id); + pr_err("shm_next_id differs: %d ---> %d\n", old->shm_next_id, new->shm_next_id); if (old->shm_ctlmax != new->shm_ctlmax) - pr_err("shm_ctlmax differs: %zu ---> %zu\n", - old->shm_ctlmax, new->shm_ctlmax); + pr_err("shm_ctlmax differs: %zu ---> %zu\n", old->shm_ctlmax, new->shm_ctlmax); if (old->shm_ctlall != new->shm_ctlall) - pr_err("shm_ctlall differs: %zu ---> %zu\n", - old->shm_ctlall, new->shm_ctlall); + pr_err("shm_ctlall differs: %zu ---> %zu\n", old->shm_ctlall, new->shm_ctlall); if (old->shm_ctlmni != new->shm_ctlmni) - pr_err("shm_ctlmni differs: %d ---> %d\n", - old->shm_ctlmni, new->shm_ctlmni); + pr_err("shm_ctlmni differs: %d ---> %d\n", old->shm_ctlmni, new->shm_ctlmni); if (old->shm_rmid_forced != new->shm_rmid_forced) - pr_err("shm_rmid_forced differs: %d ---> %d\n", - old->shm_rmid_forced, new->shm_rmid_forced); + pr_err("shm_rmid_forced differs: %d ---> %d\n", old->shm_rmid_forced, new->shm_rmid_forced); if (old->mq_queues_max != new->mq_queues_max) - pr_err("mq_queues_max differs: %d ---> %d\n", - old->mq_queues_max, new->mq_queues_max); + pr_err("mq_queues_max differs: %d ---> %d\n", old->mq_queues_max, new->mq_queues_max); if (old->mq_msg_max != new->mq_msg_max) - pr_err("mq_msg_max differs: %d ---> %d\n", - old->mq_msg_max, new->mq_msg_max); + pr_err("mq_msg_max differs: %d ---> %d\n", old->mq_msg_max, new->mq_msg_max); if (old->mq_msgsize_max != new->mq_msgsize_max) - pr_err("mq_msgsize_max differs: %d ---> %d\n", - old->mq_msgsize_max, new->mq_msgsize_max); + pr_err("mq_msgsize_max differs: %d ---> %d\n", old->mq_msgsize_max, new->mq_msgsize_max); if (old->mq_msg_default != new->mq_msg_default) - pr_err("mq_msg_default differs: %d ---> %d\n", - old->mq_msg_default, new->mq_msg_default); + pr_err("mq_msg_default differs: %d ---> %d\n", old->mq_msg_default, new->mq_msg_default); if (old->mq_msgsize_default != new->mq_msgsize_default) - pr_err("mq_msgsize_default differs: %d ---> %d\n", - old->mq_msgsize_default, new->mq_msgsize_default); + pr_err("mq_msgsize_default differs: %d ---> %d\n", old->mq_msgsize_default, new->mq_msgsize_default); } int main(int argc, char **argv) diff --git a/test/zdtm/static/jobctl00.c b/test/zdtm/static/jobctl00.c index a14c4a768..e842d418e 100644 --- a/test/zdtm/static/jobctl00.c +++ b/test/zdtm/static/jobctl00.c @@ -9,24 +9,27 @@ #include "zdtmtst.h" -const char *test_doc = "Check that job control migrates correctly"; -const char *test_author = "Roman Kagan <rkagan@parallels.com>"; +const char *test_doc = "Check that job control migrates correctly"; +const char *test_author = "Roman Kagan <rkagan@parallels.com>"; -#define JOBS_DEF 8 -#define JOBS_MAX 64 +#define JOBS_DEF 8 +#define JOBS_MAX 64 unsigned int num_jobs = JOBS_DEF; -TEST_OPTION(num_jobs, uint, "# \"jobs\" in a \"shell\" " - "(default " __stringify(JOBS_DEF) - ", max " __stringify(JOBS_MAX) ")", 0); +TEST_OPTION(num_jobs, uint, + "# \"jobs\" in a \"shell\" " + "(default " __stringify(JOBS_DEF) ", max " __stringify(JOBS_MAX) ")", + 0); -#define PROCS_DEF 4 +#define PROCS_DEF 4 unsigned int num_procs = PROCS_DEF; -TEST_OPTION(num_procs, uint, "# processes in a \"job\" " - "(default " __stringify(PROCS_DEF) ")", 0); +TEST_OPTION(num_procs, uint, + "# processes in a \"job\" " + "(default " __stringify(PROCS_DEF) ")", + 0); static const char wr_string[] = "All you need is love!\n"; static const char rd_string[] = "We all live in a yellow submarine\n"; -static const char susp_char = '\032'; /* ^Z */ +static const char susp_char = '\032'; /* ^Z */ static volatile sig_atomic_t signo = 0; @@ -47,12 +50,12 @@ static int wait4sig(int sig) sigset_t mask, oldmask; sigemptyset(&mask); sigaddset(&mask, sig); - sigaddset(&mask, SIGCHLD); /* to see our children die */ + sigaddset(&mask, SIGCHLD); /* to see our children die */ sigprocmask(SIG_BLOCK, &mask, &oldmask); while (!signo) - sigsuspend (&oldmask); - sigprocmask (SIG_UNBLOCK, &mask, NULL); + sigsuspend(&oldmask); + sigprocmask(SIG_UNBLOCK, &mask, NULL); return signo != sig; } @@ -68,8 +71,7 @@ static int is_fg(void) static int reader(int sig) { char str[sizeof(rd_string) + 1]; - return read(0, str, sizeof(str)) < 0 || - strcmp(str, rd_string); + return read(0, str, sizeof(str)) < 0 || strcmp(str, rd_string); } static int post_reader(int fd) @@ -107,30 +109,30 @@ static struct job_type { int (*action)(int sig); int (*post)(int fd); } job_types[] = { - { SIGTTOU, writer, post_writer }, - { SIGTTIN, reader, post_reader }, - { SIGCONT, wait4sig, NULL }, + { SIGTTOU, writer, post_writer }, + { SIGTTIN, reader, post_reader }, + { SIGCONT, wait4sig, NULL }, }; static int process(int (*action)(int), int sig) { int ret; - if (is_fg()) /* we must be in background on entry */ + if (is_fg()) /* we must be in background on entry */ return 1; if (signal(sig, record_and_raise_sig) == SIG_ERR) return 2; - kill(getppid(), SIGUSR2); /* tell the parent we're ready */ + kill(getppid(), SIGUSR2); /* tell the parent we're ready */ - ret = action(sig); /* will be busy doing nothing for the duration of migration */ + ret = action(sig); /* will be busy doing nothing for the duration of migration */ if (ret) return 3; - if (!is_fg()) /* we must be in foreground now */ + if (!is_fg()) /* we must be in foreground now */ return 4; - ret = signo != sig; /* have we got the desired signal? */ + ret = signo != sig; /* have we got the desired signal? */ test_waitsig(); return ret; @@ -144,22 +146,22 @@ static int job(int (*action)(int), int sig) return 1; for (i = num_procs; i; i--) { - pid_t pid = fork(); + pid_t pid = fork(); if (pid < 0) - kill(0, SIGKILL); /* kill the whole job */ + kill(0, SIGKILL); /* kill the whole job */ if (pid == 0) /* the last is worker, others are sleepers */ - exit(process(i == 1 ? action : wait4sig, sig)); + exit(process(i == 1 ? action : wait4sig, sig)); /* wait for the child to grow up before going to next one * ignore return code as the child may get stopped and SIGCHILD * us */ wait4sig(SIGUSR2); - signo = 0; /* rearm sighandler */ + signo = 0; /* rearm sighandler */ } - kill(getppid(), SIGUSR2); /* tell the parent we're ready */ + kill(getppid(), SIGUSR2); /* tell the parent we're ready */ /* we (or our children) will get suspended somehow here, so the rest * will hopefully happen after migration */ @@ -195,8 +197,7 @@ int start_jobs(pid_t *jobs, int njobs, int fdmaster, int fdslave) /* the children will signal readiness via SIGUSR2 or get stopped (or * exit :) and signal that via SIGCHLD */ - if (signal(SIGUSR2, record_sig) == SIG_ERR || - signal(SIGCHLD, record_sig) == SIG_ERR) { + if (signal(SIGUSR2, record_sig) == SIG_ERR || signal(SIGCHLD, record_sig) == SIG_ERR) { pr_perror("can't install signal handler"); return -1; } @@ -205,7 +206,7 @@ int start_jobs(pid_t *jobs, int njobs, int fdmaster, int fdslave) int jtno = i % (sizeof(job_types) / sizeof(job_types[0])); jobs[i] = fork(); - if (jobs[i] < 0) { /* we're busted - bail out */ + if (jobs[i] < 0) { /* we're busted - bail out */ pr_perror("fork failed"); goto killout; } @@ -222,7 +223,7 @@ int start_jobs(pid_t *jobs, int njobs, int fdmaster, int fdslave) /* wait for the child to grow up before proceeding */ wait4sig(SIGUSR2); - signo = 0; /* rearm sighandler */ + signo = 0; /* rearm sighandler */ } return 0; @@ -236,7 +237,7 @@ int finish_jobs(pid_t *jobs, int njobs, int fdmaster, int fdslave) { int i; - for (i = num_jobs; i--; ) { + for (i = num_jobs; i--;) { int ret; int jtno = i % (sizeof(job_types) / sizeof(job_types[0])); @@ -265,7 +266,7 @@ killout: return -1; } -int main(int argc, char ** argv) +int main(int argc, char **argv) { int fdmaster, fdslave; pid_t jobs[JOBS_MAX] = {}; diff --git a/test/zdtm/static/link10.c b/test/zdtm/static/link10.c index 9deb4a127..a0a00d661 100644 --- a/test/zdtm/static/link10.c +++ b/test/zdtm/static/link10.c @@ -9,13 +9,13 @@ #include "zdtmtst.h" -const char *test_doc = "Migrate two hardlinked, open, and unlinked files"; -const char *test_author = "Roman Kagan <rkagan@parallels.com>"; +const char *test_doc = "Migrate two hardlinked, open, and unlinked files"; +const char *test_author = "Roman Kagan <rkagan@parallels.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); -int main(int argc, char ** argv) +int main(int argc, char **argv) { int fd, fd2 = 0; struct stat stat, stat2; @@ -23,8 +23,7 @@ int main(int argc, char ** argv) test_init(argc, argv); - if (snprintf(filename2, sizeof(filename2), "%s.lnk", filename) >= - sizeof(filename2)) { + if (snprintf(filename2, sizeof(filename2), "%s.lnk", filename) >= sizeof(filename2)) { pr_perror("filename %s is too long", filename); exit(1); } @@ -57,11 +56,9 @@ int main(int argc, char ** argv) goto out; } - if (stat.st_ino != stat2.st_ino || - stat.st_dev != stat2.st_dev) { - fail("files are different: st_ino %lu != %lu or st_dev %lu != %lu", - (long unsigned)stat.st_ino, (long unsigned)stat2.st_ino, - (long unsigned)stat.st_dev, (long unsigned)stat2.st_dev); + if (stat.st_ino != stat2.st_ino || stat.st_dev != stat2.st_dev) { + fail("files are different: st_ino %lu != %lu or st_dev %lu != %lu", (long unsigned)stat.st_ino, + (long unsigned)stat2.st_ino, (long unsigned)stat.st_dev, (long unsigned)stat2.st_dev); } pass(); diff --git a/test/zdtm/static/loginuid.c b/test/zdtm/static/loginuid.c index dc27eeef3..dcd6ce04b 100644 --- a/test/zdtm/static/loginuid.c +++ b/test/zdtm/static/loginuid.c @@ -66,7 +66,6 @@ int set_loginuid(const char *path, uid_t value) return ret; } - int main(int argc, char *argv[]) { int ret; @@ -89,8 +88,7 @@ int main(int argc, char *argv[]) return -1; if (new_loginuid != test_value) { - fail("loginuid value %d is different after restore: %d", - test_value, new_loginuid); + fail("loginuid value %d is different after restore: %d", test_value, new_loginuid); return -1; } diff --git a/test/zdtm/static/macvlan.c b/test/zdtm/static/macvlan.c index 0d5feb233..1c78807c8 100644 --- a/test/zdtm/static/macvlan.c +++ b/test/zdtm/static/macvlan.c @@ -13,11 +13,11 @@ #include <net/if.h> #include "zdtmtst.h" -const char *test_doc = "check that macvlan interfaces are c/r'd correctly"; -const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; +const char *test_doc = "check that macvlan interfaces are c/r'd correctly"; +const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; #define BRIDGE_NAME "zdtmbr0" -#define IF_NAME "zdtmmvlan0" +#define IF_NAME "zdtmmvlan0" static bool wait_for_macvlan(void) { diff --git a/test/zdtm/static/maps00.c b/test/zdtm/static/maps00.c index 9ed248d4d..10a4cac79 100644 --- a/test/zdtm/static/maps00.c +++ b/test/zdtm/static/maps00.c @@ -10,9 +10,9 @@ #include <sys/stat.h> #include "zdtmtst.h" -const char *test_doc = "Create all sorts of maps and compare /proc/pid/maps\n" - "before and after migration\n"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Create all sorts of maps and compare /proc/pid/maps\n" + "before and after migration\n"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); @@ -23,9 +23,9 @@ const static int map_prots[] = { PROT_READ | PROT_WRITE, PROT_READ | PROT_WRITE | PROT_EXEC, }; -#define NUM_MPROTS sizeof(map_prots) / sizeof(int) -#define RW_PROT(x) ((x) & (PROT_READ | PROT_WRITE)) -#define X_PROT(x) ((x) & PROT_EXEC) +#define NUM_MPROTS sizeof(map_prots) / sizeof(int) +#define RW_PROT(x) ((x) & (PROT_READ | PROT_WRITE)) +#define X_PROT(x) ((x)&PROT_EXEC) int check_prot(int src_prot, int dst_prot) { @@ -37,21 +37,15 @@ int check_prot(int src_prot, int dst_prot) ** * A is a subset of B iff (A & B) == A */ - return (X_PROT(dst_prot) & X_PROT(src_prot)) == X_PROT(dst_prot); + return (X_PROT(dst_prot) & X_PROT(src_prot)) == X_PROT(dst_prot); } -const static int map_flags[] = { - MAP_PRIVATE, - MAP_SHARED, - MAP_PRIVATE | MAP_ANONYMOUS, - MAP_SHARED | MAP_ANONYMOUS -}; -#define NUM_MFLAGS sizeof(map_flags) / sizeof(int) -#define NUM_MAPS NUM_MPROTS * NUM_MFLAGS -#define ONE_MAP_SIZE 0x2000 +const static int map_flags[] = { MAP_PRIVATE, MAP_SHARED, MAP_PRIVATE | MAP_ANONYMOUS, MAP_SHARED | MAP_ANONYMOUS }; +#define NUM_MFLAGS sizeof(map_flags) / sizeof(int) +#define NUM_MAPS NUM_MPROTS *NUM_MFLAGS +#define ONE_MAP_SIZE 0x2000 -struct map -{ +struct map { int prot; int prot_real; int flag; @@ -75,8 +69,7 @@ static int make_map(struct map *map) if (!(map->flag & MAP_ANONYMOUS)) { /* need file */ - if (snprintf(map->filename, sizeof(map->filename), - "%s-%02d", filename, i++) >= sizeof(map->filename)) { + if (snprintf(map->filename, sizeof(map->filename), "%s-%02d", filename, i++) >= sizeof(map->filename)) { pr_perror("filename %s is too long", filename); return -1; } @@ -107,13 +100,12 @@ static int make_map(struct map *map) datagen(map->ptr, ONE_MAP_SIZE, &crc); } - test_msg("map: ptr %p flag %8x prot %8x\n", - map->ptr, map->flag, map->prot); + test_msg("map: ptr %p flag %8x prot %8x\n", map->ptr, map->flag, map->prot); return 0; } -static sigjmp_buf segv_ret; /* we need sig*jmp stuff, otherwise SIGSEGV will reset our handler */ +static sigjmp_buf segv_ret; /* we need sig*jmp stuff, otherwise SIGSEGV will reset our handler */ static void segfault(int signo) { siglongjmp(segv_ret, 1); @@ -131,19 +123,16 @@ static int check_map(struct map *map) { int prot = PROT_WRITE | PROT_READ | PROT_EXEC; - if (signal(SIGSEGV, segfault) == SIG_ERR) - { + if (signal(SIGSEGV, segfault) == SIG_ERR) { fail("setting SIGSEGV handler failed"); return -1; } - if (!sigsetjmp(segv_ret, 1)) - { + if (!sigsetjmp(segv_ret, 1)) { uint32_t crc = ~0; - if (datachk(map->ptr, ONE_MAP_SIZE, &crc)) /* perform read access */ + if (datachk(map->ptr, ONE_MAP_SIZE, &crc)) /* perform read access */ if (!(map->flag & MAP_ANONYMOUS) || - (map->prot & PROT_WRITE)) { /* anon maps could only be filled when r/w */ - fail("CRC mismatch: ptr %p flag %8x prot %8x", - map->ptr, map->flag, map->prot); + (map->prot & PROT_WRITE)) { /* anon maps could only be filled when r/w */ + fail("CRC mismatch: ptr %p flag %8x prot %8x", map->ptr, map->flag, map->prot); return -1; } /* prot |= PROT_READ// need barrier before this line, @@ -152,33 +141,29 @@ static int check_map(struct map *map) } else prot &= PROT_WRITE | !PROT_READ | PROT_EXEC; - if (signal(SIGSEGV, segfault) == SIG_ERR) - { + if (signal(SIGSEGV, segfault) == SIG_ERR) { fail("setting SIGSEGV handler failed"); return -1; } - if (!sigsetjmp(segv_ret, 1)) - { - * (int *) (map->ptr) = 1234; /* perform write access */ + if (!sigsetjmp(segv_ret, 1)) { + *(int *)(map->ptr) = 1234; /* perform write access */ } else prot &= !PROT_WRITE | PROT_READ | PROT_EXEC; - if (signal(SIGSEGV, segfault) == SIG_ERR) - { + if (signal(SIGSEGV, segfault) == SIG_ERR) { fail("restoring SIGSEGV handler failed"); return -1; } - if (!sigsetjmp(segv_ret, 1)) - { + if (!sigsetjmp(segv_ret, 1)) { if (map->prot & PROT_WRITE) { - memcpy(map->ptr,test_func, getpagesize()); + memcpy(map->ptr, test_func, getpagesize()); } else { if (!(map->flag & MAP_ANONYMOUS)) { uint8_t funlen = (uint8_t *)check_map - (uint8_t *)test_func; - lseek(map->fd,0,SEEK_SET); - if (write(map->fd,test_func,funlen)<funlen) { + lseek(map->fd, 0, SEEK_SET); + if (write(map->fd, test_func, funlen) < funlen) { pr_perror("failed to write %s", map->filename); return -1; } @@ -186,7 +171,7 @@ static int check_map(struct map *map) } if (!(map->flag & MAP_ANONYMOUS) || map->prot & PROT_WRITE) /* Function body has been copied into the mapping */ - ((int (*)(void))map->ptr)(); /* perform exec access */ + ((int (*)(void))map->ptr)(); /* perform exec access */ else /* No way to copy function body into mapping, * clear exec bit from effective protection @@ -195,8 +180,7 @@ static int check_map(struct map *map) } else prot &= PROT_WRITE | PROT_READ | !PROT_EXEC; - if (signal(SIGSEGV, SIG_DFL) == SIG_ERR) - { + if (signal(SIGSEGV, SIG_DFL) == SIG_ERR) { fail("restoring SIGSEGV handler failed"); return -1; } @@ -208,17 +192,15 @@ static void destroy_map(struct map *map) { munmap(map->ptr, ONE_MAP_SIZE); - if (map->fd >= 0) - { + if (map->fd >= 0) { close(map->fd); unlink(map->filename); } } +#define MAPS_LEN 0x10000 -#define MAPS_LEN 0x10000 - -int main(int argc, char ** argv) +int main(int argc, char **argv) { struct map maps[NUM_MAPS] = {}, maps_compare[NUM_MAPS] = {}; int i, j, k; @@ -237,22 +219,22 @@ int main(int argc, char ** argv) test_waitsig(); for (i = 0; i < NUM_MAPS; i++) - if ((maps[i].prot_real=check_map(maps + i))<0) + if ((maps[i].prot_real = check_map(maps + i)) < 0) goto err; - k=0; + k = 0; for (i = 0; i < NUM_MPROTS; i++) for (j = 0; j < NUM_MFLAGS; j++) init_map(maps_compare + k++, i, j); for (i = 0; i < NUM_MAPS; i++) - if (make_map(maps_compare+ i)) + if (make_map(maps_compare + i)) goto err; for (i = 0; i < NUM_MAPS; i++) - if ((maps_compare[i].prot_real=check_map(maps_compare + i))<0) + if ((maps_compare[i].prot_real = check_map(maps_compare + i)) < 0) goto err; - for (i = 0; i< NUM_MAPS; i++) - if (!check_prot(maps[i].prot_real, maps_compare[i].prot_real)){ - fail("protection on %i (flag=%d prot=%d) maps has changed (prot=%d(expected %d))", - i, maps[i].flag, maps[i].prot, maps[i].prot_real, maps_compare[i].prot_real); + for (i = 0; i < NUM_MAPS; i++) + if (!check_prot(maps[i].prot_real, maps_compare[i].prot_real)) { + fail("protection on %i (flag=%d prot=%d) maps has changed (prot=%d(expected %d))", i, + maps[i].flag, maps[i].prot, maps[i].prot_real, maps_compare[i].prot_real); goto err; } diff --git a/test/zdtm/static/maps01.c b/test/zdtm/static/maps01.c index 2bb465a25..9b8019ee2 100644 --- a/test/zdtm/static/maps01.c +++ b/test/zdtm/static/maps01.c @@ -11,15 +11,15 @@ #include <linux/limits.h> #include "zdtmtst.h" -#define MEM_SIZE (1LU << 30) -#define MEM_OFFSET (1LU << 29) +#define MEM_SIZE (1LU << 30) +#define MEM_OFFSET (1LU << 29) #define MEM_OFFSET2 (MEM_SIZE - PAGE_SIZE) #define MEM_OFFSET3 (20LU * PAGE_SIZE) -const char *test_doc = "Test shared memory"; -const char *test_author = "Andrew Vagin <avagin@openvz.org"; +const char *test_doc = "Test shared memory"; +const char *test_author = "Andrew Vagin <avagin@openvz.org"; -int main(int argc, char ** argv) +int main(int argc, char **argv) { void *m, *m2, *p, *p2; char path[PATH_MAX]; @@ -32,28 +32,23 @@ int main(int argc, char ** argv) task_waiter_init(&t); - m = mmap(NULL, MEM_SIZE, PROT_WRITE | PROT_READ, - MAP_SHARED | MAP_ANONYMOUS, -1, 0); + m = mmap(NULL, MEM_SIZE, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_ANONYMOUS, -1, 0); if (m == MAP_FAILED) { - pr_perror("Failed to mmap %lu Mb shared anonymous R/W memory", - MEM_SIZE >> 20); + pr_perror("Failed to mmap %lu Mb shared anonymous R/W memory", MEM_SIZE >> 20); goto err; } - p = mmap(NULL, MEM_SIZE, PROT_WRITE | PROT_READ, - MAP_SHARED | MAP_ANONYMOUS, -1, 0); + p = mmap(NULL, MEM_SIZE, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_ANONYMOUS, -1, 0); if (p == MAP_FAILED) { - pr_perror("Failed to mmap %ld Mb shared anonymous R/W memory", - MEM_SIZE >> 20); + pr_perror("Failed to mmap %ld Mb shared anonymous R/W memory", MEM_SIZE >> 20); goto err; } p2 = mmap(NULL, MEM_OFFSET, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (p2 == MAP_FAILED) { - pr_perror("Failed to mmap %lu Mb anonymous memory", - MEM_OFFSET >> 20); + pr_perror("Failed to mmap %lu Mb anonymous memory", MEM_OFFSET >> 20); goto err; } @@ -64,11 +59,9 @@ int main(int argc, char ** argv) } else if (pid == 0) { void *p3; - p3 = mmap(NULL, MEM_OFFSET3, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + p3 = mmap(NULL, MEM_OFFSET3, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (p3 == MAP_FAILED) { - pr_perror("Failed to mmap %lu Mb anonymous R/W memory", - MEM_OFFSET3 >> 20); + pr_perror("Failed to mmap %lu Mb anonymous R/W memory", MEM_OFFSET3 >> 20); goto err; } @@ -122,9 +115,7 @@ int main(int argc, char ** argv) if (p2 == MAP_FAILED) goto err; - snprintf(path, PATH_MAX, "/proc/self/map_files/%lx-%lx", - (unsigned long) m, - (unsigned long) m + MEM_SIZE); + snprintf(path, PATH_MAX, "/proc/self/map_files/%lx-%lx", (unsigned long)m, (unsigned long)m + MEM_SIZE); fd = open(path, O_RDWR); if (fd == -1) { pr_perror("Can't open file %s", path); diff --git a/test/zdtm/static/maps02.c b/test/zdtm/static/maps02.c index eb7c09bdc..29f1372c9 100644 --- a/test/zdtm/static/maps02.c +++ b/test/zdtm/static/maps02.c @@ -3,26 +3,25 @@ #include "get_smaps_bits.h" #ifndef MADV_DONTDUMP -#define MADV_DONTDUMP 16 +#define MADV_DONTDUMP 16 #endif -const char *test_doc = "Test shared memory with advises"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; +const char *test_doc = "Test shared memory with advises"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; struct mmap_data { - void *start; - unsigned long orig_flags; - unsigned long orig_madv; - unsigned long new_flags; - unsigned long new_madv; + void *start; + unsigned long orig_flags; + unsigned long orig_madv; + unsigned long new_flags; + unsigned long new_madv; }; #define MEM_SIZE (8192) static int alloc_anon_mmap(struct mmap_data *m, int flags, int adv) { - m->start = mmap(NULL, MEM_SIZE, PROT_READ | PROT_WRITE, - flags, -1, 0); + m->start = mmap(NULL, MEM_SIZE, PROT_READ | PROT_WRITE, flags, -1, 0); if (m->start == MAP_FAILED) { pr_perror("mmap failed"); return -1; @@ -32,7 +31,7 @@ static int alloc_anon_mmap(struct mmap_data *m, int flags, int adv) if (errno == EINVAL) { test_msg("madvise failed, no kernel support\n"); munmap(m->start, MEM_SIZE); - *m = (struct mmap_data){ }; + *m = (struct mmap_data){}; } else { pr_perror("madvise failed"); return -1; @@ -44,7 +43,7 @@ static int alloc_anon_mmap(struct mmap_data *m, int flags, int adv) int main(int argc, char **argv) { - struct mmap_data m[5] = { }; + struct mmap_data m[5] = {}; size_t i; test_init(argc, argv); @@ -70,10 +69,8 @@ int main(int argc, char **argv) return -1; test_msg("Fetch existing flags/adv\n"); - for (i = 0; i < sizeof(m)/sizeof(m[0]); i++) { - if (get_smaps_bits((unsigned long)m[i].start, - &m[i].orig_flags, - &m[i].orig_madv)) + for (i = 0; i < sizeof(m) / sizeof(m[0]); i++) { + if (get_smaps_bits((unsigned long)m[i].start, &m[i].orig_flags, &m[i].orig_madv)) return -1; } @@ -81,28 +78,23 @@ int main(int argc, char **argv) test_waitsig(); test_msg("Fetch restored flags/adv\n"); - for (i = 0; i < sizeof(m)/sizeof(m[0]); i++) { - if (get_smaps_bits((unsigned long)m[i].start, - &m[i].new_flags, - &m[i].new_madv)) + for (i = 0; i < sizeof(m) / sizeof(m[0]); i++) { + if (get_smaps_bits((unsigned long)m[i].start, &m[i].new_flags, &m[i].new_madv)) return -1; if (m[i].orig_flags != m[i].new_flags) { - pr_perror("Flags are changed %lx %lx -> %lx (%zu)", - (unsigned long)m[i].start, - m[i].orig_flags, m[i].new_flags, i); + pr_perror("Flags are changed %lx %lx -> %lx (%zu)", (unsigned long)m[i].start, m[i].orig_flags, + m[i].new_flags, i); fail(); return -1; } if (m[i].orig_madv != m[i].new_madv) { - pr_perror("Madvs are changed %lx %lx -> %lx (%zu)", - (unsigned long)m[i].start, - m[i].orig_madv, m[i].new_madv, i); + pr_perror("Madvs are changed %lx %lx -> %lx (%zu)", (unsigned long)m[i].start, m[i].orig_madv, + m[i].new_madv, i); fail(); return -1; } - } pass(); diff --git a/test/zdtm/static/maps03.c b/test/zdtm/static/maps03.c index 17299d551..064811c15 100644 --- a/test/zdtm/static/maps03.c +++ b/test/zdtm/static/maps03.c @@ -4,15 +4,15 @@ #include <limits.h> #include "zdtmtst.h" -#if (LONG_MAX == 2147483647L) /* 32 bit */ +#if (LONG_MAX == 2147483647L) /* 32 bit */ #define TEST_SKIP_REASON "64-bit arch required" #include "skip-me.c" #else -const char *test_doc = "Test for huge VMA area"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; +const char *test_doc = "Test for huge VMA area"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; int main(int argc, char **argv) { @@ -21,8 +21,7 @@ int main(int argc, char **argv) test_init(argc, argv); test_msg("Alloc huge VMA\n"); - mem = (void *)mmap(NULL, (10L << 30), PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + mem = (void *)mmap(NULL, (10L << 30), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if ((void *)mem == MAP_FAILED) { pr_perror("mmap failed"); return -1; diff --git a/test/zdtm/static/maps04.c b/test/zdtm/static/maps04.c index 780c5667d..dbbb5c644 100644 --- a/test/zdtm/static/maps04.c +++ b/test/zdtm/static/maps04.c @@ -13,10 +13,10 @@ #define MEM_SIZE (1L << 29) -const char *test_doc = "Test big mappings"; -const char *test_author = "Andrew Vagin <avagin@openvz.org"; +const char *test_doc = "Test big mappings"; +const char *test_author = "Andrew Vagin <avagin@openvz.org"; -int main(int argc, char ** argv) +int main(int argc, char **argv) { void *m; uint32_t crc; @@ -24,8 +24,7 @@ int main(int argc, char ** argv) test_init(argc, argv); - m = mmap(NULL, MEM_SIZE, PROT_WRITE | PROT_READ, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + m = mmap(NULL, MEM_SIZE, PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (m == MAP_FAILED) { fail(); @@ -35,7 +34,7 @@ int main(int argc, char ** argv) crc = ~0; datagen(m, MEM_SIZE, &crc); - for (i = 0; i < MEM_SIZE / (1<<20); i++) + for (i = 0; i < MEM_SIZE / (1 << 20); i++) if (mprotect(m + (lrand48() * PAGE_SIZE % MEM_SIZE), PAGE_SIZE, PROT_NONE)) { pr_perror("mprotect"); return 1; diff --git a/test/zdtm/static/maps05.c b/test/zdtm/static/maps05.c index faa09ee9a..be8f2309b 100644 --- a/test/zdtm/static/maps05.c +++ b/test/zdtm/static/maps05.c @@ -10,20 +10,20 @@ #include <sys/stat.h> #include "zdtmtst.h" -const char *test_doc = "Create a bunch of small VMAs and test they survive transferring\n"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; +const char *test_doc = "Create a bunch of small VMAs and test they survive transferring\n"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; -#define NR_MAPS 4096 +#define NR_MAPS 4096 -#define NR_MAPS_1 (NR_MAPS + 0) -#define NR_MAPS_2 (NR_MAPS + 1) +#define NR_MAPS_1 (NR_MAPS + 0) +#define NR_MAPS_2 (NR_MAPS + 1) -#define MAPS_SIZE_1 (140 << 10) -#define MAPS_SIZE_2 (8192) +#define MAPS_SIZE_1 (140 << 10) +#define MAPS_SIZE_2 (8192) int main(int argc, char *argv[]) { - void *map[NR_MAPS + 2] = { }, *addr; + void *map[NR_MAPS + 2] = {}, *addr; size_t i, summary; test_init(argc, argv); diff --git a/test/zdtm/static/maps06.c b/test/zdtm/static/maps06.c index 7480d6b24..6f7028ace 100644 --- a/test/zdtm/static/maps06.c +++ b/test/zdtm/static/maps06.c @@ -4,13 +4,13 @@ #include <sys/stat.h> #include <fcntl.h> -const char *test_doc = "Create a lot of file vma-s"; -const char *test_author = "Andrei Vagin <avagin@openvz.org>"; +const char *test_doc = "Create a lot of file vma-s"; +const char *test_author = "Andrei Vagin <avagin@openvz.org>"; char *filename; TEST_OPTION(filename, string, "file name", 1); -int main(int argc, char ** argv) +int main(int argc, char **argv) { void *start; int fd, i; @@ -36,15 +36,12 @@ int main(int argc, char ** argv) for (i = 0; i < test_size; i++) { int *addr; - addr = mmap(start + i * 3 * ps, ps, - PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_FILE | MAP_FIXED, fd, 0); + addr = mmap(start + i * 3 * ps, ps, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FILE | MAP_FIXED, fd, 0); if (addr == MAP_FAILED) return 1; addr[0] = i * 2; - addr = mmap(start + (i * 3 + 1) * ps, ps, - PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); + addr = mmap(start + (i * 3 + 1) * ps, ps, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); if (addr == MAP_FAILED) return 1; addr[0] = i; @@ -59,7 +56,7 @@ int main(int argc, char ** argv) addr = start + i * 3 * ps; if (addr[0] != i * 2) fail(); - addr = start + (i * 3 + 1) * ps; + addr = start + (i * 3 + 1) * ps; if (addr[0] != i) fail(); } diff --git a/test/zdtm/static/maps_file_prot.c b/test/zdtm/static/maps_file_prot.c index 3b28c1ff1..434cf075f 100644 --- a/test/zdtm/static/maps_file_prot.c +++ b/test/zdtm/static/maps_file_prot.c @@ -7,15 +7,19 @@ #include <linux/limits.h> #include "zdtmtst.h" -const char *test_doc = "Test mappings of same file with different prot"; -const char *test_author = "Jamie Liu <jamieliu@google.com>"; +const char *test_doc = "Test mappings of same file with different prot"; +const char *test_author = "Jamie Liu <jamieliu@google.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); -#define die(fmt, arg...) do { pr_perror(fmt, ## arg); return 1; } while (0) +#define die(fmt, arg...) \ + do { \ + pr_perror(fmt, ##arg); \ + return 1; \ + } while (0) -int main(int argc, char ** argv) +int main(int argc, char **argv) { void *ro_map, *rw_map; int fd; diff --git a/test/zdtm/static/mem-touch.c b/test/zdtm/static/mem-touch.c index b11c97f53..fb7f13528 100644 --- a/test/zdtm/static/mem-touch.c +++ b/test/zdtm/static/mem-touch.c @@ -7,10 +7,10 @@ #include "zdtmtst.h" -const char *test_doc = "Check changing memory"; -const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; +const char *test_doc = "Check changing memory"; +const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; -#define MEM_PAGES 16 +#define MEM_PAGES 16 int main(int argc, char **argv) { @@ -32,7 +32,10 @@ int main(int argc, char **argv) test_daemon(); while (test_go()) { unsigned pfn; - struct timespec req = { .tv_sec = 0, .tv_nsec = 100000, }; + struct timespec req = { + .tv_sec = 0, + .tv_nsec = 100000, + }; pfn = random() % MEM_PAGES; *(unsigned *)(mem + pfn * PAGE_SIZE) = rover; @@ -46,8 +49,7 @@ int main(int argc, char **argv) test_msg("final rover %u\n", rover); for (i = 0; i < MEM_PAGES; i++) if (backup[i] != *(unsigned *)(mem + i * PAGE_SIZE)) { - test_msg("Page %u differs want %u has %u\n", i, - backup[i], *(unsigned *)(mem + i * PAGE_SIZE)); + test_msg("Page %u differs want %u has %u\n", i, backup[i], *(unsigned *)(mem + i * PAGE_SIZE)); fail = 1; } else test_msg("Page %u matches %u\n", i, backup[i]); @@ -59,4 +61,3 @@ int main(int argc, char **argv) return 0; } - diff --git a/test/zdtm/static/memfd00.c b/test/zdtm/static/memfd00.c index 6b56eca01..d037f6969 100644 --- a/test/zdtm/static/memfd00.c +++ b/test/zdtm/static/memfd00.c @@ -12,10 +12,14 @@ #include "zdtmtst.h" -const char *test_doc = "memfd file descriptor"; -const char *test_author = "Nicolas Viennot <Nicolas.Viennot@twosigma.com>"; - -#define err(exitcode, msg, ...) ({ pr_perror(msg, ##__VA_ARGS__); exit(exitcode); }) +const char *test_doc = "memfd file descriptor"; +const char *test_author = "Nicolas Viennot <Nicolas.Viennot@twosigma.com>"; + +#define err(exitcode, msg, ...) \ + ({ \ + pr_perror(msg, ##__VA_ARGS__); \ + exit(exitcode); \ + }) static int _memfd_create(const char *name, unsigned int flags) { diff --git a/test/zdtm/static/memfd01.c b/test/zdtm/static/memfd01.c index 7a7853642..90ff80fa2 100644 --- a/test/zdtm/static/memfd01.c +++ b/test/zdtm/static/memfd01.c @@ -13,10 +13,14 @@ #include "zdtmtst.h" -const char *test_doc = "memfd with different file pointer"; -const char *test_author = "Nicolas Viennot <Nicolas.Viennot@twosigma.com>"; - -#define err(exitcode, msg, ...) ({ pr_perror(msg, ##__VA_ARGS__); exit(exitcode); }) +const char *test_doc = "memfd with different file pointer"; +const char *test_author = "Nicolas Viennot <Nicolas.Viennot@twosigma.com>"; + +#define err(exitcode, msg, ...) \ + ({ \ + pr_perror(msg, ##__VA_ARGS__); \ + exit(exitcode); \ + }) static int _memfd_create(const char *name, unsigned int flags) { diff --git a/test/zdtm/static/memfd02.c b/test/zdtm/static/memfd02.c index 1843e9c9a..12e294921 100644 --- a/test/zdtm/static/memfd02.c +++ b/test/zdtm/static/memfd02.c @@ -13,10 +13,14 @@ #include "zdtmtst.h" -const char *test_doc = "memfd mmap"; -const char *test_author = "Nicolas Viennot <Nicolas.Viennot@twosigma.com>"; - -#define err(exitcode, msg, ...) ({ pr_perror(msg, ##__VA_ARGS__); exit(exitcode); }) +const char *test_doc = "memfd mmap"; +const char *test_author = "Nicolas Viennot <Nicolas.Viennot@twosigma.com>"; + +#define err(exitcode, msg, ...) \ + ({ \ + pr_perror(msg, ##__VA_ARGS__); \ + exit(exitcode); \ + }) static int _memfd_create(const char *name, unsigned int flags) { diff --git a/test/zdtm/static/memfd03.c b/test/zdtm/static/memfd03.c index faedf9383..c25e211dd 100644 --- a/test/zdtm/static/memfd03.c +++ b/test/zdtm/static/memfd03.c @@ -13,35 +13,37 @@ #include "zdtmtst.h" -const char *test_doc = "memfd seals"; -const char *test_author = "Nicolas Viennot <Nicolas.Viennot@twosigma.com>"; +const char *test_doc = "memfd seals"; +const char *test_author = "Nicolas Viennot <Nicolas.Viennot@twosigma.com>"; -#define err(exitcode, msg, ...) ({ pr_perror(msg, ##__VA_ARGS__); exit(exitcode); }) +#define err(exitcode, msg, ...) \ + ({ \ + pr_perror(msg, ##__VA_ARGS__); \ + exit(exitcode); \ + }) static int _memfd_create(const char *name, unsigned int flags) { return syscall(SYS_memfd_create, name, flags); } - #ifndef F_LINUX_SPECIFIC_BASE -# define F_LINUX_SPECIFIC_BASE 1024 +#define F_LINUX_SPECIFIC_BASE 1024 #endif #ifndef F_ADD_SEALS - #define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9) +#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9) #endif #ifndef F_GET_SEALS - #define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10) +#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10) #endif - #ifndef F_SEAL_SEAL -#define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */ -#define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */ -#define F_SEAL_GROW 0x0004 /* prevent file from growing */ -#define F_SEAL_WRITE 0x0008 /* prevent writes */ +#define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */ +#define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */ +#define F_SEAL_GROW 0x0004 /* prevent file from growing */ +#define F_SEAL_WRITE 0x0008 /* prevent writes */ #endif int main(int argc, char *argv[]) diff --git a/test/zdtm/static/mlock_setuid.c b/test/zdtm/static/mlock_setuid.c index d8aec8315..86df7fd62 100644 --- a/test/zdtm/static/mlock_setuid.c +++ b/test/zdtm/static/mlock_setuid.c @@ -15,15 +15,13 @@ int main(int argc, char **argv) test_init(argc, argv); test_msg("Alloc vma of size %d\n", MEM_SIZE); - start = mmap(NULL, MEM_SIZE, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + start = mmap(NULL, MEM_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (start == MAP_FAILED) { pr_perror("mmap failed"); return -1; } - test_msg("Lock vma from %p to %lx\n", - start, (unsigned long)start + MEM_SIZE); + test_msg("Lock vma from %p to %lx\n", start, (unsigned long)start + MEM_SIZE); ret = mlock(start, MEM_SIZE); if (ret < 0) { pr_perror("mlock"); diff --git a/test/zdtm/static/mmx00.c b/test/zdtm/static/mmx00.c index b736a80a1..cf9419b63 100644 --- a/test/zdtm/static/mmx00.c +++ b/test/zdtm/static/mmx00.c @@ -3,43 +3,33 @@ #include "zdtmtst.h" -const char *test_doc = "Start a calculation, leaving MMX in a certain state,\n" -"before migration, continue after"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Start a calculation, leaving MMX in a certain state,\n" + "before migration, continue after"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; #if defined(__i386__) || defined(__x86_64__) void start(uint8_t *bytes, uint16_t *words) { - __asm__ volatile ( - "movq %0, %%mm0\n" - "movq %1, %%mm1\n" - "movq %2, %%mm2\n" - "movq %3, %%mm3\n" - "paddb %%mm0, %%mm1\n" - "psubw %%mm2, %%mm3\n" - : - : "m" (bytes[0]), "m" (bytes[8]), - "m" (words[0]), "m" (words[4]) - ); + __asm__ volatile("movq %0, %%mm0\n" + "movq %1, %%mm1\n" + "movq %2, %%mm2\n" + "movq %3, %%mm3\n" + "paddb %%mm0, %%mm1\n" + "psubw %%mm2, %%mm3\n" + : + : "m"(bytes[0]), "m"(bytes[8]), "m"(words[0]), "m"(words[4])); } void finish(uint8_t *bytes, uint16_t *words) { - __asm__ volatile ( - "movq %%mm1, %0\n" - "movq %%mm3, %1\n" - : "=m" (bytes[0]), "=m" (words[0]) - ); + __asm__ volatile("movq %%mm1, %0\n" + "movq %%mm3, %1\n" + : "=m"(bytes[0]), "=m"(words[0])); } static inline void cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx) { - __asm__("cpuid" - : "=a" (*eax), - "=b" (*ebx), - "=c" (*ecx), - "=d" (*edx) - : "0" (op), "c"(0)); + __asm__("cpuid" : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx) : "0"(op), "c"(0)); } int chk_proc_mmx(void) @@ -54,12 +44,12 @@ int chk_proc_mmx(void) int main(int argc, char **argv) { #if defined(__i386__) || defined(__x86_64__) - uint8_t bytes[16]; + uint8_t bytes[16]; uint16_t words[8]; uint32_t rnd[8]; int i; - uint8_t resbytes1[8], resbytes2[8]; + uint8_t resbytes1[8], resbytes2[8]; uint16_t reswords1[4], reswords2[4]; #endif @@ -73,8 +63,8 @@ int main(int argc, char **argv) for (i = 0; i < (sizeof(bytes) + sizeof(words)) / 4; i++) rnd[i] = mrand48(); - memcpy((uint8_t *) bytes, (uint8_t *) rnd, sizeof(bytes)); - memcpy((uint8_t *) words, (uint8_t *) rnd + sizeof(bytes), sizeof(words)); + memcpy((uint8_t *)bytes, (uint8_t *)rnd, sizeof(bytes)); + memcpy((uint8_t *)words, (uint8_t *)rnd + sizeof(bytes), sizeof(words)); start(bytes, words); finish(resbytes1, reswords1); @@ -86,9 +76,9 @@ int main(int argc, char **argv) finish(resbytes2, reswords2); - if (memcmp((uint8_t *) resbytes1, (uint8_t *) resbytes2, sizeof(resbytes1))) + if (memcmp((uint8_t *)resbytes1, (uint8_t *)resbytes2, sizeof(resbytes1))) fail("byte op mismatch"); - else if (memcmp((uint8_t *) reswords1, (uint8_t *) reswords2, sizeof(reswords2))) + else if (memcmp((uint8_t *)reswords1, (uint8_t *)reswords2, sizeof(reswords2))) fail("word op mismatch"); else pass(); diff --git a/test/zdtm/static/mnt_enablefs.c b/test/zdtm/static/mnt_enablefs.c index 3de4c57eb..6f0cb9363 100644 --- a/test/zdtm/static/mnt_enablefs.c +++ b/test/zdtm/static/mnt_enablefs.c @@ -10,8 +10,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check enabled file systems (--enable-fs)"; -const char *test_author = "Andrei Vagin <avagin@virtuozzo.com>"; +const char *test_doc = "Check enabled file systems (--enable-fs)"; +const char *test_author = "Andrei Vagin <avagin@virtuozzo.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); diff --git a/test/zdtm/static/mnt_ext_auto.c b/test/zdtm/static/mnt_ext_auto.c index 9181b370a..977dfdbf8 100644 --- a/test/zdtm/static/mnt_ext_auto.c +++ b/test/zdtm/static/mnt_ext_auto.c @@ -10,8 +10,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check --mnt-ext-map"; -const char *test_author = "Andrew Vagin <avagin@gmail.com>"; +const char *test_doc = "Check --mnt-ext-map"; +const char *test_author = "Andrew Vagin <avagin@gmail.com>"; #ifdef ZDTM_EXTMAP_MANUAL char *dirname = "mnt_ext_manual.test"; @@ -19,25 +19,25 @@ char *dirname_private_shared_bind = "mnt_ext_manual_private_shared_bind.test"; char *dirname_bind = "mnt_ext_manual_bind.test"; char *dirname_slave_shared_bind = "mnt_ext_manual_slave_shared_bind.test"; char *dirname_slave_bind = "mnt_ext_manual_slave_bind.test"; -#define DDIR "mtest" +#define DDIR "mtest" #else char *dirname = "mnt_ext_auto.test"; char *dirname_private_shared_bind = "mnt_ext_auto_private_shared_bind.test"; char *dirname_bind = "mnt_ext_auto_bind.test"; char *dirname_slave_shared_bind = "mnt_ext_auto_slave_shared_bind.test"; char *dirname_slave_bind = "mnt_ext_auto_slave_bind.test"; -#define DDIR "atest" +#define DDIR "atest" #endif TEST_OPTION(dirname, string, "directory name", 1); -int main(int argc, char ** argv) +int main(int argc, char **argv) { char src[PATH_MAX], dst[PATH_MAX], *root; - char dst_bind[PATH_MAX], dst_private_shared_bind[PATH_MAX], - dst_slave_shared_bind[PATH_MAX], dst_slave_bind[PATH_MAX]; + char dst_bind[PATH_MAX], dst_private_shared_bind[PATH_MAX], dst_slave_shared_bind[PATH_MAX], + dst_slave_bind[PATH_MAX]; char *dname = "/tmp/zdtm_ext_auto.XXXXXX"; struct stat sta, stb, bsta, bstb, ssbsta, sbsta, ssbstb, sbstb, psbsta, psbstb; - char* zdtm_newns = getenv("ZDTM_NEWNS"); + char *zdtm_newns = getenv("ZDTM_NEWNS"); root = getenv("ZDTM_ROOT"); if (root == NULL) { diff --git a/test/zdtm/static/mnt_ext_dev.c b/test/zdtm/static/mnt_ext_dev.c index 1d60fc92f..2035a4cfb 100644 --- a/test/zdtm/static/mnt_ext_dev.c +++ b/test/zdtm/static/mnt_ext_dev.c @@ -11,8 +11,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check mounts of external devices"; -const char *test_author = "Andrei Vagin <avagin@virtuozzo.com"; +const char *test_doc = "Check mounts of external devices"; +const char *test_author = "Andrei Vagin <avagin@virtuozzo.com"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); diff --git a/test/zdtm/static/mnt_ext_master.c b/test/zdtm/static/mnt_ext_master.c index 12e9ebab1..5fd8fa8b2 100644 --- a/test/zdtm/static/mnt_ext_master.c +++ b/test/zdtm/static/mnt_ext_master.c @@ -11,13 +11,13 @@ #include "zdtmtst.h" -const char *test_doc = "Check that mounts with external master peers are c/r'd"; -const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; +const char *test_doc = "Check that mounts with external master peers are c/r'd"; +const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; char *dirname = "mnt_ext_auto.test"; TEST_OPTION(dirname, string, "directory name", 1); -int main(int argc, char ** argv) +int main(int argc, char **argv) { char src[PATH_MAX], dst[PATH_MAX], *root; char *dname = "/tmp/zdtm_ext_auto.XXXXXX"; @@ -64,7 +64,6 @@ test: test_daemon(); test_waitsig(); - pass(); return 0; diff --git a/test/zdtm/static/mnt_ro_bind.c b/test/zdtm/static/mnt_ro_bind.c index 1d9881408..2802c87e5 100644 --- a/test/zdtm/static/mnt_ro_bind.c +++ b/test/zdtm/static/mnt_ro_bind.c @@ -9,14 +9,14 @@ #include "zdtmtst.h" -const char *test_doc = "Check read-only bind-mounts"; -const char *test_author = "Andrew Vagin <avagin@openvz.org>"; +const char *test_doc = "Check read-only bind-mounts"; +const char *test_author = "Andrew Vagin <avagin@openvz.org>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); -#define TEST_WORD "testtest" -#define TEST_WORD2 "TESTTEST" +#define TEST_WORD "testtest" +#define TEST_WORD2 "TESTTEST" int main(int argc, char **argv) { diff --git a/test/zdtm/static/mnt_tracefs.c b/test/zdtm/static/mnt_tracefs.c index 99d60870a..66a00c02f 100644 --- a/test/zdtm/static/mnt_tracefs.c +++ b/test/zdtm/static/mnt_tracefs.c @@ -10,13 +10,13 @@ #include "zdtmtst.h" -const char *test_doc = "Test c/r of tracefs"; -const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; +const char *test_doc = "Test c/r of tracefs"; +const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; char *dirname = "mnt_tracefs.test"; TEST_OPTION(dirname, string, "directory name", 1); -int main(int argc, char ** argv) +int main(int argc, char **argv) { char dst[PATH_MAX]; @@ -69,4 +69,3 @@ test: pass(); return 0; } - diff --git a/test/zdtm/static/mntns_deleted.c b/test/zdtm/static/mntns_deleted.c index 39f9d0b47..aea2be82f 100644 --- a/test/zdtm/static/mntns_deleted.c +++ b/test/zdtm/static/mntns_deleted.c @@ -15,20 +15,20 @@ #include "zdtmtst.h" #ifndef CLONE_NEWNS -#define CLONE_NEWNS 0x00020000 +#define CLONE_NEWNS 0x00020000 #endif -const char *test_doc = "Check the restore of deleted bindmounts"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; +const char *test_doc = "Check the restore of deleted bindmounts"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); -#define TEST_DIR_SRC "test-src" -#define TEST_DIR_DST "test-dst" +#define TEST_DIR_SRC "test-src" +#define TEST_DIR_DST "test-dst" -#define TEST_FILE_SRC "mntns-deleted-src" -#define TEST_FILE_DST "mntns-deleted-dst" +#define TEST_FILE_SRC "mntns-deleted-src" +#define TEST_FILE_DST "mntns-deleted-dst" int main(int argc, char *argv[]) { @@ -56,8 +56,7 @@ int main(int argc, char *argv[]) unlink(TEST_FILE_SRC); unlink(TEST_FILE_DST); - if (mkdir(path_src, 0700) || - mkdir(path_dst, 0700)) { + if (mkdir(path_src, 0700) || mkdir(path_dst, 0700)) { pr_perror("mkdir"); return 1; } diff --git a/test/zdtm/static/mntns_ghost.c b/test/zdtm/static/mntns_ghost.c index e0d31572a..c8c68382b 100644 --- a/test/zdtm/static/mntns_ghost.c +++ b/test/zdtm/static/mntns_ghost.c @@ -15,13 +15,12 @@ #include "zdtmtst.h" -const char *test_doc = "Check ghost and link-remap files in a few mntns"; -const char *test_author = "Andrew Vagin <avagin@parallels.com>"; +const char *test_doc = "Check ghost and link-remap files in a few mntns"; +const char *test_author = "Andrew Vagin <avagin@parallels.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); - int main(int argc, char **argv) { task_waiter_t lock; @@ -102,7 +101,6 @@ int main(int argc, char **argv) test_daemon(); test_waitsig(); - kill(pid, SIGTERM); wait(&status); if (status) { diff --git a/test/zdtm/static/mntns_ghost01.c b/test/zdtm/static/mntns_ghost01.c index 665e1e162..20397d543 100644 --- a/test/zdtm/static/mntns_ghost01.c +++ b/test/zdtm/static/mntns_ghost01.c @@ -9,13 +9,12 @@ #include "zdtmtst.h" -const char *test_doc = "Check ghost file is restored on readonly fs if it was ghost-remaped on writable bind"; -const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; +const char *test_doc = "Check ghost file is restored on readonly fs if it was ghost-remaped on writable bind"; +const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); - int main(int argc, char **argv) { char ghost_path[PATH_MAX]; @@ -71,7 +70,7 @@ int main(int argc, char **argv) return 1; } - if (mount(NULL, dirname, NULL, MS_RDONLY|MS_REMOUNT|MS_BIND, NULL)) { + if (mount(NULL, dirname, NULL, MS_RDONLY | MS_REMOUNT | MS_BIND, NULL)) { pr_perror("remount"); return 1; } diff --git a/test/zdtm/static/mntns_link_remap.c b/test/zdtm/static/mntns_link_remap.c index 6ac08191a..7c4acc01a 100644 --- a/test/zdtm/static/mntns_link_remap.c +++ b/test/zdtm/static/mntns_link_remap.c @@ -15,17 +15,17 @@ #include "zdtmtst.h" #ifndef CLONE_NEWNS -#define CLONE_NEWNS 0x00020000 +#define CLONE_NEWNS 0x00020000 #endif -const char *test_doc = "Check ghost and link-remap files in a few mntns"; -const char *test_author = "Andrew Vagin <avagin@parallels.com>"; +const char *test_doc = "Check ghost and link-remap files in a few mntns"; +const char *test_author = "Andrew Vagin <avagin@parallels.com>"; -#define MPTS_FILE "F" +#define MPTS_FILE "F" char *dirname; TEST_OPTION(dirname, string, "directory name", 1); -#define NS_STACK_SIZE 4096 +#define NS_STACK_SIZE 4096 /* All arguments should be above stack, because it grows down */ struct ns_exec_args { char stack[NS_STACK_SIZE] __stack_aligned__; @@ -34,8 +34,8 @@ struct ns_exec_args { int sync; }; -#define AWK_OK 13 -#define AWK_FAIL 42 +#define AWK_OK 13 +#define AWK_FAIL 42 static int get_mntid(int fd) { @@ -102,7 +102,7 @@ int ns_child(void *_arg) id1 = get_mntid(args->fd); id2 = get_mntid(fd2); - if (id1 <0 || id2 < 0) + if (id1 < 0 || id2 < 0) exit(1); if (fstat(args->fd, &st1) || fstat(fd2, &st2)) { @@ -117,8 +117,7 @@ int ns_child(void *_arg) #else if (st1.st_nlink != 0) { #endif - pr_perror("Wrong number of links: %lu", - (long unsigned)st1.st_nlink); + pr_perror("Wrong number of links: %lu", (long unsigned)st1.st_nlink); exit(1); } @@ -228,7 +227,6 @@ int main(int argc, char **argv) test_daemon(); test_waitsig(); - if (pid > 0) { int status = 1; kill(pid, SIGTERM); diff --git a/test/zdtm/static/mntns_open.c b/test/zdtm/static/mntns_open.c index c687080a7..7d8bbbaa4 100644 --- a/test/zdtm/static/mntns_open.c +++ b/test/zdtm/static/mntns_open.c @@ -14,18 +14,18 @@ #include "zdtmtst.h" #ifndef CLONE_NEWNS -#define CLONE_NEWNS 0x00020000 +#define CLONE_NEWNS 0x00020000 #endif -const char *test_doc = "Check that mnt_id is repsected"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check that mnt_id is repsected"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; -#define MPTS_FILE "F" +#define MPTS_FILE "F" char *dirname; TEST_OPTION(dirname, string, "directory name", 1); char fpath[PATH_MAX]; -#define NS_STACK_SIZE 4096 +#define NS_STACK_SIZE 4096 /* All arguments should be above stack, because it grows down */ struct ns_exec_args { char stack[NS_STACK_SIZE] __stack_aligned__; @@ -33,8 +33,8 @@ struct ns_exec_args { int fd; }; -#define AWK_OK 13 -#define AWK_FAIL 42 +#define AWK_OK 13 +#define AWK_FAIL 42 static int get_mntid(int fd) { @@ -74,7 +74,7 @@ int ns_child(void *_arg) test_msg("%d %d", id1, id2); - if (id1 <0 || id2 < 0) + if (id1 < 0 || id2 < 0) exit(1); if (id1 > 0 && id1 != id2) exit(AWK_OK); diff --git a/test/zdtm/static/mntns_overmount.c b/test/zdtm/static/mntns_overmount.c index ba23afca8..c2a6a72cf 100644 --- a/test/zdtm/static/mntns_overmount.c +++ b/test/zdtm/static/mntns_overmount.c @@ -10,13 +10,12 @@ #include "zdtmtst.h" -const char *test_doc = "Check two mounts in the same directory"; -const char *test_author = "Andrew Vagin <avagin@parallels.com>"; +const char *test_doc = "Check two mounts in the same directory"; +const char *test_author = "Andrew Vagin <avagin@parallels.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); - int main(int argc, char **argv) { char d1[PATH_MAX], d2[PATH_MAX], f1[PATH_MAX], f2[PATH_MAX]; @@ -27,17 +26,13 @@ int main(int argc, char **argv) snprintf(d1, sizeof(d1), "%s/1/", dirname); snprintf(d2, sizeof(d2), "%s/2/", dirname); - if (mkdir(dirname, 0700) || - mkdir(d1, 0777) || - mkdir(d2, 0700)) { + if (mkdir(dirname, 0700) || mkdir(d1, 0777) || mkdir(d2, 0700)) { pr_perror("mkdir"); return 1; } - if (mount("zdtm_d1", d1, "sysfs", 0, NULL) || - mount(NULL, d1, NULL, MS_SHARED, NULL) || - mount(d1, d2, NULL, MS_BIND, NULL) || - mount(NULL, d2, NULL, MS_SLAVE, NULL)) { + if (mount("zdtm_d1", d1, "sysfs", 0, NULL) || mount(NULL, d1, NULL, MS_SHARED, NULL) || + mount(d1, d2, NULL, MS_BIND, NULL) || mount(NULL, d2, NULL, MS_SLAVE, NULL)) { pr_perror("mount"); return 1; } diff --git a/test/zdtm/static/mntns_remap.c b/test/zdtm/static/mntns_remap.c index fd62cbf40..3ee3b4640 100644 --- a/test/zdtm/static/mntns_remap.c +++ b/test/zdtm/static/mntns_remap.c @@ -13,8 +13,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check a case when one mount overmount another one"; -const char *test_author = "Andrew Vagin <avagin@virtuozzo.com>"; +const char *test_doc = "Check a case when one mount overmount another one"; +const char *test_author = "Andrew Vagin <avagin@virtuozzo.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); diff --git a/test/zdtm/static/mntns_ro_root.c b/test/zdtm/static/mntns_ro_root.c index 8a7971018..82659709e 100644 --- a/test/zdtm/static/mntns_ro_root.c +++ b/test/zdtm/static/mntns_ro_root.c @@ -14,13 +14,12 @@ #include "zdtmtst.h" -const char *test_doc = "Check a case when a root is read-only for a sub-mntns"; -const char *test_author = "Andrew Vagin <avagin@parallels.com>"; +const char *test_doc = "Check a case when a root is read-only for a sub-mntns"; +const char *test_author = "Andrew Vagin <avagin@parallels.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); - int main(int argc, char **argv) { task_waiter_t lock; diff --git a/test/zdtm/static/mntns_root_bind.c b/test/zdtm/static/mntns_root_bind.c index 86c44e197..9e1ba06e6 100644 --- a/test/zdtm/static/mntns_root_bind.c +++ b/test/zdtm/static/mntns_root_bind.c @@ -14,16 +14,15 @@ #include "zdtmtst.h" #ifndef CLONE_NEWNS -#define CLONE_NEWNS 0x00020000 +#define CLONE_NEWNS 0x00020000 #endif -const char *test_doc = "Check bind-mouns of the root mount"; -const char *test_author = "Andrew Vagin <avagin@parallels.com>"; +const char *test_doc = "Check bind-mouns of the root mount"; +const char *test_author = "Andrew Vagin <avagin@parallels.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); - int main(int argc, char **argv) { char subdir1[PATH_MAX], path[PATH_MAX], bpath[PATH_MAX], spath[PATH_MAX], bspath[PATH_MAX]; @@ -47,13 +46,8 @@ int main(int argc, char **argv) ssprintf(subdir2, "%s/subdir2", dirname); ssprintf(bsubdir2, "%s/bsubdir2", dirname); - if (mkdir(dirname, 0700) || - mkdir(subdir1, 0777) || - mkdir(subdir2, 0777) || - mkdir(bsubdir2, 0777) || - mkdir(path, 0700) || - mkdir(spath, 0700) || - mkdir(bpath, 0700)) { + if (mkdir(dirname, 0700) || mkdir(subdir1, 0777) || mkdir(subdir2, 0777) || mkdir(bsubdir2, 0777) || + mkdir(path, 0700) || mkdir(spath, 0700) || mkdir(bpath, 0700)) { pr_perror("mkdir"); return 1; } @@ -81,7 +75,6 @@ int main(int argc, char **argv) return 1; } - if (umount2(bpath, MNT_DETACH)) { fail("umount"); return 1; diff --git a/test/zdtm/static/mntns_rw_ro_rw.c b/test/zdtm/static/mntns_rw_ro_rw.c index 6179c4788..b251964a2 100644 --- a/test/zdtm/static/mntns_rw_ro_rw.c +++ b/test/zdtm/static/mntns_rw_ro_rw.c @@ -7,8 +7,8 @@ #include "zdtmtst.h" -const char *test_doc = "Test read-only bind mounts"; -const char *test_author = "Andrey Vagin <xemul@parallels.com>"; +const char *test_doc = "Test read-only bind mounts"; +const char *test_author = "Andrey Vagin <xemul@parallels.com>"; int main(int argc, char **argv) { @@ -22,7 +22,7 @@ int main(int argc, char **argv) pr_perror("Unable to bind-mount /proc/sys/net"); return 1; } - if (mount("/proc/sys/", "/proc/sys", NULL, MS_RDONLY|MS_BIND|MS_REMOUNT, NULL)) { + if (mount("/proc/sys/", "/proc/sys", NULL, MS_RDONLY | MS_BIND | MS_REMOUNT, NULL)) { pr_perror("Unable to remount /proc/sys"); return 1; } diff --git a/test/zdtm/static/mntns_shared_bind.c b/test/zdtm/static/mntns_shared_bind.c index b0d63af58..7c745606e 100644 --- a/test/zdtm/static/mntns_shared_bind.c +++ b/test/zdtm/static/mntns_shared_bind.c @@ -14,16 +14,15 @@ #include "zdtmtst.h" #ifndef CLONE_NEWNS -#define CLONE_NEWNS 0x00020000 +#define CLONE_NEWNS 0x00020000 #endif -const char *test_doc = "Check shared non-root bind-mounts"; -const char *test_author = "Andrew Vagin <avagin@gmail.com>"; +const char *test_doc = "Check shared non-root bind-mounts"; +const char *test_author = "Andrew Vagin <avagin@gmail.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); - int main(int argc, char **argv) { char path[PATH_MAX], bpath[PATH_MAX], spath[PATH_MAX]; @@ -50,16 +49,13 @@ int main(int argc, char **argv) #ifdef SHARED_BIND02 /* */ - if (mount(dirname, dirname, "tmpfs", 0, NULL) || - mount(NULL, dirname, NULL, MS_SHARED, NULL)) { + if (mount(dirname, dirname, "tmpfs", 0, NULL) || mount(NULL, dirname, NULL, MS_SHARED, NULL)) { pr_perror("mount"); return 1; } #endif - if (mkdir(path, 0700) || - mkdir(spath, 0700) || - mkdir(bpath, 0700)) { + if (mkdir(path, 0700) || mkdir(spath, 0700) || mkdir(bpath, 0700)) { pr_perror("mkdir"); return 1; } @@ -99,7 +95,6 @@ int main(int argc, char **argv) return 1; } - test_daemon(); test_waitsig(); diff --git a/test/zdtm/static/mntns_shared_bind03.c b/test/zdtm/static/mntns_shared_bind03.c index e75fe6297..3c0ced831 100644 --- a/test/zdtm/static/mntns_shared_bind03.c +++ b/test/zdtm/static/mntns_shared_bind03.c @@ -14,16 +14,15 @@ #include "zdtmtst.h" #ifndef CLONE_NEWNS -#define CLONE_NEWNS 0x00020000 +#define CLONE_NEWNS 0x00020000 #endif -const char *test_doc = "Check shared non-root bind-mounts with different shared groups"; -const char *test_author = "Andrew Vagin <avagin@gmail.com>"; +const char *test_doc = "Check shared non-root bind-mounts with different shared groups"; +const char *test_author = "Andrew Vagin <avagin@gmail.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); - int main(int argc, char **argv) { test_init(argc, argv); @@ -51,22 +50,19 @@ int main(int argc, char **argv) return 1; } - if (mount("1", "1", NULL, MS_BIND, NULL) || - mount(NULL, "1", NULL, MS_PRIVATE, NULL) || + if (mount("1", "1", NULL, MS_BIND, NULL) || mount(NULL, "1", NULL, MS_PRIVATE, NULL) || mount(NULL, "1", NULL, MS_SHARED, NULL)) { pr_perror("mount"); return 1; } - if (mount("1", "A", NULL, MS_BIND, NULL) || - mount(NULL, "A", NULL, MS_PRIVATE, NULL) || + if (mount("1", "A", NULL, MS_BIND, NULL) || mount(NULL, "A", NULL, MS_PRIVATE, NULL) || mount(NULL, "A", NULL, MS_SHARED, NULL)) { pr_perror("mount"); return 1; } - if (mount("1", "B", NULL, MS_BIND, NULL) || - mount(NULL, "B", NULL, MS_SLAVE, NULL)) { + if (mount("1", "B", NULL, MS_BIND, NULL) || mount(NULL, "B", NULL, MS_SLAVE, NULL)) { pr_perror("mount"); return 1; } diff --git a/test/zdtm/static/mntns_shared_vs_private.c b/test/zdtm/static/mntns_shared_vs_private.c index 5849bbbdb..c44fb0066 100644 --- a/test/zdtm/static/mntns_shared_vs_private.c +++ b/test/zdtm/static/mntns_shared_vs_private.c @@ -14,16 +14,15 @@ #include "zdtmtst.h" #ifndef CLONE_NEWNS -#define CLONE_NEWNS 0x00020000 +#define CLONE_NEWNS 0x00020000 #endif -const char *test_doc = "Check a private mount in a shared mount"; -const char *test_author = "Andrew Vagin <avagin@gmail.com>"; +const char *test_doc = "Check a private mount in a shared mount"; +const char *test_author = "Andrew Vagin <avagin@gmail.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); - int main(int argc, char **argv) { char path[PATH_MAX]; @@ -106,7 +105,8 @@ int main(int argc, char **argv) } if (status) { - pr_err("%d/%d/%d/%d\n", WIFEXITED(status), WEXITSTATUS(status), WIFSIGNALED(status), WTERMSIG(status)); + pr_err("%d/%d/%d/%d\n", WIFEXITED(status), WEXITSTATUS(status), WIFSIGNALED(status), + WTERMSIG(status)); return 1; } } diff --git a/test/zdtm/static/mount_paths.c b/test/zdtm/static/mount_paths.c index 2377e9c94..6b9ce1c24 100644 --- a/test/zdtm/static/mount_paths.c +++ b/test/zdtm/static/mount_paths.c @@ -8,8 +8,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that special characters in paths are handled correctly"; -const char *test_author = "Andrew Vagin <avagin@virtuozzo.com>"; +const char *test_doc = "Check that special characters in paths are handled correctly"; +const char *test_author = "Andrew Vagin <avagin@virtuozzo.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); diff --git a/test/zdtm/static/mountpoints.c b/test/zdtm/static/mountpoints.c index cf54d1096..b5fd72aad 100644 --- a/test/zdtm/static/mountpoints.c +++ b/test/zdtm/static/mountpoints.c @@ -11,12 +11,12 @@ #include "zdtmtst.h" -const char *test_doc = "Check that mountpoints (in mount namespace) are supported"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check that mountpoints (in mount namespace) are supported"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; -#define MPTS_ROOT "/zdtm_mpts/" +#define MPTS_ROOT "/zdtm_mpts/" -#define NS_STACK_SIZE 4096 +#define NS_STACK_SIZE 4096 /* All arguments should be above stack, because it grows down */ struct ns_exec_args { char stack[NS_STACK_SIZE] __stack_aligned__; @@ -32,22 +32,22 @@ int ns_child(void *_arg) pid_t pid; int fd, ufd; - mkdir(MPTS_ROOT"/dev/mntns2", 0600); - if (mount("none", MPTS_ROOT"/dev/mntns2", "tmpfs", 0, "") < 0) { + mkdir(MPTS_ROOT "/dev/mntns2", 0600); + if (mount("none", MPTS_ROOT "/dev/mntns2", "tmpfs", 0, "") < 0) { fail("Can't mount tmpfs"); return 1; } - mkdir(MPTS_ROOT"/dev/mntns2/test", 0600); + mkdir(MPTS_ROOT "/dev/mntns2/test", 0600); - fd = open(MPTS_ROOT"/dev/mntns2/test/test.file", O_WRONLY | O_CREAT, 0666); + fd = open(MPTS_ROOT "/dev/mntns2/test/test.file", O_WRONLY | O_CREAT, 0666); if (fd < 0) return 1; - ufd = open(MPTS_ROOT"/dev/mntns2/test/test.file.unlinked", O_WRONLY | O_CREAT, 0666); + ufd = open(MPTS_ROOT "/dev/mntns2/test/test.file.unlinked", O_WRONLY | O_CREAT, 0666); if (ufd < 0) return 1; - unlink(MPTS_ROOT"/dev/mntns2/test/test.file.unlinked"); + unlink(MPTS_ROOT "/dev/mntns2/test/test.file.unlinked"); pid = fork(); @@ -63,7 +63,7 @@ int ns_child(void *_arg) return 1; } - if (stat(MPTS_ROOT"/dev/mntns2/test", &st)) { + if (stat(MPTS_ROOT "/dev/mntns2/test", &st)) { pr_perror("Can't stat /dev/share-1/test.share/test.share"); return 1; } @@ -92,133 +92,132 @@ int main(int argc, char **argv) return 1; } - if (mount("none", MPTS_ROOT"/dev", "tmpfs", 0, "") < 0) { + if (mount("none", MPTS_ROOT "/dev", "tmpfs", 0, "") < 0) { fail("Can't mount tmpfs"); return 1; } - tmpfs_fd = open(MPTS_ROOT"/dev/test", O_WRONLY | O_CREAT); + tmpfs_fd = open(MPTS_ROOT "/dev/test", O_WRONLY | O_CREAT); if (write(tmpfs_fd, "hello", 5) <= 0) { pr_perror("write() failed"); return 1; } /* Check that over-mounted files are restored on tmpfs */ - mkdir(MPTS_ROOT"/dev/overmount", 0600); - fd = open(MPTS_ROOT"/dev/overmount/test.over", O_WRONLY | O_CREAT); + mkdir(MPTS_ROOT "/dev/overmount", 0600); + fd = open(MPTS_ROOT "/dev/overmount/test.over", O_WRONLY | O_CREAT); if (fd == -1) { - pr_perror("Unable to open "MPTS_ROOT"/dev/overmount"); + pr_perror("Unable to open " MPTS_ROOT "/dev/overmount"); return -1; } close(fd); - if (mount("none", MPTS_ROOT"/dev/overmount", "tmpfs", 0, "") < 0) { - pr_perror("Can't mount "MPTS_ROOT"/dev/overmount"); + if (mount("none", MPTS_ROOT "/dev/overmount", "tmpfs", 0, "") < 0) { + pr_perror("Can't mount " MPTS_ROOT "/dev/overmount"); return 1; } - mkdir(MPTS_ROOT"/dev/non-root", 0600); - if (mount(MPTS_ROOT"/dev/non-root", MPTS_ROOT"/module", NULL, MS_BIND, NULL) < 0) { - pr_perror("Can't bind-mount %s -> %s", MPTS_ROOT"/dev/tdir", MPTS_ROOT"/module"); + mkdir(MPTS_ROOT "/dev/non-root", 0600); + if (mount(MPTS_ROOT "/dev/non-root", MPTS_ROOT "/module", NULL, MS_BIND, NULL) < 0) { + pr_perror("Can't bind-mount %s -> %s", MPTS_ROOT "/dev/tdir", MPTS_ROOT "/module"); } - mkdir(MPTS_ROOT"/dev/non-root/test", 0600); + mkdir(MPTS_ROOT "/dev/non-root/test", 0600); - mkdir(MPTS_ROOT"/dev/share-1", 0600); - if (mount("none", MPTS_ROOT"/dev/share-1/", "tmpfs", 0, "") < 0) { + mkdir(MPTS_ROOT "/dev/share-1", 0600); + if (mount("none", MPTS_ROOT "/dev/share-1/", "tmpfs", 0, "") < 0) { fail("Can't mount tmpfs"); return 1; } - if (mount("none", MPTS_ROOT"/dev/share-1/", NULL, MS_SHARED, NULL) < 0) { + if (mount("none", MPTS_ROOT "/dev/share-1/", NULL, MS_SHARED, NULL) < 0) { fail("Can't mount tmpfs"); return 1; } //#define CR_NEXT #ifdef CR_NEXT - mkdir(MPTS_ROOT"/dev/share-1/alone", 0600); - if (mount("none", MPTS_ROOT"/dev/share-1/alone", "tmpfs", 0, "") < 0) { + mkdir(MPTS_ROOT "/dev/share-1/alone", 0600); + if (mount("none", MPTS_ROOT "/dev/share-1/alone", "tmpfs", 0, "") < 0) { fail("Can't mount tmpfs"); return 1; } #endif - mkdir(MPTS_ROOT"/dev/share-2", 0600); - if (mount(MPTS_ROOT"/dev/share-1", MPTS_ROOT"/dev/share-2", NULL, MS_BIND, NULL) < 0) { + mkdir(MPTS_ROOT "/dev/share-2", 0600); + if (mount(MPTS_ROOT "/dev/share-1", MPTS_ROOT "/dev/share-2", NULL, MS_BIND, NULL) < 0) { fail("Can't bind mount a tmpfs directory"); return 1; } - mkdir(MPTS_ROOT"/dev/share-3", 0600); - if (mount(MPTS_ROOT"/dev/share-1", MPTS_ROOT"/dev/share-3", NULL, MS_BIND, NULL) < 0) { + mkdir(MPTS_ROOT "/dev/share-3", 0600); + if (mount(MPTS_ROOT "/dev/share-1", MPTS_ROOT "/dev/share-3", NULL, MS_BIND, NULL) < 0) { fail("Can't bind mount a tmpfs directory"); return 1; } - mkdir(MPTS_ROOT"/dev/slave", 0600); - if (mount(MPTS_ROOT"/dev/share-1", MPTS_ROOT"/dev/slave", NULL, MS_BIND, NULL) < 0) { + mkdir(MPTS_ROOT "/dev/slave", 0600); + if (mount(MPTS_ROOT "/dev/share-1", MPTS_ROOT "/dev/slave", NULL, MS_BIND, NULL) < 0) { fail("Can't bind mount a tmpfs directory"); return 1; } - if (mount("none", MPTS_ROOT"/dev/slave", NULL, MS_SLAVE, NULL) < 0) { + if (mount("none", MPTS_ROOT "/dev/slave", NULL, MS_SLAVE, NULL) < 0) { fail("Can't mount tmpfs"); return 1; } - mkdir(MPTS_ROOT"/dev/slave2", 0600); - if (mount(MPTS_ROOT"/dev/share-3", MPTS_ROOT"/dev/slave2", NULL, MS_BIND, NULL) < 0) { + mkdir(MPTS_ROOT "/dev/slave2", 0600); + if (mount(MPTS_ROOT "/dev/share-3", MPTS_ROOT "/dev/slave2", NULL, MS_BIND, NULL) < 0) { fail("Can't bind mount a tmpfs directory"); return 1; } - if (mount("none", MPTS_ROOT"/dev/slave2", NULL, MS_SLAVE, NULL) < 0) { + if (mount("none", MPTS_ROOT "/dev/slave2", NULL, MS_SLAVE, NULL) < 0) { fail("Can't mount tmpfs"); return 1; } - mkdir(MPTS_ROOT"/dev/share-1/test.mnt.share", 0600); - if (mount("none", MPTS_ROOT"/dev/share-1/test.mnt.share", "tmpfs", 0, "size=1G") < 0) { + mkdir(MPTS_ROOT "/dev/share-1/test.mnt.share", 0600); + if (mount("none", MPTS_ROOT "/dev/share-1/test.mnt.share", "tmpfs", 0, "size=1G") < 0) { fail("Can't mount tmpfs"); return 1; } - mkdir(MPTS_ROOT"/dev/share-1/test.mnt.share/test.share", 0600); - if (umount(MPTS_ROOT"/dev/slave2/test.mnt.share")) { - pr_perror("Can't umount "MPTS_ROOT"/dev/slave2/test.mnt.share"); + mkdir(MPTS_ROOT "/dev/share-1/test.mnt.share/test.share", 0600); + if (umount(MPTS_ROOT "/dev/slave2/test.mnt.share")) { + pr_perror("Can't umount " MPTS_ROOT "/dev/slave2/test.mnt.share"); return 1; } - mkdir(MPTS_ROOT"/dev/slave/test.mnt.slave", 0600); - if (mount("none", MPTS_ROOT"/dev/slave/test.mnt.slave", "tmpfs", 0, "") < 0) { + mkdir(MPTS_ROOT "/dev/slave/test.mnt.slave", 0600); + if (mount("none", MPTS_ROOT "/dev/slave/test.mnt.slave", "tmpfs", 0, "") < 0) { fail("Can't mount tmpfs"); return 1; } - mkdir(MPTS_ROOT"/dev/slave/test.mnt.slave/test.slave", 0600); + mkdir(MPTS_ROOT "/dev/slave/test.mnt.slave/test.slave", 0600); - fd = open(MPTS_ROOT"/dev/bmfile", O_CREAT | O_WRONLY); + fd = open(MPTS_ROOT "/dev/bmfile", O_CREAT | O_WRONLY); if (fd < 0) { pr_perror("Can't create " MPTS_ROOT "/dev/share-1/bmfile"); return 1; } close(fd); - fd = open(MPTS_ROOT"/dev/bmfile-mount", O_CREAT | O_WRONLY); + fd = open(MPTS_ROOT "/dev/bmfile-mount", O_CREAT | O_WRONLY); if (fd < 0) { pr_perror("Can't create " MPTS_ROOT "/dev/share-1/bmfile"); return 1; } close(fd); - if (mount(MPTS_ROOT"/dev/bmfile", MPTS_ROOT"/dev/bmfile-mount", NULL, MS_BIND, NULL) < 0) { + if (mount(MPTS_ROOT "/dev/bmfile", MPTS_ROOT "/dev/bmfile-mount", NULL, MS_BIND, NULL) < 0) { fail("Can't mount tmpfs"); return 1; } - if (mount("none", MPTS_ROOT"/kernel", "proc", 0, "") < 0) { + if (mount("none", MPTS_ROOT "/kernel", "proc", 0, "") < 0) { fail("Can't mount proc"); return 1; } - if (mount("none", MPTS_ROOT"/kernel/sys/fs/binfmt_misc", - "binfmt_misc", 0, "") == 0) + if (mount("none", MPTS_ROOT "/kernel/sys/fs/binfmt_misc", "binfmt_misc", 0, "") == 0) have_bfmtm = 1; - fd = open(MPTS_ROOT"/kernel/meminfo", O_RDONLY); + fd = open(MPTS_ROOT "/kernel/meminfo", O_RDONLY); if (fd == -1) return 1; @@ -236,32 +235,32 @@ int main(int argc, char **argv) test_waitsig(); /* this checks both -- sys and proc presence */ - if (access(MPTS_ROOT"/kernel/meminfo", F_OK)) { + if (access(MPTS_ROOT "/kernel/meminfo", F_OK)) { fail("No proc after restore"); return 1; } - if (have_bfmtm && access(MPTS_ROOT"/kernel/sys/fs/binfmt_misc/register", F_OK)) { + if (have_bfmtm && access(MPTS_ROOT "/kernel/sys/fs/binfmt_misc/register", F_OK)) { fail("No binfmt_misc after restore"); return 1; } - if (umount(MPTS_ROOT"/dev/overmount") == -1) { - pr_perror("Can't umount "MPTS_ROOT"/dev/overmount"); + if (umount(MPTS_ROOT "/dev/overmount") == -1) { + pr_perror("Can't umount " MPTS_ROOT "/dev/overmount"); return -1; } - if (access(MPTS_ROOT"/dev/overmount/test.over", F_OK)) { - fail(MPTS_ROOT"/dev/overmount/test.over"); + if (access(MPTS_ROOT "/dev/overmount/test.over", F_OK)) { + fail(MPTS_ROOT "/dev/overmount/test.over"); return -1; } { struct stat st1, st2; - if (stat(MPTS_ROOT"/dev/share-1/test.mnt.share/test.share", &st1)) { + if (stat(MPTS_ROOT "/dev/share-1/test.mnt.share/test.share", &st1)) { pr_perror("Can't stat /dev/share-1/test.share/test.share"); return 1; } - if (stat(MPTS_ROOT"/dev/share-2/test.mnt.share/test.share", &st2)) { + if (stat(MPTS_ROOT "/dev/share-2/test.mnt.share/test.share", &st2)) { pr_perror("Can't stat /dev/share-2/test.mnt.share/test.share"); return 1; } @@ -269,7 +268,7 @@ int main(int argc, char **argv) fail("/dev/share-1 and /dev/share-1 is not shared"); return 1; } - if (stat(MPTS_ROOT"/dev/slave/test.mnt.share/test.share", &st2)) { + if (stat(MPTS_ROOT "/dev/slave/test.mnt.share/test.share", &st2)) { pr_perror("Can't stat /dev/slave/test.mnt.share/test.share"); return 1; } @@ -277,15 +276,15 @@ int main(int argc, char **argv) fail("/dev/slave is not slave of /dev/share-1"); return 1; } - if (stat(MPTS_ROOT"/dev/share-1/test.mnt.slave/test.slave", &st1) != -1 || errno != ENOENT) { + if (stat(MPTS_ROOT "/dev/share-1/test.mnt.slave/test.slave", &st1) != -1 || errno != ENOENT) { pr_perror("/dev/share-1/test.mnt.slave/test.slave exists"); return 1; } - if (stat(MPTS_ROOT"/dev/slave/test.mnt.slave/test.slave", &st2)) { + if (stat(MPTS_ROOT "/dev/slave/test.mnt.slave/test.slave", &st2)) { pr_perror("Can't stat /dev/slave/test.mnt.slave/test.slave"); return 1; } - if (stat(MPTS_ROOT"/dev/non-root/test", &st1)) { + if (stat(MPTS_ROOT "/dev/non-root/test", &st1)) { pr_perror("Can't stat /dev/non-root/test"); return 1; } diff --git a/test/zdtm/static/mprotect00.c b/test/zdtm/static/mprotect00.c index bf852e596..006b64772 100644 --- a/test/zdtm/static/mprotect00.c +++ b/test/zdtm/static/mprotect00.c @@ -10,19 +10,19 @@ #include "zdtmtst.h" -const char *test_doc = "Check that memory protection migrates correctly\n"; -const char *test_author = "Roman Kagan <rkagan@parallels.com>"; +const char *test_doc = "Check that memory protection migrates correctly\n"; +const char *test_author = "Roman Kagan <rkagan@parallels.com>"; const static int prots[] = { PROT_NONE, PROT_READ, - /* PROT_WRITE, */ /* doesn't work w/o READ */ - PROT_READ | PROT_WRITE, + /* PROT_WRITE, */ /* doesn't work w/o READ */ + PROT_READ | PROT_WRITE, PROT_READ | PROT_WRITE | PROT_EXEC, }; -#define NUM_MPROTS sizeof(prots) / sizeof(int) +#define NUM_MPROTS sizeof(prots) / sizeof(int) -static sigjmp_buf segv_ret; /* we need sig*jmp stuff, otherwise SIGSEGV will reset our handler */ +static sigjmp_buf segv_ret; /* we need sig*jmp stuff, otherwise SIGSEGV will reset our handler */ static void segfault(int signo) { siglongjmp(segv_ret, 1); @@ -44,12 +44,11 @@ static int check_prot(char *ptr, int prot) fail("PROT_READ bypassed"); return -1; } - } - else /* we come here on return from SIGSEGV handler */ + } else /* we come here on return from SIGSEGV handler */ if (prot & PROT_READ) { - fail("PROT_READ rejected"); - return -1; - } + fail("PROT_READ rejected"); + return -1; + } if (!sigsetjmp(segv_ret, 1)) { ptr[20] = 67; @@ -57,13 +56,11 @@ static int check_prot(char *ptr, int prot) fail("PROT_WRITE bypassed"); return -1; } - } - else /* we come here on return from SIGSEGV handler */ + } else /* we come here on return from SIGSEGV handler */ if (prot & PROT_WRITE) { - fail("PROT_WRITE rejected"); - return -1; - } - + fail("PROT_WRITE rejected"); + return -1; + } if (signal(SIGSEGV, SIG_DFL) == SIG_ERR) { fail("restoring SIGSEGV handler failed"); @@ -73,7 +70,7 @@ static int check_prot(char *ptr, int prot) return 0; } -int main(int argc, char ** argv) +int main(int argc, char **argv) { char *ptr, *ptr_aligned; int pagesize; @@ -93,12 +90,10 @@ int main(int argc, char ** argv) return -1; } - ptr_aligned = (char *)(((unsigned long) ptr + pagesize - 1) & - ~(pagesize - 1)); + ptr_aligned = (char *)(((unsigned long)ptr + pagesize - 1) & ~(pagesize - 1)); for (i = 0; i < NUM_MPROTS; i++) - if (mprotect(ptr_aligned + pagesize * i, - pagesize / 2, prots[i]) < 0) { + if (mprotect(ptr_aligned + pagesize * i, pagesize / 2, prots[i]) < 0) { pr_perror("mprotect failed"); exit(1); } diff --git a/test/zdtm/static/msgque.c b/test/zdtm/static/msgque.c index f52307221..933258cf8 100644 --- a/test/zdtm/static/msgque.c +++ b/test/zdtm/static/msgque.c @@ -14,18 +14,18 @@ #include "zdtmtst.h" -const char *test_doc="Tests sysv5 msg queues supporting by checkpointing"; -const char *test_author="Stanislav Kinsbursky <skinsbursky@openvz.org>"; +const char *test_doc = "Tests sysv5 msg queues supporting by checkpointing"; +const char *test_author = "Stanislav Kinsbursky <skinsbursky@openvz.org>"; struct msg1 { long mtype; char mtext[30]; }; #define TEST_STRING "Test sysv5 msg" -#define MSG_TYPE 1 +#define MSG_TYPE 1 #define ANOTHER_TEST_STRING "Yet another test sysv5 msg" -#define ANOTHER_MSG_TYPE 26538 +#define ANOTHER_MSG_TYPE 26538 int main(int argc, char **argv) { @@ -102,8 +102,7 @@ int main(int argc, char **argv) wait(&chret); chret = WEXITSTATUS(chret); if (chret) { - fail("Parent: child exited with non-zero code %d (%s)", - chret, strerror(chret)); + fail("Parent: child exited with non-zero code %d (%s)", chret, strerror(chret)); goto out; } diff --git a/test/zdtm/static/mtime_mmap.c b/test/zdtm/static/mtime_mmap.c index 90b4d6883..f9a595864 100644 --- a/test/zdtm/static/mtime_mmap.c +++ b/test/zdtm/static/mtime_mmap.c @@ -12,12 +12,12 @@ #include "zdtmtst.h" const char *test_doc = "file mmaped for write and being written should change mtime\n" - "and be migrated with correct new data"; + "and be migrated with correct new data"; char *filename; TEST_OPTION(filename, string, "file name", 1); -#define FILE_SIZE (16 * 1024) +#define FILE_SIZE (16 * 1024) int main(int argc, char **argv) { @@ -27,8 +27,8 @@ int main(int argc, char **argv) int i; char *ptr; struct stat fst; - time_t mtime_old, mtime_new; - time_t ctime_old, ctime_new; + time_t mtime_old, mtime_new; + time_t ctime_old, ctime_new; test_init(argc, argv); @@ -51,8 +51,7 @@ int main(int argc, char **argv) goto failed; } - ptr = (char *)mmap(NULL, count, PROT_READ | PROT_WRITE, - MAP_SHARED, fd, 0); + ptr = (char *)mmap(NULL, count, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (ptr == MAP_FAILED) { pr_perror("mmap() failed"); goto failed; @@ -75,20 +74,17 @@ int main(int argc, char **argv) goto failed; } - mtime_new = fst.st_mtime; /* time of last modification */ if (mtime_new <= mtime_old) { - fail("mtime %ld wasn't updated on mmapped %s file", - mtime_new, filename); + fail("mtime %ld wasn't updated on mmapped %s file", mtime_new, filename); goto failed; } ctime_new = fst.st_ctime; /* time of last status change */ if (ctime_new <= ctime_old) { - fail("time of last status change of %s file wasn't changed", - filename); + fail("time of last status change of %s file wasn't changed", filename); goto failed; } diff --git a/test/zdtm/static/netns-dev.c b/test/zdtm/static/netns-dev.c index 46bb90639..e220daa7f 100644 --- a/test/zdtm/static/netns-dev.c +++ b/test/zdtm/static/netns-dev.c @@ -4,14 +4,14 @@ #include "zdtmtst.h" -#define LO_CONF_DIR_PATH "/proc/sys/net/ipv4/conf/lo" -#define DEF_CONF_DIR_PATH "/proc/sys/net/ipv4/conf/default" -#define ALL_CONF_DIR_PATH "/proc/sys/net/ipv4/conf/all" -#define LO_CONF6_DIR_PATH "/proc/sys/net/ipv6/conf/lo" +#define LO_CONF_DIR_PATH "/proc/sys/net/ipv4/conf/lo" +#define DEF_CONF_DIR_PATH "/proc/sys/net/ipv4/conf/default" +#define ALL_CONF_DIR_PATH "/proc/sys/net/ipv4/conf/all" +#define LO_CONF6_DIR_PATH "/proc/sys/net/ipv6/conf/lo" #define DEF_CONF6_DIR_PATH "/proc/sys/net/ipv6/conf/default" #define ALL_CONF6_DIR_PATH "/proc/sys/net/ipv6/conf/all" -#define INT_MAX ((int)(~0U>>1)) +#define INT_MAX ((int)(~0U >> 1)) #define INT_MIN (-INT_MAX - 1) char *devconfs4[] = { @@ -55,37 +55,37 @@ struct range { }; struct range rand_range4[] = { - {0, 1}, /* accept_local */ - {-1, 0}, /* accept_source_route */ - {0, 1}, /* arp_accept */ - {0, 2}, /* arp_announce */ - {0, 1}, /* arp_filter */ - {0, 8}, /* arp_ignore */ - {0, 1}, /* arp_notify */ - {0, 1}, /* bootp_relay */ - {0, 1}, /* disable_policy */ - {0, 1}, /* disable_xfrm */ - {0, 1}, /* drop_gratuitous_arp */ - {0, 1}, /* drop_unicast_in_l2_multicast */ - {0, INT_MAX}, /* force_igmp_version */ - {0, 1}, /* forwarding */ - {0, 1}, /* accept_redirects */ - {0, INT_MAX}, /* igmpv2_unsolicited_report_interval */ - {0, INT_MAX}, /* igmpv3_unsolicited_report_interval */ - {0, 1}, /* ignore_routes_with_linkdown */ - {0, 1}, /* log_martians */ - {0, 1}, /* mc_forwarding */ - {-1, INT_MAX}, /* medium_id */ - {0, 1}, /* promote_secondaries */ - {0, 1}, /* proxy_arp */ - {0, 1}, /* proxy_arp_pvlan */ - {0, 1}, /* route_localnet */ - {0, 2}, /* rp_filter */ - {0, 1}, /* secure_redirects */ - {0, 1}, /* send_redirects */ - {0, 1}, /* shared_media */ - {0, 1}, /* src_valid_mark */ - {INT_MIN, INT_MAX}, /* tag */ + { 0, 1 }, /* accept_local */ + { -1, 0 }, /* accept_source_route */ + { 0, 1 }, /* arp_accept */ + { 0, 2 }, /* arp_announce */ + { 0, 1 }, /* arp_filter */ + { 0, 8 }, /* arp_ignore */ + { 0, 1 }, /* arp_notify */ + { 0, 1 }, /* bootp_relay */ + { 0, 1 }, /* disable_policy */ + { 0, 1 }, /* disable_xfrm */ + { 0, 1 }, /* drop_gratuitous_arp */ + { 0, 1 }, /* drop_unicast_in_l2_multicast */ + { 0, INT_MAX }, /* force_igmp_version */ + { 0, 1 }, /* forwarding */ + { 0, 1 }, /* accept_redirects */ + { 0, INT_MAX }, /* igmpv2_unsolicited_report_interval */ + { 0, INT_MAX }, /* igmpv3_unsolicited_report_interval */ + { 0, 1 }, /* ignore_routes_with_linkdown */ + { 0, 1 }, /* log_martians */ + { 0, 1 }, /* mc_forwarding */ + { -1, INT_MAX }, /* medium_id */ + { 0, 1 }, /* promote_secondaries */ + { 0, 1 }, /* proxy_arp */ + { 0, 1 }, /* proxy_arp_pvlan */ + { 0, 1 }, /* route_localnet */ + { 0, 2 }, /* rp_filter */ + { 0, 1 }, /* secure_redirects */ + { 0, 1 }, /* send_redirects */ + { 0, 1 }, /* shared_media */ + { 0, 1 }, /* src_valid_mark */ + { INT_MIN, INT_MAX }, /* tag */ }; char *devconfs6[] = { @@ -134,52 +134,52 @@ char *devconfs6[] = { }; #define IPV6_MIN_MTU 1280 -#define ROUTER_MAX 60 +#define ROUTER_MAX 60 /* According to kernel docs do not make max_addresses too large */ #define MAX_ADDRESSES 128 struct range rand_range6[] = { - {0, 2}, /* accept_dad */ - {0, 2}, /* accept_ra */ - {0, 1}, /* accept_ra_defrtr */ - {0, 1}, /* accept_ra_from_local */ - {0, INT_MAX}, /* accept_ra_min_hop_limit */ - {0, 1}, /* accept_ra_mtu */ - {0, 1}, /* accept_ra_pinfo */ - {0, INT_MAX}, /* accept_ra_rt_info_max_plen */ - {0, 1}, /* accept_ra_rtr_pref */ - {-1, 0}, /* accept_source_route */ - {0, 1}, /* autoconf */ - {0, INT_MAX}, /* dad_transmits */ - {0, 1}, /* disable_ipv6 */ - {0, 1}, /* drop_unicast_in_l2_multicast */ - {0, 1}, /* drop_unsolicited_na */ - {0, 2}, /* force_mld_version */ - {0, 1}, /* force_tllao */ - {0, 1}, /* forwarding */ - {0, 1}, /* accept_redirects */ - {1, 255}, /* hop_limit */ - {0, 1}, /* ignore_routes_with_linkdown */ - {-1, 1}, /* keep_addr_on_down */ - {0, MAX_ADDRESSES}, /* max_addresses */ - {0, INT_MAX}, /* max_desync_factor */ - {0, INT_MAX}, /* mldv1_unsolicited_report_interval */ - {0, INT_MAX}, /* mldv2_unsolicited_report_interval */ - {IPV6_MIN_MTU, IPV6_MIN_MTU}, /* mtu */ - {0, 1}, /* ndisc_notify */ - {0, 1}, /* optimistic_dad */ - {0, 1}, /* proxy_ndp */ - {0, INT_MAX}, /* regen_max_retry */ - {0, ROUTER_MAX}, /* router_probe_interval */ - {0, ROUTER_MAX}, /* router_solicitation_delay */ - {0, ROUTER_MAX}, /* router_solicitation_interval */ - {0, ROUTER_MAX}, /* router_solicitations */ - {0, 1}, /* suppress_frag_ndisc */ - {0, INT_MAX}, /* temp_prefered_lft */ - {0, INT_MAX}, /* temp_valid_lft */ - {0, 1}, /* use_oif_addrs_only */ - {0, 1}, /* use_optimistic */ - {0, 2}, /* use_tempaddr */ + { 0, 2 }, /* accept_dad */ + { 0, 2 }, /* accept_ra */ + { 0, 1 }, /* accept_ra_defrtr */ + { 0, 1 }, /* accept_ra_from_local */ + { 0, INT_MAX }, /* accept_ra_min_hop_limit */ + { 0, 1 }, /* accept_ra_mtu */ + { 0, 1 }, /* accept_ra_pinfo */ + { 0, INT_MAX }, /* accept_ra_rt_info_max_plen */ + { 0, 1 }, /* accept_ra_rtr_pref */ + { -1, 0 }, /* accept_source_route */ + { 0, 1 }, /* autoconf */ + { 0, INT_MAX }, /* dad_transmits */ + { 0, 1 }, /* disable_ipv6 */ + { 0, 1 }, /* drop_unicast_in_l2_multicast */ + { 0, 1 }, /* drop_unsolicited_na */ + { 0, 2 }, /* force_mld_version */ + { 0, 1 }, /* force_tllao */ + { 0, 1 }, /* forwarding */ + { 0, 1 }, /* accept_redirects */ + { 1, 255 }, /* hop_limit */ + { 0, 1 }, /* ignore_routes_with_linkdown */ + { -1, 1 }, /* keep_addr_on_down */ + { 0, MAX_ADDRESSES }, /* max_addresses */ + { 0, INT_MAX }, /* max_desync_factor */ + { 0, INT_MAX }, /* mldv1_unsolicited_report_interval */ + { 0, INT_MAX }, /* mldv2_unsolicited_report_interval */ + { IPV6_MIN_MTU, IPV6_MIN_MTU }, /* mtu */ + { 0, 1 }, /* ndisc_notify */ + { 0, 1 }, /* optimistic_dad */ + { 0, 1 }, /* proxy_ndp */ + { 0, INT_MAX }, /* regen_max_retry */ + { 0, ROUTER_MAX }, /* router_probe_interval */ + { 0, ROUTER_MAX }, /* router_solicitation_delay */ + { 0, ROUTER_MAX }, /* router_solicitation_interval */ + { 0, ROUTER_MAX }, /* router_solicitations */ + { 0, 1 }, /* suppress_frag_ndisc */ + { 0, INT_MAX }, /* temp_prefered_lft */ + { 0, INT_MAX }, /* temp_valid_lft */ + { 0, 1 }, /* use_oif_addrs_only */ + { 0, 1 }, /* use_optimistic */ + { 0, 2 }, /* use_tempaddr */ }; struct test_conf { @@ -191,8 +191,8 @@ struct test_conf { char *dir6; } lo, def, all; -static int save_conf(FILE *fp, int *conf, int *conf_rand, - struct range *range, char *path) { +static int save_conf(FILE *fp, int *conf, int *conf_rand, struct range *range, char *path) +{ int ret; /* @@ -207,11 +207,13 @@ static int save_conf(FILE *fp, int *conf, int *conf_rand, return 0; } -static int rand_in_small_range(struct range *r) { +static int rand_in_small_range(struct range *r) +{ return lrand48() % (r->max - r->min + 1) + r->min; } -static int rand_in_range(struct range *r) { +static int rand_in_range(struct range *r) +{ struct range small; int mid = r->max / 2 + r->min / 2; int half = r->max / 2 - r->min / 2; @@ -230,8 +232,8 @@ static int rand_in_range(struct range *r) { return rand_in_small_range(&small); } -static int gen_conf(FILE *fp, int *conf, int *conf_rand, - struct range *range, char *path) { +static int gen_conf(FILE *fp, int *conf, int *conf_rand, struct range *range, char *path) +{ int ret; /* * Set random value @@ -249,8 +251,8 @@ static int gen_conf(FILE *fp, int *conf, int *conf_rand, #define MAX_MSEC_GRANULARITY 10 -static int check_conf(FILE *fp, int *conf, int *conf_rand, - struct range *range, char *path) { +static int check_conf(FILE *fp, int *conf, int *conf_rand, struct range *range, char *path) +{ int ret; int val; @@ -264,11 +266,10 @@ static int check_conf(FILE *fp, int *conf, int *conf_rand, } if (val != *conf_rand) { - fail("Option \"%s\" changed from %d to %d", - path, *conf_rand, val); - if ((strstr(path, "mldv1_unsolicited_report_interval") - || strstr(path, "mldv2_unsolicited_report_interval")) - && val - *conf_rand < MAX_MSEC_GRANULARITY) + fail("Option \"%s\" changed from %d to %d", path, *conf_rand, val); + if ((strstr(path, "mldv1_unsolicited_report_interval") || + strstr(path, "mldv2_unsolicited_report_interval")) && + val - *conf_rand < MAX_MSEC_GRANULARITY) return 0; return -1; } @@ -276,8 +277,8 @@ static int check_conf(FILE *fp, int *conf, int *conf_rand, return 0; } -static int restore_conf(FILE *fp, int *conf, int *conf_rand, - struct range *range, char *path) { +static int restore_conf(FILE *fp, int *conf, int *conf_rand, struct range *range, char *path) +{ int ret; /* * Restore opt @@ -291,8 +292,9 @@ static int restore_conf(FILE *fp, int *conf, int *conf_rand, return 0; } -static int for_each_option_do(int (*f)(FILE *fp, int *conf, int *conf_rand, - struct range *range, char *path), struct test_conf *tc) { +static int for_each_option_do(int (*f)(FILE *fp, int *conf, int *conf_rand, struct range *range, char *path), + struct test_conf *tc) +{ int ret; int i; @@ -356,7 +358,8 @@ static int for_each_option_do(int (*f)(FILE *fp, int *conf, int *conf_rand, #define IPV6ADDR_EXAMPLE "2607:f0d0:1002:0051:0000:0000:0000:0004" #define MAX_STR_CONF_LEN 200 -static int set_stable_secret(struct test_conf *tc) { +static int set_stable_secret(struct test_conf *tc) +{ int ret; FILE *fp; char path[PATH_MAX]; @@ -388,11 +391,12 @@ static int set_stable_secret(struct test_conf *tc) { return 0; } -static int check_stable_secret(struct test_conf *tc) { +static int check_stable_secret(struct test_conf *tc) +{ int ret; FILE *fp; char path[PATH_MAX]; - char val[MAX_STR_CONF_LEN+1]; + char val[MAX_STR_CONF_LEN + 1]; ret = snprintf(path, sizeof(path), "%s/%s", tc->dir6, "stable_secret"); if (ret < 0) { @@ -418,8 +422,7 @@ static int check_stable_secret(struct test_conf *tc) { } if (strcmp(val, IPV6ADDR_EXAMPLE)) { - fail("Option \"%s\" changed from %s to %s", - path, IPV6ADDR_EXAMPLE, val); + fail("Option \"%s\" changed from %s to %s", path, IPV6ADDR_EXAMPLE, val); fclose(fp); return -1; } diff --git a/test/zdtm/static/netns-nf.c b/test/zdtm/static/netns-nf.c index 393f0e732..2d5968503 100644 --- a/test/zdtm/static/netns-nf.c +++ b/test/zdtm/static/netns-nf.c @@ -5,8 +5,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that netfilter rules (some) are kept"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check that netfilter rules (some) are kept"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); diff --git a/test/zdtm/static/netns-nft-ipt.c b/test/zdtm/static/netns-nft-ipt.c index 02c2a2f58..627500151 100644 --- a/test/zdtm/static/netns-nft-ipt.c +++ b/test/zdtm/static/netns-nft-ipt.c @@ -5,8 +5,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that both nftables & iptables rules (some) are C/R properly"; -const char *test_author = "Alexander Mikhalitsyn <alexander@mihalicyn.com>"; +const char *test_doc = "Check that both nftables & iptables rules (some) are C/R properly"; +const char *test_author = "Alexander Mikhalitsyn <alexander@mihalicyn.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); diff --git a/test/zdtm/static/netns-nft.c b/test/zdtm/static/netns-nft.c index f4991afda..673cc007e 100644 --- a/test/zdtm/static/netns-nft.c +++ b/test/zdtm/static/netns-nft.c @@ -5,8 +5,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that nft rules (some) are kept"; -const char *test_author = "Alexander Mikhalitsyn <alexander@mihalicyn.com>"; +const char *test_doc = "Check that nft rules (some) are kept"; +const char *test_author = "Alexander Mikhalitsyn <alexander@mihalicyn.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); diff --git a/test/zdtm/static/netns.c b/test/zdtm/static/netns.c index b7a75b6d9..bc7f66319 100644 --- a/test/zdtm/static/netns.c +++ b/test/zdtm/static/netns.c @@ -4,8 +4,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that network environment (links, addresses and routes) are preserved"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check that network environment (links, addresses and routes) are preserved"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; int main(int argc, char **argv) { diff --git a/test/zdtm/static/netns_lock.c b/test/zdtm/static/netns_lock.c index f58ba83da..9b3a4f1c0 100644 --- a/test/zdtm/static/netns_lock.c +++ b/test/zdtm/static/netns_lock.c @@ -7,9 +7,9 @@ const char *test_author = "Zeyad Yasser <zeyady98@gmail.com>"; #include <fcntl.h> #include <sched.h> -#define NS_PATH "/var/run/netns/criu-net-lock-test" +#define NS_PATH "/var/run/netns/criu-net-lock-test" #define SYNCFILE_PATH "net_lock.sync" -#define MAX_RETRY 3 +#define MAX_RETRY 3 int main(int argc, char **argv) { @@ -42,7 +42,7 @@ int main(int argc, char **argv) */ for (i = 0; i < MAX_RETRY; i++) { - if (access(SYNCFILE_PATH, F_OK )) { + if (access(SYNCFILE_PATH, F_OK)) { /* Netns not created yet by post-start hook */ sleep(1); continue; diff --git a/test/zdtm/static/netns_sub.c b/test/zdtm/static/netns_sub.c index 9f77bf96b..501e97bd7 100644 --- a/test/zdtm/static/netns_sub.c +++ b/test/zdtm/static/netns_sub.c @@ -14,7 +14,7 @@ #include "zdtmtst.h" -const char *test_doc = "Check dump and restore a few network namespaces"; +const char *test_doc = "Check dump and restore a few network namespaces"; static int fill_name(int nsid, struct sockaddr_un *name) { @@ -41,7 +41,7 @@ static int create_socket(int nsid) return -1; } - if (bind(sk, (struct sockaddr *) &name, len) < 0) { + if (bind(sk, (struct sockaddr *)&name, len) < 0) { pr_perror("bind"); close(sk); return -1; @@ -63,7 +63,7 @@ static int check_socket(int nsid, bool success) return -1; } - if (connect(sk, (struct sockaddr *) &name, len) < 0) { + if (connect(sk, (struct sockaddr *)&name, len) < 0) { if (!success && errno == ECONNREFUSED) return 0; pr_perror("connect to %d", nsid); diff --git a/test/zdtm/static/netns_sub_sysctl.c b/test/zdtm/static/netns_sub_sysctl.c index bf828e08e..545a17308 100644 --- a/test/zdtm/static/netns_sub_sysctl.c +++ b/test/zdtm/static/netns_sub_sysctl.c @@ -3,8 +3,8 @@ #include "zdtmtst.h" #include "sysctl.h" -const char *test_doc = "Check dump and restore a net.unix.max_dgram_qlen sysctl parameter in subns"; -const char *test_author = "Alexander Mikhalitsyn <alexander@mihalicyn.com>"; +const char *test_doc = "Check dump and restore a net.unix.max_dgram_qlen sysctl parameter in subns"; +const char *test_author = "Alexander Mikhalitsyn <alexander@mihalicyn.com>"; typedef struct { const char *path; @@ -12,12 +12,9 @@ typedef struct { int new; } sysctl_opt_t; -#define CONF_UNIX_BASE "/proc/sys/net/unix" +#define CONF_UNIX_BASE "/proc/sys/net/unix" -static sysctl_opt_t net_unix_params[] = { - {CONF_UNIX_BASE"/max_dgram_qlen", 0, 0}, - {NULL, 0, 0} -}; +static sysctl_opt_t net_unix_params[] = { { CONF_UNIX_BASE "/max_dgram_qlen", 0, 0 }, { NULL, 0, 0 } }; int main(int argc, char **argv) { diff --git a/test/zdtm/static/netns_sub_veth.c b/test/zdtm/static/netns_sub_veth.c index c0a71b337..e072d7816 100644 --- a/test/zdtm/static/netns_sub_veth.c +++ b/test/zdtm/static/netns_sub_veth.c @@ -20,12 +20,12 @@ #include "zdtmtst.h" -const char *test_doc = "Check dump and restore a few network namespaces"; +const char *test_doc = "Check dump and restore a few network namespaces"; #ifndef NSIO -#define NSIO 0xb7 -#define NS_GET_USERNS _IO(NSIO, 0x1) -#define NS_GET_PARENT _IO(NSIO, 0x2) +#define NSIO 0xb7 +#define NS_GET_USERNS _IO(NSIO, 0x1) +#define NS_GET_PARENT _IO(NSIO, 0x2) #endif int main(int argc, char **argv) @@ -33,7 +33,7 @@ int main(int argc, char **argv) task_waiter_t lock; pid_t pid[2]; int status = -1, ret, i; - struct rtnl_link *link = NULL, *new; + struct rtnl_link *link = NULL, *new; struct nl_sock *sk; int has_index = 1; @@ -77,11 +77,13 @@ int main(int argc, char **argv) for (i = 0; i < 2; i++) { char cmd[4096]; - snprintf(cmd, sizeof(cmd), "ip link add name zdtm%d index %d netns %d type veth peer name zdtm%d index %d", - i, i * 10 + 12, pid[i], i, i * 10 + 12); + snprintf(cmd, sizeof(cmd), + "ip link add name zdtm%d index %d netns %d type veth peer name zdtm%d index %d", i, + i * 10 + 12, pid[i], i, i * 10 + 12); if (system(cmd)) { has_index = 0; - snprintf(cmd, sizeof(cmd), "ip link add name zdtm%d netns %d type veth peer name zdtm%d", i, pid[i], i); + snprintf(cmd, sizeof(cmd), "ip link add name zdtm%d netns %d type veth peer name zdtm%d", i, + pid[i], i); if (system(cmd)) return 1; } diff --git a/test/zdtm/static/non_uniform_share_propagation.c b/test/zdtm/static/non_uniform_share_propagation.c index 7a18247ab..e4f7ee275 100644 --- a/test/zdtm/static/non_uniform_share_propagation.c +++ b/test/zdtm/static/non_uniform_share_propagation.c @@ -4,8 +4,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check non-uniform shares restore fine"; -const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; +const char *test_doc = "Check non-uniform shares restore fine"; +const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); diff --git a/test/zdtm/static/ofd_file_locks.c b/test/zdtm/static/ofd_file_locks.c index 5b19532f8..68b6f22f5 100644 --- a/test/zdtm/static/ofd_file_locks.c +++ b/test/zdtm/static/ofd_file_locks.c @@ -16,9 +16,7 @@ static int parse_ofd_lock(char *buf, struct flock *lck) if (strncmp(buf, "lock:\t", 6) != 0) return 1; /* isn't lock, skip record */ - num = sscanf(buf, - "%*s %*d: %s %s %s %*d %*x:%*x:%*d %lld %s", - fl_flag, fl_type, fl_option, &start, fl_end); + num = sscanf(buf, "%*s %*d: %s %s %s %*d %*x:%*x:%*d %lld %s", fl_flag, fl_type, fl_option, &start, fl_end); if (num < 4) { pr_err("Invalid lock info %s\n", buf); @@ -118,9 +116,7 @@ out: static int check_file_locks_match(struct flock *orig_lck, struct flock *lck) { - return orig_lck->l_start == lck->l_start && - orig_lck->l_len == lck->l_len && - orig_lck->l_type == lck->l_type; + return orig_lck->l_start == lck->l_start && orig_lck->l_len == lck->l_len && orig_lck->l_type == lck->l_type; } int check_file_lock_restored(int pid, int fd, struct flock *lck) @@ -164,30 +160,30 @@ int zdtm_fcntl(int fd, int cmd, struct flock *f) { #if defined(__i386__) #ifndef __NR_fcntl64 -# define __NR_fcntl64 221 +#define __NR_fcntl64 221 #endif struct flock64 f64 = {}; int ret; switch (cmd) { - case F_OFD_SETLK: - case F_OFD_SETLKW: - f64.l_type = f->l_type; - f64.l_whence = f->l_whence; - f64.l_start = f->l_start; - f64.l_len = f->l_len; - f64.l_pid = f->l_pid; - return syscall(__NR_fcntl64, fd, cmd, &f64); - case F_OFD_GETLK: - ret = syscall(__NR_fcntl64, fd, cmd, &f64); - f->l_type = f64.l_type; - f->l_whence = f64.l_whence; - f->l_start = f64.l_start; - f->l_len = f64.l_len; - f->l_pid = f64.l_pid; - return ret; - default: - break; + case F_OFD_SETLK: + case F_OFD_SETLKW: + f64.l_type = f->l_type; + f64.l_whence = f->l_whence; + f64.l_start = f->l_start; + f64.l_len = f->l_len; + f64.l_pid = f->l_pid; + return syscall(__NR_fcntl64, fd, cmd, &f64); + case F_OFD_GETLK: + ret = syscall(__NR_fcntl64, fd, cmd, &f64); + f->l_type = f64.l_type; + f->l_whence = f64.l_whence; + f->l_start = f64.l_start; + f->l_len = f64.l_len; + f->l_pid = f64.l_pid; + return ret; + default: + break; } #endif return fcntl(fd, cmd, f); diff --git a/test/zdtm/static/oom_score_adj.c b/test/zdtm/static/oom_score_adj.c index 8e9c40782..cbbdfb810 100644 --- a/test/zdtm/static/oom_score_adj.c +++ b/test/zdtm/static/oom_score_adj.c @@ -65,7 +65,6 @@ int set_oom_score_adj(const char *path, int value) return ret; } - int main(int argc, char *argv[]) { int ret; @@ -84,8 +83,7 @@ int main(int argc, char *argv[]) return -1; if (new_oom_score_adj != test_value) { - fail("OOM score value %d is different after restore: %d", - test_value, new_oom_score_adj); + fail("OOM score value %d is different after restore: %d", test_value, new_oom_score_adj); return -1; } diff --git a/test/zdtm/static/opath_file.c b/test/zdtm/static/opath_file.c index 40e5987c3..779060844 100644 --- a/test/zdtm/static/opath_file.c +++ b/test/zdtm/static/opath_file.c @@ -5,13 +5,13 @@ #include "zdtmtst.h" -#define TEST_FILE "test_file" -#define BUF_SIZE 4096 -#define fdinfo_field(str, field) !strncmp(str, field":", sizeof(field)) -#define pr_debug(format, arg...) test_msg("DBG: %s:%d: " format, __FILE__, __LINE__, ## arg) +#define TEST_FILE "test_file" +#define BUF_SIZE 4096 +#define fdinfo_field(str, field) !strncmp(str, field ":", sizeof(field)) +#define pr_debug(format, arg...) test_msg("DBG: %s:%d: " format, __FILE__, __LINE__, ##arg) -const char *test_doc = "Check open file with O_PATH preserved"; -const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; +const char *test_doc = "Check open file with O_PATH preserved"; +const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); diff --git a/test/zdtm/static/overmount_dev.c b/test/zdtm/static/overmount_dev.c index e126d301d..dd16c11a8 100644 --- a/test/zdtm/static/overmount_dev.c +++ b/test/zdtm/static/overmount_dev.c @@ -8,10 +8,10 @@ #include "zdtmtst.h" -const char *test_doc = "Check that we can migrate with a device special file " - "open in a directory which has been mounted over by " - "another filesystem"; -const char *test_author = "Roman Kagan <rkagan@parallels.com>"; +const char *test_doc = "Check that we can migrate with a device special file " + "open in a directory which has been mounted over by " + "another filesystem"; +const char *test_author = "Roman Kagan <rkagan@parallels.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); diff --git a/test/zdtm/static/overmount_fifo.c b/test/zdtm/static/overmount_fifo.c index c73793036..f3693fef6 100644 --- a/test/zdtm/static/overmount_fifo.c +++ b/test/zdtm/static/overmount_fifo.c @@ -7,10 +7,10 @@ #include "zdtmtst.h" -const char *test_doc = "Check that we can migrate with a named pipe " - "open in a directory which has been mounted over by " - "another filesystem"; -const char *test_author = "Roman Kagan <rkagan@parallels.com>"; +const char *test_doc = "Check that we can migrate with a named pipe " + "open in a directory which has been mounted over by " + "another filesystem"; +const char *test_author = "Roman Kagan <rkagan@parallels.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); diff --git a/test/zdtm/static/overmount_file.c b/test/zdtm/static/overmount_file.c index e20d98f93..178b34182 100644 --- a/test/zdtm/static/overmount_file.c +++ b/test/zdtm/static/overmount_file.c @@ -7,10 +7,10 @@ #include "zdtmtst.h" -const char *test_doc = "Check that we can't migrate with a file open in a " - "directory which has been mounted over by another " - "filesystem"; -const char *test_author = "Roman Kagan <rkagan@parallels.com>"; +const char *test_doc = "Check that we can't migrate with a file open in a " + "directory which has been mounted over by another " + "filesystem"; +const char *test_author = "Roman Kagan <rkagan@parallels.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); diff --git a/test/zdtm/static/overmount_sock.c b/test/zdtm/static/overmount_sock.c index 8d2d28bf6..6e3ab935b 100644 --- a/test/zdtm/static/overmount_sock.c +++ b/test/zdtm/static/overmount_sock.c @@ -10,10 +10,10 @@ #include "zdtmtst.h" -const char *test_doc = "Check that we can migrate with a unix socket " - "bound in a directory which has been mounted over by" - " another filesystem"; -const char *test_author = "Roman Kagan <rkagan@parallels.com>"; +const char *test_doc = "Check that we can migrate with a unix socket " + "bound in a directory which has been mounted over by" + " another filesystem"; +const char *test_author = "Roman Kagan <rkagan@parallels.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); @@ -44,7 +44,7 @@ static int setup_srv_sock(const char *filename) return -1; } - if (bind(sock, (struct sockaddr *) &name, SUN_LEN(&name)) < 0) { + if (bind(sock, (struct sockaddr *)&name, SUN_LEN(&name)) < 0) { pr_perror("can't bind to socket \"%s\"", filename); goto err; } @@ -72,7 +72,7 @@ static int setup_clnt_sock(const char *filename) if (sock < 0) return -1; - if (connect(sock, (struct sockaddr *) &name, SUN_LEN(&name)) < 0) + if (connect(sock, (struct sockaddr *)&name, SUN_LEN(&name)) < 0) goto err; return sock; @@ -81,7 +81,7 @@ err: return -1; } -int main(int argc, char ** argv) +int main(int argc, char **argv) { int sock, acc_sock, ret; char path[256]; @@ -111,7 +111,7 @@ int main(int argc, char ** argv) goto out; } - if (pid == 0) { /* child writes to the overmounted socket and returns */ + if (pid == 0) { /* child writes to the overmounted socket and returns */ close(sock); sock = setup_clnt_sock(path); @@ -159,8 +159,7 @@ int main(int argc, char ** argv) if (WIFEXITED(ret)) { ret = WEXITSTATUS(ret); if (ret) { - fail("child exited with nonzero code %d (%s)", ret, - strerror(ret)); + fail("child exited with nonzero code %d (%s)", ret, strerror(ret)); goto out; } } diff --git a/test/zdtm/static/overmount_with_shared_parent.c b/test/zdtm/static/overmount_with_shared_parent.c index 1fcb5a5cb..95b455ec0 100644 --- a/test/zdtm/static/overmount_with_shared_parent.c +++ b/test/zdtm/static/overmount_with_shared_parent.c @@ -4,8 +4,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check overmount on shared parent works"; -const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; +const char *test_doc = "Check overmount on shared parent works"; +const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); diff --git a/test/zdtm/static/overmounted_file.c b/test/zdtm/static/overmounted_file.c index ee1d1c58f..c72d27cb8 100644 --- a/test/zdtm/static/overmounted_file.c +++ b/test/zdtm/static/overmounted_file.c @@ -6,8 +6,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check open file on overmounted mounts doesn't dump"; -const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; +const char *test_doc = "Check open file on overmounted mounts doesn't dump"; +const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; #define DATA "Data" @@ -50,7 +50,7 @@ int main(int argc, char **argv) } ssprintf(file, "%s/file", overmounted); - fd = open(file, O_CREAT|O_WRONLY, 0600); + fd = open(file, O_CREAT | O_WRONLY, 0600); if (fd < 0) { pr_perror("open"); return 1; diff --git a/test/zdtm/static/packet_sock.c b/test/zdtm/static/packet_sock.c index 36516fa99..4a9078f81 100644 --- a/test/zdtm/static/packet_sock.c +++ b/test/zdtm/static/packet_sock.c @@ -24,30 +24,27 @@ const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; #include <linux/if_packet.h> #include <net/ethernet.h> -#define SK_RESERVE 8 -#define DEF_FANOUT 13 +#define SK_RESERVE 8 +#define DEF_FANOUT 13 #ifndef PACKET_FANOUT -#define PACKET_FANOUT 18 +#define PACKET_FANOUT 18 #endif static int test_sockaddr(int n, struct sockaddr_ll *have, struct sockaddr_ll *want) { if (have->sll_family != want->sll_family) { - fail("%d Family mismatch %d/%d", n, - (int)have->sll_family, (int)want->sll_family); + fail("%d Family mismatch %d/%d", n, (int)have->sll_family, (int)want->sll_family); return 1; } if (have->sll_protocol != want->sll_protocol) { - fail("%d Proto mismatch %d/%d", n, - (int)have->sll_protocol, (int)want->sll_protocol); + fail("%d Proto mismatch %d/%d", n, (int)have->sll_protocol, (int)want->sll_protocol); return 1; } if (have->sll_ifindex != want->sll_ifindex) { - fail("%d Index mismatch %d/%d", n, - have->sll_ifindex, want->sll_ifindex); + fail("%d Index mismatch %d/%d", n, have->sll_ifindex, want->sll_ifindex); return 1; } @@ -56,19 +53,19 @@ static int test_sockaddr(int n, struct sockaddr_ll *have, struct sockaddr_ll *wa } #ifndef MAX_ADDR_LEN -#define MAX_ADDR_LEN 32 +#define MAX_ADDR_LEN 32 #endif struct packet_mreq_max { - int mr_ifindex; - unsigned short mr_type; - unsigned short mr_alen; - unsigned char mr_address[MAX_ADDR_LEN]; + int mr_ifindex; + unsigned short mr_type; + unsigned short mr_alen; + unsigned char mr_address[MAX_ADDR_LEN]; }; -#define LO_ADDR_LEN 6 +#define LO_ADDR_LEN 6 -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0) struct tpacket_req3 { unsigned int tp_block_size; diff --git a/test/zdtm/static/packet_sock_mmap.c b/test/zdtm/static/packet_sock_mmap.c index 93d6ebbf2..2a105582b 100644 --- a/test/zdtm/static/packet_sock_mmap.c +++ b/test/zdtm/static/packet_sock_mmap.c @@ -18,7 +18,7 @@ const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; #include <net/ethernet.h> #include <sys/mman.h> -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0) struct tpacket_req3 { unsigned int tp_block_size; diff --git a/test/zdtm/static/packet_sock_spkt.c b/test/zdtm/static/packet_sock_spkt.c index 55cd16518..7aaaabd14 100644 --- a/test/zdtm/static/packet_sock_spkt.c +++ b/test/zdtm/static/packet_sock_spkt.c @@ -23,7 +23,7 @@ static int do_bind(int sk) addr.sa_family = AF_PACKET; strcpy(addr.sa_data, "lo"); - return bind(sk, (struct sockaddr *) &addr, sizeof(addr)); + return bind(sk, (struct sockaddr *)&addr, sizeof(addr)); } static int check_socket_binding(int sk, char *dev) @@ -53,7 +53,7 @@ int main(int argc, char **argv) sk1 = socket(AF_PACKET, SOCK_PACKET, htons(ETH_P_ALL)); - if (sk1 < 0) { + if (sk1 < 0) { pr_perror("Can't create socket 1"); return 1; } diff --git a/test/zdtm/static/pdeath_sig.c b/test/zdtm/static/pdeath_sig.c index 0f7436f63..d680e4842 100644 --- a/test/zdtm/static/pdeath_sig.c +++ b/test/zdtm/static/pdeath_sig.c @@ -8,8 +8,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that pdeath sig is preserved"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check that pdeath sig is preserved"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; static int sigrecvd = 0; static void sigh(int s, siginfo_t *i, void *d) diff --git a/test/zdtm/static/pid00.c b/test/zdtm/static/pid00.c index 4fd3e09aa..a60f8af45 100644 --- a/test/zdtm/static/pid00.c +++ b/test/zdtm/static/pid00.c @@ -4,8 +4,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that p?pid and e?[ug]id didn't change"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check that p?pid and e?[ug]id didn't change"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; int setfsuid(uid_t fsuid); int setfsgid(uid_t fsgid); @@ -40,11 +40,12 @@ int main(int argc, char **argv) read(f_p[0], &res, 1); close(f_p[0]); -#define CHECK_ID(__t, __w, __e) do { \ - if (__t##id != w_##__t##__w##id) { \ - res = __e; \ - goto bad; \ - } \ +#define CHECK_ID(__t, __w, __e) \ + do { \ + if (__t##id != w_##__t##__w##id) { \ + res = __e; \ + goto bad; \ + } \ } while (0) rid = eid = sid = fsid = 0; @@ -65,7 +66,7 @@ int main(int argc, char **argv) CHECK_ID(fs, g, '8'); res = '0'; -bad: + bad: write(r_p[1], &res, 1); close(r_p[1]); _exit(0); diff --git a/test/zdtm/static/pid_file.c b/test/zdtm/static/pid_file.c index 3ee6a3942..bd4df6bfb 100644 --- a/test/zdtm/static/pid_file.c +++ b/test/zdtm/static/pid_file.c @@ -7,8 +7,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that environment didn't change"; -const char *test_author = "Andrei Vagin <avagin@gmail.com>"; +const char *test_doc = "Check that environment didn't change"; +const char *test_author = "Andrei Vagin <avagin@gmail.com>"; int main(int argc, char **argv) { diff --git a/test/zdtm/static/pipe00.c b/test/zdtm/static/pipe00.c index dd487d091..492722573 100644 --- a/test/zdtm/static/pipe00.c +++ b/test/zdtm/static/pipe00.c @@ -6,12 +6,12 @@ #include "zdtmtst.h" -const char *test_doc = "Lock inversion"; -const char *test_author = "Andrey Vagin <avagin@parallels.com>"; +const char *test_doc = "Lock inversion"; +const char *test_author = "Andrey Vagin <avagin@parallels.com>"; #define TEST_STRING "Hello world" -int main(int argc, char ** argv) +int main(int argc, char **argv) { int pipe1[2]; int pipe2[2]; @@ -42,7 +42,7 @@ int main(int argc, char ** argv) return 1; } } else { - if (dup2(pipe1[0], 12) == -1 || dup2(pipe2[1], 11) == -1) { + if (dup2(pipe1[0], 12) == -1 || dup2(pipe2[1], 11) == -1) { pr_perror("dup2 failed"); goto err; } diff --git a/test/zdtm/static/pipe01.c b/test/zdtm/static/pipe01.c index fd51988b5..587f42568 100644 --- a/test/zdtm/static/pipe01.c +++ b/test/zdtm/static/pipe01.c @@ -10,12 +10,12 @@ #include "zdtmtst.h" -const char *test_doc = "Test that all data can be restored"; -const char *test_author = "Andrey Vagin <avagin@parallels.com>"; +const char *test_doc = "Test that all data can be restored"; +const char *test_author = "Andrey Vagin <avagin@parallels.com>"; #define TEST_STRING "Hello world" -int main(int argc, char ** argv) +int main(int argc, char **argv) { int pfd[2], pfd_dup[2], pfd_rop[2]; char path[PATH_MAX]; @@ -43,8 +43,7 @@ int main(int argc, char ** argv) snprintf(path, PATH_MAX, "/proc/self/fd/%d", pfd[1]); pfd_rop[1] = open(path, O_WRONLY); - if (pfd_rop[0] == -1 || pfd_rop[1] == -1 || - pfd_dup[0] == -1 || pfd_dup[1] == -1) { + if (pfd_rop[0] == -1 || pfd_rop[1] == -1 || pfd_dup[0] == -1 || pfd_dup[1] == -1) { pr_perror("dup() failed"); return 1; } diff --git a/test/zdtm/static/pipe02.c b/test/zdtm/static/pipe02.c index 2a8cca7da..9ee522ea8 100644 --- a/test/zdtm/static/pipe02.c +++ b/test/zdtm/static/pipe02.c @@ -10,10 +10,10 @@ #include "zdtmtst.h" -const char *test_doc = "Create two unshared descriptor for the one end of a pipe"; -const char *test_author = "Andrey Vagin <avagin@parallels.com>"; +const char *test_doc = "Create two unshared descriptor for the one end of a pipe"; +const char *test_author = "Andrey Vagin <avagin@parallels.com>"; -int main(int argc, char ** argv) +int main(int argc, char **argv) { int p[2], fd; int ret; diff --git a/test/zdtm/static/pipe03.c b/test/zdtm/static/pipe03.c index d649007b7..d6c8f74cf 100644 --- a/test/zdtm/static/pipe03.c +++ b/test/zdtm/static/pipe03.c @@ -5,11 +5,11 @@ #include "zdtmtst.h" -const char *test_doc = "Check that pipes with a non-default size can be c/r-ed"; -const char *test_author = "Andrei Vagin <avagin@gmail.com>"; +const char *test_doc = "Check that pipes with a non-default size can be c/r-ed"; +const char *test_author = "Andrei Vagin <avagin@gmail.com>"; #define DATA_SIZE (1 << 20) -#define BUF_SIZE (4096) +#define BUF_SIZE (4096) int main(int argc, char **argv) { diff --git a/test/zdtm/static/poll.c b/test/zdtm/static/poll.c index 53d801a0b..60eb54f34 100644 --- a/test/zdtm/static/poll.c +++ b/test/zdtm/static/poll.c @@ -16,8 +16,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check poll() timeouts"; -const char *test_author = "Cyrill Gorcunov <gorcunov@parallels.com>"; +const char *test_doc = "Check poll() timeouts"; +const char *test_author = "Cyrill Gorcunov <gorcunov@parallels.com>"; static void show_timestamp(char *prefix, unsigned long tv_sec, unsigned long tv_usec) { @@ -29,8 +29,7 @@ static void show_pollfd(struct pollfd *fds, size_t nfds) size_t i; for (i = 0; i < nfds; i++) { - test_msg("%2zu) fd: %2d events %2x revents %2x\n", - i, fds[i].fd, fds[i].events, fds[i].revents); + test_msg("%2zu) fd: %2d events %2x revents %2x\n", i, fds[i].fd, fds[i].events, fds[i].revents); } } @@ -100,11 +99,9 @@ int main(int argc, char *argv[]) } show_timestamp("Stop", time2.tv_sec, time2.tv_usec); - show_timestamp("Diff", time2.tv_sec - time1.tv_sec, - time2.tv_usec - time1.tv_usec); + show_timestamp("Diff", time2.tv_sec - time1.tv_sec, time2.tv_usec - time1.tv_usec); if ((time2.tv_sec - time1.tv_sec) > delta) { - fail("Delta is too big %lu", - (unsigned long)(time2.tv_sec - time1.tv_sec)); + fail("Delta is too big %lu", (unsigned long)(time2.tv_sec - time1.tv_sec)); exit(1); } } diff --git a/test/zdtm/static/posix_timers.c b/test/zdtm/static/posix_timers.c index b88114cdb..b2ed0dcf9 100644 --- a/test/zdtm/static/posix_timers.c +++ b/test/zdtm/static/posix_timers.c @@ -8,24 +8,24 @@ #include "zdtmtst.h" -const char *test_doc ="Posix timers migration check"; +const char *test_doc = "Posix timers migration check"; const char *test_author = "Kinsbursky Stanislav <skinsbursky@parallels.com>"; sigset_t mask; -#define WRONG_SIGNAL 1 -#define WRONG_SI_PTR 2 -#define FAIL_OVERRUN 4 +#define WRONG_SIGNAL 1 +#define WRONG_SI_PTR 2 +#define FAIL_OVERRUN 4 -#define MAX_TIMER_DISPLACEMENT 10 +#define MAX_TIMER_DISPLACEMENT 10 #define NO_PERIODIC #ifndef CLOCK_MONOTONIC_COARSE -# define CLOCK_MONOTONIC_COARSE 6 +#define CLOCK_MONOTONIC_COARSE 6 #endif #ifndef CLOCK_BOOTTIME -# define CLOCK_BOOTTIME 7 +#define CLOCK_BOOTTIME 7 #endif #ifndef NO_PERIODIC @@ -115,8 +115,7 @@ static struct posix_timers_info { { } }; -static int check_handler_status(struct posix_timers_info *info, - struct itimerspec *its, int ms_passed, int delta) +static int check_handler_status(struct posix_timers_info *info, struct itimerspec *its, int ms_passed, int delta) { int displacement; int timer_ms; @@ -179,7 +178,8 @@ static int check_handler_status(struct posix_timers_info *info, test_msg("%20s: Handler count : %d\n", info->name, info->handler_cnt); if (displacement > MAX_TIMER_DISPLACEMENT) { - fail("%32s: Time displacement: %d%% (max alloved: %d%%)", info->name, displacement, MAX_TIMER_DISPLACEMENT); + fail("%32s: Time displacement: %d%% (max alloved: %d%%)", info->name, displacement, + MAX_TIMER_DISPLACEMENT); return -EFAULT; } return 0; @@ -213,14 +213,14 @@ static int check_timers(int delta, struct timespec *sleep_start, struct timespec * Adjust with @total_sleep_time if needed. */ if (info->clock == CLOCK_BOOTTIME) { - info->start.tv_sec -= sleep_start->tv_sec; - info->start.tv_nsec -= sleep_start->tv_nsec; - info->end.tv_sec -= sleep_end->tv_sec; - info->end.tv_nsec -= sleep_end->tv_nsec; + info->start.tv_sec -= sleep_start->tv_sec; + info->start.tv_nsec -= sleep_start->tv_nsec; + info->end.tv_sec -= sleep_end->tv_sec; + info->end.tv_nsec -= sleep_end->tv_nsec; } ms_passed = (info->end.tv_sec - info->start.tv_sec) * 1000 + - (info->end.tv_nsec - info->start.tv_nsec) / (1000 * 1000); + (info->end.tv_nsec - info->start.tv_nsec) / (1000 * 1000); if (check_handler_status(info, &oldval, ms_passed, delta)) status--; @@ -229,8 +229,7 @@ static int check_timers(int delta, struct timespec *sleep_start, struct timespec return status; } -static void generic_handler(struct posix_timers_info *info, - struct posix_timers_info *real, int sig) +static void generic_handler(struct posix_timers_info *info, struct posix_timers_info *real, int sig) { int overrun; @@ -256,41 +255,35 @@ static void generic_handler(struct posix_timers_info *info, #ifndef NO_PERIODIC static void monotonic_periodic_handler(int sig, siginfo_t *si, void *uc) { - generic_handler(si->si_value.sival_ptr, - &posix_timers[MONOTONIC_PERIODIC_INFO], sig); + generic_handler(si->si_value.sival_ptr, &posix_timers[MONOTONIC_PERIODIC_INFO], sig); } static void boottime_periodic_handler(int sig, siginfo_t *si, void *uc) { - generic_handler(si->si_value.sival_ptr, - &posix_timers[BOOTTIME_PERIODIC_INFO], sig); + generic_handler(si->si_value.sival_ptr, &posix_timers[BOOTTIME_PERIODIC_INFO], sig); } #endif static void monotonic_oneshot_handler(int sig, siginfo_t *si, void *uc) { - generic_handler(si->si_value.sival_ptr, - &posix_timers[MONOTONIC_ONESHOT_INFO], sig); + generic_handler(si->si_value.sival_ptr, &posix_timers[MONOTONIC_ONESHOT_INFO], sig); } static void boottime_oneshot_handler(int sig, siginfo_t *si, void *uc) { - generic_handler(si->si_value.sival_ptr, - &posix_timers[BOOTTIME_ONESHOT_INFO], sig); + generic_handler(si->si_value.sival_ptr, &posix_timers[BOOTTIME_ONESHOT_INFO], sig); } #ifndef NO_PERIODIC static void realtime_periodic_handler(int sig, siginfo_t *si, void *uc) { - generic_handler(si->si_value.sival_ptr, - &posix_timers[REALTIME_PERIODIC_INFO], sig); + generic_handler(si->si_value.sival_ptr, &posix_timers[REALTIME_PERIODIC_INFO], sig); } #endif static void realtime_oneshot_handler(int sig, siginfo_t *si, void *uc) { - generic_handler(si->si_value.sival_ptr, - &posix_timers[REALTIME_ONESHOT_INFO], sig); + generic_handler(si->si_value.sival_ptr, &posix_timers[REALTIME_ONESHOT_INFO], sig); } static int setup_timers(void) @@ -302,7 +295,7 @@ static int setup_timers(void) struct itimerspec its; sigemptyset(&mask); - while(info->handler) { + while (info->handler) { sigaddset(&mask, info->sig); info++; } @@ -313,18 +306,18 @@ static int setup_timers(void) } info = posix_timers; - while(info->handler) { + while (info->handler) { /* Add and delete fake timers to test restoring 'with holes' */ timer_t timeridt; for (i = 0; i < 10; i++) { ret = timer_create(CLOCK_REALTIME, NULL, &timeridt); if (ret < 0) { - pr_perror("Can't create temporary posix timer %lx", (long) timeridt); + pr_perror("Can't create temporary posix timer %lx", (long)timeridt); return -errno; } ret = timer_delete(timeridt); if (ret < 0) { - pr_perror("Can't remove temporaty posix timer %lx", (long) timeridt); + pr_perror("Can't remove temporaty posix timer %lx", (long)timeridt); return -errno; } } @@ -398,10 +391,7 @@ static int get_total_sleep_time(struct timespec *tv, char *type) test_msg("(%6s) boottime %lu " "boottime-coarse %lu " "total_sleep_time %lu\n", - type, - (long)boottime.tv_sec, - (long)boottime_coarse.tv_sec, - (long)tv->tv_sec); + type, (long)boottime.tv_sec, (long)boottime_coarse.tv_sec, (long)tv->tv_sec); return 0; } @@ -432,9 +422,8 @@ int main(int argc, char **argv) err = get_total_sleep_time(&sleep_end, "end"); if (err) return err; - err = check_timers((end.tv_sec - start.tv_sec) * 1000 + - (end.tv_nsec - start.tv_nsec) / 1000000, - &sleep_start, &sleep_end); + err = check_timers((end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000, &sleep_start, + &sleep_end); if (err) return err; diff --git a/test/zdtm/static/private_bind_propagation.c b/test/zdtm/static/private_bind_propagation.c index ee4adbd2d..2b92f7062 100644 --- a/test/zdtm/static/private_bind_propagation.c +++ b/test/zdtm/static/private_bind_propagation.c @@ -4,8 +4,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check sharing options are restored for bindmounted shared group children"; -const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; +const char *test_doc = "Check sharing options are restored for bindmounted shared group children"; +const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); diff --git a/test/zdtm/static/proc-self.c b/test/zdtm/static/proc-self.c index 6f0a30e7d..10218c86b 100644 --- a/test/zdtm/static/proc-self.c +++ b/test/zdtm/static/proc-self.c @@ -12,8 +12,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check for /proc/self/ns path restore"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; +const char *test_doc = "Check for /proc/self/ns path restore"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; const char nspath[] = "/proc/self/ns/net"; diff --git a/test/zdtm/static/pstree.c b/test/zdtm/static/pstree.c index ba94a275d..38cc99339 100644 --- a/test/zdtm/static/pstree.c +++ b/test/zdtm/static/pstree.c @@ -5,8 +5,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that environment didn't change"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check that environment didn't change"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; int main(int argc, char **argv) { diff --git a/test/zdtm/static/pthread00.c b/test/zdtm/static/pthread00.c index 4da824056..adbf74a40 100644 --- a/test/zdtm/static/pthread00.c +++ b/test/zdtm/static/pthread00.c @@ -18,35 +18,34 @@ #include "zdtmtst.h" -#define exit_group(code) \ - syscall(__NR_exit_group, code) +#define exit_group(code) syscall(__NR_exit_group, code) -const char *test_doc = "Create a few pthreads/forks and compare TLS and mmap data on restore\n"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org"; +const char *test_doc = "Create a few pthreads/forks and compare TLS and mmap data on restore\n"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org"; static __thread char tls_data[10]; -#define TRANSITION_PASSED 4 -#define TRANSITION_FAILED 8 +#define TRANSITION_PASSED 4 +#define TRANSITION_FAILED 8 -#define MAP(map, i) (((int *)map)[i]) +#define MAP(map, i) (((int *)map)[i]) -#define SET_PASSED(map, i) MAP(map, i) = TRANSITION_PASSED -#define SET_FAILED(map, i) MAP(map, i) = TRANSITION_FAILED +#define SET_PASSED(map, i) MAP(map, i) = TRANSITION_PASSED +#define SET_FAILED(map, i) MAP(map, i) = TRANSITION_FAILED -#define IS_PASSED(map, i) (MAP(map, i) & TRANSITION_PASSED) +#define IS_PASSED(map, i) (MAP(map, i) & TRANSITION_PASSED) -#define NR_WAITERS 6 +#define NR_WAITERS 6 static task_waiter_t waiter[NR_WAITERS]; -#define passage(index) \ - do { \ - task_waiter_complete(&waiter[index], 1); \ - task_waiter_wait4(&waiter[index], 2); \ - if (memcmp(tls_data, __tls_data, sizeof(tls_data))) \ - SET_FAILED(map, index); \ - else \ - SET_PASSED(map, index); \ +#define passage(index) \ + do { \ + task_waiter_complete(&waiter[index], 1); \ + task_waiter_wait4(&waiter[index], 2); \ + if (memcmp(tls_data, __tls_data, sizeof(tls_data))) \ + SET_FAILED(map, index); \ + else \ + SET_PASSED(map, index); \ } while (0) static void *thread_subfunc_1(void *map) @@ -171,11 +170,7 @@ int main(int argc, char *argv[]) pthread_join(th1, NULL); pthread_join(th2, NULL); - if (IS_PASSED(map, 0) && - IS_PASSED(map, 1) && - IS_PASSED(map, 2) && - IS_PASSED(map, 3) && - IS_PASSED(map, 4) && + if (IS_PASSED(map, 0) && IS_PASSED(map, 1) && IS_PASSED(map, 2) && IS_PASSED(map, 3) && IS_PASSED(map, 4) && IS_PASSED(map, 5)) pass(); else diff --git a/test/zdtm/static/pthread01.c b/test/zdtm/static/pthread01.c index bdd7c59d8..6aa8d80a8 100644 --- a/test/zdtm/static/pthread01.c +++ b/test/zdtm/static/pthread01.c @@ -14,14 +14,14 @@ #include "zdtmtst.h" -#define gettid() pthread_self() +#define gettid() pthread_self() -const char *test_doc = "Create a few pthreads and test TLS + blocked signals\n"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org"; +const char *test_doc = "Create a few pthreads and test TLS + blocked signals\n"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org"; static __thread struct tls_data_s { - char *rand_string[10]; - sigset_t blk_sigset; + char *rand_string[10]; + sigset_t blk_sigset; } tls_data; static task_waiter_t t1; @@ -36,19 +36,45 @@ static char *decode_signal(const sigset_t *s, char *buf) { buf[0] = '\0'; -#define COLLECT(sig) \ - do { \ - if (sigismember(s, sig)) \ - strcat(buf, #sig " "); \ +#define COLLECT(sig) \ + do { \ + if (sigismember(s, sig)) \ + strcat(buf, #sig " "); \ } while (0) - COLLECT(SIGHUP); COLLECT(SIGINT); COLLECT(SIGQUIT); COLLECT(SIGILL); COLLECT(SIGTRAP); - COLLECT(SIGABRT); COLLECT(SIGIOT); COLLECT(SIGBUS); COLLECT(SIGFPE); COLLECT(SIGKILL); - COLLECT(SIGUSR1); COLLECT(SIGSEGV); COLLECT(SIGUSR2); COLLECT(SIGPIPE); COLLECT(SIGALRM); - COLLECT(SIGTERM); COLLECT(SIGSTKFLT); COLLECT(SIGCHLD); COLLECT(SIGCONT); COLLECT(SIGSTOP); - COLLECT(SIGTSTP); COLLECT(SIGTTIN); COLLECT(SIGTTOU); COLLECT(SIGURG); COLLECT(SIGXCPU); - COLLECT(SIGXFSZ); COLLECT(SIGVTALRM); COLLECT(SIGPROF); COLLECT(SIGWINCH); COLLECT(SIGIO); - COLLECT(SIGPOLL); COLLECT(SIGPWR); COLLECT(SIGSYS); + COLLECT(SIGHUP); + COLLECT(SIGINT); + COLLECT(SIGQUIT); + COLLECT(SIGILL); + COLLECT(SIGTRAP); + COLLECT(SIGABRT); + COLLECT(SIGIOT); + COLLECT(SIGBUS); + COLLECT(SIGFPE); + COLLECT(SIGKILL); + COLLECT(SIGUSR1); + COLLECT(SIGSEGV); + COLLECT(SIGUSR2); + COLLECT(SIGPIPE); + COLLECT(SIGALRM); + COLLECT(SIGTERM); + COLLECT(SIGSTKFLT); + COLLECT(SIGCHLD); + COLLECT(SIGCONT); + COLLECT(SIGSTOP); + COLLECT(SIGTSTP); + COLLECT(SIGTTIN); + COLLECT(SIGTTOU); + COLLECT(SIGURG); + COLLECT(SIGXCPU); + COLLECT(SIGXFSZ); + COLLECT(SIGVTALRM); + COLLECT(SIGPROF); + COLLECT(SIGWINCH); + COLLECT(SIGIO); + COLLECT(SIGPOLL); + COLLECT(SIGPWR); + COLLECT(SIGSYS); #undef COLLECT return buf; @@ -56,20 +82,20 @@ static char *decode_signal(const sigset_t *s, char *buf) static void __show_sigset(int line, const sigset_t *s) { - char buf[sizeof(sigset_t) * 2 + 1] = { }; + char buf[sizeof(sigset_t) * 2 + 1] = {}; decode_signal(s, buf); test_msg("sigset at %4d: %s\n", line, buf); } -#define show_sigset(set) __show_sigset(__LINE__, set) +#define show_sigset(set) __show_sigset(__LINE__, set) static void *ch_thread_2(void *arg) { char __tls_data[sizeof(tls_data.rand_string)] = "XM5o:?B*[a"; int *results_map = arg; - sigset_t blk_sigset = { }; - sigset_t new = { }; + sigset_t blk_sigset = {}; + sigset_t new = {}; memcpy(tls_data.rand_string, __tls_data, sizeof(tls_data.rand_string)); @@ -114,8 +140,8 @@ static void *ch_thread_1(void *arg) { char __tls_data[sizeof(tls_data.rand_string)] = "pffYQSBo?6"; int *results_map = arg; - sigset_t blk_sigset = { }; - sigset_t new = { }; + sigset_t blk_sigset = {}; + sigset_t new = {}; memcpy(tls_data.rand_string, __tls_data, sizeof(tls_data.rand_string)); @@ -200,12 +226,8 @@ int main(int argc, char *argv[]) pthread_join(thread_1, NULL); pthread_join(thread_2, NULL); - if (results_map[1] == 1 && - results_map[2] == 1 && - results_map[3] == 1 && - results_map[4] == 1 && - results_map[5] == 1 && - results_map[6] == 1) + if (results_map[1] == 1 && results_map[2] == 1 && results_map[3] == 1 && results_map[4] == 1 && + results_map[5] == 1 && results_map[6] == 1) pass(); else fail(); diff --git a/test/zdtm/static/pthread02.c b/test/zdtm/static/pthread02.c index 186271b74..173a55e15 100644 --- a/test/zdtm/static/pthread02.c +++ b/test/zdtm/static/pthread02.c @@ -10,9 +10,8 @@ #include "zdtmtst.h" -const char *test_doc = "Create a thread with a dead leader\n"; -const char *test_author = "Andrew Vagin <avagin@openvz.org"; - +const char *test_doc = "Create a thread with a dead leader\n"; +const char *test_author = "Andrew Vagin <avagin@openvz.org"; static void *thread_func(void *args) { @@ -28,7 +27,6 @@ int main(int argc, char *argv[]) test_init(argc, argv); - ret = pthread_create(&th1, NULL, &thread_func, NULL); if (ret) { diff --git a/test/zdtm/static/pthread_timers.c b/test/zdtm/static/pthread_timers.c index f4b183fc6..ddf41074d 100644 --- a/test/zdtm/static/pthread_timers.c +++ b/test/zdtm/static/pthread_timers.c @@ -8,11 +8,12 @@ #include "zdtmtst.h" -const char *test_doc = "Check SIGEV_THREAD timers"; -const char *test_author = "Andrei Vagin <avagin@gmail.com>"; +const char *test_doc = "Check SIGEV_THREAD timers"; +const char *test_author = "Andrei Vagin <avagin@gmail.com>"; int efd; -static void timer_func(union sigval sigval) { +static void timer_func(union sigval sigval) +{ long long int val = 1; if (write(efd, &val, sizeof(val)) != sizeof(val)) { diff --git a/test/zdtm/static/ptrace_sig.c b/test/zdtm/static/ptrace_sig.c index b70f8f1b0..c77cf1ea0 100644 --- a/test/zdtm/static/ptrace_sig.c +++ b/test/zdtm/static/ptrace_sig.c @@ -7,8 +7,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check ptrace, if the child process's stopped by signal"; -const char *test_author = "Andrey Vagin <avagin@parallels.com>"; +const char *test_doc = "Check ptrace, if the child process's stopped by signal"; +const char *test_author = "Andrey Vagin <avagin@parallels.com>"; typedef void (*sighandler_t)(int); @@ -55,7 +55,7 @@ int child(int fd) return 0; } -int main(int argc, char ** argv) +int main(int argc, char **argv) { int ret, status = 0; pid_t pid, spid, cpid; @@ -82,7 +82,7 @@ int main(int argc, char ** argv) close(child_pipe[1]); test_msg("wait while child initialized"); ret = read(child_pipe[0], &status, sizeof(status)); - if (ret != sizeof(status)) { + if (ret != sizeof(status)) { pr_perror("read from child process failed"); return 1; } @@ -122,7 +122,6 @@ int main(int argc, char ** argv) } if (WIFSTOPPED(status)) { - test_msg("pid=%d stopsig=%d\n", pid, WSTOPSIG(status)); ret = ptrace(PTRACE_GETSIGINFO, pid, 0, &siginfo); @@ -137,7 +136,7 @@ int main(int argc, char ** argv) pr_perror("ptrace failed"); ret = read(child_pipe[0], &status, sizeof(status)); - if (ret != sizeof(status)) { + if (ret != sizeof(status)) { pr_perror("read"); return 1; } diff --git a/test/zdtm/static/pty00.c b/test/zdtm/static/pty00.c index 2c76d9c3e..f6db95ac0 100644 --- a/test/zdtm/static/pty00.c +++ b/test/zdtm/static/pty00.c @@ -9,8 +9,8 @@ #include <termios.h> #include <signal.h> -const char *test_doc = "Check, that pseudoterminals are restored"; -const char *test_author = "Andrey Vagin <avagin@openvz.org>"; +const char *test_doc = "Check, that pseudoterminals are restored"; +const char *test_author = "Andrey Vagin <avagin@openvz.org>"; static unsigned int nr_sighups; @@ -19,7 +19,7 @@ static void signal_handler_sighup(int signum) nr_sighups++; } -int main(int argc, char ** argv) +int main(int argc, char **argv) { int fdm, fds, ret, tty, i; char *slavename; @@ -77,7 +77,7 @@ int main(int argc, char ** argv) close(fds); fds = 100; - for (i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) { /* Check connectivity */ ret = write(fdm, teststr, sizeof(teststr) - 1); if (ret != sizeof(teststr) - 1) { @@ -89,7 +89,7 @@ int main(int argc, char ** argv) test_daemon(); test_waitsig(); - for (i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) { ret = read(fds, buf, sizeof(teststr) - 1); if (ret != sizeof(teststr) - 1) { pr_perror("read(fds) failed"); diff --git a/test/zdtm/static/pty01.c b/test/zdtm/static/pty01.c index cb7fff9af..ba0adac17 100644 --- a/test/zdtm/static/pty01.c +++ b/test/zdtm/static/pty01.c @@ -13,8 +13,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check two pts on ptmx"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; +const char *test_doc = "Check two pts on ptmx"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; static const char teststr[] = "ping\n"; @@ -81,9 +81,8 @@ int main(int argc, char *argv[]) } if (st.st_uid != new_uid || st.st_gid != new_gid) { - fail("UID/GID mismatch (got %d/%d but %d/%d expected)", - (int)st.st_uid, (int)st.st_gid, - (int)new_uid, (int)new_gid); + fail("UID/GID mismatch (got %d/%d but %d/%d expected)", (int)st.st_uid, (int)st.st_gid, (int)new_uid, + (int)new_gid); return 1; } diff --git a/test/zdtm/static/pty02.c b/test/zdtm/static/pty02.c index 041a4e4be..69bac8990 100644 --- a/test/zdtm/static/pty02.c +++ b/test/zdtm/static/pty02.c @@ -9,16 +9,18 @@ #include <termios.h> #include <signal.h> -const char *test_doc = "Check forked master ptmx"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; +const char *test_doc = "Check forked master ptmx"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; static const char teststr[] = "ping\n"; -#define exit_shot(pid, code) \ - do { kill(pid, SIGKILL); exit(code); } while (0) +#define exit_shot(pid, code) \ + do { \ + kill(pid, SIGKILL); \ + exit(code); \ + } while (0) -#define exit_shot_parent(code) \ - exit_shot(getppid(), 1) +#define exit_shot_parent(code) exit_shot(getppid(), 1) int main(int argc, char *argv[]) { diff --git a/test/zdtm/static/pty03.c b/test/zdtm/static/pty03.c index 3c2b36369..59672d697 100644 --- a/test/zdtm/static/pty03.c +++ b/test/zdtm/static/pty03.c @@ -10,8 +10,8 @@ #include <signal.h> #include <sys/ioctl.h> -const char *test_doc = "Check a non-opened control terminal"; -const char *test_author = "Andrey Vagin <avagin@openvz.org>"; +const char *test_doc = "Check a non-opened control terminal"; +const char *test_author = "Andrey Vagin <avagin@openvz.org>"; static const char teststr[] = "ping\n"; diff --git a/test/zdtm/static/pty04.c b/test/zdtm/static/pty04.c index 74d8ab466..406fbee4d 100644 --- a/test/zdtm/static/pty04.c +++ b/test/zdtm/static/pty04.c @@ -10,8 +10,8 @@ #include <signal.h> #include <sys/ioctl.h> -const char *test_doc = "Check two pts with a fake ptmx"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; +const char *test_doc = "Check two pts with a fake ptmx"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; int main(int argc, char *argv[]) { diff --git a/test/zdtm/static/remap_dead_pid.c b/test/zdtm/static/remap_dead_pid.c index 5d4241fc6..56294654b 100644 --- a/test/zdtm/static/remap_dead_pid.c +++ b/test/zdtm/static/remap_dead_pid.c @@ -10,7 +10,7 @@ #include "zdtmtst.h" #ifndef CLONE_NEWNS -#define CLONE_NEWNS 0x00020000 +#define CLONE_NEWNS 0x00020000 #endif #ifdef REMAP_PID_ROOT @@ -19,8 +19,8 @@ const char *proc_path = "/proc/%d"; const char *proc_path = "/proc/%d/mountinfo"; #endif -const char *test_doc = "Check that dead pid's /proc entries are remapped correctly"; -const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; +const char *test_doc = "Check that dead pid's /proc entries are remapped correctly"; +const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; int main(int argc, char **argv) { @@ -37,7 +37,7 @@ int main(int argc, char **argv) if (pid == 0) { /* Child process just sleeps until it is killed. All we need * here is a process to open the mountinfo of. */ - while(1) + while (1) sleep(10); } else { int fd, ret; diff --git a/test/zdtm/static/rlimits00.c b/test/zdtm/static/rlimits00.c index 17ea8daea..395d61719 100644 --- a/test/zdtm/static/rlimits00.c +++ b/test/zdtm/static/rlimits00.c @@ -5,8 +5,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that rlimits are saved"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check that rlimits are saved"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; int main(int argc, char **argv) { @@ -21,8 +21,7 @@ int main(int argc, char **argv) goto out; } - if (rlims[r].rlim_cur > 1 && - rlims[r].rlim_cur != RLIM_INFINITY) { + if (rlims[r].rlim_cur > 1 && rlims[r].rlim_cur != RLIM_INFINITY) { rlims[r].rlim_cur--; if (setrlimit(r, &rlims[r])) { @@ -63,4 +62,3 @@ int main(int argc, char **argv) out: return 0; } - diff --git a/test/zdtm/static/rmdir_open.c b/test/zdtm/static/rmdir_open.c index f671ac48f..93b0246bd 100644 --- a/test/zdtm/static/rmdir_open.c +++ b/test/zdtm/static/rmdir_open.c @@ -8,8 +8,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that opened removed dir works"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check that opened removed dir works"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); diff --git a/test/zdtm/static/rtc.c b/test/zdtm/static/rtc.c index 28a79b1e2..df1f3833a 100644 --- a/test/zdtm/static/rtc.c +++ b/test/zdtm/static/rtc.c @@ -10,7 +10,7 @@ #include "zdtmtst.h" -#define TEST_HZ 4 +#define TEST_HZ 4 #define NR_FAILS 10 int main(int argc, char **argv) @@ -48,7 +48,7 @@ int main(int argc, char **argv) gettimeofday(&end, NULL); end.tv_usec += end.tv_sec * 1000000; delta = end.tv_usec - start.tv_usec; - if (labs(delta - 1000000 / TEST_HZ ) > 100000) { + if (labs(delta - 1000000 / TEST_HZ) > 100000) { pr_perror("delta = %ld", delta); fail--; if (fail == 0) diff --git a/test/zdtm/static/s390x_gs_threads.c b/test/zdtm/static/s390x_gs_threads.c index 6f6e7de22..3944062e3 100644 --- a/test/zdtm/static/s390x_gs_threads.c +++ b/test/zdtm/static/s390x_gs_threads.c @@ -10,13 +10,13 @@ #include "zdtmtst.h" #include "lock.h" -#define NR_THREADS 4 -#define GS_ENABLE 0 -#define GS_SET_BC_CB 2 -#define GS_BROADCAST 4 +#define NR_THREADS 4 +#define GS_ENABLE 0 +#define GS_SET_BC_CB 2 +#define GS_BROADCAST 4 #ifndef __NR_guarded_storage -#define __NR_guarded_storage 378 +#define __NR_guarded_storage 378 #endif const char *test_doc = "Check the guarded storage broadcast"; @@ -60,12 +60,11 @@ static futex_t futex2; * Load guarded-storage */ void load_guarded(unsigned long *mem); -asm( - ".global load_guarded\n" - "load_guarded:\n" - " .insn rxy,0xe3000000004c,%r2,0(%r2)\n" - " br %r14\n" - " .size load_guarded,.-load_guarded\n"); +asm(".global load_guarded\n" + "load_guarded:\n" + " .insn rxy,0xe3000000004c,%r2,0(%r2)\n" + " br %r14\n" + " .size load_guarded,.-load_guarded\n"); /* * Inline assembly to deal with interrupted context to the call of @@ -73,23 +72,22 @@ asm( * function. */ void gs_handler_asm(void); -asm( - ".globl gs_handler_asm\n" - "gs_handler_asm:\n" - " lgr %r14,%r15\n" - " aghi %r15,-320\n" - " stmg %r0,%r14,192(%r15)\n" - " stg %r14,312(%r14)\n" - " la %r2,160(%r15)\n" - " .insn rxy,0xe30000000049,0,160(%r15)\n" - " lg %r14,24(%r2)\n" - " lg %r14,40(%r14)\n" - " la %r14,6(%r14)\n" - " stg %r14,304(%r15)\n" - " brasl %r14,gs_handler\n" - " lmg %r0,%r15,192(%r15)\n" - " br %r14\n" - " .size gs_handler_asm,.-gs_handler_asm\n"); +asm(".globl gs_handler_asm\n" + "gs_handler_asm:\n" + " lgr %r14,%r15\n" + " aghi %r15,-320\n" + " stmg %r0,%r14,192(%r15)\n" + " stg %r14,312(%r14)\n" + " la %r2,160(%r15)\n" + " .insn rxy,0xe30000000049,0,160(%r15)\n" + " lg %r14,24(%r2)\n" + " lg %r14,40(%r14)\n" + " la %r14,6(%r14)\n" + " stg %r14,304(%r15)\n" + " brasl %r14,gs_handler\n" + " lmg %r0,%r15,192(%r15)\n" + " br %r14\n" + " .size gs_handler_asm,.-gs_handler_asm\n"); /* * GS handler called when GS event occurs @@ -123,14 +121,14 @@ static void *thread_run(void *param) } gs_cb->gsd = 0x1234000000UL | 26; gs_cb->gssm = -1UL; - gs_cb->gs_epl_a = (unsigned long) gs_epl; - gs_epl[1] = (unsigned long) gs_handler_asm; + gs_cb->gs_epl_a = (unsigned long)gs_epl; + gs_epl[1] = (unsigned long)gs_handler_asm; /* Set the GS broadcast control block */ syscall(__NR_guarded_storage, GS_SET_BC_CB, gs_cb); futex_dec_and_wake(&futex); /* Wait for all threads to set the GS broadcast control block */ futex_wait_until(&futex, 0); - test_msg("Thread %016lx staring loop\n", syscall(SYS_gettid)); + test_msg("Thread %016lx staring loop\n", syscall(SYS_gettid)); /* * Designate a guarded-storage section until the main task * performs the GS_BROADCAST action and the following load_guarded diff --git a/test/zdtm/static/s390x_mmap_high.c b/test/zdtm/static/s390x_mmap_high.c index c4bd1c83d..6349113b7 100644 --- a/test/zdtm/static/s390x_mmap_high.c +++ b/test/zdtm/static/s390x_mmap_high.c @@ -5,23 +5,22 @@ #include "zdtmtst.h" -#define TASK_SIZE_LEVEL_4 0x20000000000000UL /* 8 PB */ -#define MAP_SIZE 0x1000 -#define VAL 0x77 +#define TASK_SIZE_LEVEL_4 0x20000000000000UL /* 8 PB */ +#define MAP_SIZE 0x1000 +#define VAL 0x77 -const char *test_doc = "Verify that tasks > 4TB can be checkpointed"; -const char *test_author = "Michael Holzheu <holzheu@linux.vnet.ibm.com>"; +const char *test_doc = "Verify that tasks > 4TB can be checkpointed"; +const char *test_author = "Michael Holzheu <holzheu@linux.vnet.ibm.com>"; /* * Map memory at the very end of the 8 PB address space */ int main(int argc, char **argv) { - void *addr = (void *) TASK_SIZE_LEVEL_4 - MAP_SIZE; + void *addr = (void *)TASK_SIZE_LEVEL_4 - MAP_SIZE; char *buf; int i; - test_init(argc, argv); /* @@ -39,8 +38,7 @@ int main(int argc, char **argv) } /* Map memory at the very end of the 8 PB address space */ - buf = mmap(addr, MAP_SIZE, PROT_WRITE | PROT_READ, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + buf = mmap(addr, MAP_SIZE, PROT_WRITE | PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); if (buf == MAP_FAILED) { pr_perror("Could not create mapping"); exit(1); diff --git a/test/zdtm/static/s390x_regs_check.c b/test/zdtm/static/s390x_regs_check.c index 9aaf41951..8d6b47997 100644 --- a/test/zdtm/static/s390x_regs_check.c +++ b/test/zdtm/static/s390x_regs_check.c @@ -48,7 +48,7 @@ const char *test_author = "Michael Holzheu <holzheu@linux.vnet.ibm.com>"; * $ zdtmp.py run --norst --pre 2 -t zdtm/static/s390x_regs_check * $ zdtmp.py run --check-only -t zdtm/static/s390x_regs_check */ -#define NR_THREADS 2 +#define NR_THREADS 2 #define NR_THREADS_ALL (NR_THREADS + 1) static pid_t thread_pids[NR_THREADS_ALL]; @@ -58,222 +58,198 @@ static int pipefd[2]; * Generic structure to define a register set and test data */ struct reg_set { - const char *name; /* Name of regset */ - int nr; /* Number of regset */ - void *data; /* Test data */ - int len; /* Number of bytes of test data */ - bool optional; /* Not all kernels/machines have this reg set */ - bool available; /* Current kernel/machine has this reg set */ + const char *name; /* Name of regset */ + int nr; /* Number of regset */ + void *data; /* Test data */ + int len; /* Number of bytes of test data */ + bool optional; /* Not all kernels/machines have this reg set */ + bool available; /* Current kernel/machine has this reg set */ }; /* * s390 floating point registers */ struct prfpreg { - uint32_t fpc; - uint64_t fprs[16]; + uint32_t fpc; + uint64_t fprs[16]; }; -struct prfpreg prfpreg_data = { - .fpc = 0, - .fprs = { - 0x0000000000000000, - 0x1111111111111110, - 0x2222222222222220, - 0x3333333333333330, - 0x4444444444444440, - 0x5555555555555550, - 0x6666666666666660, - 0x7777777777777770, - 0x8888888888888880, - 0x9999999999999990, - 0xaaaaaaaaaaaaaaa0, - 0xbbbbbbbbbbbbbbb0, - 0xccccccccccccccc0, - 0xddddddddddddddd0, - 0xeeeeeeeeeeeeeee0, - 0xfffffffffffffff0, - } -}; +struct prfpreg prfpreg_data = { .fpc = 0, + .fprs = { + 0x0000000000000000, + 0x1111111111111110, + 0x2222222222222220, + 0x3333333333333330, + 0x4444444444444440, + 0x5555555555555550, + 0x6666666666666660, + 0x7777777777777770, + 0x8888888888888880, + 0x9999999999999990, + 0xaaaaaaaaaaaaaaa0, + 0xbbbbbbbbbbbbbbb0, + 0xccccccccccccccc0, + 0xddddddddddddddd0, + 0xeeeeeeeeeeeeeee0, + 0xfffffffffffffff0, + } }; struct reg_set reg_set_prfpreg = { - .name = "PRFPREG", - .nr = NT_PRFPREG, - .data = &prfpreg_data, - .len = sizeof(prfpreg_data), - .optional = false, + .name = "PRFPREG", + .nr = NT_PRFPREG, + .data = &prfpreg_data, + .len = sizeof(prfpreg_data), + .optional = false, }; /* * s390 vector VXRS_LOW registers */ -#define NT_S390_VXRS_LOW 0x309 +#define NT_S390_VXRS_LOW 0x309 struct vxrs_low { - uint64_t regs[16]; + uint64_t regs[16]; }; -struct vxrs_low vxrs_low_data = { - .regs = { - 0x0000000000000001, - 0x1111111111111111, - 0x2222222222222221, - 0x3333333333333331, - 0x4444444444444441, - 0x5555555555555551, - 0x6666666666666661, - 0x7777777777777771, - 0x8888888888888881, - 0x9999999999999991, - 0xaaaaaaaaaaaaaaa1, - 0xbbbbbbbbbbbbbbb1, - 0xccccccccccccccc1, - 0xddddddddddddddd1, - 0xeeeeeeeeeeeeeee1, - 0xfffffffffffffff1, - } -}; +struct vxrs_low vxrs_low_data = { .regs = { + 0x0000000000000001, + 0x1111111111111111, + 0x2222222222222221, + 0x3333333333333331, + 0x4444444444444441, + 0x5555555555555551, + 0x6666666666666661, + 0x7777777777777771, + 0x8888888888888881, + 0x9999999999999991, + 0xaaaaaaaaaaaaaaa1, + 0xbbbbbbbbbbbbbbb1, + 0xccccccccccccccc1, + 0xddddddddddddddd1, + 0xeeeeeeeeeeeeeee1, + 0xfffffffffffffff1, + } }; struct reg_set reg_set_vxrs_low = { - .name = "VXRS_LOW", - .nr = NT_S390_VXRS_LOW, - .data = &vxrs_low_data, - .len = sizeof(vxrs_low_data), - .optional = true, + .name = "VXRS_LOW", + .nr = NT_S390_VXRS_LOW, + .data = &vxrs_low_data, + .len = sizeof(vxrs_low_data), + .optional = true, }; /* * s390 vector VXRS_HIGH registers */ -#define NT_S390_VXRS_HIGH 0x30a +#define NT_S390_VXRS_HIGH 0x30a struct vxrs_high { - uint64_t regs[32]; + uint64_t regs[32]; }; -struct vxrs_high vxrs_high_data = { - .regs = { - 0x0000000000000002, 0x0000000000000002, - 0x1111111111111112, 0x1111111111111112, - 0x2222222222222222, 0x2222222222222222, - 0x3333333333333332, 0x3333333333333332, - 0x4444444444444442, 0x4444444444444442, - 0x5555555555555552, 0x5555555555555552, - 0x6666666666666662, 0x6666666666666662, - 0x7777777777777772, 0x7777777777777772, - 0x8888888888888882, 0x8888888888888882, - 0x9999999999999992, 0x9999999999999992, - 0xaaaaaaaaaaaaaaa2, 0xaaaaaaaaaaaaaaa2, - 0xbbbbbbbbbbbbbbb2, 0xbbbbbbbbbbbbbbb2, - 0xccccccccccccccc2, 0xccccccccccccccc2, - 0xddddddddddddddd2, 0xddddddddddddddd2, - 0xeeeeeeeeeeeeeee2, 0xeeeeeeeeeeeeeee2, - 0xfffffffffffffff2, 0xfffffffffffffff2, - } -}; +struct vxrs_high vxrs_high_data = { .regs = { + 0x0000000000000002, 0x0000000000000002, 0x1111111111111112, + 0x1111111111111112, 0x2222222222222222, 0x2222222222222222, + 0x3333333333333332, 0x3333333333333332, 0x4444444444444442, + 0x4444444444444442, 0x5555555555555552, 0x5555555555555552, + 0x6666666666666662, 0x6666666666666662, 0x7777777777777772, + 0x7777777777777772, 0x8888888888888882, 0x8888888888888882, + 0x9999999999999992, 0x9999999999999992, 0xaaaaaaaaaaaaaaa2, + 0xaaaaaaaaaaaaaaa2, 0xbbbbbbbbbbbbbbb2, 0xbbbbbbbbbbbbbbb2, + 0xccccccccccccccc2, 0xccccccccccccccc2, 0xddddddddddddddd2, + 0xddddddddddddddd2, 0xeeeeeeeeeeeeeee2, 0xeeeeeeeeeeeeeee2, + 0xfffffffffffffff2, 0xfffffffffffffff2, + } }; struct reg_set reg_set_vxrs_high = { - .name = "VXRS_HIGH", - .nr = NT_S390_VXRS_HIGH, - .data = &vxrs_high_data, - .len = sizeof(vxrs_high_data), - .optional = true, + .name = "VXRS_HIGH", + .nr = NT_S390_VXRS_HIGH, + .data = &vxrs_high_data, + .len = sizeof(vxrs_high_data), + .optional = true, }; /* * s390 guarded-storage registers */ -#define NT_S390_GS_CB 0x30b -#define NT_S390_GS_BC 0x30c +#define NT_S390_GS_CB 0x30b +#define NT_S390_GS_BC 0x30c struct gs_cb { uint64_t regs[4]; }; -struct gs_cb gs_cb_data = { - .regs = { - 0x0000000000000000, - 0x000000123400001a, - 0x5555555555555555, - 0x000000014b58a010, - } -}; +struct gs_cb gs_cb_data = { .regs = { + 0x0000000000000000, + 0x000000123400001a, + 0x5555555555555555, + 0x000000014b58a010, + } }; struct reg_set reg_set_gs_cb = { - .name = "GS_CB", - .nr = NT_S390_GS_CB, - .data = &gs_cb_data, - .len = sizeof(gs_cb_data), - .optional = true, + .name = "GS_CB", + .nr = NT_S390_GS_CB, + .data = &gs_cb_data, + .len = sizeof(gs_cb_data), + .optional = true, }; -struct gs_cb gs_bc_data = { - .regs = { - 0x0000000000000000, - 0x000000123400001a, - 0xffffffffffffffff, - 0x0000000aaaaaaaaa, - } -}; +struct gs_cb gs_bc_data = { .regs = { + 0x0000000000000000, + 0x000000123400001a, + 0xffffffffffffffff, + 0x0000000aaaaaaaaa, + } }; struct reg_set reg_set_gs_bc = { - .name = "GS_BC_CB", - .nr = NT_S390_GS_BC, - .data = &gs_bc_data, - .len = sizeof(gs_bc_data), - .optional = true, + .name = "GS_BC_CB", + .nr = NT_S390_GS_BC, + .data = &gs_bc_data, + .len = sizeof(gs_bc_data), + .optional = true, }; /* * s390 runtime-instrumentation control block */ -#define NT_S390_RI_CB 0x30d +#define NT_S390_RI_CB 0x30d struct ri_cb { uint64_t regs[8]; }; -struct ri_cb ri_cb_data = { - .regs = { - 0x000002aa13aae000, - 0x000002aa13aad000, - 0x000002aa13aadfff, - 0xe0a1000400000000, - 0x0000000000000000, - 0x0000000000004e20, - 0x0000000000003479, - 0x0000000000000000, - } -}; +struct ri_cb ri_cb_data = { .regs = { + 0x000002aa13aae000, + 0x000002aa13aad000, + 0x000002aa13aadfff, + 0xe0a1000400000000, + 0x0000000000000000, + 0x0000000000004e20, + 0x0000000000003479, + 0x0000000000000000, + } }; struct reg_set reg_set_ri_cb = { - .name = "RI_CB", - .nr = NT_S390_RI_CB, - .data = &ri_cb_data, - .len = sizeof(ri_cb_data), - .optional = true, + .name = "RI_CB", + .nr = NT_S390_RI_CB, + .data = &ri_cb_data, + .len = sizeof(ri_cb_data), + .optional = true, }; /* * Vector with all regsets */ struct reg_set *reg_set_vec[] = { - ®_set_prfpreg, - ®_set_vxrs_low, - ®_set_vxrs_high, - ®_set_gs_cb, - ®_set_gs_bc, - ®_set_ri_cb, - NULL, + ®_set_prfpreg, ®_set_vxrs_low, ®_set_vxrs_high, ®_set_gs_cb, ®_set_gs_bc, ®_set_ri_cb, NULL, }; /* * Print hexdump for buffer with variable group parameter */ -void util_hexdump_grp(const char *tag, const void *data, int grp, - int count, int indent) +void util_hexdump_grp(const char *tag, const void *data, int grp, int count, int indent) { char str[1024], *ptr = str; const char *buf = data; @@ -325,19 +301,16 @@ static int set_regset(pid_t pid, struct reg_set *reg_set) switch (errno) { case EOPNOTSUPP: case ENODEV: - test_msg(" REGSET: %12s -> not supported by machine\n", - reg_set->name); + test_msg(" REGSET: %12s -> not supported by machine\n", reg_set->name); return 0; case EINVAL: - test_msg(" REGSET: %12s -> not supported by kernel\n", - reg_set->name); + test_msg(" REGSET: %12s -> not supported by kernel\n", reg_set->name); return 0; default: break; } } - pr_perror("PTRACE_SETREGSET for %s failed for pid %d", - reg_set->name, pid); + pr_perror("PTRACE_SETREGSET for %s failed for pid %d", reg_set->name, pid); return -1; } @@ -373,8 +346,7 @@ static int check_regset(pid_t pid, struct reg_set *reg_set) iov.iov_len = reg_set->len; if (ptrace(PTRACE_GETREGSET, pid, reg_set->nr, iov) != 0) { - pr_perror("PTRACE_SETREGSET for %s failed for pid %d", - reg_set->name, pid); + pr_perror("PTRACE_SETREGSET for %s failed for pid %d", reg_set->name, pid); free(data); return -1; } @@ -423,14 +395,15 @@ static inline void send_tid_and_loop(int fd) { int tid = syscall(__NR_gettid); - asm volatile( - "lgr 2,%0\n" /* Arg 1: fd */ + asm volatile("lgr 2,%0\n" /* Arg 1: fd */ "la 3,%1\n" /* Arg 2: &tid */ - "lghi 4,4\n" /* Arg 3: sizeof(int) */ - "svc 4\n" /* __NR_write SVC: */ + "lghi 4,4\n" /* Arg 3: sizeof(int) */ + "svc 4\n" /* __NR_write SVC: */ /* After SVC no more registers are changed */ "0: j 0b\n" /* Loop here */ - : : "d" (fd), "Q" (tid) : "2", "3", "4"); + : + : "d"(fd), "Q"(tid) + : "2", "3", "4"); } /* @@ -501,8 +474,7 @@ int main(int argc, char *argv[]) test_init(argc, argv); - test_msg("------------- START 1 PROCESS + %d THREADS ---------------\n", - NR_THREADS); + test_msg("------------- START 1 PROCESS + %d THREADS ---------------\n", NR_THREADS); if (pipe(pipefd) == -1) { perror("pipe failed"); exit(EXIT_FAILURE); diff --git a/test/zdtm/static/s390x_runtime_instr.c b/test/zdtm/static/s390x_runtime_instr.c index ff692d7c6..e6c55d3ff 100644 --- a/test/zdtm/static/s390x_runtime_instr.c +++ b/test/zdtm/static/s390x_runtime_instr.c @@ -19,61 +19,61 @@ #include "zdtmtst.h" #ifndef __NR_s390_runtime_instr -#define __NR_s390_runtime_instr 342 +#define __NR_s390_runtime_instr 342 #endif -#define NT_S390_RI_CB 0x30d +#define NT_S390_RI_CB 0x30d -#define BUF_SIZE (1024*1024) +#define BUF_SIZE (1024 * 1024) -const char *test_doc = "Check runtime-instrumentation"; +const char *test_doc = "Check runtime-instrumentation"; /* Original test provided by Martin Schwidefsky <schwidefsky@de.ibm.com> */ -const char *test_author = "Alice Frosi <alice@linux.vnet.ibm.com>"; +const char *test_author = "Alice Frosi <alice@linux.vnet.ibm.com>"; struct runtime_instr_cb { unsigned long rca; unsigned long roa; unsigned long rla; - unsigned int v : 1; - unsigned int s : 1; - unsigned int k : 1; - unsigned int h : 1; - unsigned int a : 1; - unsigned int reserved1 : 3; - unsigned int ps : 1; - unsigned int qs : 1; - unsigned int pc : 1; - unsigned int qc : 1; - unsigned int reserved2 : 1; - unsigned int g : 1; - unsigned int u : 1; - unsigned int l : 1; - unsigned int key : 4; - unsigned int reserved3 : 8; - unsigned int t : 1; - unsigned int rgs : 3; - - unsigned int m : 4; - unsigned int n : 1; - unsigned int mae : 1; - unsigned int reserved4 : 2; - unsigned int c : 1; - unsigned int r : 1; - unsigned int b : 1; - unsigned int j : 1; - unsigned int e : 1; - unsigned int x : 1; - unsigned int reserved5 : 2; - unsigned int bpxn : 1; - unsigned int bpxt : 1; - unsigned int bpti : 1; - unsigned int bpni : 1; - unsigned int reserved6 : 2; - - unsigned int d : 1; - unsigned int f : 1; - unsigned int ic : 4; - unsigned int dc : 4; + unsigned int v : 1; + unsigned int s : 1; + unsigned int k : 1; + unsigned int h : 1; + unsigned int a : 1; + unsigned int reserved1 : 3; + unsigned int ps : 1; + unsigned int qs : 1; + unsigned int pc : 1; + unsigned int qc : 1; + unsigned int reserved2 : 1; + unsigned int g : 1; + unsigned int u : 1; + unsigned int l : 1; + unsigned int key : 4; + unsigned int reserved3 : 8; + unsigned int t : 1; + unsigned int rgs : 3; + + unsigned int m : 4; + unsigned int n : 1; + unsigned int mae : 1; + unsigned int reserved4 : 2; + unsigned int c : 1; + unsigned int r : 1; + unsigned int b : 1; + unsigned int j : 1; + unsigned int e : 1; + unsigned int x : 1; + unsigned int reserved5 : 2; + unsigned int bpxn : 1; + unsigned int bpxt : 1; + unsigned int bpti : 1; + unsigned int bpni : 1; + unsigned int reserved6 : 2; + + unsigned int d : 1; + unsigned int f : 1; + unsigned int ic : 4; + unsigned int dc : 4; unsigned long reserved7; unsigned long sf; @@ -88,8 +88,8 @@ static inline unsigned long extract_psw(void) { unsigned int reg1, reg2; - asm volatile("epsw %0,%1" : "=d" (reg1), "=a" (reg2)); - return (((unsigned long) reg1) << 32) | ((unsigned long) reg2); + asm volatile("epsw %0,%1" : "=d"(reg1), "=a"(reg2)); + return (((unsigned long)reg1) << 32) | ((unsigned long)reg2); } /* @@ -97,7 +97,7 @@ static inline unsigned long extract_psw(void) */ static inline void rion(void) { - asm volatile (".word 0xaa01, 0x0000"); + asm volatile(".word 0xaa01, 0x0000"); } /* @@ -105,7 +105,7 @@ static inline void rion(void) */ static inline void rioff(void) { - asm volatile (".word 0xaa03, 0x0000"); + asm volatile(".word 0xaa03, 0x0000"); } /* @@ -113,7 +113,7 @@ static inline void rioff(void) */ static inline void mric(struct runtime_instr_cb *cb) { - asm volatile(".insn rsy,0xeb0000000062,0,0,%0" : : "Q" (*cb)); + asm volatile(".insn rsy,0xeb0000000062,0,0,%0" : : "Q"(*cb)); } /* @@ -121,7 +121,7 @@ static inline void mric(struct runtime_instr_cb *cb) */ static inline void stric(struct runtime_instr_cb *cb) { - asm volatile(".insn rsy,0xeb0000000061,0,0,%0" : "=Q" (*cb) : : "cc"); + asm volatile(".insn rsy,0xeb0000000061,0,0,%0" : "=Q"(*cb) : : "cc"); } /* @@ -130,8 +130,8 @@ static inline void stric(struct runtime_instr_cb *cb) int main(int argc, char **argv) { struct runtime_instr_cb ricb, ricb_check; - unsigned long *ricb_check_ptr = (unsigned long *) &ricb_check; - unsigned long *ricb_ptr = (unsigned long *) &ricb; + unsigned long *ricb_check_ptr = (unsigned long *)&ricb_check; + unsigned long *ricb_ptr = (unsigned long *)&ricb; unsigned long psw_mask; void *buf; int i; @@ -155,8 +155,8 @@ int main(int argc, char **argv) return -1; } /* Set buffer for RI */ - ricb.rca = ricb.roa = (unsigned long) buf; - ricb.rla = (unsigned long) buf + BUF_SIZE; + ricb.rca = ricb.roa = (unsigned long)buf; + ricb.rla = (unsigned long)buf + BUF_SIZE; mric(&ricb); /* Enable RI - afterwards the PSW will have RI bit set */ rion(); @@ -204,8 +204,7 @@ int main(int argc, char **argv) /* Skip sf field because its value may change */ if (i == 6) continue; - fail("%d:Got %016lx expected %016lx", - i, ricb_ptr[i], ricb_check_ptr[i]); + fail("%d:Got %016lx expected %016lx", i, ricb_ptr[i], ricb_check_ptr[i]); return -1; } diff --git a/test/zdtm/static/sched_policy00.c b/test/zdtm/static/sched_policy00.c index 7312abd6b..794c11af2 100644 --- a/test/zdtm/static/sched_policy00.c +++ b/test/zdtm/static/sched_policy00.c @@ -10,8 +10,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check sched policy to be preserved"; -const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; +const char *test_doc = "Check sched policy to be preserved"; +const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; static const int parm = 3; @@ -23,7 +23,7 @@ static int do_nothing(void) return -1; } -int main(int argc, char ** argv) +int main(int argc, char **argv) { int pid, ret, err = 0; struct sched_param p; @@ -82,7 +82,6 @@ int main(int argc, char ** argv) fprintf(file, "%d\n", old_rt_runtime_us); fclose(file); } - } return err; } diff --git a/test/zdtm/static/sched_prio00.c b/test/zdtm/static/sched_prio00.c index ea4a2ee13..4bc878786 100644 --- a/test/zdtm/static/sched_prio00.c +++ b/test/zdtm/static/sched_prio00.c @@ -11,10 +11,10 @@ #include "zdtmtst.h" -const char *test_doc = "Check sched prios to be preserved"; -const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; +const char *test_doc = "Check sched prios to be preserved"; +const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; -#define NRTASKS 3 +#define NRTASKS 3 static int do_nothing(void) { @@ -32,7 +32,7 @@ static void kill_all(int *pid, int n) kill(pid[i], SIGKILL); } -int main(int argc, char ** argv) +int main(int argc, char **argv) { int pid[NRTASKS], i, parm[NRTASKS], ret; diff --git a/test/zdtm/static/scm00.c b/test/zdtm/static/scm00.c index de626d9c9..d66975582 100644 --- a/test/zdtm/static/scm00.c +++ b/test/zdtm/static/scm00.c @@ -6,8 +6,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that SCM_RIGHTS are preserved"; -const char *test_author = "Pavel Emelyanov <xemul@virtuozzo.com>"; +const char *test_doc = "Check that SCM_RIGHTS are preserved"; +const char *test_author = "Pavel Emelyanov <xemul@virtuozzo.com>"; static int send_fd(int via, int fd) { diff --git a/test/zdtm/static/scm03.c b/test/zdtm/static/scm03.c index cf6049781..a40fc0101 100644 --- a/test/zdtm/static/scm03.c +++ b/test/zdtm/static/scm03.c @@ -6,8 +6,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that SCM_RIGHTS are preserved"; -const char *test_author = "Pavel Emelyanov <xemul@virtuozzo.com>"; +const char *test_doc = "Check that SCM_RIGHTS are preserved"; +const char *test_author = "Pavel Emelyanov <xemul@virtuozzo.com>"; static int send_fd(int via, int fd1, int fd2) { diff --git a/test/zdtm/static/scm05.c b/test/zdtm/static/scm05.c index c17bddda3..ebafc93e7 100644 --- a/test/zdtm/static/scm05.c +++ b/test/zdtm/static/scm05.c @@ -7,8 +7,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that SCM_RIGHTS are preserved"; -const char *test_author = "Kirill Tkhai <ktkhai@virtuozzo.com>"; +const char *test_doc = "Check that SCM_RIGHTS are preserved"; +const char *test_author = "Kirill Tkhai <ktkhai@virtuozzo.com>"; static int send_fd(int via, int fd) { @@ -82,7 +82,7 @@ int main(int argc, char **argv) { struct epoll_event event = { .events = EPOLLIN, - }; + }; int sk[2], ep, ret; test_init(argc, argv); diff --git a/test/zdtm/static/scm06.c b/test/zdtm/static/scm06.c index 6c9a78b4d..2d62f6695 100644 --- a/test/zdtm/static/scm06.c +++ b/test/zdtm/static/scm06.c @@ -11,8 +11,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check a send of looped unix sockets"; -const char *test_author = "Kirill Tkhai <ktkhai@virtuozzo.com>"; +const char *test_doc = "Check a send of looped unix sockets"; +const char *test_author = "Kirill Tkhai <ktkhai@virtuozzo.com>"; static int send_fd(int via, int fd) { @@ -99,8 +99,7 @@ int main(int argc, char **argv) for (i = 0; i < 2; i++) { addr.sun_path[0] = '\0'; addr.sun_path[1] = i; - if (bind(ska[i], (struct sockaddr *)&addr, - sizeof(addr.sun_family) + 2)) { + if (bind(ska[i], (struct sockaddr *)&addr, sizeof(addr.sun_family) + 2)) { fail("Can't bind"); exit(1); } diff --git a/test/zdtm/static/seccomp_filter.c b/test/zdtm/static/seccomp_filter.c index 501a4941c..757591e24 100644 --- a/test/zdtm/static/seccomp_filter.c +++ b/test/zdtm/static/seccomp_filter.c @@ -18,8 +18,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that SECCOMP_MODE_FILTER is restored"; -const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; +const char *test_doc = "Check that SECCOMP_MODE_FILTER is restored"; +const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; #ifdef __NR_seccomp @@ -52,14 +52,14 @@ int get_seccomp_mode(pid_t pid) int filter_syscall(int syscall_nr) { struct sock_filter filter[] = { - BPF_STMT(BPF_LD+BPF_W+BPF_ABS, offsetof(struct seccomp_data, nr)), - BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, syscall_nr, 0, 1), - BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_KILL), - BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW), + BPF_STMT(BPF_LD + BPF_W + BPF_ABS, offsetof(struct seccomp_data, nr)), + BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, syscall_nr, 0, 1), + BPF_STMT(BPF_RET + BPF_K, SECCOMP_RET_KILL), + BPF_STMT(BPF_RET + BPF_K, SECCOMP_RET_ALLOW), }; struct sock_fprog bpf_prog = { - .len = (unsigned short)(sizeof(filter)/sizeof(filter[0])), + .len = (unsigned short)(sizeof(filter) / sizeof(filter[0])), .filter = filter, }; @@ -71,7 +71,7 @@ int filter_syscall(int syscall_nr) return 0; } -int main(int argc, char ** argv) +int main(int argc, char **argv) { pid_t pid; int mode, status; @@ -92,7 +92,6 @@ int main(int argc, char ** argv) } if (pid == 0) { - sk = sk_pair[1]; close(sk_pair[0]); diff --git a/test/zdtm/static/seccomp_filter_inheritance.c b/test/zdtm/static/seccomp_filter_inheritance.c index 3129185ea..7a86cd85e 100644 --- a/test/zdtm/static/seccomp_filter_inheritance.c +++ b/test/zdtm/static/seccomp_filter_inheritance.c @@ -11,15 +11,15 @@ #include <sys/syscall.h> #ifdef __NR_seccomp -# include <linux/seccomp.h> -# include <linux/filter.h> -# include <linux/limits.h> +#include <linux/seccomp.h> +#include <linux/filter.h> +#include <linux/limits.h> #endif #include "zdtmtst.h" -const char *test_doc = "Check that SECCOMP_MODE_FILTER is restored"; -const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; +const char *test_doc = "Check that SECCOMP_MODE_FILTER is restored"; +const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; #ifdef __NR_seccomp @@ -52,14 +52,14 @@ int get_seccomp_mode(pid_t pid) int filter_syscall(int syscall_nr) { struct sock_filter filter[] = { - BPF_STMT(BPF_LD+BPF_W+BPF_ABS, offsetof(struct seccomp_data, nr)), - BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, syscall_nr, 0, 1), - BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_KILL), - BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW), + BPF_STMT(BPF_LD + BPF_W + BPF_ABS, offsetof(struct seccomp_data, nr)), + BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, syscall_nr, 0, 1), + BPF_STMT(BPF_RET + BPF_K, SECCOMP_RET_KILL), + BPF_STMT(BPF_RET + BPF_K, SECCOMP_RET_ALLOW), }; struct sock_fprog bpf_prog = { - .len = (unsigned short)(sizeof(filter)/sizeof(filter[0])), + .len = (unsigned short)(sizeof(filter) / sizeof(filter[0])), .filter = filter, }; @@ -71,7 +71,7 @@ int filter_syscall(int syscall_nr) return 0; } -int main(int argc, char ** argv) +int main(int argc, char **argv) { pid_t pid; int mode, status; @@ -92,7 +92,6 @@ int main(int argc, char ** argv) } if (pid == 0) { - pid_t pid2; sk = sk_pair[1]; @@ -112,7 +111,6 @@ int main(int argc, char ** argv) _exit(1); if (!pid2) { - if (write(sk, &c, 1) != 1) { pr_perror("write"); _exit(1); @@ -181,7 +179,6 @@ err: return 1; } - #else /* __NR_seccomp */ #define TEST_SKIP_REASON "incompatible kernel (no seccomp)" diff --git a/test/zdtm/static/seccomp_filter_threads.c b/test/zdtm/static/seccomp_filter_threads.c index 8d5b77d16..6c84ada1f 100644 --- a/test/zdtm/static/seccomp_filter_threads.c +++ b/test/zdtm/static/seccomp_filter_threads.c @@ -12,10 +12,10 @@ #include <sys/mman.h> #ifdef __NR_seccomp -# include <linux/seccomp.h> -# include <linux/filter.h> -# include <linux/limits.h> -# include <pthread.h> +#include <linux/seccomp.h> +#include <linux/filter.h> +#include <linux/limits.h> +#include <pthread.h> #endif #include "zdtmtst.h" @@ -29,12 +29,15 @@ #define SECCOMP_FILTER_FLAG_TSYNC 1 #endif -const char *test_doc = "Check threads to carry different seccomps"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; +const char *test_doc = "Check threads to carry different seccomps"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; #ifdef __NR_seccomp -static long sys_gettid(void) { return syscall(__NR_gettid); } +static long sys_gettid(void) +{ + return syscall(__NR_gettid); +} static futex_t *wait_rdy; static futex_t *wait_run; @@ -70,14 +73,14 @@ int get_seccomp_mode(pid_t pid) int filter_syscall(int syscall_nr, unsigned int flags) { struct sock_filter filter[] = { - BPF_STMT(BPF_LD+BPF_W+BPF_ABS, offsetof(struct seccomp_data, nr)), - BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, syscall_nr, 0, 1), - BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ERRNO | (SECCOMP_RET_DATA & magic)), - BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW), + BPF_STMT(BPF_LD + BPF_W + BPF_ABS, offsetof(struct seccomp_data, nr)), + BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, syscall_nr, 0, 1), + BPF_STMT(BPF_RET + BPF_K, SECCOMP_RET_ERRNO | (SECCOMP_RET_DATA & magic)), + BPF_STMT(BPF_RET + BPF_K, SECCOMP_RET_ALLOW), }; struct sock_fprog bpf_prog = { - .len = (unsigned short)(sizeof(filter)/sizeof(filter[0])), + .len = (unsigned short)(sizeof(filter) / sizeof(filter[0])), .filter = filter, }; @@ -89,21 +92,28 @@ int filter_syscall(int syscall_nr, unsigned int flags) return 0; } -int tigger_ptrace(void) { return ptrace(PTRACE_TRACEME); } -int trigger_prctl(void) { return prctl(PR_SET_PDEATHSIG, 9, 0, 0, 0); } -int trigger_mincore(void) { return mincore(NULL, 0, NULL); } - -#define gen_param(__syscall_nr, __trigger) \ -{ \ - .syscall_name = # __syscall_nr, \ - .syscall_nr = __syscall_nr, \ - .trigger = __trigger, \ +int tigger_ptrace(void) +{ + return ptrace(PTRACE_TRACEME); +} +int trigger_prctl(void) +{ + return prctl(PR_SET_PDEATHSIG, 9, 0, 0, 0); +} +int trigger_mincore(void) +{ + return mincore(NULL, 0, NULL); } +#define gen_param(__syscall_nr, __trigger) \ + { \ + .syscall_name = #__syscall_nr, .syscall_nr = __syscall_nr, .trigger = __trigger, \ + } + struct { - char *syscall_name; - unsigned int syscall_nr; - int (*trigger)(void); + char *syscall_name; + unsigned int syscall_nr; + int (*trigger)(void); } pthread_seccomp_params[] = { gen_param(__NR_ptrace, tigger_ptrace), gen_param(__NR_prctl, trigger_prctl), @@ -115,21 +125,17 @@ struct { void *thread_main(void *arg) { int ret; - size_t nr = (long) arg; + size_t nr = (long)arg; if (filter_syscall(pthread_seccomp_params[nr].syscall_nr, 0) < 0) pthread_exit((void *)1); - test_msg("%s filtered inside a sole thread %lu\n", - pthread_seccomp_params[nr].syscall_name, - sys_gettid()); + test_msg("%s filtered inside a sole thread %lu\n", pthread_seccomp_params[nr].syscall_name, sys_gettid()); futex_inc_and_wake(wait_rdy); futex_wait_while_lt(wait_run, 1); - test_msg("Triggering %zu %s thread %lu\n", - nr, pthread_seccomp_params[nr].syscall_name, - sys_gettid()); + test_msg("Triggering %zu %s thread %lu\n", nr, pthread_seccomp_params[nr].syscall_name, sys_gettid()); ret = pthread_seccomp_params[nr].trigger(); if (ret == -1 && errno == magic) @@ -139,7 +145,7 @@ void *thread_main(void *arg) return (void *)1; } -int main(int argc, char ** argv) +int main(int argc, char **argv) { int ret, mode, status; size_t i; @@ -147,10 +153,8 @@ int main(int argc, char ** argv) test_init(argc, argv); - wait_rdy = mmap(NULL, sizeof(*wait_rdy), PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_SHARED, -1, 0); - wait_run = mmap(NULL, sizeof(*wait_rdy), PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_SHARED, -1, 0); + wait_rdy = mmap(NULL, sizeof(*wait_rdy), PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED, -1, 0); + wait_run = mmap(NULL, sizeof(*wait_rdy), PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED, -1, 0); if (wait_rdy == MAP_FAILED || wait_run == MAP_FAILED) { pr_perror("mmap failed"); @@ -169,7 +173,6 @@ int main(int argc, char ** argv) return -1; } - if (pid == 0) { pthread_t thread[ARRAY_SIZE(pthread_seccomp_params)]; void *ret; diff --git a/test/zdtm/static/seccomp_filter_tsync.c b/test/zdtm/static/seccomp_filter_tsync.c index 739ea96f7..41be83426 100644 --- a/test/zdtm/static/seccomp_filter_tsync.c +++ b/test/zdtm/static/seccomp_filter_tsync.c @@ -11,10 +11,10 @@ #include <sys/syscall.h> #ifdef __NR_seccomp -# include <linux/seccomp.h> -# include <linux/filter.h> -# include <linux/limits.h> -# include <pthread.h> +#include <linux/seccomp.h> +#include <linux/filter.h> +#include <linux/limits.h> +#include <pthread.h> #endif #include "zdtmtst.h" @@ -27,8 +27,8 @@ #define SECCOMP_FILTER_FLAG_TSYNC 1 #endif -const char *test_doc = "Check that SECCOMP_FILTER_FLAG_TSYNC works correctly after restore"; -const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; +const char *test_doc = "Check that SECCOMP_FILTER_FLAG_TSYNC works correctly after restore"; +const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; #ifdef __NR_seccomp @@ -65,14 +65,14 @@ int get_seccomp_mode(pid_t pid) int filter_syscall(int syscall_nr, unsigned int flags) { struct sock_filter filter[] = { - BPF_STMT(BPF_LD+BPF_W+BPF_ABS, offsetof(struct seccomp_data, nr)), - BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, syscall_nr, 0, 1), - BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ERRNO | (SECCOMP_RET_DATA & magic)), - BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW), + BPF_STMT(BPF_LD + BPF_W + BPF_ABS, offsetof(struct seccomp_data, nr)), + BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, syscall_nr, 0, 1), + BPF_STMT(BPF_RET + BPF_K, SECCOMP_RET_ERRNO | (SECCOMP_RET_DATA & magic)), + BPF_STMT(BPF_RET + BPF_K, SECCOMP_RET_ALLOW), }; struct sock_fprog bpf_prog = { - .len = (unsigned short)(sizeof(filter)/sizeof(filter[0])), + .len = (unsigned short)(sizeof(filter) / sizeof(filter[0])), .filter = filter, }; @@ -101,7 +101,7 @@ void *wait_and_getpid(void *arg) return ((void *)1); } -int main(int argc, char ** argv) +int main(int argc, char **argv) { pid_t pid; int mode, status; diff --git a/test/zdtm/static/seccomp_strict.c b/test/zdtm/static/seccomp_strict.c index 9042924b2..74bb6e9b8 100644 --- a/test/zdtm/static/seccomp_strict.c +++ b/test/zdtm/static/seccomp_strict.c @@ -9,14 +9,14 @@ #include <sys/syscall.h> #ifdef __NR_seccomp -# include <linux/seccomp.h> -# include <linux/limits.h> +#include <linux/seccomp.h> +#include <linux/limits.h> #endif #include "zdtmtst.h" -const char *test_doc = "Check that SECCOMP_MODE_STRICT is restored"; -const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; +const char *test_doc = "Check that SECCOMP_MODE_STRICT is restored"; +const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; #ifdef __NR_seccomp @@ -46,7 +46,7 @@ int get_seccomp_mode(pid_t pid) return -1; } -int main(int argc, char ** argv) +int main(int argc, char **argv) { pid_t pid; int mode, status; diff --git a/test/zdtm/static/selfexe00.c b/test/zdtm/static/selfexe00.c index bc6117248..4839ea18b 100644 --- a/test/zdtm/static/selfexe00.c +++ b/test/zdtm/static/selfexe00.c @@ -16,10 +16,10 @@ #include "zdtmtst.h" -#define gettid() pthread_self() +#define gettid() pthread_self() -const char *test_doc = "Check if /proc/self/exe points to same location after restore\n"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org"; +const char *test_doc = "Check if /proc/self/exe points to same location after restore\n"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org"; int main(int argc, char *argv[]) { diff --git a/test/zdtm/static/selinux00.c b/test/zdtm/static/selinux00.c index be647834d..00aaeb53c 100644 --- a/test/zdtm/static/selinux00.c +++ b/test/zdtm/static/selinux00.c @@ -12,8 +12,8 @@ /* Enabling the right policy happens in selinux00.hook and selinx00.checkskip */ -const char *test_doc = "Check that a SELinux profile is restored"; -const char *test_author = "Adrian Reber <areber@redhat.com>"; +const char *test_doc = "Check that a SELinux profile is restored"; +const char *test_author = "Adrian Reber <areber@redhat.com>"; /* This is all based on Tycho's apparmor code */ @@ -60,7 +60,6 @@ int checkprofile(void) char context[1024]; int len; - fd = open("/proc/self/attr/current", O_RDONLY); if (fd < 0) { fail("Could not open /proc/self/attr/current"); @@ -70,8 +69,7 @@ int checkprofile(void) len = read(fd, context, strlen(CONTEXT)); close(fd); if (len != strlen(CONTEXT)) { - fail("SELinux context has unexpected length %d, expected %zd", - len, strlen(CONTEXT)); + fail("SELinux context has unexpected length %d, expected %zd", len, strlen(CONTEXT)); return -1; } diff --git a/test/zdtm/static/selinux01.c b/test/zdtm/static/selinux01.c index 14e99c739..b9e0a58fc 100644 --- a/test/zdtm/static/selinux01.c +++ b/test/zdtm/static/selinux01.c @@ -14,8 +14,8 @@ /* Enabling the right policy happens in selinux00.hook and selinx00.checkskip */ -const char *test_doc = "Check that a SELinux socket context is restored"; -const char *test_author = "Adrian Reber <areber@redhat.com>"; +const char *test_doc = "Check that a SELinux socket context is restored"; +const char *test_author = "Adrian Reber <areber@redhat.com>"; /* This is all based on Tycho's apparmor code */ @@ -83,7 +83,6 @@ int check_sockcreate(void) char context[1024]; int len; - fd = open("/proc/self/attr/sockcreate", O_RDONLY); if (fd < 0) { fail("Could not open /proc/self/attr/sockcreate"); @@ -93,8 +92,7 @@ int check_sockcreate(void) len = read(fd, context, strlen(CONTEXT)); close(fd); if (len != strlen(CONTEXT)) { - fail("SELinux context has unexpected length %d, expected %zd", - len, strlen(CONTEXT)); + fail("SELinux context has unexpected length %d, expected %zd", len, strlen(CONTEXT)); return -1; } diff --git a/test/zdtm/static/sem.c b/test/zdtm/static/sem.c index 257dd84ca..a3335dcfe 100644 --- a/test/zdtm/static/sem.c +++ b/test/zdtm/static/sem.c @@ -13,12 +13,10 @@ #include "zdtmtst.h" -const char *test_doc="Tests IPC semaphores migrates fine"; -const char *test_author="Stanislav Kinsbursky <skinsbursky@parallels.com>"; +const char *test_doc = "Tests IPC semaphores migrates fine"; +const char *test_author = "Stanislav Kinsbursky <skinsbursky@parallels.com>"; -static int sem_test(int id, - struct sembuf *lock, struct sembuf *unlock, - int lock_ops, int unlock_ops) +static int sem_test(int id, struct sembuf *lock, struct sembuf *unlock, int lock_ops, int unlock_ops) { if (semop(id, lock, lock_ops) == -1) { fail("Failed to lock semaphore"); @@ -38,27 +36,25 @@ static int check_sem_by_key(int key, int num) int id; struct sembuf lock[2] = { { - .sem_num = num, - .sem_op = 0, - .sem_flg = 0, + .sem_num = num, + .sem_op = 0, + .sem_flg = 0, }, { - .sem_num = num, - .sem_op = 1, - .sem_flg = 0, + .sem_num = num, + .sem_op = 1, + .sem_flg = 0, }, }; - struct sembuf unlock[1] = { - { + struct sembuf unlock[1] = { { .sem_num = num, .sem_op = -1, .sem_flg = 0, - } - }; + } }; int val; id = semget(key, NSEMS, 0777); - if (id == -1) { + if (id == -1) { fail("Can't get sem"); return -errno; } @@ -69,9 +65,7 @@ static int check_sem_by_key(int key, int num) return -errno; } - return sem_test(id, lock, unlock, - sizeof(lock)/sizeof(struct sembuf), - sizeof(unlock)/sizeof(struct sembuf)); + return sem_test(id, lock, unlock, sizeof(lock) / sizeof(struct sembuf), sizeof(unlock) / sizeof(struct sembuf)); } static int check_sem_by_id(int id, int num, int val) @@ -79,18 +73,16 @@ static int check_sem_by_id(int id, int num, int val) int curr; struct sembuf lock[] = { { - .sem_num = num, - .sem_op = val, - .sem_flg = 0, + .sem_num = num, + .sem_op = val, + .sem_flg = 0, }, }; - struct sembuf unlock[] = { - { + struct sembuf unlock[] = { { .sem_num = num, - .sem_op = - val * 2, + .sem_op = -val * 2, .sem_flg = 0, - } - }; + } }; curr = semctl(id, num, GETVAL); if (curr < 0) { @@ -101,9 +93,7 @@ static int check_sem_by_id(int id, int num, int val) fail("Sem has wrong value: %d instead of %d", curr, val); return -EFAULT; } - return sem_test(id, lock, unlock, - sizeof(lock)/sizeof(struct sembuf), - sizeof(unlock)/sizeof(struct sembuf)); + return sem_test(id, lock, unlock, sizeof(lock) / sizeof(struct sembuf), sizeof(unlock) / sizeof(struct sembuf)); } int main(int argc, char **argv) @@ -112,10 +102,10 @@ int main(int argc, char **argv) int i; /* See man semctl */ union semun { - int val; - struct semid_ds *buf; - unsigned short *array; - struct seminfo *__buf; + int val; + struct semid_ds *buf; + unsigned short *array; + struct seminfo *__buf; } val[NSEMS]; int ret, fail_count = 0; @@ -128,7 +118,7 @@ int main(int argc, char **argv) } id = semget(key, NSEMS, 0777 | IPC_CREAT | IPC_EXCL); - if (id == -1) { + if (id == -1) { fail_count++; pr_perror("Can't get sem array"); goto out; diff --git a/test/zdtm/static/session00.c b/test/zdtm/static/session00.c index f65b3cdef..147ecfb0a 100644 --- a/test/zdtm/static/session00.c +++ b/test/zdtm/static/session00.c @@ -4,13 +4,13 @@ #include "zdtmtst.h" -const char *test_doc = "Test that sid, pgid are restored"; -const char *test_author = "Andrey Vagin <avagin@openvz.org>"; +const char *test_doc = "Test that sid, pgid are restored"; +const char *test_author = "Andrey Vagin <avagin@openvz.org>"; -#define DETACH 1 -#define NEWSID 2 -#define CHANGESID 4 -#define DOUBLE_CHANGESID 8 +#define DETACH 1 +#define NEWSID 2 +#define CHANGESID 4 +#define DOUBLE_CHANGESID 8 struct testcase { int flags; @@ -18,14 +18,24 @@ struct testcase { pid_t sid; }; -static struct testcase testcases[] = { - {DETACH, }, - {NEWSID, }, - {0, }, - {DETACH|NEWSID, }, - {CHANGESID, }, - {DOUBLE_CHANGESID | CHANGESID, } - }; +static struct testcase testcases[] = { { + DETACH, + }, + { + NEWSID, + }, + { + 0, + }, + { + DETACH | NEWSID, + }, + { + CHANGESID, + }, + { + DOUBLE_CHANGESID | CHANGESID, + } }; /* 2 2 session00 4 4 \_ session00 # {NEWSID, }, @@ -91,8 +101,8 @@ static int fork_child(int i) close(p[1]); wait(NULL); if (getsid(0) != sid) { - fail("The process %d (%x) has SID=%d (expected %d)", - pid, testcases[i].flags, sid, testcases[i].sid); + fail("The process %d (%x) has SID=%d (expected %d)", pid, testcases[i].flags, sid, + testcases[i].sid); exit(1); } exit(0); @@ -118,14 +128,14 @@ static int fork_child(int i) close(p[1]); wait(NULL); if (getsid(0) != sid) { - fail("The process %d (%x) has SID=%d (expected %d)", - pid, testcases[i].flags, sid, testcases[i].sid); + fail("The process %d (%x) has SID=%d (expected %d)", pid, testcases[i].flags, sid, + testcases[i].sid); exit(1); } exit(0); } -child: + child: pid = getpid(); write(p[1], &pid, sizeof(pid)); close(p[1]); @@ -171,7 +181,7 @@ child: return 0; } -int main(int argc, char ** argv) +int main(int argc, char **argv) { int i, ret, err = 0, status; pid_t pid; @@ -198,8 +208,8 @@ int main(int argc, char ** argv) pid_t sid = getsid(pid); if (sid != testcases[i].sid) { - fail("The process %d (%x) has SID=%d (expected %d)", - pid, testcases[i].flags, sid, testcases[i].sid); + fail("The process %d (%x) has SID=%d (expected %d)", pid, testcases[i].flags, sid, + testcases[i].sid); err++; } diff --git a/test/zdtm/static/session01.c b/test/zdtm/static/session01.c index 48cfb26de..0f727a9a6 100644 --- a/test/zdtm/static/session01.c +++ b/test/zdtm/static/session01.c @@ -7,8 +7,8 @@ #include "zdtmtst.h" #include "lock.h" -const char *test_doc = "Test that sid, pgid are restored"; -const char *test_author = "Andrey Vagin <avagin@openvz.org>"; +const char *test_doc = "Test that sid, pgid are restored"; +const char *test_author = "Andrey Vagin <avagin@openvz.org>"; struct master { pid_t pid; @@ -40,27 +40,33 @@ enum { static struct testcase *testcases; static futex_t *fstate; static struct testcase __testcases[] = { - { 2, 1, 2, 1, 2, 1 }, /* session00 */ - { 4, 2, 4, 2, 4, 1 }, /* |\_session00 */ - {15, 4, 4, 4, 15, 1 }, /* | |\_session00 */ - {16, 4, 4, 4, 15, 1 }, /* | \_session00 */ - {17, 4, 4, 4, 17, 0 }, /* | |\_session00 */ - {18, 4, 4, 4, 17, 1 }, /* | \_session00 */ - { 5, 2, 2, 2, 2, 1 }, /* |\_session00 */ - { 8, 2, 8, 2, 8, 1 }, /* |\_session00 */ - { 9, 8, 2, 2, 2, 1 }, /* | \_session00 */ - {10, 2, 10, 2, 10, 1 }, /* |\_session00 */ - {11, 10, 11, 2, 11, 1 }, /* | \_session00 */ - {12, 11, 2, 2, 2, 1 }, /* | \_session00 */ - {13, 2, 2, 2, 2, 0 }, /* \_session00 */ - { 3, 13, 2, 2, 2, 1 }, /* session00 */ - { 6, 2, 6, 2, 6, 0 }, /* \_session00 */ - {14, 6, 6, 6, 6, 1 }, /* session00 */ + { 2, 1, 2, 1, 2, 1 }, /* session00 */ + { 4, 2, 4, 2, 4, 1 }, /* |\_session00 */ + { 15, 4, 4, 4, 15, 1 }, /* | |\_session00 */ + { 16, 4, 4, 4, 15, 1 }, /* | \_session00 */ + { 17, 4, 4, 4, 17, 0 }, /* | |\_session00 */ + { 18, 4, 4, 4, 17, 1 }, /* | \_session00 */ + { 5, 2, 2, 2, 2, 1 }, /* |\_session00 */ + { 8, 2, 8, 2, 8, 1 }, /* |\_session00 */ + { 9, 8, 2, 2, 2, 1 }, /* | \_session00 */ + { 10, 2, 10, 2, 10, 1 }, /* |\_session00 */ + { 11, 10, 11, 2, 11, 1 }, /* | \_session00 */ + { 12, 11, 2, 2, 2, 1 }, /* | \_session00 */ + { 13, 2, 2, 2, 2, 0 }, /* \_session00 */ + { 3, 13, 2, 2, 2, 1 }, /* session00 */ + { 6, 2, 6, 2, 6, 0 }, /* \_session00 */ + { 14, 6, 6, 6, 6, 1 }, /* session00 */ }; #define TESTS (sizeof(__testcases) / sizeof(struct testcase)) -#define check(n, a, b) do { if ((a) != (b)) { pr_perror("%s mismatch %d != %d", n, a, b); goto err; } } while (0) +#define check(n, a, b) \ + do { \ + if ((a) != (b)) { \ + pr_perror("%s mismatch %d != %d", n, a, b); \ + goto err; \ + } \ + } while (0) static int child(const int c); static int fork_children(struct testcase *t, int leader) @@ -73,7 +79,7 @@ static int fork_children(struct testcase *t, int leader) continue; if (leader ^ (t->pid == testcases[i].born_sid)) - continue; + continue; cid = test_fork_id(i); if (cid < 0) @@ -135,7 +141,7 @@ static int child(const int c) goto err; } - t->master.pgid = testcases[i].master.pid; + t->master.pgid = testcases[i].master.pid; break; } @@ -160,17 +166,17 @@ static int child(const int c) futex_wait_until(fstate, TEST_MASTER); /* Save the master copy */ - t->master.ppid = getppid(); - t->master.sid = getsid(0); + t->master.ppid = getppid(); + t->master.sid = getsid(0); futex_set_and_wake(&t->futex, c); futex_wait_until(fstate, TEST_CHECK); - check("pid", t->master.pid, getpid()); - check("ppid", t->master.ppid, getppid()); - check("sid", t->master.sid, getsid(0)); - check("pgid", t->master.pgid, getpgid(0)); + check("pid", t->master.pid, getpid()); + check("ppid", t->master.ppid, getppid()); + check("sid", t->master.sid, getsid(0)); + check("pgid", t->master.pgid, getpgid(0)); futex_set_and_wake(&t->futex, c); @@ -183,7 +189,7 @@ err: return 1; } -int main(int argc, char ** argv) +int main(int argc, char **argv) { int i, err, ret; void *ptr; @@ -238,8 +244,7 @@ int main(int argc, char ** argv) continue; if (testcases[i].alive) continue; - test_msg("Wait porcess %d (pid %d)\n", - i, testcases[i].master.pid); + test_msg("Wait porcess %d (pid %d)\n", i, testcases[i].master.pid); waitpid(testcases[i].master.pid, NULL, 0); } @@ -272,28 +277,24 @@ int main(int argc, char ** argv) struct testcase *p = testcases + j; /* sanity check */ if (p->pid == t->sid && t->master.sid != p->master.pid) { - pr_perror("session mismatch (%d) %d != (%d) %d", - i, t->master.sid, j, p->master.pid); + pr_perror("session mismatch (%d) %d != (%d) %d", i, t->master.sid, j, p->master.pid); err++; } if (p->pid == t->pgid && t->master.pgid != p->master.pid) { - pr_perror("pgid mismatch (%d) %d != (%d) %d", - i, t->master.pgid, j, p->master.pid); + pr_perror("pgid mismatch (%d) %d != (%d) %d", i, t->master.pgid, j, p->master.pid); err++; } } sid = getsid(t->master.pid); if (t->master.sid != sid) { - pr_perror("%d: session mismatch %d (expected %d)", - i, sid, t->master.sid); + pr_perror("%d: session mismatch %d (expected %d)", i, sid, t->master.sid); err++; } pgid = getpgid(t->master.pid); if (t->master.pgid != pgid) { - pr_perror("%d: pgid mismatch %d (expected %d)", - i, t->master.pgid, pgid); + pr_perror("%d: pgid mismatch %d (expected %d)", i, t->master.pgid, pgid); err++; } } diff --git a/test/zdtm/static/session02.c b/test/zdtm/static/session02.c index f5c81df16..0967e04b2 100644 --- a/test/zdtm/static/session02.c +++ b/test/zdtm/static/session02.c @@ -10,11 +10,10 @@ #include "zdtmtst.h" -const char *test_doc = "Create a crazy process tree"; -const char *test_author = "Andrew Vagin <avagin@parallels.com>"; +const char *test_doc = "Create a crazy process tree"; +const char *test_author = "Andrew Vagin <avagin@parallels.com>"; -struct process -{ +struct process { pid_t pid; pid_t sid; int sks[2]; @@ -39,20 +38,12 @@ static void cleanup(void) } } -enum commands -{ - TEST_FORK, - TEST_WAIT, - TEST_SUBREAPER, - TEST_SETSID, - TEST_DIE -}; +enum commands { TEST_FORK, TEST_WAIT, TEST_SUBREAPER, TEST_SETSID, TEST_DIE }; -struct command -{ - enum commands cmd; - int arg1; - int arg2; +struct command { + enum commands cmd; + int arg1; + int arg2; }; static void handle_command(void); @@ -63,7 +54,7 @@ static void mainloop(void) handle_command(); } -#define CLONE_STACK_SIZE 4096 +#define CLONE_STACK_SIZE 4096 /* All arguments should be above stack, because it grows down */ struct clone_args { char stack[CLONE_STACK_SIZE] __stack_aligned__; @@ -73,7 +64,7 @@ struct clone_args { static int clone_func(void *_arg) { - struct clone_args *args = (struct clone_args *) _arg; + struct clone_args *args = (struct clone_args *)_arg; current = args->id; @@ -89,8 +80,7 @@ static int make_child(int id, int flags) args.id = id; - cid = clone(clone_func, args.stack_ptr, - flags | SIGCHLD, &args); + cid = clone(clone_func, args.stack_ptr, flags | SIGCHLD, &args); if (cid < 0) pr_perror("clone(%d, %d)", id, flags); @@ -112,24 +102,20 @@ static void handle_command(void) } switch (cmd.cmd) { - case TEST_FORK: - { - pid_t pid; - - pid = make_child(cmd.arg1, cmd.arg2); - if (pid == -1) { - status = -1; - goto err; - } - - test_msg("%3d: fork(%d, %x) = %d\n", - current, cmd.arg1, cmd.arg2, pid); - processes[cmd.arg1].pid = pid; + case TEST_FORK: { + pid_t pid; + + pid = make_child(cmd.arg1, cmd.arg2); + if (pid == -1) { + status = -1; + goto err; } - break; + + test_msg("%3d: fork(%d, %x) = %d\n", current, cmd.arg1, cmd.arg2, pid); + processes[cmd.arg1].pid = pid; + } break; case TEST_WAIT: - test_msg("%3d: wait(%d) = %d\n", current, - cmd.arg1, processes[cmd.arg1].pid); + test_msg("%3d: wait(%d) = %d\n", current, cmd.arg1, processes[cmd.arg1].pid); if (waitpid(processes[cmd.arg1].pid, NULL, 0) == -1) { pr_perror("waitpid(%d)", processes[cmd.arg1].pid); @@ -145,7 +131,7 @@ static void handle_command(void) break; case TEST_SETSID: test_msg("%3d: setsid()\n", current); - if(setsid() == -1) { + if (setsid() == -1) { pr_perror("setsid"); status = -1; } @@ -175,7 +161,7 @@ err: static int send_command(int id, enum commands op, int arg1, int arg2) { int sk = processes[id].sks[1], ret, status; - struct command cmd = {op, arg1, arg2}; + struct command cmd = { op, arg1, arg2 }; if (op == TEST_FORK) { if (processes[arg1].pid) { @@ -208,15 +194,14 @@ err: exit(1); } -int main(int argc, char ** argv) +int main(int argc, char **argv) { int pid, i; int fail_cnt = 0; test_init(argc, argv); - processes = mmap(NULL, PAGE_SIZE, PROT_WRITE | PROT_READ, - MAP_SHARED | MAP_ANONYMOUS, 0, 0); + processes = mmap(NULL, PAGE_SIZE, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_ANONYMOUS, 0, 0); if (processes == NULL) { pr_perror("Unable to map share memory"); return 1; @@ -243,39 +228,39 @@ int main(int argc, char ** argv) * 13 12 \_ session02 ( 8) */ - send_command(0, TEST_SUBREAPER, 1, 0); - send_command(0, TEST_SETSID, 0, 0); + send_command(0, TEST_SUBREAPER, 1, 0); + send_command(0, TEST_SETSID, 0, 0); - send_command(0, TEST_FORK, 1, 0); - send_command(1, TEST_FORK, 2, 0); + send_command(0, TEST_FORK, 1, 0); + send_command(1, TEST_FORK, 2, 0); - send_command(2, TEST_SETSID, 0, 0); - send_command(2, TEST_FORK, 3, CLONE_PARENT); - send_command(2, TEST_DIE, 0, 0); - send_command(1, TEST_WAIT, 2, 0); + send_command(2, TEST_SETSID, 0, 0); + send_command(2, TEST_FORK, 3, CLONE_PARENT); + send_command(2, TEST_DIE, 0, 0); + send_command(1, TEST_WAIT, 2, 0); - send_command(3, TEST_FORK, 4, 0); - send_command(4, TEST_FORK, 5, 0); - send_command(5, TEST_FORK, 6, 0); + send_command(3, TEST_FORK, 4, 0); + send_command(4, TEST_FORK, 5, 0); + send_command(5, TEST_FORK, 6, 0); - send_command(5, TEST_FORK, 7, 0); - send_command(7, TEST_SETSID, 0, 0); - send_command(7, TEST_FORK, 8, CLONE_PARENT); - send_command(7, TEST_FORK, 9, CLONE_PARENT); - send_command(7, TEST_DIE, 0, 0); - send_command(5, TEST_WAIT, 7, 0); + send_command(5, TEST_FORK, 7, 0); + send_command(7, TEST_SETSID, 0, 0); + send_command(7, TEST_FORK, 8, CLONE_PARENT); + send_command(7, TEST_FORK, 9, CLONE_PARENT); + send_command(7, TEST_DIE, 0, 0); + send_command(5, TEST_WAIT, 7, 0); - send_command(9, TEST_FORK, 10, 0); - send_command(1, TEST_SUBREAPER, 1, 0); - send_command(9, TEST_DIE, 0, 0); - send_command(5, TEST_WAIT, 9, 0); - send_command(1, TEST_SUBREAPER, 0, 0); + send_command(9, TEST_FORK, 10, 0); + send_command(1, TEST_SUBREAPER, 1, 0); + send_command(9, TEST_DIE, 0, 0); + send_command(5, TEST_WAIT, 9, 0); + send_command(1, TEST_SUBREAPER, 0, 0); - send_command(4, TEST_DIE, 0, 0); - send_command(3, TEST_WAIT, 4, 0); + send_command(4, TEST_DIE, 0, 0); + send_command(3, TEST_WAIT, 4, 0); - send_command(1, TEST_SETSID, 0, 0); - send_command(5, TEST_SETSID, 0, 0); + send_command(1, TEST_SETSID, 0, 0); + send_command(5, TEST_SETSID, 0, 0); for (i = 0; i < nr_processes; i++) { if (processes[i].dead) @@ -309,8 +294,7 @@ int main(int argc, char ** argv) } if (sid != processes[i].sid) { - fail("%d, %d: wrong sid %d (expected %d)", - i, processes[i].pid, sid, processes[i].sid); + fail("%d, %d: wrong sid %d (expected %d)", i, processes[i].pid, sid, processes[i].sid); fail_cnt++; } } diff --git a/test/zdtm/static/session03.c b/test/zdtm/static/session03.c index 8ca16e410..6e6f948ab 100644 --- a/test/zdtm/static/session03.c +++ b/test/zdtm/static/session03.c @@ -10,11 +10,10 @@ #include "zdtmtst.h" -const char *test_doc = "Create a crazy process tree"; -const char *test_author = "Andrew Vagin <avagin@parallels.com>"; +const char *test_doc = "Create a crazy process tree"; +const char *test_author = "Andrew Vagin <avagin@parallels.com>"; -struct process -{ +struct process { pid_t pid; pid_t sid; int sks[2]; @@ -23,7 +22,7 @@ struct process }; #define MEM_SIZE (2 * PAGE_SIZE) -#define PR_MAX (MEM_SIZE / sizeof(struct process)) +#define PR_MAX (MEM_SIZE / sizeof(struct process)) struct process *processes; int nr_processes = 0; @@ -60,17 +59,9 @@ static void cleanup(void) } } -enum commands -{ - TEST_FORK, - TEST_DIE_WAIT, - TEST_DIE, - TEST_SUBREAPER, - TEST_SETSID, - TEST_MAX -}; +enum commands { TEST_FORK, TEST_DIE_WAIT, TEST_DIE, TEST_SUBREAPER, TEST_SETSID, TEST_MAX }; -int cmd_weght[TEST_MAX] = {10, 3, 1, 10, 7}; +int cmd_weght[TEST_MAX] = { 10, 3, 1, 10, 7 }; int sum_weight = 0; static int get_rnd_op(void) { @@ -90,11 +81,10 @@ static int get_rnd_op(void) return -1; } -struct command -{ - enum commands cmd; - int arg1; - int arg2; +struct command { + enum commands cmd; + int arg1; + int arg2; }; static void handle_command(void); @@ -105,7 +95,7 @@ static void mainloop(void) handle_command(); } -#define CLONE_STACK_SIZE 4096 +#define CLONE_STACK_SIZE 4096 /* All arguments should be above stack, because it grows down */ struct clone_args { char stack[CLONE_STACK_SIZE] __stack_aligned__; @@ -115,7 +105,7 @@ struct clone_args { static int clone_func(void *_arg) { - struct clone_args *args = (struct clone_args *) _arg; + struct clone_args *args = (struct clone_args *)_arg; current = args->id; @@ -131,8 +121,7 @@ static int make_child(int id, int flags) args.id = id; - cid = clone(clone_func, args.stack_ptr, - flags | SIGCHLD, &args); + cid = clone(clone_func, args.stack_ptr, flags | SIGCHLD, &args); if (cid < 0) pr_perror("clone(%d, %d)", id, flags); @@ -154,21 +143,18 @@ static void handle_command(void) } switch (cmd.cmd) { - case TEST_FORK: - { - pid_t pid; - - pid = make_child(cmd.arg1, cmd.arg2 ? CLONE_PARENT : 0); - if (pid < 0) { - status = -1; - goto err; - } - - test_msg("%3d: fork(%d, %x) = %d\n", - current, cmd.arg1, cmd.arg2, pid); - processes[cmd.arg1].pid = pid; + case TEST_FORK: { + pid_t pid; + + pid = make_child(cmd.arg1, cmd.arg2 ? CLONE_PARENT : 0); + if (pid < 0) { + status = -1; + goto err; } - break; + + test_msg("%3d: fork(%d, %x) = %d\n", current, cmd.arg1, cmd.arg2, pid); + processes[cmd.arg1].pid = pid; + } break; case TEST_SUBREAPER: test_msg("%3d: subreaper(%d)\n", current, cmd.arg1); if (prctl(PR_SET_CHILD_SUBREAPER, cmd.arg1, 0, 0, 0) == -1) { @@ -180,7 +166,7 @@ static void handle_command(void) if (getsid(0) == getpid()) break; test_msg("%3d: setsid()\n", current); - if(setsid() == -1) { + if (setsid() == -1) { pr_perror("setsid"); status = -1; } @@ -218,7 +204,7 @@ err: static int send_command(int id, enum commands op, int arg) { int sk = processes[id].sks[1], ret, status; - struct command cmd = {op, arg}; + struct command cmd = { op, arg }; if (op == TEST_FORK) { cmd.arg1 = nr_processes; @@ -236,8 +222,7 @@ static int send_command(int id, enum commands op, int arg) status = 0; ret = read(sk, &status, sizeof(status)); - if (ret != sizeof(status) && - !(status == 0 && (op == TEST_DIE || op == TEST_DIE_WAIT))) { + if (ret != sizeof(status) && !(status == 0 && (op == TEST_DIE || op == TEST_DIE_WAIT))) { pr_perror("Unable to get answer"); goto err; } @@ -253,7 +238,7 @@ err: exit(1); } -int main(int argc, char ** argv) +int main(int argc, char **argv) { struct sigaction act; int pid, i, ret; @@ -283,8 +268,7 @@ int main(int argc, char ** argv) return -1; } - processes = mmap(NULL, MEM_SIZE, PROT_WRITE | PROT_READ, - MAP_SHARED | MAP_ANONYMOUS, 0, 0); + processes = mmap(NULL, MEM_SIZE, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_ANONYMOUS, 0, 0); if (processes == NULL) { pr_perror("Unable to map share memory"); return 1; @@ -302,7 +286,7 @@ int main(int argc, char ** argv) if (pid < 0) return -1; - while(nr_processes < PR_MAX) { + while (nr_processes < PR_MAX) { int op, id; int flags = lrand48() % 2; @@ -357,8 +341,7 @@ int main(int argc, char ** argv) } if (sid != processes[i].sid) { - fail("%d, %d: wrong sid %d (expected %d)", - i, processes[i].pid, sid, processes[i].sid); + fail("%d, %d: wrong sid %d (expected %d)", i, processes[i].pid, sid, processes[i].sid); fail_cnt++; } } diff --git a/test/zdtm/static/shared_mount_propagation.c b/test/zdtm/static/shared_mount_propagation.c index 4e81b9ec6..47ffa8263 100644 --- a/test/zdtm/static/shared_mount_propagation.c +++ b/test/zdtm/static/shared_mount_propagation.c @@ -5,8 +5,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check mounts are propagated to shared mounts"; -const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; +const char *test_doc = "Check mounts are propagated to shared mounts"; +const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); diff --git a/test/zdtm/static/shared_slave_mount_children.c b/test/zdtm/static/shared_slave_mount_children.c index 75c2513c6..172a61a60 100644 --- a/test/zdtm/static/shared_slave_mount_children.c +++ b/test/zdtm/static/shared_slave_mount_children.c @@ -4,8 +4,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check non-uniform shares restore fine"; -const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; +const char *test_doc = "Check non-uniform shares restore fine"; +const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); diff --git a/test/zdtm/static/shm-mp.c b/test/zdtm/static/shm-mp.c index a7c87962d..1929dac19 100644 --- a/test/zdtm/static/shm-mp.c +++ b/test/zdtm/static/shm-mp.c @@ -8,10 +8,10 @@ #include "zdtmtst.h" -const char *test_doc="Tests mprotected SYSVIPC shmems"; -const char *test_author="Pavel Emelyanov <xemul@openvz.org>"; +const char *test_doc = "Tests mprotected SYSVIPC shmems"; +const char *test_author = "Pavel Emelyanov <xemul@openvz.org>"; -static sigjmp_buf segv_ret; /* we need sig*jmp stuff, otherwise SIGSEGV will reset our handler */ +static sigjmp_buf segv_ret; /* we need sig*jmp stuff, otherwise SIGSEGV will reset our handler */ static void segfault(int signo) { siglongjmp(segv_ret, 1); @@ -33,11 +33,11 @@ static int check_prot(char *ptr, char val, int prot) fail("PROT_READ bypassed"); return -1; } - } else /* we come here on return from SIGSEGV handler */ + } else /* we come here on return from SIGSEGV handler */ if (prot & PROT_READ) { - fail("PROT_READ rejected"); - return -1; - } + fail("PROT_READ rejected"); + return -1; + } if (!sigsetjmp(segv_ret, 1)) { *ptr = val; @@ -45,11 +45,11 @@ static int check_prot(char *ptr, char val, int prot) fail("PROT_WRITE bypassed"); return -1; } - } else /* we come here on return from SIGSEGV handler */ + } else /* we come here on return from SIGSEGV handler */ if (prot & PROT_WRITE) { - fail("PROT_WRITE rejected"); - return -1; - } + fail("PROT_WRITE rejected"); + return -1; + } if (signal(SIGSEGV, SIG_DFL) == SIG_ERR) { fail("restoring SIGSEGV handler failed"); @@ -100,7 +100,6 @@ int main(int argc, char **argv) if (check_prot(mem + PAGE_SIZE, 'W', PROT_READ | PROT_WRITE)) f++; - if (!f) pass(); else diff --git a/test/zdtm/static/shm.c b/test/zdtm/static/shm.c index 320211bfc..3da29daeb 100644 --- a/test/zdtm/static/shm.c +++ b/test/zdtm/static/shm.c @@ -13,14 +13,14 @@ #include "zdtmtst.h" -const char *test_doc="Tests detached shmems migrate fine"; -const char *test_author="Stanislav Kinsbursky <skinsbursky@parallels.com>"; +const char *test_doc = "Tests detached shmems migrate fine"; +const char *test_author = "Stanislav Kinsbursky <skinsbursky@parallels.com>"; -#define DEF_MEM_SIZE (40960) +#define DEF_MEM_SIZE (40960) unsigned int shmem_size = DEF_MEM_SIZE; TEST_OPTION(shmem_size, uint, "Size of shared memory segment", 0); -#define INIT_CRC (~0) +#define INIT_CRC (~0) static int fill_shm_seg(int id, size_t size) { diff --git a/test/zdtm/static/shmemfd-priv.c b/test/zdtm/static/shmemfd-priv.c index bbdb46905..0f6e817cc 100644 --- a/test/zdtm/static/shmemfd-priv.c +++ b/test/zdtm/static/shmemfd-priv.c @@ -9,10 +9,14 @@ #include "zdtmtst.h" -const char *test_doc = "Test C/R of shared memory file descriptors"; -const char *test_author = "Andrei Vagin <avagin@gmail.com>"; +const char *test_doc = "Test C/R of shared memory file descriptors"; +const char *test_author = "Andrei Vagin <avagin@gmail.com>"; -#define err(exitcode, msg, ...) ({ pr_perror(msg, ##__VA_ARGS__); exit(exitcode); }) +#define err(exitcode, msg, ...) \ + ({ \ + pr_perror(msg, ##__VA_ARGS__); \ + exit(exitcode); \ + }) int main(int argc, char *argv[]) { @@ -28,12 +32,11 @@ int main(int argc, char *argv[]) return 1; } - *(int *) addr = 1; - *(int *) (addr + PAGE_SIZE) = 11; - *(int *) (addr + 2 * PAGE_SIZE) = 111; + *(int *)addr = 1; + *(int *)(addr + PAGE_SIZE) = 11; + *(int *)(addr + 2 * PAGE_SIZE) = 111; - snprintf(path, sizeof(path), "/proc/self/map_files/%lx-%lx", - (long)addr, (long)addr + 5 * PAGE_SIZE); + snprintf(path, sizeof(path), "/proc/self/map_files/%lx-%lx", (long)addr, (long)addr + 5 * PAGE_SIZE); fd = open(path, O_RDWR | O_LARGEFILE); if (fd < 0) err(1, "Can't open %s", path); @@ -50,30 +53,30 @@ int main(int argc, char *argv[]) return 1; } - *(int *) (priv_addr + PAGE_SIZE) = 22; + *(int *)(priv_addr + PAGE_SIZE) = 22; test_daemon(); test_waitsig(); - if (*(int *) (priv_addr + PAGE_SIZE) != 22) { + if (*(int *)(priv_addr + PAGE_SIZE) != 22) { fail("the second page of the private mapping is corrupted"); return 1; } - if (*(int *) (priv_addr) != 11) { + if (*(int *)(priv_addr) != 11) { fail("the first page of the private mapping is corrupted"); return 1; } - if (*(int *) (addr2) != 111) { + if (*(int *)(addr2) != 111) { fail("the first page of the second shared mapping is corrupted"); return 1; } - *(int *) (addr2) = 333; - if (*(int *) (addr + 2 * PAGE_SIZE) != 333) { + *(int *)(addr2) = 333; + if (*(int *)(addr + 2 * PAGE_SIZE) != 333) { fail("the first page of the second shared mapping isn't shared"); return 1; } - *(int *) (addr + 3 * PAGE_SIZE) = 444; - if (*(int *) (priv_addr + 2 * PAGE_SIZE) != 444) { + *(int *)(addr + 3 * PAGE_SIZE) = 444; + if (*(int *)(priv_addr + 2 * PAGE_SIZE) != 444) { fail("the third page of the private mapping is corrupted"); return 1; } diff --git a/test/zdtm/static/shmemfd.c b/test/zdtm/static/shmemfd.c index b65faa2e1..8a5232bbd 100644 --- a/test/zdtm/static/shmemfd.c +++ b/test/zdtm/static/shmemfd.c @@ -9,10 +9,14 @@ #include "zdtmtst.h" -const char *test_doc = "Test C/R of shared memory file descriptors"; -const char *test_author = "Andrei Vagin <avagin@gmail.com>"; +const char *test_doc = "Test C/R of shared memory file descriptors"; +const char *test_author = "Andrei Vagin <avagin@gmail.com>"; -#define err(exitcode, msg, ...) ({ pr_perror(msg, ##__VA_ARGS__); exit(exitcode); }) +#define err(exitcode, msg, ...) \ + ({ \ + pr_perror(msg, ##__VA_ARGS__); \ + exit(exitcode); \ + }) int main(int argc, char *argv[]) { @@ -31,8 +35,7 @@ int main(int argc, char *argv[]) return 1; } - snprintf(path, sizeof(path), "/proc/self/map_files/%lx-%lx", - (long)addr, (long)addr + PAGE_SIZE); + snprintf(path, sizeof(path), "/proc/self/map_files/%lx-%lx", (long)addr, (long)addr + PAGE_SIZE); fd = open(path, O_RDWR | O_LARGEFILE); if (fd < 0) err(1, "Can't open %s", path); diff --git a/test/zdtm/static/sigaltstack.c b/test/zdtm/static/sigaltstack.c index 13602d3a1..dd7c82d39 100644 --- a/test/zdtm/static/sigaltstack.c +++ b/test/zdtm/static/sigaltstack.c @@ -11,8 +11,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check for alternate signal stack"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; +const char *test_doc = "Check for alternate signal stack"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; #define TESTSIGSTKSZ 16384 @@ -31,20 +31,17 @@ static stack_t sas_state[SAS_MAX]; static task_waiter_t t; -#define exit_group(code) syscall(__NR_exit_group, code) -#define gettid() syscall(__NR_gettid) +#define exit_group(code) syscall(__NR_exit_group, code) +#define gettid() syscall(__NR_gettid) static int sascmp(stack_t *old, stack_t *new) { - return old->ss_size != new->ss_size || - old->ss_sp != new->ss_sp || - old->ss_flags != new->ss_flags; + return old->ss_size != new->ss_size || old->ss_sp != new->ss_sp || old->ss_flags != new->ss_flags; } static void show_ss(char *prefix, stack_t *s) { - test_msg("%20s: at %p (size %8zu flags %#2x)\n", - prefix, s->ss_sp, s->ss_size, s->ss_flags); + test_msg("%20s: at %p (size %8zu flags %#2x)\n", prefix, s->ss_sp, s->ss_size, s->ss_flags); } void thread_sigaction(int signo, siginfo_t *info, void *context) @@ -64,14 +61,14 @@ void thread_sigaction(int signo, siginfo_t *info, void *context) static void *thread_func(void *arg) { struct sigaction sa = { - .sa_sigaction = thread_sigaction, - .sa_flags = SA_RESTART | SA_ONSTACK, + .sa_sigaction = thread_sigaction, + .sa_flags = SA_RESTART | SA_ONSTACK, }; - sas_state[SAS_THRD_OLD] = (stack_t) { - .ss_size = sizeof(stack_thread) - 8, - .ss_sp = stack_thread, - .ss_flags = 0, + sas_state[SAS_THRD_OLD] = (stack_t){ + .ss_size = sizeof(stack_thread) - 8, + .ss_sp = stack_thread, + .ss_flags = 0, }; sigemptyset(&sa.sa_mask); @@ -106,14 +103,14 @@ int main(int argc, char *argv[]) pthread_t thread; struct sigaction sa = { - .sa_sigaction = leader_sigaction, - .sa_flags = SA_RESTART | SA_ONSTACK, + .sa_sigaction = leader_sigaction, + .sa_flags = SA_RESTART | SA_ONSTACK, }; - sas_state[SAS_MAIN_OLD] = (stack_t) { - .ss_size = sizeof(stack_main) - 8, - .ss_sp = stack_main, - .ss_flags = 0, + sas_state[SAS_MAIN_OLD] = (stack_t){ + .ss_size = sizeof(stack_main) - 8, + .ss_sp = stack_main, + .ss_flags = 0, }; sigemptyset(&sa.sa_mask); diff --git a/test/zdtm/static/signalfd00.c b/test/zdtm/static/signalfd00.c index 61b1f0398..b98372885 100644 --- a/test/zdtm/static/signalfd00.c +++ b/test/zdtm/static/signalfd00.c @@ -18,8 +18,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check for signalfd without signals"; -const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; +const char *test_doc = "Check for signalfd without signals"; +const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; int main(int argc, char *argv[]) { diff --git a/test/zdtm/static/sigpending.c b/test/zdtm/static/sigpending.c index 4d174588c..1641fdd86 100644 --- a/test/zdtm/static/sigpending.c +++ b/test/zdtm/static/sigpending.c @@ -9,13 +9,13 @@ #include "zdtmtst.h" -const char *test_doc = "Check pending signals"; -const char *test_author = "Andrew Vagin <avagin@parallels.com>"; +const char *test_doc = "Check pending signals"; +const char *test_author = "Andrew Vagin <avagin@parallels.com>"; static pid_t child; static int numsig; -#define TESTSIG (SIGRTMAX) +#define TESTSIG (SIGRTMAX) #define THREADSIG (SIGRTMIN) static siginfo_t share_infos[2]; static siginfo_t self_infos[64]; /* self */ @@ -25,7 +25,7 @@ static int self_nr; static int thread_nr; #ifndef offsetof -# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#define offsetof(TYPE, MEMBER) ((size_t) & ((TYPE *)0)->MEMBER) #endif /* cr_siginfo is declared to get an offset of _sifields */ @@ -59,7 +59,7 @@ typedef union cr_siginfo cr_siginfo_t; * } _rt; * Look at __copy_siginfo_to_user32() for more information. */ -# define _si_fields_sz 12 +#define _si_fields_sz 12 #define siginfo_filled (offsetof(cr_siginfo_t, _info._sifields) + _si_fields_sz) static pthread_mutex_t exit_lock; @@ -78,9 +78,7 @@ static void sig_handler(int signal, siginfo_t *info, void *data) switch (signal) { case SIGCHLD: - if ((info->si_code & CLD_EXITED) && - (info->si_pid == child) && - (info->si_status == 5)) + if ((info->si_code & CLD_EXITED) && (info->si_pid == child) && (info->si_status == 5)) numsig++; else { fail("Wrong siginfo"); @@ -104,12 +102,12 @@ static void sig_handler(int signal, siginfo_t *info, void *data) } crc = ~0; - if (datachk((uint8_t *) siginf_body(info), _si_fields_sz, &crc)) { + if (datachk((uint8_t *)siginf_body(info), _si_fields_sz, &crc)) { fail("CRC mismatch"); return; } - if (memcmp(info, src, siginfo_filled)) { + if (memcmp(info, src, siginfo_filled)) { fail("Source and received info are differ"); return; } @@ -186,7 +184,7 @@ int send_siginfo(int signo, pid_t pid, pid_t tid, int group, siginfo_t *info) info->si_code = si_code; si_code--; info->si_signo = signo; - datagen((uint8_t *) siginf_body(info), _si_fields_sz, &crc); + datagen((uint8_t *)siginf_body(info), _si_fields_sz, &crc); sent_sigs++; @@ -196,7 +194,7 @@ int send_siginfo(int signo, pid_t pid, pid_t tid, int group, siginfo_t *info) return syscall(SYS_rt_tgsigqueueinfo, pid, tid, signo, info); } -int main(int argc, char ** argv) +int main(int argc, char **argv) { sigset_t blockmask, oldset, newset; struct sigaction act; @@ -239,7 +237,7 @@ int main(int argc, char ** argv) return -1; } - if(child == 0) + if (child == 0) return 5; /* SIGCHLD */ if (waitid(P_PID, child, &infop, WNOWAIT | WEXITED)) { pr_perror("waitid"); diff --git a/test/zdtm/static/sigtrap.c b/test/zdtm/static/sigtrap.c index 659213cf5..6bd30aad4 100644 --- a/test/zdtm/static/sigtrap.c +++ b/test/zdtm/static/sigtrap.c @@ -18,10 +18,12 @@ #include "zdtmtst.h" -const char *test_doc = "Check that a pending SIGTRAP handled correctly"; -const char *test_author = "Andrei Vagin <avagin@gmail.com>"; +const char *test_doc = "Check that a pending SIGTRAP handled correctly"; +const char *test_author = "Andrei Vagin <avagin@gmail.com>"; -static void sigh(int signo) {} +static void sigh(int signo) +{ +} int main(int argc, char *argv[]) { diff --git a/test/zdtm/static/sigtrap01.c b/test/zdtm/static/sigtrap01.c index a63e55d6a..a61f4368e 100644 --- a/test/zdtm/static/sigtrap01.c +++ b/test/zdtm/static/sigtrap01.c @@ -5,15 +5,15 @@ #include "zdtmtst.h" -const char *test_doc = "Check that a signal handler for SIGTRAP is restored"; -const char *test_author = "Andrei Vagin <avagin@gmail.com>"; +const char *test_doc = "Check that a signal handler for SIGTRAP is restored"; +const char *test_author = "Andrei Vagin <avagin@gmail.com>"; static int sigtrap = 0; -static void sigh(int signo) { +static void sigh(int signo) +{ sigtrap = 1; } - int main(int argc, char **argv) { test_init(argc, argv); diff --git a/test/zdtm/static/sit.c b/test/zdtm/static/sit.c index 07c36ab5d..8deb2901d 100644 --- a/test/zdtm/static/sit.c +++ b/test/zdtm/static/sit.c @@ -13,12 +13,12 @@ #include <net/if.h> #include "zdtmtst.h" -const char *test_doc = "check sit devices"; -const char *test_author = "Pavel Emelyanov <xemul@virtuozzo.com>"; +const char *test_doc = "check sit devices"; +const char *test_author = "Pavel Emelyanov <xemul@virtuozzo.com>"; -#define IF_NAME "zdtmsit0" -#define LOCAL_ADDR "1.1.1.2" -#define REMOT_ADDR "2.2.2.1" +#define IF_NAME "zdtmsit0" +#define LOCAL_ADDR "1.1.1.2" +#define REMOT_ADDR "2.2.2.1" int main(int argc, char **argv) { @@ -55,4 +55,3 @@ int main(int argc, char **argv) out: return ret; } - diff --git a/test/zdtm/static/sk-freebind.c b/test/zdtm/static/sk-freebind.c index de30329c9..0fc719f6c 100644 --- a/test/zdtm/static/sk-freebind.c +++ b/test/zdtm/static/sk-freebind.c @@ -2,12 +2,12 @@ #include <stdlib.h> #include <string.h> #include <sys/socket.h> -#include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */ +#include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */ #include "zdtmtst.h" -const char *test_doc = "Check that IP_FREEBIND is restored"; -const char *test_author = "Andrew Vagin <avagin@virtuozzo.com>"; +const char *test_doc = "Check that IP_FREEBIND is restored"; +const char *test_author = "Andrew Vagin <avagin@virtuozzo.com>"; union sockaddr_inet { struct sockaddr_in v4; @@ -40,18 +40,18 @@ int main(int argc, char **argv) return -1; } val = 1; - if (setsockopt(sock, SOL_IP, IP_FREEBIND, &val, sizeof(int)) == -1 ) { + if (setsockopt(sock, SOL_IP, IP_FREEBIND, &val, sizeof(int)) == -1) { pr_perror("setsockopt() error"); return -1; } - if (bind(sock, (struct sockaddr *) &addr, sizeof(addr))) { + if (bind(sock, (struct sockaddr *)&addr, sizeof(addr))) { pr_perror("bind()"); return -1; } if (!fb_keep) { val = 0; - if (setsockopt(sock, SOL_IP, IP_FREEBIND, &val, sizeof(int)) == -1 ) { + if (setsockopt(sock, SOL_IP, IP_FREEBIND, &val, sizeof(int)) == -1) { pr_perror("setsockopt() error"); return -1; } @@ -61,7 +61,7 @@ int main(int argc, char **argv) test_waitsig(); len = sizeof(int); - if (getsockopt(sock, SOL_IP, IP_FREEBIND, &val, &len) == -1 ) { + if (getsockopt(sock, SOL_IP, IP_FREEBIND, &val, &len) == -1) { pr_perror("setsockopt() error"); return -1; } diff --git a/test/zdtm/static/sk-netlink.c b/test/zdtm/static/sk-netlink.c index 7f06f0259..b79ac0cf7 100644 --- a/test/zdtm/static/sk-netlink.c +++ b/test/zdtm/static/sk-netlink.c @@ -7,15 +7,15 @@ #include "zdtmtst.h" #ifndef SOL_NETLINK -#define SOL_NETLINK 270 +#define SOL_NETLINK 270 #endif -#define UDEV_MONITOR_TEST 32 +#define UDEV_MONITOR_TEST 32 -const char *test_doc = "Support of netlink sockets"; -const char *test_author = "Andrew Vagin <avagin@parallels.com>"; +const char *test_doc = "Support of netlink sockets"; +const char *test_author = "Andrew Vagin <avagin@parallels.com>"; -int main(int argc, char ** argv) +int main(int argc, char **argv) { int ssk, bsk, csk, dsk; struct sockaddr_nl addr; @@ -64,21 +64,21 @@ int main(int argc, char ** argv) addr.nl_family = AF_NETLINK; addr.nl_groups = 0; addr.nl_pid = getpid(); - if (bind(ssk, (struct sockaddr *) &addr, sizeof(struct sockaddr_nl))) { + if (bind(ssk, (struct sockaddr *)&addr, sizeof(struct sockaddr_nl))) { pr_perror("bind"); return 1; } addr.nl_groups = 1 << (UDEV_MONITOR_TEST - 1); addr.nl_pid = 0; - if (bind(bsk, (struct sockaddr *) &addr, sizeof(struct sockaddr_nl))) { + if (bind(bsk, (struct sockaddr *)&addr, sizeof(struct sockaddr_nl))) { pr_perror("bind"); return 1; } addr.nl_pid = getpid(); addr.nl_groups = 1 << (UDEV_MONITOR_TEST - 1); - if (connect(csk, (struct sockaddr *) &addr, sizeof(struct sockaddr_nl))) { + if (connect(csk, (struct sockaddr *)&addr, sizeof(struct sockaddr_nl))) { pr_perror("connect"); return 1; } @@ -87,18 +87,18 @@ int main(int argc, char ** argv) test_waitsig(); - req.hdr.nlmsg_len = sizeof(req); - req.hdr.nlmsg_type = 0x1234; - req.hdr.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST; - req.hdr.nlmsg_seq = 0xabcd; + req.hdr.nlmsg_len = sizeof(req); + req.hdr.nlmsg_type = 0x1234; + req.hdr.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST; + req.hdr.nlmsg_seq = 0xabcd; memset(&msg, 0, sizeof(msg)); msg.msg_namelen = 0; - msg.msg_iov = &iov; - msg.msg_iovlen = 1; + msg.msg_iov = &iov; + msg.msg_iovlen = 1; - iov.iov_base = (void *) &req; - iov.iov_len = sizeof(req); + iov.iov_base = (void *)&req; + iov.iov_len = sizeof(req); if (sendmsg(csk, &msg, 0) < 0) { pr_perror("Can't send request message"); @@ -107,11 +107,11 @@ int main(int argc, char ** argv) memset(&msg, 0, sizeof(msg)); msg.msg_namelen = 0; - msg.msg_iov = &iov; - msg.msg_iovlen = 1; + msg.msg_iov = &iov; + msg.msg_iovlen = 1; - iov.iov_base = buf; - iov.iov_len = sizeof(buf); + iov.iov_base = buf; + iov.iov_len = sizeof(buf); if (recvmsg(ssk, &msg, 0) < 0) { pr_perror("Can't recv request message"); @@ -129,12 +129,12 @@ int main(int argc, char ** argv) memset(&msg, 0, sizeof(msg)); msg.msg_namelen = sizeof(addr); - msg.msg_name = &addr; - msg.msg_iov = &iov; - msg.msg_iovlen = 1; + msg.msg_name = &addr; + msg.msg_iov = &iov; + msg.msg_iovlen = 1; - iov.iov_base = (void *) &req; - iov.iov_len = sizeof(req); + iov.iov_base = (void *)&req; + iov.iov_len = sizeof(req); if (sendmsg(dsk, &msg, 0) < 0) { pr_perror("Can't send request message"); @@ -143,11 +143,11 @@ int main(int argc, char ** argv) memset(&msg, 0, sizeof(msg)); msg.msg_namelen = 0; - msg.msg_iov = &iov; - msg.msg_iovlen = 1; + msg.msg_iov = &iov; + msg.msg_iovlen = 1; - iov.iov_base = buf; - iov.iov_len = sizeof(buf); + iov.iov_base = buf; + iov.iov_len = sizeof(buf); if (recvmsg(ssk, &msg, 0) < 0) { pr_perror("Can't recv request message"); diff --git a/test/zdtm/static/sk-unix-dgram-ghost.c b/test/zdtm/static/sk-unix-dgram-ghost.c index a726d6a64..fdf8fb18b 100644 --- a/test/zdtm/static/sk-unix-dgram-ghost.c +++ b/test/zdtm/static/sk-unix-dgram-ghost.c @@ -1,5 +1,5 @@ #ifndef _GNU_SOURCE -# define _GNU_SOURCE +#define _GNU_SOURCE #endif #include <stdlib.h> @@ -18,8 +18,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check data of bound ghost DGRAM unix socket and possibility to connect"; -const char *test_author = "Alexander Mikhalitsyn <alexander@mihalicyn.com>"; +const char *test_doc = "Check data of bound ghost DGRAM unix socket and possibility to connect"; +const char *test_author = "Alexander Mikhalitsyn <alexander@mihalicyn.com>"; /* * PROCESS_NUM | FREEZE_FREQ @@ -41,8 +41,7 @@ static int fill_sock_name(struct sockaddr_un *name, const char *filename) cwd = get_current_dir_name(); if (strlen(filename) + strlen(cwd) + 1 >= sizeof(name->sun_path)) { - pr_err("Name %s/%s is too long for socket\n", - cwd, filename); + pr_err("Name %s/%s is too long for socket\n", cwd, filename); return -1; } @@ -67,7 +66,7 @@ static int client(int i, task_waiter_t t) return 1; } - if (connect(sk, (struct sockaddr *) &addr, sizeof(struct sockaddr_un)) < 0) { + if (connect(sk, (struct sockaddr *)&addr, sizeof(struct sockaddr_un)) < 0) { pr_perror("connect failed %d", i); return 1; } @@ -163,7 +162,7 @@ int main(int argc, char **argv) goto clean; } - if (bind(srv, (struct sockaddr *) &addr, sizeof(struct sockaddr_un))) { + if (bind(srv, (struct sockaddr *)&addr, sizeof(struct sockaddr_un))) { pr_perror("bind srv"); ret = 1; goto clean; diff --git a/test/zdtm/static/sk-unix-mntns.c b/test/zdtm/static/sk-unix-mntns.c index 46376ff50..cd37b8d02 100644 --- a/test/zdtm/static/sk-unix-mntns.c +++ b/test/zdtm/static/sk-unix-mntns.c @@ -15,8 +15,8 @@ #include "zdtmtst.h" -const char *test_doc = "Test that unix sockets are restored in proper mount namespaces\n"; -const char *test_author = "Andrei Vagin <avagin@openvz.org>"; +const char *test_doc = "Test that unix sockets are restored in proper mount namespaces\n"; +const char *test_author = "Andrei Vagin <avagin@openvz.org>"; char *dirname; TEST_OPTION(dirname, string, "socket file name", 1); @@ -87,13 +87,13 @@ int main(int argc, char *argv[]) exit(1); } - ret = bind(sk, (struct sockaddr *) &addr, addrlen); + ret = bind(sk, (struct sockaddr *)&addr, addrlen); if (ret) { fail("bind"); exit(1); } - if (connect(csk, (struct sockaddr *) &addr, addrlen)) { + if (connect(csk, (struct sockaddr *)&addr, addrlen)) { fail("connect"); exit(1); } @@ -136,7 +136,7 @@ int main(int argc, char *argv[]) pr_perror("socket"); exit(1); } - if (connect(csk, (struct sockaddr *) &addr, addrlen)) { + if (connect(csk, (struct sockaddr *)&addr, addrlen)) { pr_perror("connect"); exit(1); } diff --git a/test/zdtm/static/sk-unix-rel.c b/test/zdtm/static/sk-unix-rel.c index a62a5c92d..10c19080a 100644 --- a/test/zdtm/static/sk-unix-rel.c +++ b/test/zdtm/static/sk-unix-rel.c @@ -15,8 +15,8 @@ #include "zdtmtst.h" -const char *test_doc = "Test unix stream sockets with relative name\n"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org"; +const char *test_doc = "Test unix stream sockets with relative name\n"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org"; #define SK_DATA "packet" @@ -67,7 +67,7 @@ int main(int argc, char *argv[]) exit(1); } - ret = bind(sock[0], (struct sockaddr *) &addr, addrlen); + ret = bind(sock[0], (struct sockaddr *)&addr, addrlen); if (ret) { fail("bind"); exit(1); @@ -82,7 +82,7 @@ int main(int argc, char *argv[]) test_daemon(); test_waitsig(); - if (connect(sock[1], (struct sockaddr *) &addr, addrlen)) { + if (connect(sock[1], (struct sockaddr *)&addr, addrlen)) { fail("connect"); exit(1); } diff --git a/test/zdtm/static/sk-unix-unconn.c b/test/zdtm/static/sk-unix-unconn.c index 91e3d433b..caad3d315 100644 --- a/test/zdtm/static/sk-unix-unconn.c +++ b/test/zdtm/static/sk-unix-unconn.c @@ -6,10 +6,10 @@ #include "zdtmtst.h" -const char *test_doc = "Check unconnected unix sockets"; -const char *test_author = "Vagin Andrew <avagin@parallels.com>"; +const char *test_doc = "Check unconnected unix sockets"; +const char *test_author = "Vagin Andrew <avagin@parallels.com>"; -int main(int argc, char ** argv) +int main(int argc, char **argv) { int sk, skc; int ret, len; @@ -43,7 +43,7 @@ int main(int argc, char ** argv) addr.sun_path[0] = 0; addr.sun_path[len - 1] = 0; - ret = bind(sk, (struct sockaddr *) &addr, addrlen); + ret = bind(sk, (struct sockaddr *)&addr, addrlen); if (ret) { fail("bind"); return 1; @@ -58,7 +58,7 @@ int main(int argc, char ** argv) return 1; } - if (connect(skc, (struct sockaddr *) &addr, addrlen) == -1) { + if (connect(skc, (struct sockaddr *)&addr, addrlen) == -1) { fail("Unable to connect"); return 1; } diff --git a/test/zdtm/static/sk-unix01.c b/test/zdtm/static/sk-unix01.c index 0e9006a15..c2bb8b9ed 100644 --- a/test/zdtm/static/sk-unix01.c +++ b/test/zdtm/static/sk-unix01.c @@ -1,5 +1,5 @@ #ifndef _GNU_SOURCE -# define _GNU_SOURCE +#define _GNU_SOURCE #endif #include <stdlib.h> @@ -18,8 +18,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that deleted unix sockets with dirs are restored correctly"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; +const char *test_doc = "Check that deleted unix sockets with dirs are restored correctly"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); @@ -62,16 +62,16 @@ static int sk_alloc_connect(int type, struct sockaddr_un *addr) return sk; } -#define write_int(__f, __p) \ - ({ \ - ssize_t __r = write(__f, __p, sizeof(*(__p))); \ - (__r == sizeof(*(__p))) ? 0 : -1; \ +#define write_int(__f, __p) \ + ({ \ + ssize_t __r = write(__f, __p, sizeof(*(__p))); \ + (__r == sizeof(*(__p))) ? 0 : -1; \ }) -#define read_int(__f, __p) \ - ({ \ - ssize_t __r = read(__f, __p, sizeof(*(__p))); \ - (__r == sizeof(*(__p))) ? 0 : -1; \ +#define read_int(__f, __p) \ + ({ \ + ssize_t __r = read(__f, __p, sizeof(*(__p))); \ + (__r == sizeof(*(__p))) ? 0 : -1; \ }) int main(int argc, char **argv) @@ -215,8 +215,7 @@ int main(int argc, char **argv) pr_perror("Can't create dgram pair"); return 1; } - test_msg("sk-dgp: sockpair %d %d\n", - sk_dgram_pair[0], sk_dgram_pair[1]); + test_msg("sk-dgp: sockpair %d %d\n", sk_dgram_pair[0], sk_dgram_pair[1]); ssprintf(filename, "%s/%s", subdir_dg, "sk-dtp"); if (unix_fill_sock_name(&addr, filename)) { @@ -303,39 +302,35 @@ int main(int argc, char **argv) test_daemon(); test_waitsig(); - if (write_int(sk_dgram[1], &c1) || read_int(sk_dgram[0], &c2) || - write_int(sk_dgram[3], &c3) || read_int(sk_dgram[2], &c4)) { + if (write_int(sk_dgram[1], &c1) || read_int(sk_dgram[0], &c2) || write_int(sk_dgram[3], &c3) || + read_int(sk_dgram[2], &c4)) { fail("Unable to send/receive a message on dgram"); return 1; } if (c1 != c2 || c3 != c4) { - fail("Vals mismatch on dgram: c1 %d c2 %d c3 %d c4 %d", - c1, c2, c3, c4); + fail("Vals mismatch on dgram: c1 %d c2 %d c3 %d c4 %d", c1, c2, c3, c4); return 1; } - if (write_int(sk_dgram_pair[1], &c9) || - read_int(sk_dgram_pair[0], &c10)) { + if (write_int(sk_dgram_pair[1], &c9) || read_int(sk_dgram_pair[0], &c10)) { fail("Unable to send/receive a message on paired dgram"); return 1; } if (c9 != c10) { - fail("Vals mismatch on dgram: c9 %d c10 %d", - c9, c10); + fail("Vals mismatch on dgram: c9 %d c10 %d", c9, c10); return 1; } - if (write_int(sk_st[2], &c5) || read_int(sk_st[1], &c6) || - write_int(sk_st[4], &c7) || read_int(sk_st[3], &c8)) { + if (write_int(sk_st[2], &c5) || read_int(sk_st[1], &c6) || write_int(sk_st[4], &c7) || + read_int(sk_st[3], &c8)) { fail("Unable to send/receive a message on stream"); return 1; } if (c5 != c6 || c7 != c8) { - fail("Vals mismatch on stream: c5 %d c6 %d c7 %d c8 %d", - c5, c6, c7, c8); + fail("Vals mismatch on stream: c5 %d c6 %d c7 %d c8 %d", c5, c6, c7, c8); return 1; } diff --git a/test/zdtm/static/skip-me.c b/test/zdtm/static/skip-me.c index 9a552761e..a7f3e8d33 100644 --- a/test/zdtm/static/skip-me.c +++ b/test/zdtm/static/skip-me.c @@ -1,4 +1,4 @@ -int main(int argc, char ** argv) +int main(int argc, char **argv) { test_init(argc, argv); diff --git a/test/zdtm/static/sleeping00.c b/test/zdtm/static/sleeping00.c index f59ffaf1f..fb45ebc46 100644 --- a/test/zdtm/static/sleeping00.c +++ b/test/zdtm/static/sleeping00.c @@ -2,10 +2,10 @@ #include "zdtmtst.h" -const char *test_doc = "Suspend while migrating"; -const char *test_author = "Roman Kagan <rkagan@parallels.com>"; +const char *test_doc = "Suspend while migrating"; +const char *test_author = "Roman Kagan <rkagan@parallels.com>"; -int main(int argc, char ** argv) +int main(int argc, char **argv) { test_init(argc, argv); diff --git a/test/zdtm/static/sock_filter00.c b/test/zdtm/static/sock_filter00.c index 7c408220c..abaabc4ee 100644 --- a/test/zdtm/static/sock_filter00.c +++ b/test/zdtm/static/sock_filter00.c @@ -8,17 +8,17 @@ #include "zdtmtst.h" -const char *test_doc = "Check socket filter"; -const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; +const char *test_doc = "Check socket filter"; +const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; #ifndef SO_GET_FILTER -#define SO_GET_FILTER SO_ATTACH_FILTER +#define SO_GET_FILTER SO_ATTACH_FILTER #endif #ifdef SOCK_FILTER01 -#define SFLEN 4 +#define SFLEN 4 #else -#define SFLEN 14 +#define SFLEN 14 #endif int main(int argc, char **argv) @@ -27,27 +27,18 @@ int main(int argc, char **argv) struct sock_fprog p; #ifdef SOCK_FILTER01 struct sock_filter f[SFLEN] = { - { 0x6, 0, 0, 0x0000ffff }, - { 0x6, 0, 0, 0x0000ffff }, - { 0x6, 0, 0, 0x0000ffff }, - { 0x6, 0, 0, 0x0000ffff }, + { 0x6, 0, 0, 0x0000ffff }, + { 0x6, 0, 0, 0x0000ffff }, + { 0x6, 0, 0, 0x0000ffff }, + { 0x6, 0, 0, 0x0000ffff }, }; #else struct sock_filter f[SFLEN] = { - { 0x28, 0, 0, 0x0000000c }, - { 0x15, 0, 4, 0x00000800 }, - { 0x20, 0, 0, 0x0000001a }, - { 0x15, 8, 0, 0x7f000001 }, - { 0x20, 0, 0, 0x0000001e }, - { 0x15, 6, 7, 0x7f000001 }, - { 0x15, 1, 0, 0x00000806 }, - { 0x15, 0, 5, 0x00008035 }, - { 0x20, 0, 0, 0x0000001c }, - { 0x15, 2, 0, 0x7f000001 }, - { 0x20, 0, 0, 0x00000026 }, - { 0x15, 0, 1, 0x7f000001 }, - { 0x6, 0, 0, 0x0000ffff }, - { 0x6, 0, 0, 0x00000000 }, + { 0x28, 0, 0, 0x0000000c }, { 0x15, 0, 4, 0x00000800 }, { 0x20, 0, 0, 0x0000001a }, + { 0x15, 8, 0, 0x7f000001 }, { 0x20, 0, 0, 0x0000001e }, { 0x15, 6, 7, 0x7f000001 }, + { 0x15, 1, 0, 0x00000806 }, { 0x15, 0, 5, 0x00008035 }, { 0x20, 0, 0, 0x0000001c }, + { 0x15, 2, 0, 0x7f000001 }, { 0x20, 0, 0, 0x00000026 }, { 0x15, 0, 1, 0x7f000001 }, + { 0x6, 0, 0, 0x0000ffff }, { 0x6, 0, 0, 0x00000000 }, }; #endif struct sock_filter f2[SFLEN], f3[SFLEN]; @@ -125,4 +116,3 @@ int main(int argc, char **argv) return 0; } - diff --git a/test/zdtm/static/sock_opts00.c b/test/zdtm/static/sock_opts00.c index e02a2e7ba..5b4624f6d 100644 --- a/test/zdtm/static/sock_opts00.c +++ b/test/zdtm/static/sock_opts00.c @@ -6,15 +6,15 @@ #include "zdtmtst.h" -const char *test_doc = "Check various socket options to work"; -const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; +const char *test_doc = "Check various socket options to work"; +const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; #define TEST_PORT 59687 #define TEST_ADDR INADDR_ANY -#define NOPTS 8 +#define NOPTS 8 -int main(int argc, char ** argv) +int main(int argc, char **argv) { int sock, ret = 0, vname[NOPTS], val[NOPTS], rval, i; socklen_t len = sizeof(int); @@ -59,8 +59,7 @@ int main(int argc, char ** argv) if (rval != val[i]) { if (rval + 1 == val[i]) { - pr_perror("can't reset option %d want %d have %d", i, - val[i], rval); + pr_perror("can't reset option %d want %d have %d", i, val[i], rval); return 1; } diff --git a/test/zdtm/static/sock_opts01.c b/test/zdtm/static/sock_opts01.c index 7dfce2257..2709d8586 100644 --- a/test/zdtm/static/sock_opts01.c +++ b/test/zdtm/static/sock_opts01.c @@ -8,10 +8,10 @@ #include "zdtmtst.h" -const char *test_doc = "Check that SO_BINDTODEVICE option works"; -const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; +const char *test_doc = "Check that SO_BINDTODEVICE option works"; +const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; -int main(int argc, char ** argv) +int main(int argc, char **argv) { int sock, ret; char dev[IFNAMSIZ], dev2[IFNAMSIZ]; diff --git a/test/zdtm/static/sock_peercred.c b/test/zdtm/static/sock_peercred.c index 23c709bb5..5ebfe757a 100644 --- a/test/zdtm/static/sock_peercred.c +++ b/test/zdtm/static/sock_peercred.c @@ -12,10 +12,10 @@ #include "zdtmtst.h" #define STACK_SIZE (1024 * 1024) -#define GID_INC 1 -#define UID_INC 1 +#define GID_INC 1 +#define UID_INC 1 -const char *test_doc = "Check peercred of a unix socket remains the same"; +const char *test_doc = "Check peercred of a unix socket remains the same"; const char *test_author = "Kirill Tkhai <ktkhai@virtuozzo.com>"; static int child_func(void *fd_p) @@ -93,7 +93,7 @@ int main(int argc, char **argv) goto out; } - pid = clone(child_func, stack + STACK_SIZE, CLONE_FILES|SIGCHLD, (void *)(unsigned long)fd); + pid = clone(child_func, stack + STACK_SIZE, CLONE_FILES | SIGCHLD, (void *)(unsigned long)fd); if (pid == -1) { pr_perror("clone"); goto out; @@ -113,15 +113,14 @@ int main(int argc, char **argv) goto out; } - if (ucred.pid != pid || ucred.gid != getuid() + UID_INC || - ucred.gid != getgid() + GID_INC) { + if (ucred.pid != pid || ucred.gid != getuid() + UID_INC || ucred.gid != getgid() + GID_INC) { fail("Wrong pid, uid or gid"); goto out; } pass(); exit_code = 0; - out: +out: free(stack); return exit_code; } diff --git a/test/zdtm/static/socket-ext.c b/test/zdtm/static/socket-ext.c index 88e70559f..6ebe02b1d 100644 --- a/test/zdtm/static/socket-ext.c +++ b/test/zdtm/static/socket-ext.c @@ -14,8 +14,8 @@ #include "zdtmtst.h" -const char *test_doc = "Test external sockets\n"; -const char *test_author = "Andrey Vagin <avagin@openvz.org"; +const char *test_doc = "Test external sockets\n"; +const char *test_author = "Andrey Vagin <avagin@openvz.org"; #define SK_DATA "packet" @@ -50,8 +50,7 @@ int main(int argc, char *argv[]) } chmod(dir, 0777); addr.sun_family = AF_UNIX; - snprintf(addr.sun_path, sizeof(addr.sun_path), - "%s/%s", dir, "sock"); + snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%s", dir, "sock"); path = addr.sun_path; addrlen = sizeof(addr.sun_family) + strlen(path); @@ -70,7 +69,7 @@ int main(int argc, char *argv[]) pr_perror("Can't create socket"); return 1; } - ret = bind(sk, (struct sockaddr *) &addr, addrlen); + ret = bind(sk, (struct sockaddr *)&addr, addrlen); if (ret < 0) { pr_perror("Can't bind socket to %s", path); return 1; @@ -97,13 +96,12 @@ int main(int argc, char *argv[]) return 1; } - ret = connect(sk, (struct sockaddr *) &addr, addrlen); + ret = connect(sk, (struct sockaddr *)&addr, addrlen); if (ret < 0) { pr_perror("Can't connect socket"); return 1; } - test_daemon(); test_waitsig(); diff --git a/test/zdtm/static/socket-linger.c b/test/zdtm/static/socket-linger.c index b512745ca..ffa01f91f 100644 --- a/test/zdtm/static/socket-linger.c +++ b/test/zdtm/static/socket-linger.c @@ -5,13 +5,13 @@ #include "zdtmtst.h" -const char *test_doc = "Check SO_LINGER socket option"; -const char *test_author = "Radostin Stoyanov <rstoyanov1@gmail.com>"; +const char *test_doc = "Check SO_LINGER socket option"; +const char *test_author = "Radostin Stoyanov <rstoyanov1@gmail.com>"; int main(int argc, char **argv) { int sk; - struct linger dump = {true, 30}, restore = {0, 0}; + struct linger dump = { true, 30 }, restore = { 0, 0 }; socklen_t optlen = sizeof(restore); test_init(argc, argv); @@ -36,14 +36,12 @@ int main(int argc, char **argv) } if (restore.l_onoff != dump.l_onoff) { - fail("linger.l_onoff has incorrect value (%d != %d)", - restore.l_onoff, dump.l_onoff); + fail("linger.l_onoff has incorrect value (%d != %d)", restore.l_onoff, dump.l_onoff); return 1; } if (restore.l_linger != dump.l_linger) { - fail("linger.l_linger has incorrect value (%d != %d)", - restore.l_linger, dump.l_linger); + fail("linger.l_linger has incorrect value (%d != %d)", restore.l_linger, dump.l_linger); return 1; } diff --git a/test/zdtm/static/socket-raw.c b/test/zdtm/static/socket-raw.c index 7382bf7c4..3bcfc3db6 100644 --- a/test/zdtm/static/socket-raw.c +++ b/test/zdtm/static/socket-raw.c @@ -29,36 +29,36 @@ * http://www.binarytides.com/raw-udp-sockets-c-linux/ */ -const char *test_doc = "Test RAW sockets (IPv4,6)\n"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; +const char *test_doc = "Test RAW sockets (IPv4,6)\n"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; #ifndef SO_IP_SET -# define SO_IP_SET 83 +#define SO_IP_SET 83 #endif #ifndef IP_SET_OP_VERSION -# define IP_SET_OP_VERSION 0x00000100 /* Ask kernel version */ +#define IP_SET_OP_VERSION 0x00000100 /* Ask kernel version */ #endif -#define pr_debug(format, arg...) test_msg("DBG: %s:%d: " format, __FILE__, __LINE__, ## arg) +#define pr_debug(format, arg...) test_msg("DBG: %s:%d: " format, __FILE__, __LINE__, ##arg) struct ip_set_req_version { - unsigned int op; - unsigned int version; + unsigned int op; + unsigned int version; }; struct pseudo_header { - uint32_t source_address; - uint32_t dest_address; - uint8_t placeholder; - uint8_t protocol; - uint16_t udp_length; + uint32_t source_address; + uint32_t dest_address; + uint8_t placeholder; + uint8_t protocol; + uint16_t udp_length; }; static int stop_icmp(int sk_icmp, int sk_icmpv6) { - struct icmp6_filter filter6 = { }; - struct icmp_filter filter = { }; + struct icmp6_filter filter6 = {}; + struct icmp_filter filter = {}; socklen_t aux; int ret = 0; @@ -70,8 +70,7 @@ static int stop_icmp(int sk_icmp, int sk_icmpv6) } if (filter.data != (1 << ICMP_TIMESTAMP)) { - pr_err("data mismatch on icmp filter %d != %d\n", - filter.data, (1 << ICMP_TIMESTAMP)); + pr_err("data mismatch on icmp filter %d != %d\n", filter.data, (1 << ICMP_TIMESTAMP)); return -1; } @@ -83,27 +82,25 @@ static int stop_icmp(int sk_icmp, int sk_icmpv6) } if (filter6.data[0] != (1 << ICMP_TIMESTAMP)) { - pr_err("data mismatch on icmp filter %d != %d\n", - filter6.data[0], (1 << ICMP_TIMESTAMP)); + pr_err("data mismatch on icmp filter %d != %d\n", filter6.data[0], (1 << ICMP_TIMESTAMP)); return -1; } return ret; } -static int start_icmp(int sk_icmp, int sk_icmpv6, - const char *a4, const char *a6, int port) +static int start_icmp(int sk_icmp, int sk_icmpv6, const char *a4, const char *a6, int port) { struct sockaddr_in addr_client; - struct icmp6_filter filter6 = { }; - struct icmp_filter filter = { }; + struct icmp6_filter filter6 = {}; + struct icmp_filter filter = {}; int ret = 0; memset(&addr_client, 0, sizeof(addr_client)); - addr_client.sin_family = AF_INET; - addr_client.sin_port = htons(port); - addr_client.sin_addr.s_addr = inet_addr(a4); + addr_client.sin_family = AF_INET; + addr_client.sin_port = htons(port); + addr_client.sin_addr.s_addr = inet_addr(a4); ret = bind(sk_icmp, (struct sockaddr *)&addr_client, sizeof(addr_client)); if (ret < 0) { @@ -164,7 +161,6 @@ static void raw_socks_storm(void) int sk6[IPPROTO_MAX]; size_t i; - for (i = 1; i < ARRAY_SIZE(sk4); i++) { sk4[i] = socket(PF_INET, SOCK_RAW | SOCK_NONBLOCK, i); if (sk4[i] >= 0) @@ -265,13 +261,13 @@ int main(int argc, char *argv[]) memset(&addr_serv, 0, sizeof(addr_serv)); memset(&addr_client, 0, sizeof(addr_client)); - addr_client.sin_family = AF_INET; - addr_client.sin_port = htons(port_client); - addr_client.sin_addr.s_addr = inet_addr(string_client_ip); + addr_client.sin_family = AF_INET; + addr_client.sin_port = htons(port_client); + addr_client.sin_addr.s_addr = inet_addr(string_client_ip); - addr_serv.sin_family = AF_INET; - addr_serv.sin_port = htons(port_serv); - addr_serv.sin_addr.s_addr = inet_addr(string_serv_ip); + addr_serv.sin_family = AF_INET; + addr_serv.sin_port = htons(port_serv); + addr_serv.sin_addr.s_addr = inet_addr(string_serv_ip); ret = bind(sk_udp_serv, (struct sockaddr *)&addr_serv, sizeof(addr_serv)); if (ret < 0) { @@ -287,36 +283,35 @@ int main(int argc, char *argv[]) } pr_debug("Bound sk_udp\n"); - if (start_icmp(sk_icmp, sk_icmpv6, string_client_icmp_ip, - string_client_icmpv6_ip, port_client)) + if (start_icmp(sk_icmp, sk_icmpv6, string_client_icmp_ip, string_client_icmpv6_ip, port_client)) return 1; data = datagram + sizeof(struct iphdr) + sizeof(struct udphdr); strcpy(data, string_data); - iph->ihl = 5; - iph->version = 4; - iph->tos = 0; - iph->tot_len = sizeof(struct iphdr) + sizeof(struct udphdr) + strlen(string_data); - iph->id = htonl(54321); - iph->frag_off = 0; - iph->ttl = 255; - iph->protocol = IPPROTO_UDP; - iph->check = 0; - iph->saddr = inet_addr(string_client_ip); - iph->daddr = addr_serv.sin_addr.s_addr; - iph->check = csum((unsigned short *)datagram, sizeof(struct iphdr)); - - udph->source = htons(port_client); - udph->dest = htons(port_serv); - udph->len = htons(8 + strlen(data)); - udph->check = 0; - - psh.source_address = inet_addr(string_client_ip); - psh.dest_address = addr_serv.sin_addr.s_addr; - psh.placeholder = 0; - psh.protocol = IPPROTO_UDP; - psh.udp_length = htons(sizeof(struct udphdr) + strlen(string_data)); + iph->ihl = 5; + iph->version = 4; + iph->tos = 0; + iph->tot_len = sizeof(struct iphdr) + sizeof(struct udphdr) + strlen(string_data); + iph->id = htonl(54321); + iph->frag_off = 0; + iph->ttl = 255; + iph->protocol = IPPROTO_UDP; + iph->check = 0; + iph->saddr = inet_addr(string_client_ip); + iph->daddr = addr_serv.sin_addr.s_addr; + iph->check = csum((unsigned short *)datagram, sizeof(struct iphdr)); + + udph->source = htons(port_client); + udph->dest = htons(port_serv); + udph->len = htons(8 + strlen(data)); + udph->check = 0; + + psh.source_address = inet_addr(string_client_ip); + psh.dest_address = addr_serv.sin_addr.s_addr; + psh.placeholder = 0; + psh.protocol = IPPROTO_UDP; + psh.udp_length = htons(sizeof(struct udphdr) + strlen(string_data)); psize = sizeof(psh) + sizeof(struct udphdr) + strlen(string_data); pseudogram = malloc(psize); @@ -325,7 +320,7 @@ int main(int argc, char *argv[]) exit(1); } - memcpy(pseudogram, (char *)&psh , sizeof(psh)); + memcpy(pseudogram, (char *)&psh, sizeof(psh)); memcpy(pseudogram + sizeof(psh), udph, sizeof(*udph) + strlen(string_data)); udph->check = csum((unsigned short *)pseudogram, psize); @@ -340,8 +335,7 @@ int main(int argc, char *argv[]) if (pid == 0) { task_waiter_wait4(&waiter, 2); pr_debug("Gonna read data\n"); - ret = recvfrom(sk_udp_serv, receiver, sizeof(receiver), 0, - (struct sockaddr *)&addr_client, &len); + ret = recvfrom(sk_udp_serv, receiver, sizeof(receiver), 0, (struct sockaddr *)&addr_client, &len); if (ret < 0) { task_waiter_complete(&waiter, 2); fail("Can't read data"); @@ -353,8 +347,7 @@ int main(int argc, char *argv[]) task_waiter_complete(&waiter, 3); if (strcmp(receiver, string_data)) { - pr_err("Data mismatch (got %s but expected %s)\n", - receiver, string_data); + pr_err("Data mismatch (got %s but expected %s)\n", receiver, string_data); exit(1); } else pr_debug("Data match\n"); @@ -369,8 +362,7 @@ int main(int argc, char *argv[]) test_daemon(); test_waitsig(); - if (sendto(sk_udp, datagram, iph->tot_len, 0, - (struct sockaddr *)&addr_serv, sizeof(addr_serv)) < 0) { + if (sendto(sk_udp, datagram, iph->tot_len, 0, (struct sockaddr *)&addr_serv, sizeof(addr_serv)) < 0) { kill(pid, SIGKILL); fail("Can't send RAW data"); exit(1); diff --git a/test/zdtm/static/socket-tcp-close-wait.c b/test/zdtm/static/socket-tcp-close-wait.c index 152dcf31f..6e5ccdbeb 100644 --- a/test/zdtm/static/socket-tcp-close-wait.c +++ b/test/zdtm/static/socket-tcp-close-wait.c @@ -1,13 +1,13 @@ #include "zdtmtst.h" #ifdef ZDTM_IPV4V6 -#define ZDTM_FAMILY AF_INET +#define ZDTM_FAMILY AF_INET #define ZDTM_SRV_FAMILY AF_INET6 #elif defined(ZDTM_IPV6) -#define ZDTM_FAMILY AF_INET6 +#define ZDTM_FAMILY AF_INET6 #define ZDTM_SRV_FAMILY AF_INET6 #else -#define ZDTM_FAMILY AF_INET +#define ZDTM_FAMILY AF_INET #define ZDTM_SRV_FAMILY AF_INET #endif @@ -169,8 +169,7 @@ int main(int argc, char **argv) if (size < 0) return 1; #else - if (read(fd, buf, sizeof(buf)) != sizeof(TEST_MSG) || - strncmp(buf, TEST_MSG, sizeof(TEST_MSG))) { + if (read(fd, buf, sizeof(buf)) != sizeof(TEST_MSG) || strncmp(buf, TEST_MSG, sizeof(TEST_MSG))) { pr_perror("read"); return 1; } diff --git a/test/zdtm/static/socket-tcp-close0.c b/test/zdtm/static/socket-tcp-close0.c index 270965cbd..96ac2b38a 100644 --- a/test/zdtm/static/socket-tcp-close0.c +++ b/test/zdtm/static/socket-tcp-close0.c @@ -18,7 +18,7 @@ static int check_socket_closed(int sk) { int err, buffer = 0; struct { - __u8 tcpi_state; + __u8 tcpi_state; } info; socklen_t len = sizeof(info); struct pollfd pollfd = {}; diff --git a/test/zdtm/static/socket-tcp-close1.c b/test/zdtm/static/socket-tcp-close1.c index 49a34a6ef..d5e473bee 100644 --- a/test/zdtm/static/socket-tcp-close1.c +++ b/test/zdtm/static/socket-tcp-close1.c @@ -15,7 +15,7 @@ static int check_socket_state(int sk, int state) { int err; struct { - __u8 tcpi_state; + __u8 tcpi_state; } info; socklen_t len = sizeof(info); diff --git a/test/zdtm/static/socket-tcp-closed.c b/test/zdtm/static/socket-tcp-closed.c index e8fc25c56..f9516357c 100644 --- a/test/zdtm/static/socket-tcp-closed.c +++ b/test/zdtm/static/socket-tcp-closed.c @@ -1,13 +1,13 @@ #include "zdtmtst.h" #ifdef ZDTM_IPV4V6 -#define ZDTM_FAMILY AF_INET +#define ZDTM_FAMILY AF_INET #define ZDTM_SRV_FAMILY AF_INET6 #elif defined(ZDTM_IPV6) -#define ZDTM_FAMILY AF_INET6 +#define ZDTM_FAMILY AF_INET6 #define ZDTM_SRV_FAMILY AF_INET6 #else -#define ZDTM_FAMILY AF_INET +#define ZDTM_FAMILY AF_INET #define ZDTM_SRV_FAMILY AF_INET #endif diff --git a/test/zdtm/static/socket-tcp-closing.c b/test/zdtm/static/socket-tcp-closing.c index 84ff6be9d..87e1d7533 100644 --- a/test/zdtm/static/socket-tcp-closing.c +++ b/test/zdtm/static/socket-tcp-closing.c @@ -1,13 +1,13 @@ #include "zdtmtst.h" #ifdef ZDTM_IPV4V6 -#define ZDTM_FAMILY AF_INET +#define ZDTM_FAMILY AF_INET #define ZDTM_SRV_FAMILY AF_INET6 #elif defined(ZDTM_IPV6) -#define ZDTM_FAMILY AF_INET6 +#define ZDTM_FAMILY AF_INET6 #define ZDTM_SRV_FAMILY AF_INET6 #else -#define ZDTM_FAMILY AF_INET +#define ZDTM_FAMILY AF_INET #define ZDTM_SRV_FAMILY AF_INET #endif diff --git a/test/zdtm/static/socket-tcp-fin-wait1.c b/test/zdtm/static/socket-tcp-fin-wait1.c index 4bc7b3238..9b8488904 100644 --- a/test/zdtm/static/socket-tcp-fin-wait1.c +++ b/test/zdtm/static/socket-tcp-fin-wait1.c @@ -1,13 +1,13 @@ #include "zdtmtst.h" #ifdef ZDTM_IPV4V6 -#define ZDTM_FAMILY AF_INET +#define ZDTM_FAMILY AF_INET #define ZDTM_SRV_FAMILY AF_INET6 #elif defined(ZDTM_IPV6) -#define ZDTM_FAMILY AF_INET6 +#define ZDTM_FAMILY AF_INET6 #define ZDTM_SRV_FAMILY AF_INET6 #else -#define ZDTM_FAMILY AF_INET +#define ZDTM_FAMILY AF_INET #define ZDTM_SRV_FAMILY AF_INET #endif @@ -202,7 +202,6 @@ int main(int argc, char **argv) return 1; } - test_daemon(); test_waitsig(); @@ -211,8 +210,7 @@ int main(int argc, char **argv) return 1; } - if (recv(fd, buf, sizeof(buf), MSG_WAITALL) != sizeof(TEST_MSG) || - strncmp(buf, TEST_MSG, sizeof(TEST_MSG))) { + if (recv(fd, buf, sizeof(buf), MSG_WAITALL) != sizeof(TEST_MSG) || strncmp(buf, TEST_MSG, sizeof(TEST_MSG))) { pr_perror("recv: expected %s, got %s", TEST_MSG, buf); return 1; } diff --git a/test/zdtm/static/socket-tcp-listen.c b/test/zdtm/static/socket-tcp-listen.c index 52d21d894..da3dcb8cf 100644 --- a/test/zdtm/static/socket-tcp-listen.c +++ b/test/zdtm/static/socket-tcp-listen.c @@ -1,13 +1,13 @@ #include "zdtmtst.h" #ifdef ZDTM_IPV4V6 -#define ZDTM_FAMILY AF_INET +#define ZDTM_FAMILY AF_INET #define ZDTM_SRV_FAMILY AF_INET6 #elif defined(ZDTM_IPV6) -#define ZDTM_FAMILY AF_INET6 +#define ZDTM_FAMILY AF_INET6 #define ZDTM_SRV_FAMILY AF_INET6 #else -#define ZDTM_FAMILY AF_INET +#define ZDTM_FAMILY AF_INET #define ZDTM_SRV_FAMILY AF_INET #endif @@ -65,7 +65,6 @@ int main(int argc, char **argv) int val; socklen_t optlen; - test_init(argc, argv); if ((fd_s = tcp_init_server(ZDTM_SRV_FAMILY, &port)) < 0) { @@ -87,7 +86,7 @@ int main(int argc, char **argv) test_waitsig(); clt = tcp_init_client_with_fd(clt, ZDTM_FAMILY, "localhost", port); - if (clt < 0) + if (clt < 0) return 1; /* diff --git a/test/zdtm/static/socket-tcp-reseted.c b/test/zdtm/static/socket-tcp-reseted.c index 07ad36009..ad382e38e 100644 --- a/test/zdtm/static/socket-tcp-reseted.c +++ b/test/zdtm/static/socket-tcp-reseted.c @@ -2,19 +2,19 @@ #include "zdtmtst.h" #include <string.h> #include <sys/socket.h> -#include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */ +#include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */ #include <stdlib.h> #include <sys/wait.h> #include <signal.h> #ifdef ZDTM_IPV4V6 -#define ZDTM_FAMILY AF_INET +#define ZDTM_FAMILY AF_INET #define ZDTM_SRV_FAMILY AF_INET6 #elif defined(ZDTM_IPV6) -#define ZDTM_FAMILY AF_INET6 +#define ZDTM_FAMILY AF_INET6 #define ZDTM_SRV_FAMILY AF_INET6 #else -#define ZDTM_FAMILY AF_INET +#define ZDTM_FAMILY AF_INET #define ZDTM_SRV_FAMILY AF_INET #endif @@ -46,11 +46,10 @@ int main(int argc, char **argv) return 1; } - clt = tcp_init_client(ZDTM_FAMILY, "localhost", port); if (clt < 0) { pr_perror("Unable to create a client socket"); - return 1; + return 1; } /* @@ -65,7 +64,8 @@ int main(int argc, char **argv) pr_perror("Unable to write into a socket"); return 1; } - snprintf(cmd, sizeof(cmd), "iptables -w -t filter --protocol tcp -A INPUT --dport %d -j REJECT --reject-with tcp-reset", port); + snprintf(cmd, sizeof(cmd), + "iptables -w -t filter --protocol tcp -A INPUT --dport %d -j REJECT --reject-with tcp-reset", port); if (system(cmd)) return 1; @@ -74,7 +74,8 @@ int main(int argc, char **argv) return 1; } - snprintf(cmd, sizeof(cmd), "iptables -w -t filter --protocol tcp -D INPUT --dport %d -j REJECT --reject-with tcp-reset", port); + snprintf(cmd, sizeof(cmd), + "iptables -w -t filter --protocol tcp -D INPUT --dport %d -j REJECT --reject-with tcp-reset", port); if (system(cmd)) return 1; diff --git a/test/zdtm/static/socket-tcp-reuseport.c b/test/zdtm/static/socket-tcp-reuseport.c index a085ab503..25e0493d4 100644 --- a/test/zdtm/static/socket-tcp-reuseport.c +++ b/test/zdtm/static/socket-tcp-reuseport.c @@ -19,7 +19,7 @@ const char *test_author = "Andrey Vagin <avagin@parallels.com"; #include <sched.h> #include <netinet/tcp.h> #include <sys/socket.h> -#include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */ +#include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */ #define BUF_SIZE 4096 @@ -54,9 +54,7 @@ int write_data(int fd, const unsigned char *buf, int size) int main(int argc, char **argv) { - struct zdtm_tcp_opts opts = { .reuseaddr = false, - .reuseport = true, - .flags = SOCK_NONBLOCK}; + struct zdtm_tcp_opts opts = { .reuseaddr = false, .reuseport = true, .flags = SOCK_NONBLOCK }; unsigned char buf[BUF_SIZE]; int port = 8880, port2; int fd, fd_s, fd_s2, clt, i; @@ -79,12 +77,11 @@ int main(int argc, char **argv) if (port != port2) return 1; - if (setsockopt(fd_s, SOL_SOCKET, SO_REUSEPORT, &no, sizeof(int)) == -1 ) { + if (setsockopt(fd_s, SOL_SOCKET, SO_REUSEPORT, &no, sizeof(int)) == -1) { pr_perror("Unable to set SO_REUSEPORT"); return -1; } - clt = tcp_init_client(ZDTM_FAMILY, "localhost", port); if (clt < 0) return 1; @@ -103,7 +100,6 @@ int main(int argc, char **argv) test_daemon(); test_waitsig(); - optlen = sizeof(val); if (getsockopt(fd_s, SOL_SOCKET, SO_REUSEPORT, &val, &optlen)) { pr_perror("getsockopt"); @@ -123,7 +119,7 @@ int main(int argc, char **argv) return 1; } - for (i = 0; ; i++) { + for (i = 0;; i++) { crc = 0; datagen(buf, BUF_SIZE, &crc); if (write_data(fd, buf, BUF_SIZE)) { diff --git a/test/zdtm/static/socket-tcp-skip-in-flight.c b/test/zdtm/static/socket-tcp-skip-in-flight.c index 99ca03ac5..51d74d2ce 100644 --- a/test/zdtm/static/socket-tcp-skip-in-flight.c +++ b/test/zdtm/static/socket-tcp-skip-in-flight.c @@ -24,7 +24,6 @@ const char *test_author = "Radostin Stoyanov <rstoyanov1@gmail.com>"; #include <unistd.h> #include <fcntl.h> - int main(int argc, char **argv) { struct pollfd poll_set[1]; diff --git a/test/zdtm/static/socket-tcp-syn-sent.c b/test/zdtm/static/socket-tcp-syn-sent.c index 755532a8a..8265d5fb7 100644 --- a/test/zdtm/static/socket-tcp-syn-sent.c +++ b/test/zdtm/static/socket-tcp-syn-sent.c @@ -1,13 +1,13 @@ #include "zdtmtst.h" #ifdef ZDTM_IPV4V6 -#define ZDTM_FAMILY AF_INET +#define ZDTM_FAMILY AF_INET #define ZDTM_SRV_FAMILY AF_INET6 #elif defined(ZDTM_IPV6) -#define ZDTM_FAMILY AF_INET6 +#define ZDTM_FAMILY AF_INET6 #define ZDTM_SRV_FAMILY AF_INET6 #else -#define ZDTM_FAMILY AF_INET +#define ZDTM_FAMILY AF_INET #define ZDTM_SRV_FAMILY AF_INET #endif @@ -52,7 +52,6 @@ int main(int argc, char **argv) return 1; } - if ((sock = socket(ZDTM_FAMILY, SOCK_STREAM | SOCK_NONBLOCK, IPPROTO_TCP)) < 0) { pr_perror("can't create socket"); return -1; @@ -61,13 +60,13 @@ int main(int argc, char **argv) /* Construct the server address structure */ memset(&addr, 0, sizeof(addr)); if (ZDTM_FAMILY == AF_INET) { - addr.v4.sin_family = AF_INET; + addr.v4.sin_family = AF_INET; inet_pton(AF_INET, "localhost", &addr.v4.sin_addr); } else { - addr.v6.sin6_family = AF_INET6; + addr.v6.sin6_family = AF_INET6; inet_pton(AF_INET6, "localhost", &addr.v6.sin6_addr); } - if (bind(sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) { + if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) { pr_perror("can't connect to server"); return -1; } @@ -79,17 +78,17 @@ int main(int argc, char **argv) /* Construct the server address structure */ memset(&addr, 0, sizeof(addr)); if (ZDTM_FAMILY == AF_INET) { - addr.v4.sin_family = AF_INET; - addr.v4.sin_port = htons(port); + addr.v4.sin_family = AF_INET; + addr.v4.sin_port = htons(port); inet_pton(AF_INET, "localhost", &addr.v4.sin_addr); } else { - addr.v6.sin6_family = AF_INET6; - addr.v6.sin6_port = htons(port); + addr.v6.sin6_family = AF_INET6; + addr.v6.sin6_port = htons(port); inet_pton(AF_INET6, "localhost", &addr.v6.sin6_addr); } errno = 0; - if (connect(sock, (struct sockaddr *) &addr, sizeof(addr)) == 0 || errno != EINPROGRESS) { + if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) == 0 || errno != EINPROGRESS) { pr_perror("can't connect to server"); return -1; } @@ -137,7 +136,6 @@ int main(int argc, char **argv) return 1; } - pass(); return 0; } diff --git a/test/zdtm/static/socket-tcp-unconn.c b/test/zdtm/static/socket-tcp-unconn.c index 1b3e1a660..bfb0cdb8e 100644 --- a/test/zdtm/static/socket-tcp-unconn.c +++ b/test/zdtm/static/socket-tcp-unconn.c @@ -1,13 +1,13 @@ #include "zdtmtst.h" #ifdef ZDTM_IPV4V6 -#define ZDTM_FAMILY AF_INET +#define ZDTM_FAMILY AF_INET #define ZDTM_SRV_FAMILY AF_INET6 #elif defined(ZDTM_IPV6) -#define ZDTM_FAMILY AF_INET6 +#define ZDTM_FAMILY AF_INET6 #define ZDTM_SRV_FAMILY AF_INET6 #else -#define ZDTM_FAMILY AF_INET +#define ZDTM_FAMILY AF_INET #define ZDTM_SRV_FAMILY AF_INET #endif @@ -51,7 +51,6 @@ int main(int argc, char **argv) return 1; } - if ((sock = socket(ZDTM_FAMILY, SOCK_STREAM, IPPROTO_TCP)) < 0) { pr_perror("can't create socket"); return -1; @@ -60,13 +59,13 @@ int main(int argc, char **argv) /* Construct the server address structure */ memset(&addr, 0, sizeof(addr)); if (ZDTM_FAMILY == AF_INET) { - addr.v4.sin_family = AF_INET; + addr.v4.sin_family = AF_INET; inet_pton(AF_INET, "localhost", &addr.v4.sin_addr); } else { - addr.v6.sin6_family = AF_INET6; + addr.v6.sin6_family = AF_INET6; inet_pton(AF_INET6, "localhost", &addr.v6.sin6_addr); } - if (bind(sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) { + if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) { pr_perror("can't connect to server"); return -1; } @@ -93,15 +92,15 @@ int main(int argc, char **argv) /* Construct the server address structure */ memset(&addr, 0, sizeof(addr)); if (ZDTM_FAMILY == AF_INET) { - addr.v4.sin_family = AF_INET; - addr.v4.sin_port = htons(port); + addr.v4.sin_family = AF_INET; + addr.v4.sin_port = htons(port); inet_pton(AF_INET, "localhost", &addr.v4.sin_addr); } else { - addr.v6.sin6_family = AF_INET6; - addr.v6.sin6_port = htons(port); + addr.v6.sin6_family = AF_INET6; + addr.v6.sin6_port = htons(port); inet_pton(AF_INET6, "localhost", &addr.v6.sin6_addr); } - if (connect(sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) { + if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) { pr_perror("can't connect to server"); return -1; } @@ -116,7 +115,6 @@ int main(int argc, char **argv) } close(fd_s); - pass(); return 0; } diff --git a/test/zdtm/static/socket-tcp.c b/test/zdtm/static/socket-tcp.c index 80c2e7b3b..f6ef47385 100644 --- a/test/zdtm/static/socket-tcp.c +++ b/test/zdtm/static/socket-tcp.c @@ -1,13 +1,13 @@ #include "zdtmtst.h" #ifdef ZDTM_IPV4V6 -#define ZDTM_FAMILY AF_INET +#define ZDTM_FAMILY AF_INET #define ZDTM_SRV_FAMILY AF_INET6 #elif defined(ZDTM_IPV6) -#define ZDTM_FAMILY AF_INET6 +#define ZDTM_FAMILY AF_INET6 #define ZDTM_SRV_FAMILY AF_INET6 #else -#define ZDTM_FAMILY AF_INET +#define ZDTM_FAMILY AF_INET #define ZDTM_SRV_FAMILY AF_INET #endif diff --git a/test/zdtm/static/socket-tcpbuf.c b/test/zdtm/static/socket-tcpbuf.c index fbb4043f1..0ed69c09a 100644 --- a/test/zdtm/static/socket-tcpbuf.c +++ b/test/zdtm/static/socket-tcpbuf.c @@ -22,7 +22,7 @@ const char *test_author = "Andrey Vagin <avagin@parallels.com"; static int port = 8880; -#define BUF_SIZE 4096 +#define BUF_SIZE 4096 #define TCP_MAX_BUF (100 << 20) static void read_safe(int fd, void *buf, size_t size) @@ -236,15 +236,13 @@ int main(int argc, char **argv) } sk_bsize = TCP_MAX_BUF; - if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, - &sk_bsize, sizeof(sk_bsize)) == -1) { + if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &sk_bsize, sizeof(sk_bsize)) == -1) { pr_perror("Can't set snd buf"); return 1; } sk_bsize = TCP_MAX_BUF; - if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, - &sk_bsize, sizeof(sk_bsize)) == -1) { + if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &sk_bsize, sizeof(sk_bsize)) == -1) { pr_perror("Can't set snd buf"); return 1; } diff --git a/test/zdtm/static/socket6_udp.c b/test/zdtm/static/socket6_udp.c index b81a6afee..15f1239c0 100644 --- a/test/zdtm/static/socket6_udp.c +++ b/test/zdtm/static/socket6_udp.c @@ -12,7 +12,7 @@ const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>\n"; #include <errno.h> #include <stdlib.h> #include <sys/socket.h> -#include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */ +#include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */ #include <sys/wait.h> static int port = 8880; @@ -54,7 +54,7 @@ int main(int argc, char **argv) memset(&addr2, 0, sizeof(addr2)); addr2.sin6_family = AF_INET6; - addr2.sin6_port = htons(port+1); + addr2.sin6_port = htons(port + 1); inet_pton(AF_INET6, "::1", &addr2.sin6_addr); ret = bind(sk2, (struct sockaddr *)&addr2, len); @@ -72,8 +72,7 @@ int main(int argc, char **argv) test_daemon(); test_waitsig(); - ret = sendto(sk1, MSG1, sizeof(MSG1), 0, - (struct sockaddr *)&addr2, len); + ret = sendto(sk1, MSG1, sizeof(MSG1), 0, (struct sockaddr *)&addr2, len); if (ret < 0) { fail("Can't send"); return 1; @@ -85,8 +84,7 @@ int main(int argc, char **argv) return 1; } - ret = recvfrom(sk1, buf, sizeof(buf), 0, - (struct sockaddr *)&addr, &len); + ret = recvfrom(sk1, buf, sizeof(buf), 0, (struct sockaddr *)&addr, &len); if (ret <= 0) { fail("Can't recv C"); return 1; @@ -102,8 +100,7 @@ int main(int argc, char **argv) return 1; } - ret = recvfrom(sk2, buf, sizeof(buf), 0, - (struct sockaddr *)&addr, &len); + ret = recvfrom(sk2, buf, sizeof(buf), 0, (struct sockaddr *)&addr, &len); if (ret <= 0) { fail("Can't recv"); return 1; diff --git a/test/zdtm/static/socket_aio.c b/test/zdtm/static/socket_aio.c index 1dcdfec42..a545483e1 100644 --- a/test/zdtm/static/socket_aio.c +++ b/test/zdtm/static/socket_aio.c @@ -31,7 +31,7 @@ int main(int argc, char **argv) int status; pid_t pid; int ret, res; - const struct aiocb *aioary[1]; + const struct aiocb *aioary[1]; task_waiter_t child_waiter; test_init(argc, argv); @@ -77,7 +77,7 @@ int main(int argc, char **argv) test_msg("."); #endif res = 0; -again: + again: if (aio_suspend(aioary, 1, NULL) < 0 && errno != EINTR) { pr_perror("aio_suspend failed"); res = 1; @@ -125,7 +125,6 @@ again: } close(fd); - if (wait(&status) < 0) { pr_perror("wait failed"); goto error; diff --git a/test/zdtm/static/socket_close_data.c b/test/zdtm/static/socket_close_data.c index de552ada9..301896443 100644 --- a/test/zdtm/static/socket_close_data.c +++ b/test/zdtm/static/socket_close_data.c @@ -6,8 +6,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check one end of socketpair with data"; -const char *test_author = "Andrew Vagin <avagin@openvz.org"; +const char *test_doc = "Check one end of socketpair with data"; +const char *test_author = "Andrew Vagin <avagin@openvz.org"; #define MSG "hello" int main(int argc, char **argv) diff --git a/test/zdtm/static/socket_close_data01.c b/test/zdtm/static/socket_close_data01.c index df4b894b2..7ffbd7f21 100644 --- a/test/zdtm/static/socket_close_data01.c +++ b/test/zdtm/static/socket_close_data01.c @@ -9,8 +9,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check data of bound socket and possibility to connect"; -const char *test_author = "Kirill Tkhai <ktkhai@virtuozzo"; +const char *test_doc = "Check data of bound socket and possibility to connect"; +const char *test_author = "Kirill Tkhai <ktkhai@virtuozzo"; #define MSG "hello" char *filename; @@ -30,7 +30,7 @@ static int client(const char *iter) addr.sun_family = AF_UNIX; strcpy(addr.sun_path, filename); - if (connect(sk, (struct sockaddr *) &addr, sizeof(struct sockaddr_un)) < 0) { + if (connect(sk, (struct sockaddr *)&addr, sizeof(struct sockaddr_un)) < 0) { pr_perror("connect failed %s", iter); return 1; } @@ -60,7 +60,7 @@ int main(int argc, char **argv) addr.sun_family = AF_UNIX; strcpy(addr.sun_path, filename); - if (bind(srv, (struct sockaddr *) &addr, sizeof(struct sockaddr_un))) { + if (bind(srv, (struct sockaddr *)&addr, sizeof(struct sockaddr_un))) { pr_perror("bind srv"); exit(1); } diff --git a/test/zdtm/static/socket_dgram_data.c b/test/zdtm/static/socket_dgram_data.c index 0f29af0ad..d555050a4 100644 --- a/test/zdtm/static/socket_dgram_data.c +++ b/test/zdtm/static/socket_dgram_data.c @@ -7,8 +7,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that data in dgram socket are restored correctly"; -const char *test_author = "Andrew Vagin <avagin@openvz.org"; +const char *test_doc = "Check that data in dgram socket are restored correctly"; +const char *test_author = "Andrew Vagin <avagin@openvz.org"; #define SK_SRV "\0socket_dgram_srv" @@ -42,15 +42,15 @@ int main(int argc, char **argv) memcpy(addr.sun_path, SK_SRV, sizeof(SK_SRV)); addrlen = sizeof(addr.sun_family) + sizeof(SK_SRV); - if (bind(srv, (struct sockaddr *) &addr, addrlen)) { + if (bind(srv, (struct sockaddr *)&addr, addrlen)) { fail("bind"); exit(1); } - if (connect(clnt1, (struct sockaddr *) &addr, addrlen)) { + if (connect(clnt1, (struct sockaddr *)&addr, addrlen)) { fail("connect"); exit(1); } - if (connect(clnt2, (struct sockaddr *) &addr, addrlen)) { + if (connect(clnt2, (struct sockaddr *)&addr, addrlen)) { fail("connect"); exit(1); } diff --git a/test/zdtm/static/socket_listen.c b/test/zdtm/static/socket_listen.c index a4d3e66bd..519107d01 100644 --- a/test/zdtm/static/socket_listen.c +++ b/test/zdtm/static/socket_listen.c @@ -1,13 +1,13 @@ #include "zdtmtst.h" #ifdef ZDTM_IPV4V6 -#define ZDTM_FAMILY AF_INET +#define ZDTM_FAMILY AF_INET #define ZDTM_SRV_FAMILY AF_INET6 #elif defined(ZDTM_IPV6) -#define ZDTM_FAMILY AF_INET6 +#define ZDTM_FAMILY AF_INET6 #define ZDTM_SRV_FAMILY AF_INET6 #else -#define ZDTM_FAMILY AF_INET +#define ZDTM_FAMILY AF_INET #define ZDTM_SRV_FAMILY AF_INET #endif @@ -31,7 +31,9 @@ static int port = 8880; #define BUF_SIZE 1024 -static void sig_hand(int signo) {} +static void sig_hand(int signo) +{ +} int main(int argc, char **argv) { @@ -42,7 +44,7 @@ int main(int argc, char **argv) int res; uint32_t crc; struct sigaction sa = { - .sa_handler = sig_hand, + .sa_handler = sig_hand, /* don't set SA_RESTART */ }; @@ -103,7 +105,6 @@ int main(int argc, char **argv) } close(fd); - if (wait(&status) < 0) { pr_perror("wait failed"); goto error; diff --git a/test/zdtm/static/socket_queues.c b/test/zdtm/static/socket_queues.c index 86e052db7..e30bca0e1 100644 --- a/test/zdtm/static/socket_queues.c +++ b/test/zdtm/static/socket_queues.c @@ -16,8 +16,8 @@ /* FIXME Need gram sockets tests */ -const char *test_doc = "Test unix sockets queues (2 messages in queue)\n"; -const char *test_author = "Stanislav Kinsbursky <skinsbursky@parallels.com>\n"; +const char *test_doc = "Test unix sockets queues (2 messages in queue)\n"; +const char *test_author = "Stanislav Kinsbursky <skinsbursky@parallels.com>\n"; #define SK_DATA_S1 "packet stream left" #define SK_DATA_S2 "packet stream right" @@ -96,7 +96,7 @@ int main(int argc, char *argv[]) fail("data corrupted"); exit(1); } - read(ssk_pair_d[0], buf_right,strlen(SK_DATA_D1) + 1); + read(ssk_pair_d[0], buf_right, strlen(SK_DATA_D1) + 1); if (strcmp(buf_right, SK_DATA_D1)) { fail("data corrupted"); exit(1); diff --git a/test/zdtm/static/socket_snd_addr.c b/test/zdtm/static/socket_snd_addr.c index 89a0a1762..a78af3a70 100644 --- a/test/zdtm/static/socket_snd_addr.c +++ b/test/zdtm/static/socket_snd_addr.c @@ -7,16 +7,16 @@ #include "zdtmtst.h" -const char *test_doc = "Check that sender addresses are restored"; -const char *test_author = "Andrew Vagin <avagin@openvz.org"; +const char *test_doc = "Check that sender addresses are restored"; +const char *test_author = "Andrew Vagin <avagin@openvz.org"; -#define SK_SRV "\0socket_snd_srv" +#define SK_SRV "\0socket_snd_srv" #define SK_NAME "\0A-socket_snd_clnt" char sk_names[2][128] = { - SK_NAME, - SK_NAME, - }; + SK_NAME, + SK_NAME, +}; #define MSG "hello" int main(int argc, char **argv) @@ -26,15 +26,15 @@ int main(int argc, char **argv) int srv, clnt = -1, ret, i; char buf[1024]; struct iovec iov = { - .iov_base = &buf, - .iov_len = sizeof(buf), - }; + .iov_base = &buf, + .iov_len = sizeof(buf), + }; struct msghdr hdr = { - .msg_name = &addr, - .msg_namelen = sizeof(addr), - .msg_iov = &iov, - .msg_iovlen = 1, - }; + .msg_name = &addr, + .msg_namelen = sizeof(addr), + .msg_iov = &iov, + .msg_iovlen = 1, + }; test_init(argc, argv); @@ -44,7 +44,7 @@ int main(int argc, char **argv) memcpy(addr.sun_path, SK_SRV, sizeof(SK_SRV)); addrlen = sizeof(addr.sun_family) + sizeof(SK_SRV); - if (bind(srv, (struct sockaddr *) &addr, addrlen)) { + if (bind(srv, (struct sockaddr *)&addr, addrlen)) { fail("bind"); exit(1); } @@ -58,14 +58,14 @@ int main(int argc, char **argv) memcpy(addr.sun_path, sk_names[i], sizeof(SK_NAME)); addrlen = sizeof(addr.sun_family) + sizeof(SK_NAME); - if (bind(clnt, (struct sockaddr *) &addr, addrlen)) { + if (bind(clnt, (struct sockaddr *)&addr, addrlen)) { fail("bind"); exit(1); } memcpy(addr.sun_path, SK_SRV, sizeof(SK_SRV)); addrlen = sizeof(addr.sun_family) + sizeof(SK_SRV); - if (connect(clnt, (struct sockaddr *) &addr, addrlen)) { + if (connect(clnt, (struct sockaddr *)&addr, addrlen)) { fail("connect"); exit(1); } diff --git a/test/zdtm/static/socket_udp-corked.c b/test/zdtm/static/socket_udp-corked.c index 540b9456a..f502ec7ea 100644 --- a/test/zdtm/static/socket_udp-corked.c +++ b/test/zdtm/static/socket_udp-corked.c @@ -17,7 +17,7 @@ const char *test_author = "Pavel Emelyanov <xemul@parallels.com<>\n"; #include <errno.h> #include <stdlib.h> #include <sys/socket.h> -#include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */ +#include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */ #include <sys/wait.h> #include <netinet/udp.h> @@ -70,7 +70,6 @@ int main(int argc, char **argv) test_daemon(); test_waitsig(); - pass(); return 0; } diff --git a/test/zdtm/static/socket_udp.c b/test/zdtm/static/socket_udp.c index cce29fc96..c38bcb6fd 100644 --- a/test/zdtm/static/socket_udp.c +++ b/test/zdtm/static/socket_udp.c @@ -17,7 +17,7 @@ const char *test_author = "Pavel Emelyanov <xemul@parallels.com<>\n"; #include <errno.h> #include <stdlib.h> #include <sys/socket.h> -#include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */ +#include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */ #include <sys/wait.h> static int port = 8880; @@ -77,8 +77,7 @@ int main(int argc, char **argv) test_daemon(); test_waitsig(); - ret = sendto(sk1, MSG1, sizeof(MSG1), 0, - (struct sockaddr *)&addr2, len); + ret = sendto(sk1, MSG1, sizeof(MSG1), 0, (struct sockaddr *)&addr2, len); if (ret < 0) { fail("Can't send"); return 1; @@ -90,8 +89,7 @@ int main(int argc, char **argv) return 1; } - ret = recvfrom(sk1, buf, sizeof(buf), 0, - (struct sockaddr *)&addr, &len); + ret = recvfrom(sk1, buf, sizeof(buf), 0, (struct sockaddr *)&addr, &len); if (ret <= 0) { fail("Can't recv C"); return 1; @@ -107,8 +105,7 @@ int main(int argc, char **argv) return 1; } - ret = recvfrom(sk2, buf, sizeof(buf), 0, - (struct sockaddr *)&addr, &len); + ret = recvfrom(sk2, buf, sizeof(buf), 0, (struct sockaddr *)&addr, &len); if (ret <= 0) { fail("Can't recv"); return 1; diff --git a/test/zdtm/static/socket_udp_shutdown.c b/test/zdtm/static/socket_udp_shutdown.c index 5d65348ea..91dc8f30a 100644 --- a/test/zdtm/static/socket_udp_shutdown.c +++ b/test/zdtm/static/socket_udp_shutdown.c @@ -7,13 +7,13 @@ #include <errno.h> #include <stdlib.h> #include <sys/socket.h> -#include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */ +#include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */ #include <sys/wait.h> #include "zdtmtst.h" -const char *test_doc = "static test for UDP shutdown'ed socket"; -const char *test_author = "Cyrill Gorcunov <gorcunov@virtuozzo.com>"; +const char *test_doc = "static test for UDP shutdown'ed socket"; +const char *test_author = "Cyrill Gorcunov <gorcunov@virtuozzo.com>"; static int port = 8881; @@ -39,41 +39,36 @@ int main(int argc, char **argv) memset(&addr1, 0, sizeof(addr1)); memset(&addr2, 0, sizeof(addr1)); - addr1.sin_family = AF_INET; - addr1.sin_addr.s_addr = inet_addr("127.0.0.10"); - addr1.sin_port = htons(port); + addr1.sin_family = AF_INET; + addr1.sin_addr.s_addr = inet_addr("127.0.0.10"); + addr1.sin_port = htons(port); - addr2.sin_family = AF_INET; - addr2.sin_addr.s_addr = inet_addr("127.0.0.10"); - addr2.sin_port = htons(port + 1); + addr2.sin_family = AF_INET; + addr2.sin_addr.s_addr = inet_addr("127.0.0.10"); + addr2.sin_port = htons(port + 1); - if (bind(sk1, (struct sockaddr *)&addr1, len) < 0 || - bind(sk2, (struct sockaddr *)&addr2, len) < 0) { + if (bind(sk1, (struct sockaddr *)&addr1, len) < 0 || bind(sk2, (struct sockaddr *)&addr2, len) < 0) { pr_perror("Can't bind socket"); return 1; } - if (connect(sk1, (struct sockaddr *)&addr2, len) || - connect(sk2, (struct sockaddr *)&addr1, len)) { + if (connect(sk1, (struct sockaddr *)&addr2, len) || connect(sk2, (struct sockaddr *)&addr1, len)) { pr_perror("Can't connect"); return 1; } - if (shutdown(sk1, SHUT_WR) || - shutdown(sk2, SHUT_RD)) { + if (shutdown(sk1, SHUT_WR) || shutdown(sk2, SHUT_RD)) { pr_perror("Can't shutdown"); return 1; } - ret = sendto(sk2, MSG1, sizeof(MSG1), 0, - (struct sockaddr *)&addr1, len); + ret = sendto(sk2, MSG1, sizeof(MSG1), 0, (struct sockaddr *)&addr1, len); if (ret < 0) { pr_perror("Can't send"); return 1; } - ret = recvfrom(sk1, buf, sizeof(buf), 0, - (struct sockaddr *)&addr, &len); + ret = recvfrom(sk1, buf, sizeof(buf), 0, (struct sockaddr *)&addr, &len); if (ret <= 0) { pr_perror("Can't receive data"); return 1; @@ -92,15 +87,13 @@ int main(int argc, char **argv) test_daemon(); test_waitsig(); - ret = sendto(sk2, MSG1, sizeof(MSG1), 0, - (struct sockaddr *)&addr1, len); + ret = sendto(sk2, MSG1, sizeof(MSG1), 0, (struct sockaddr *)&addr1, len); if (ret < 0) { pr_perror("Can't send"); return 1; } - ret = recvfrom(sk1, buf, sizeof(buf), 0, - (struct sockaddr *)&addr, &len); + ret = recvfrom(sk1, buf, sizeof(buf), 0, (struct sockaddr *)&addr, &len); if (ret <= 0) { pr_perror("Can't receive data"); return 1; @@ -116,8 +109,7 @@ int main(int argc, char **argv) return 1; } - ret = sendto(sk1, MSG1, sizeof(MSG1), 0, - (struct sockaddr *)&addr2, len); + ret = sendto(sk1, MSG1, sizeof(MSG1), 0, (struct sockaddr *)&addr2, len); if (ret >= 0) { fail("Sent to write-shutdown'ed socket"); return 1; diff --git a/test/zdtm/static/socket_udplite.c b/test/zdtm/static/socket_udplite.c index 763df319b..886317455 100644 --- a/test/zdtm/static/socket_udplite.c +++ b/test/zdtm/static/socket_udplite.c @@ -17,7 +17,7 @@ const char *test_author = "Pavel Emelyanov <xemul@parallels.com<>\n"; #include <errno.h> #include <stdlib.h> #include <sys/socket.h> -#include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */ +#include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */ #include <sys/wait.h> static int port = 8890; @@ -133,8 +133,7 @@ int main(int argc, char **argv) test_daemon(); test_waitsig(); - ret = sendto(sk1, MSG1, sizeof(MSG1), 0, - (struct sockaddr *)&addr2, len); + ret = sendto(sk1, MSG1, sizeof(MSG1), 0, (struct sockaddr *)&addr2, len); if (ret < 0) { fail("Can't send"); return 1; @@ -146,8 +145,7 @@ int main(int argc, char **argv) return 1; } - ret = recvfrom(sk1, buf, sizeof(buf), 0, - (struct sockaddr *)&addr, &len); + ret = recvfrom(sk1, buf, sizeof(buf), 0, (struct sockaddr *)&addr, &len); if (ret <= 0) { fail("Can't recv C"); return 1; @@ -163,8 +161,7 @@ int main(int argc, char **argv) return 1; } - ret = recvfrom(sk2, buf, sizeof(buf), 0, - (struct sockaddr *)&addr, &len); + ret = recvfrom(sk2, buf, sizeof(buf), 0, (struct sockaddr *)&addr, &len); if (ret <= 0) { fail("Can't recv"); return 1; diff --git a/test/zdtm/static/sockets00.c b/test/zdtm/static/sockets00.c index 4aa8ae098..53890077b 100644 --- a/test/zdtm/static/sockets00.c +++ b/test/zdtm/static/sockets00.c @@ -15,8 +15,8 @@ #include "zdtmtst.h" -const char *test_doc = "Test unix stream sockets\n"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org"; +const char *test_doc = "Test unix stream sockets\n"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org"; #define SK_DATA "packet" @@ -66,7 +66,7 @@ int main(int argc, char *argv[]) exit(1); } - ret = bind(ssk_icon[0], (struct sockaddr *) &addr, addrlen); + ret = bind(ssk_icon[0], (struct sockaddr *)&addr, addrlen); if (ret) { fail("bind"); exit(1); @@ -90,7 +90,7 @@ int main(int argc, char *argv[]) exit(1); } - ret = connect(ssk_icon[2], (struct sockaddr *) &addr, addrlen); + ret = connect(ssk_icon[2], (struct sockaddr *)&addr, addrlen); if (ret) { fail("connect"); exit(1); @@ -102,7 +102,7 @@ int main(int argc, char *argv[]) exit(1); } - ret = connect(ssk_icon[1], (struct sockaddr *) &addr, addrlen); + ret = connect(ssk_icon[1], (struct sockaddr *)&addr, addrlen); if (ret) { fail("connect"); exit(1); @@ -124,14 +124,12 @@ int main(int argc, char *argv[]) } if (st_b.st_mode != st_a.st_mode) { - fail("The file permissions for %s were changed %o %o", - path, st_b.st_mode, st_a.st_mode); + fail("The file permissions for %s were changed %o %o", path, st_b.st_mode, st_a.st_mode); exit(1); } if (st_b.st_uid != uid || st_b.st_gid != gid) { - fail("Owner user or group for %s corrupted, uid=%d, gid=%d", - path, st_b.st_uid, st_b.st_gid); + fail("Owner user or group for %s corrupted, uid=%d, gid=%d", path, st_b.st_uid, st_b.st_gid); exit(1); } diff --git a/test/zdtm/static/sockets01.c b/test/zdtm/static/sockets01.c index 12650536f..e35a31fec 100644 --- a/test/zdtm/static/sockets01.c +++ b/test/zdtm/static/sockets01.c @@ -13,13 +13,21 @@ #include "zdtmtst.h" -const char *test_doc = "Test unix sockets shutdown"; -const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; - -#define fin(msg) do { pr_perror(msg); exit(1); } while (0) -#define ffin(msg) do { fail(msg); exit(1); } while (0) - -#define TEST_MSG "test-message" +const char *test_doc = "Test unix sockets shutdown"; +const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; + +#define fin(msg) \ + do { \ + pr_perror(msg); \ + exit(1); \ + } while (0) +#define ffin(msg) \ + do { \ + fail(msg); \ + exit(1); \ + } while (0) + +#define TEST_MSG "test-message" static char buf[sizeof(TEST_MSG)]; int main(int argc, char *argv[]) diff --git a/test/zdtm/static/sockets02.c b/test/zdtm/static/sockets02.c index a227c88ae..2729ade2c 100644 --- a/test/zdtm/static/sockets02.c +++ b/test/zdtm/static/sockets02.c @@ -13,8 +13,8 @@ #include "zdtmtst.h" -const char *test_doc = "Test semi-closed unix stream connection\n"; -const char *test_author = "Pavel Emelyanov <xemul@parallels.com>\n"; +const char *test_doc = "Test semi-closed unix stream connection\n"; +const char *test_author = "Pavel Emelyanov <xemul@parallels.com>\n"; int main(int argc, char *argv[]) { diff --git a/test/zdtm/static/sockets03.c b/test/zdtm/static/sockets03.c index cbc46ca27..cd6f60831 100644 --- a/test/zdtm/static/sockets03.c +++ b/test/zdtm/static/sockets03.c @@ -14,8 +14,8 @@ #include "zdtmtst.h" -const char *test_doc = "Test unix stream sockets with mismatch in shutdown state\n"; -const char *test_author = "Andrey Ryabinin <aryabinin@virtuozzo.com>"; +const char *test_doc = "Test unix stream sockets with mismatch in shutdown state\n"; +const char *test_author = "Andrey Ryabinin <aryabinin@virtuozzo.com>"; #define SK_DATA "packet" @@ -59,7 +59,7 @@ int main(int argc, char *argv[]) exit(1); } - ret = bind(sk[0], (struct sockaddr *) &addr, addrlen); + ret = bind(sk[0], (struct sockaddr *)&addr, addrlen); if (ret) { fail("bind"); exit(1); @@ -77,7 +77,7 @@ int main(int argc, char *argv[]) exit(1); } - ret = connect(sk[1], (struct sockaddr *) &addr, addrlen); + ret = connect(sk[1], (struct sockaddr *)&addr, addrlen); if (ret) { fail("connect"); exit(1); diff --git a/test/zdtm/static/sockets_dgram.c b/test/zdtm/static/sockets_dgram.c index 35ee88244..e88b43f89 100644 --- a/test/zdtm/static/sockets_dgram.c +++ b/test/zdtm/static/sockets_dgram.c @@ -13,12 +13,12 @@ #include "zdtmtst.h" -const char *test_doc = "Test unix dgram sockets\n"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org"; +const char *test_doc = "Test unix dgram sockets\n"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org"; -#define SK_DATA_BOUND "data-packet-bound" -#define SK_DATA_CONN "data-packet-conn" -#define SK_DATA_BOUND_CONN "data-packet-bound-conn" +#define SK_DATA_BOUND "data-packet-bound" +#define SK_DATA_CONN "data-packet-conn" +#define SK_DATA_BOUND_CONN "data-packet-bound-conn" char *filename; TEST_OPTION(filename, string, "socket file name", 1); @@ -55,19 +55,15 @@ int main(int argc, char *argv[]) snprintf(path, sizeof(path), "%s/%s", dirname, filename); unlink(path); - sk_dgram_bound_client = socket(AF_UNIX, SOCK_DGRAM, 0); - sk_dgram_bound_server = socket(AF_UNIX, SOCK_DGRAM, 0); - sk_dgram_conn_client = socket(AF_UNIX, SOCK_DGRAM, 0); - sk_dgram_conn_client2 = socket(AF_UNIX, SOCK_DGRAM, 0); - sk_dgram_conn_server = socket(AF_UNIX, SOCK_DGRAM, 0); - sk_dgram_bound_conn = socket(AF_UNIX, SOCK_DGRAM, 0); - - if (sk_dgram_conn_server < 0 || - sk_dgram_bound_server < 0 || - sk_dgram_conn_client < 0 || - sk_dgram_conn_client2 < 0 || - sk_dgram_conn_server < 0 || - sk_dgram_bound_conn < 0) { + sk_dgram_bound_client = socket(AF_UNIX, SOCK_DGRAM, 0); + sk_dgram_bound_server = socket(AF_UNIX, SOCK_DGRAM, 0); + sk_dgram_conn_client = socket(AF_UNIX, SOCK_DGRAM, 0); + sk_dgram_conn_client2 = socket(AF_UNIX, SOCK_DGRAM, 0); + sk_dgram_conn_server = socket(AF_UNIX, SOCK_DGRAM, 0); + sk_dgram_bound_conn = socket(AF_UNIX, SOCK_DGRAM, 0); + + if (sk_dgram_conn_server < 0 || sk_dgram_bound_server < 0 || sk_dgram_conn_client < 0 || + sk_dgram_conn_client2 < 0 || sk_dgram_conn_server < 0 || sk_dgram_bound_conn < 0) { fail("socket"); exit(1); } @@ -94,54 +90,54 @@ int main(int argc, char *argv[]) snprintf(path, sizeof(path), "%s/%s.bound-conn", dirname, filename); unlink(path); - if (strlen(path) >= sizeof(name_bound_conn.sun_path)) { - fail("too long path"); - exit(1); - } + if (strlen(path) >= sizeof(name_bound_conn.sun_path)) { + fail("too long path"); + exit(1); + } name_bound_conn.sun_family = AF_UNIX; strncpy(name_bound_conn.sun_path, path, sizeof(name_bound_conn.sun_path)); - ret = bind(sk_dgram_bound_server, (struct sockaddr *) &name_bound, sizeof(name_bound)); + ret = bind(sk_dgram_bound_server, (struct sockaddr *)&name_bound, sizeof(name_bound)); if (ret) { fail("bind"); exit(1); } - ret = bind(sk_dgram_conn_server, (struct sockaddr *) &name_conn, sizeof(name_conn)); + ret = bind(sk_dgram_conn_server, (struct sockaddr *)&name_conn, sizeof(name_conn)); if (ret) { fail("bind"); exit(1); } - ret = connect(sk_dgram_conn_client, (struct sockaddr *) &name_conn, sizeof(name_conn)); + ret = connect(sk_dgram_conn_client, (struct sockaddr *)&name_conn, sizeof(name_conn)); if (ret) { fail("connect"); exit(1); } - ret = connect(sk_dgram_conn_client2, (struct sockaddr *) &name_conn, sizeof(name_conn)); + ret = connect(sk_dgram_conn_client2, (struct sockaddr *)&name_conn, sizeof(name_conn)); if (ret) { fail("connect"); exit(1); } - ret = bind(sk_dgram_bound_conn, (struct sockaddr *) &name_bound_conn, sizeof(name_bound_conn)); + ret = bind(sk_dgram_bound_conn, (struct sockaddr *)&name_bound_conn, sizeof(name_bound_conn)); if (ret) { fail("bind"); exit(1); } /* Note, it's already bound, so make it more idiotic! */ - ret = connect(sk_dgram_bound_conn, (struct sockaddr *) &name_bound_conn, sizeof(name_bound_conn)); + ret = connect(sk_dgram_bound_conn, (struct sockaddr *)&name_bound_conn, sizeof(name_bound_conn)); if (ret) { fail("connect"); exit(1); } memset(buf, 0, sizeof(buf)); - sendto(sk_dgram_bound_client, SK_DATA_BOUND, sizeof(SK_DATA_BOUND), 0, - (struct sockaddr *) &name_bound, sizeof(name_bound)); + sendto(sk_dgram_bound_client, SK_DATA_BOUND, sizeof(SK_DATA_BOUND), 0, (struct sockaddr *)&name_bound, + sizeof(name_bound)); read(sk_dgram_bound_server, &buf, sizeof(buf)); if (strcmp(buf, SK_DATA_BOUND)) { fail("data corrupted"); @@ -171,8 +167,8 @@ int main(int argc, char *argv[]) test_waitsig(); memset(buf, 0, sizeof(buf)); - sendto(sk_dgram_bound_client, SK_DATA_BOUND, sizeof(SK_DATA_BOUND), 0, - (struct sockaddr *) &name_bound, sizeof(name_bound)); + sendto(sk_dgram_bound_client, SK_DATA_BOUND, sizeof(SK_DATA_BOUND), 0, (struct sockaddr *)&name_bound, + sizeof(name_bound)); read(sk_dgram_bound_server, &buf, sizeof(buf)); if (strcmp(buf, SK_DATA_BOUND)) { fail("data corrupted"); diff --git a/test/zdtm/static/sockets_spair.c b/test/zdtm/static/sockets_spair.c index a67cdb312..2dbb132aa 100644 --- a/test/zdtm/static/sockets_spair.c +++ b/test/zdtm/static/sockets_spair.c @@ -13,8 +13,8 @@ #include "zdtmtst.h" -const char *test_doc = "Test unix stream socketpair\n"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org"; +const char *test_doc = "Test unix stream socketpair\n"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org"; #define SK_DATA "packet" diff --git a/test/zdtm/static/sse00.c b/test/zdtm/static/sse00.c index c2d601948..737f40f21 100644 --- a/test/zdtm/static/sse00.c +++ b/test/zdtm/static/sse00.c @@ -3,40 +3,31 @@ #include "zdtmtst.h" -const char *test_doc = "Start a calculation, leaving SSE in a certain state,\n" - "before migration, continue after"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Start a calculation, leaving SSE in a certain state,\n" + "before migration, continue after"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; #if defined(__i386__) || defined(__x86_64__) void start(float *in) { - __asm__ volatile ( - "movaps %0, %%xmm0\n" - "movaps %1, %%xmm1\n" - "addps %%xmm0, %%xmm1\n" - "sqrtps %%xmm1, %%xmm2\n" - : - : "m" (in[0]), "m" (in[4]) - ); + __asm__ volatile("movaps %0, %%xmm0\n" + "movaps %1, %%xmm1\n" + "addps %%xmm0, %%xmm1\n" + "sqrtps %%xmm1, %%xmm2\n" + : + : "m"(in[0]), "m"(in[4])); } void finish(float *out) { - __asm__ volatile ( - "movaps %%xmm1, %0\n" - "movaps %%xmm2, %1\n" - : "=m" (out[0]), "=m" (out[4]) - ); + __asm__ volatile("movaps %%xmm1, %0\n" + "movaps %%xmm2, %1\n" + : "=m"(out[0]), "=m"(out[4])); } static inline void cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx) { - __asm__("cpuid" - : "=a" (*eax), - "=b" (*ebx), - "=c" (*ecx), - "=d" (*edx) - : "0" (op), "c"(0)); + __asm__("cpuid" : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx) : "0"(op), "c"(0)); } int chk_proc_sse(void) @@ -77,7 +68,7 @@ int main(int argc, char **argv) finish(res2); - if (memcmp((uint8_t *) res1, (uint8_t *) res2, sizeof(res1))) + if (memcmp((uint8_t *)res1, (uint8_t *)res2, sizeof(res1))) fail("results differ"); else pass(); diff --git a/test/zdtm/static/sse20.c b/test/zdtm/static/sse20.c index 1958eedfa..bfe3a37b2 100644 --- a/test/zdtm/static/sse20.c +++ b/test/zdtm/static/sse20.c @@ -3,40 +3,31 @@ #include "zdtmtst.h" -const char *test_doc = "Start a calculation, leaving SSE2 in a certain state,\n" - "before migration, continue after"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Start a calculation, leaving SSE2 in a certain state,\n" + "before migration, continue after"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; #if defined(__i386__) || defined(__x86_64__) void start(double *in) { - __asm__ volatile ( - "movapd %0, %%xmm0\n" - "movapd %1, %%xmm1\n" - "addpd %%xmm0, %%xmm1\n" - "sqrtpd %%xmm1, %%xmm2\n" - : - : "m" (in[0]), "m" (in[2]) - ); + __asm__ volatile("movapd %0, %%xmm0\n" + "movapd %1, %%xmm1\n" + "addpd %%xmm0, %%xmm1\n" + "sqrtpd %%xmm1, %%xmm2\n" + : + : "m"(in[0]), "m"(in[2])); } void finish(double *out) { - __asm__ volatile ( - "movapd %%xmm1, %0\n" - "movapd %%xmm2, %1\n" - : "=m" (out[0]), "=m" (out[2]) - ); + __asm__ volatile("movapd %%xmm1, %0\n" + "movapd %%xmm2, %1\n" + : "=m"(out[0]), "=m"(out[2])); } static inline void cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx) { - __asm__("cpuid" - : "=a" (*eax), - "=b" (*ebx), - "=c" (*ecx), - "=d" (*edx) - : "0" (op), "c"(0)); + __asm__("cpuid" : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx) : "0"(op), "c"(0)); } int chk_proc_sse2(void) @@ -77,7 +68,7 @@ int main(int argc, char **argv) finish(res2); - if (memcmp((uint8_t *) res1, (uint8_t *) res2, sizeof(res1))) + if (memcmp((uint8_t *)res1, (uint8_t *)res2, sizeof(res1))) fail("results differ"); else pass(); diff --git a/test/zdtm/static/stopped.c b/test/zdtm/static/stopped.c index 9bb849363..059a2a92a 100644 --- a/test/zdtm/static/stopped.c +++ b/test/zdtm/static/stopped.c @@ -7,8 +7,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check, that stopped tasts are restored correctly"; -const char *test_author = "Andrew Vagin <avagin@parallels.com>"; +const char *test_doc = "Check, that stopped tasts are restored correctly"; +const char *test_author = "Andrew Vagin <avagin@parallels.com>"; int main(int argc, char **argv) { @@ -66,7 +66,7 @@ int main(int argc, char **argv) if (WIFSTOPPED(status)) test_msg("The procces stopped\n"); - else{ + else { fail("The process doesn't stopped"); goto out; } diff --git a/test/zdtm/static/symlink.c b/test/zdtm/static/symlink.c index 074c80052..fb34db3a7 100644 --- a/test/zdtm/static/symlink.c +++ b/test/zdtm/static/symlink.c @@ -7,11 +7,11 @@ #include "zdtmtst.h" -#define TEST_FILE "test_file" +#define TEST_FILE "test_file" #define TEST_SYMLINK "test_symlink" -const char *test_doc = "Check open symlink preserved"; -const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; +const char *test_doc = "Check open symlink preserved"; +const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); diff --git a/test/zdtm/static/tempfs.c b/test/zdtm/static/tempfs.c index 8a103be6d..e03576e2b 100644 --- a/test/zdtm/static/tempfs.c +++ b/test/zdtm/static/tempfs.c @@ -8,14 +8,14 @@ #include "zdtmtst.h" -const char *test_doc = "Check tmpfs mount"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check tmpfs mount"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); -#define TEST_WORD "testtest" -#define TEST_WORD2 "TESTTEST" +#define TEST_WORD "testtest" +#define TEST_WORD2 "TESTTEST" int main(int argc, char **argv) { diff --git a/test/zdtm/static/tempfs_overmounted.c b/test/zdtm/static/tempfs_overmounted.c index ed329bf99..41577e19d 100644 --- a/test/zdtm/static/tempfs_overmounted.c +++ b/test/zdtm/static/tempfs_overmounted.c @@ -8,8 +8,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check tmpfs mount"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check tmpfs mount"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); diff --git a/test/zdtm/static/tempfs_overmounted01.c b/test/zdtm/static/tempfs_overmounted01.c index 5a7250903..c0ecba5d5 100644 --- a/test/zdtm/static/tempfs_overmounted01.c +++ b/test/zdtm/static/tempfs_overmounted01.c @@ -10,8 +10,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check how file systems are dumped if some mount points are overmounted"; -const char *test_author = "Andrei Vagin <avagin@gmail.com>"; +const char *test_doc = "Check how file systems are dumped if some mount points are overmounted"; +const char *test_author = "Andrei Vagin <avagin@gmail.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); @@ -50,8 +50,7 @@ int main(int argc, char **argv) /* Create a chain when a parent mount is overmounted */ mkdir("a", 0700); mkdir("b", 0700); - if (mount("zdtm1", "a", "tmpfs", 0, "") || - mount("a", "b", NULL, MS_BIND, "")) { + if (mount("zdtm1", "a", "tmpfs", 0, "") || mount("a", "b", NULL, MS_BIND, "")) { pr_perror("Can't mount tmpfs"); return 1; } @@ -75,8 +74,7 @@ int main(int argc, char **argv) } mkdir("b/b", 0700); mkdir("b/b/z", 0700); - if (mount("b", "b/b", NULL, MS_BIND, NULL) || - mount("b/b/b", "b/b", NULL, MS_BIND, NULL)) { + if (mount("b", "b/b", NULL, MS_BIND, NULL) || mount("b/b/b", "b/b", NULL, MS_BIND, NULL)) { pr_perror("can't mount tmpfs"); return 1; } @@ -88,8 +86,7 @@ int main(int argc, char **argv) pr_perror("umount"); return 1; } - if (umount2("b/b", MNT_DETACH) || - umount2("b/b", MNT_DETACH)) { + if (umount2("b/b", MNT_DETACH) || umount2("b/b", MNT_DETACH)) { pr_perror("umount"); return 1; } diff --git a/test/zdtm/static/tempfs_ro.c b/test/zdtm/static/tempfs_ro.c index f30ae8dc5..4c823d8fd 100644 --- a/test/zdtm/static/tempfs_ro.c +++ b/test/zdtm/static/tempfs_ro.c @@ -8,13 +8,13 @@ #include "zdtmtst.h" -const char *test_doc = "Check read-only tmpfs mount"; -const char *test_author = "Andrew Vagin <avagin@openvz.org>"; +const char *test_doc = "Check read-only tmpfs mount"; +const char *test_author = "Andrew Vagin <avagin@openvz.org>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); -#define TEST_WORD "testtest" +#define TEST_WORD "testtest" int main(int argc, char **argv) { @@ -50,7 +50,6 @@ int main(int argc, char **argv) test_daemon(); test_waitsig(); - fd = open(fname, O_RDONLY); if (fd < 0) { pr_perror("open failed"); diff --git a/test/zdtm/static/tempfs_ro02.c b/test/zdtm/static/tempfs_ro02.c index 7b70b866e..d313aff86 100644 --- a/test/zdtm/static/tempfs_ro02.c +++ b/test/zdtm/static/tempfs_ro02.c @@ -8,13 +8,13 @@ #include "zdtmtst.h" -const char *test_doc = "Check read-only tmpfs mount"; -const char *test_author = "Andrew Vagin <avagin@openvz.org>"; +const char *test_doc = "Check read-only tmpfs mount"; +const char *test_author = "Andrew Vagin <avagin@openvz.org>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); -#define TEST_WORD "testtest" +#define TEST_WORD "testtest" int main(int argc, char **argv) { @@ -34,7 +34,6 @@ int main(int argc, char **argv) test_daemon(); test_waitsig(); - fd = open(fname, O_RDWR | O_CREAT, 0777); if (fd >= 0 || errno != EROFS) { pr_perror("open failed -> %d", fd); diff --git a/test/zdtm/static/tempfs_subns.c b/test/zdtm/static/tempfs_subns.c index 610f427d7..ed3ef9a3a 100644 --- a/test/zdtm/static/tempfs_subns.c +++ b/test/zdtm/static/tempfs_subns.c @@ -10,8 +10,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check tmpfs in a non-root mntns"; -const char *test_author = "Andrew Vagin <avagin@virtuozzo.com"; +const char *test_doc = "Check tmpfs in a non-root mntns"; +const char *test_author = "Andrew Vagin <avagin@virtuozzo.com"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); diff --git a/test/zdtm/static/thp_disable.c b/test/zdtm/static/thp_disable.c index a809caaff..ab88120c2 100644 --- a/test/zdtm/static/thp_disable.c +++ b/test/zdtm/static/thp_disable.c @@ -4,11 +4,11 @@ #include "get_smaps_bits.h" #ifndef MADV_DONTDUMP -#define MADV_DONTDUMP 16 +#define MADV_DONTDUMP 16 #endif -const char *test_doc = "Test prctl(THP_DISABLE) behaviour"; -const char *test_author = "Mike Rapoport <rppt@linux.ibm.com>"; +const char *test_doc = "Test prctl(THP_DISABLE) behaviour"; +const char *test_author = "Mike Rapoport <rppt@linux.ibm.com>"; #define MEM_SIZE (2 << 20) @@ -20,8 +20,7 @@ int main(int argc, char **argv) test_init(argc, argv); - area = mmap(NULL, MEM_SIZE, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + area = mmap(NULL, MEM_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (area == MAP_FAILED) { pr_perror("mmap failed"); return -1; diff --git a/test/zdtm/static/thread_different_uid_gid.c b/test/zdtm/static/thread_different_uid_gid.c index 4344654e7..3a0b6291b 100644 --- a/test/zdtm/static/thread_different_uid_gid.c +++ b/test/zdtm/static/thread_different_uid_gid.c @@ -15,16 +15,15 @@ #include "zdtmtst.h" -#define exit_group(code) \ - syscall(__NR_exit_group, code) +#define exit_group(code) syscall(__NR_exit_group, code) -const char *test_doc = "Acquire UID/GID setting caps, create thread and drop thread to non-root by changing UID/GID\n"; -const char *test_author = "Vitaly Ostrosablin <vostrosablin@virtuozzo.com>"; +const char *test_doc = "Acquire UID/GID setting caps, create thread and drop thread to non-root by changing UID/GID\n"; +const char *test_author = "Vitaly Ostrosablin <vostrosablin@virtuozzo.com>"; unsigned int gid; unsigned int uid; -pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; -pthread_cond_t cond = PTHREAD_COND_INITIALIZER; +pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; +pthread_cond_t cond = PTHREAD_COND_INITIALIZER; task_waiter_t t; int done = 0; diff --git a/test/zdtm/static/time.c b/test/zdtm/static/time.c index d37e2a8f8..3f9c4c99b 100644 --- a/test/zdtm/static/time.c +++ b/test/zdtm/static/time.c @@ -5,16 +5,15 @@ #include "zdtmtst.h" -const char *test_doc = "Check monotonic and boot clocks"; -const char *test_author = "Andrei Vagin <avagin@gmail.com"; - +const char *test_doc = "Check monotonic and boot clocks"; +const char *test_author = "Andrei Vagin <avagin@gmail.com"; #define NSEC_PER_SEC 1000000000ULL int main(int argc, char **argv) { struct timespec tss[2], ts; - int clocks[] = {CLOCK_MONOTONIC, CLOCK_BOOTTIME}; + int clocks[] = { CLOCK_MONOTONIC, CLOCK_BOOTTIME }; unsigned long long a, b; int i; diff --git a/test/zdtm/static/timens_for_kids.c b/test/zdtm/static/timens_for_kids.c index 72543486b..7712147f7 100644 --- a/test/zdtm/static/timens_for_kids.c +++ b/test/zdtm/static/timens_for_kids.c @@ -9,12 +9,11 @@ #include "zdtmtst.h" -const char *test_doc = "Check nested time namespaces"; -const char *test_author = "Andrei Vagin <avagin@gmail.com"; - +const char *test_doc = "Check nested time namespaces"; +const char *test_author = "Andrei Vagin <avagin@gmail.com"; #ifndef CLONE_NEWTIME -#define CLONE_NEWTIME 0x00000080 +#define CLONE_NEWTIME 0x00000080 #endif int main(int argc, char **argv) @@ -26,7 +25,6 @@ int main(int argc, char **argv) return 1; } - test_daemon(); test_waitsig(); diff --git a/test/zdtm/static/timens_nested.c b/test/zdtm/static/timens_nested.c index 3f4b0e821..05214f6be 100644 --- a/test/zdtm/static/timens_nested.c +++ b/test/zdtm/static/timens_nested.c @@ -10,12 +10,11 @@ #include "zdtmtst.h" -const char *test_doc = "Check nested time namespaces"; -const char *test_author = "Andrei Vagin <avagin@gmail.com"; - +const char *test_doc = "Check nested time namespaces"; +const char *test_author = "Andrei Vagin <avagin@gmail.com"; #ifndef CLONE_NEWTIME -#define CLONE_NEWTIME 0x00000080 +#define CLONE_NEWTIME 0x00000080 #endif int main(int argc, char **argv) diff --git a/test/zdtm/static/timerfd.c b/test/zdtm/static/timerfd.c index 132c3acd8..a4ff9c73c 100644 --- a/test/zdtm/static/timerfd.c +++ b/test/zdtm/static/timerfd.c @@ -11,26 +11,21 @@ const char *test_doc = "Checks timerfd survives checkpoint/restore\n"; const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; -#define TIMERFD_VNSEC 50000 -#define TIMERFD_ISEC 4 +#define TIMERFD_VNSEC 50000 +#define TIMERFD_ISEC 4 struct timerfd_status { - int clockid; - uint64_t ticks; - int settime_flags; - struct itimerspec v; + int clockid; + uint64_t ticks; + int settime_flags; + struct itimerspec v; }; static void show_timerfd(char *prefix, struct timerfd_status *s) { - test_msg("\t%s clockid %d ticks %llu settime_flags %d it_value(%llu, %llu) it_interval(%llu, %llu)\n", - prefix, - s->clockid, - (unsigned long long)s->ticks, - s->settime_flags, - (unsigned long long)s->v.it_value.tv_sec, - (unsigned long long)s->v.it_value.tv_nsec, - (unsigned long long)s->v.it_interval.tv_sec, + test_msg("\t%s clockid %d ticks %llu settime_flags %d it_value(%llu, %llu) it_interval(%llu, %llu)\n", prefix, + s->clockid, (unsigned long long)s->ticks, s->settime_flags, (unsigned long long)s->v.it_value.tv_sec, + (unsigned long long)s->v.it_value.tv_nsec, (unsigned long long)s->v.it_interval.tv_sec, (unsigned long long)s->v.it_interval.tv_nsec); } @@ -58,7 +53,7 @@ static int parse_self_fdinfo(int fd, struct timerfd_status *s) */ while (fgets(buf, sizeof(buf), f)) { if (strncmp(buf, "clockid:", 8)) - continue; + continue; if (sscanf(buf, "clockid: %d", &s->clockid) != 1) goto parse_err; @@ -75,15 +70,13 @@ static int parse_self_fdinfo(int fd, struct timerfd_status *s) if (!fgets(buf, sizeof(buf), f)) goto parse_err; - if (sscanf(buf, "it_value: (%llu, %llu)", - (unsigned long long *)&s->v.it_value.tv_sec, + if (sscanf(buf, "it_value: (%llu, %llu)", (unsigned long long *)&s->v.it_value.tv_sec, (unsigned long long *)&s->v.it_value.tv_nsec) != 2) goto parse_err; if (!fgets(buf, sizeof(buf), f)) goto parse_err; - if (sscanf(buf, "it_interval: (%llu, %llu)", - (unsigned long long *)&s->v.it_interval.tv_sec, + if (sscanf(buf, "it_interval: (%llu, %llu)", (unsigned long long *)&s->v.it_interval.tv_sec, (unsigned long long *)&s->v.it_interval.tv_nsec) != 2) goto parse_err; @@ -110,11 +103,8 @@ static int check_timerfd(int fd, struct timerfd_status *old) return -1; show_timerfd("restored", &new); - if (old->clockid != new.clockid || - old->settime_flags != new.settime_flags || - old->ticks > new.ticks || - old->v.it_value.tv_sec > new.v.it_value.tv_sec || - old->v.it_interval.tv_sec != new.v.it_interval.tv_sec) + if (old->clockid != new.clockid || old->settime_flags != new.settime_flags || old->ticks > new.ticks || + old->v.it_value.tv_sec > new.v.it_value.tv_sec || old->v.it_interval.tv_sec != new.v.it_interval.tv_sec) return -1; return 0; diff --git a/test/zdtm/static/timers.c b/test/zdtm/static/timers.c index 256a5c1be..e5f7f2a02 100644 --- a/test/zdtm/static/timers.c +++ b/test/zdtm/static/timers.c @@ -11,14 +11,15 @@ static struct { const int timer_type; const int signal; volatile sig_atomic_t count; -} timer_tests[] = { /* from slowest to fastest */ - { ITIMER_VIRTUAL, SIGVTALRM }, - { ITIMER_PROF, SIGPROF }, - { ITIMER_REAL, SIGALRM }, +} timer_tests[] = { + /* from slowest to fastest */ + { ITIMER_VIRTUAL, SIGVTALRM }, + { ITIMER_PROF, SIGPROF }, + { ITIMER_REAL, SIGALRM }, }; #define NUM_TIMERS (sizeof(timer_tests) / sizeof(timer_tests[0])) -#define MAX_TIMER_COUNT 10 +#define MAX_TIMER_COUNT 10 static void timer_tick(int sig) { @@ -36,14 +37,8 @@ static void setup_timers(void) { int i; struct itimerval tv = { - .it_interval = { - .tv_sec = 0, - .tv_usec = 100000 - }, - .it_value = { - .tv_sec = 0, - .tv_usec = 100 - }, + .it_interval = { .tv_sec = 0, .tv_usec = 100000 }, + .it_value = { .tv_sec = 0, .tv_usec = 100 }, }; for (i = 0; i < NUM_TIMERS; i++) { @@ -62,14 +57,15 @@ static void setup_timers(void) static void check_timers(void) { int i; - volatile unsigned int j; /* avoid optimizing the loop away */ + volatile unsigned int j; /* avoid optimizing the loop away */ - for (i = 0; i < NUM_TIMERS; i++) /* reset counters first */ + for (i = 0; i < NUM_TIMERS; i++) /* reset counters first */ timer_tests[i].count = 0; /* waste some real and CPU time: run for MAX_TIMER_COUNT ticks or until * j overflows */ - for (j = 1; j && timer_tests[0].count < MAX_TIMER_COUNT; j++); + for (j = 1; j && timer_tests[0].count < MAX_TIMER_COUNT; j++) + ; for (i = 0; i < NUM_TIMERS; i++) if (!timer_tests[i].count) { diff --git a/test/zdtm/static/tty00.c b/test/zdtm/static/tty00.c index 473650cdd..080f8d4b0 100644 --- a/test/zdtm/static/tty00.c +++ b/test/zdtm/static/tty00.c @@ -10,8 +10,8 @@ #include <termios.h> #include <sys/ioctl.h> -const char *test_doc = "Check that a control terminal is restored"; -const char *test_author = "Andrey Vagin <avagin@openvz.org>"; +const char *test_doc = "Check that a control terminal is restored"; +const char *test_author = "Andrey Vagin <avagin@openvz.org>"; static int sighup = 0; static void sighup_handler(int signo) @@ -20,7 +20,7 @@ static void sighup_handler(int signo) sighup = 1; } -int main(int argc, char ** argv) +int main(int argc, char **argv) { int fdm, fds, status; task_waiter_t t; diff --git a/test/zdtm/static/tty02.c b/test/zdtm/static/tty02.c index bac0d82be..e0ff11203 100644 --- a/test/zdtm/static/tty02.c +++ b/test/zdtm/static/tty02.c @@ -9,10 +9,10 @@ #include <termios.h> #include <sys/ioctl.h> -const char *test_doc = "Check a non-controling terminal"; -const char *test_author = "Andrey Vagin <avagin@openvz.org>"; +const char *test_doc = "Check a non-controling terminal"; +const char *test_author = "Andrey Vagin <avagin@openvz.org>"; -int main(int argc, char ** argv) +int main(int argc, char **argv) { int fdm, fds; char *slavename; diff --git a/test/zdtm/static/tty03.c b/test/zdtm/static/tty03.c index a582f1031..6abd1e61a 100644 --- a/test/zdtm/static/tty03.c +++ b/test/zdtm/static/tty03.c @@ -9,10 +9,10 @@ #include <termios.h> #include <sys/ioctl.h> -const char *test_doc = "Check a controlling terminal, if a proper fd belongs to another session leader"; -const char *test_author = "Andrey Vagin <avagin@openvz.org>"; +const char *test_doc = "Check a controlling terminal, if a proper fd belongs to another session leader"; +const char *test_author = "Andrey Vagin <avagin@openvz.org>"; -int main(int argc, char ** argv) +int main(int argc, char **argv) { int fdm, fds, exit_code = 1, status; task_waiter_t t; diff --git a/test/zdtm/static/tun.c b/test/zdtm/static/tun.c index f6bfeb91b..85c504c5d 100644 --- a/test/zdtm/static/tun.c +++ b/test/zdtm/static/tun.c @@ -9,19 +9,19 @@ #include "zdtmtst.h" -const char *test_doc = "Test TUN/TAP devices\n"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Test TUN/TAP devices\n"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; -#define TUN_DEVICE "/dev/net/tun" +#define TUN_DEVICE "/dev/net/tun" #ifndef IFF_MULTI_QUEUE -#define IFF_MULTI_QUEUE 0x0100 +#define IFF_MULTI_QUEUE 0x0100 #define IFF_ATTACH_QUEUE 0x0200 #define IFF_DETACH_QUEUE 0x0400 -#define IFF_PERSIST 0x0800 +#define IFF_PERSIST 0x0800 #endif #ifndef TUNSETQUEUE -#define TUNSETQUEUE _IOW('T', 217, int) +#define TUNSETQUEUE _IOW('T', 217, int) #endif static int any_fail = 0; @@ -39,7 +39,9 @@ static int __open_tun(void) static int set_tun_queue(int fd, const char *name, unsigned flags) { - struct ifreq ifr = { .ifr_flags = flags, }; + struct ifreq ifr = { + .ifr_flags = flags, + }; if (ioctl(fd, TUNSETQUEUE, &ifr) < 0) { pr_perror("Can't set queue on %s", name); @@ -51,9 +53,11 @@ static int set_tun_queue(int fd, const char *name, unsigned flags) static int __attach_tun(int fd, const char *name, unsigned flags) { - struct ifreq ifr = { .ifr_flags = flags, }; + struct ifreq ifr = { + .ifr_flags = flags, + }; - strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)-1); + strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name) - 1); if (ioctl(fd, TUNSETIFF, &ifr) < 0) { if (!(flags & IFF_TUN_EXCL)) @@ -77,7 +81,7 @@ static int open_tun(const char *name, unsigned flags) static void check_tun(int fd, const char *name, unsigned flags) { - struct ifreq ifr = { }; + struct ifreq ifr = {}; if (ioctl(fd, TUNGETIFF, &ifr) > 0) { any_fail = 1; @@ -97,7 +101,7 @@ static void check_tun(int fd, const char *name, unsigned flags) static int dev_get_hwaddr(int fd, const char *name, char *a) { - struct ifreq ifr = { }; + struct ifreq ifr = {}; if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) { pr_perror("Can't get hwaddr on %s", name); @@ -225,9 +229,7 @@ int main(int argc, char **argv) pr_perror("No hwaddr for tap? (2)"); any_fail = 1; } else if (memcmp(addr, a2, sizeof(addr))) { - fail("Address mismatch on tap %x:%x -> %x:%x", - (int)addr[0], (int)addr[1], - (int)a2[0], (int)a2[1]); + fail("Address mismatch on tap %x:%x -> %x:%x", (int)addr[0], (int)addr[1], (int)a2[0], (int)a2[1]); any_fail = 1; } diff --git a/test/zdtm/static/uffd-events.c b/test/zdtm/static/uffd-events.c index 5a46d7e6d..c811bcf4c 100644 --- a/test/zdtm/static/uffd-events.c +++ b/test/zdtm/static/uffd-events.c @@ -11,11 +11,11 @@ #include <linux/limits.h> #include "zdtmtst.h" -const char *test_doc = "Test uffd events"; -const char *test_author = "Mike Rapoport <rppt@linux.vnet.ibm.com>"; +const char *test_doc = "Test uffd events"; +const char *test_author = "Mike Rapoport <rppt@linux.vnet.ibm.com>"; -#define NR_MAPS 5 -#define MAP_SIZE (1 << 20) +#define NR_MAPS 5 +#define MAP_SIZE (1 << 20) static void *map[NR_MAPS]; @@ -25,8 +25,7 @@ static int create_mappings(void) int i; for (i = 0; i < NR_MAPS; i++) { - map[i] = mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + map[i] = mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); if (map[i] == MAP_FAILED) { fail("mmap failed"); return 1; @@ -134,7 +133,7 @@ static int check_swapped_mappings(int idx) return 0; } -int main(int argc, char ** argv) +int main(int argc, char **argv) { uint32_t crc; int pid; diff --git a/test/zdtm/static/umask00.c b/test/zdtm/static/umask00.c index 5acf5a39b..9d50b98de 100644 --- a/test/zdtm/static/umask00.c +++ b/test/zdtm/static/umask00.c @@ -2,8 +2,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that umask didn't change"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check that umask didn't change"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; unsigned int mask; TEST_OPTION(mask, uint, "umask", 1); diff --git a/test/zdtm/static/unbindable.c b/test/zdtm/static/unbindable.c index 2f7b38164..6966d4181 100644 --- a/test/zdtm/static/unbindable.c +++ b/test/zdtm/static/unbindable.c @@ -6,8 +6,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check unbindable flag does not break mount restore"; -const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; +const char *test_doc = "Check unbindable flag does not break mount restore"; +const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); diff --git a/test/zdtm/static/unbound_sock.c b/test/zdtm/static/unbound_sock.c index f1d610d20..98f9a710a 100644 --- a/test/zdtm/static/unbound_sock.c +++ b/test/zdtm/static/unbound_sock.c @@ -6,19 +6,19 @@ #include "zdtmtst.h" -const char *test_doc = "Create a socket before migration, and bind to it after\n"; -const char *test_author = "Roman Kagan <rkagan@parallels.com>"; +const char *test_doc = "Create a socket before migration, and bind to it after\n"; +const char *test_author = "Roman Kagan <rkagan@parallels.com>"; #define TEST_PORT 59687 #define TEST_ADDR INADDR_ANY -int main(int argc, char ** argv) +int main(int argc, char **argv) { int sock; struct sockaddr_in name = { - .sin_family = AF_INET, - .sin_port = htons(TEST_PORT), - .sin_addr.s_addr = htonl(TEST_ADDR), + .sin_family = AF_INET, + .sin_port = htons(TEST_PORT), + .sin_addr.s_addr = htonl(TEST_ADDR), }; test_init(argc, argv); @@ -32,7 +32,7 @@ int main(int argc, char ** argv) test_daemon(); test_waitsig(); - if (bind(sock, (struct sockaddr *) &name, sizeof(name)) < 0) + if (bind(sock, (struct sockaddr *)&name, sizeof(name)) < 0) fail("can't bind to a socket"); else pass(); diff --git a/test/zdtm/static/unhashed_proc.c b/test/zdtm/static/unhashed_proc.c index 75fe881ce..c6c94803c 100644 --- a/test/zdtm/static/unhashed_proc.c +++ b/test/zdtm/static/unhashed_proc.c @@ -9,10 +9,10 @@ #include "zdtmtst.h" -const char *test_doc = "Chdir into unhashed proc entry"; -const char *test_author = "Konstantin Khlebnikov <khlebnikov@openvz.org>"; +const char *test_doc = "Chdir into unhashed proc entry"; +const char *test_author = "Konstantin Khlebnikov <khlebnikov@openvz.org>"; -int main(int argc, char ** argv) +int main(int argc, char **argv) { int pid, len; char cwd1[PATH_MAX], cwd2[PATH_MAX]; @@ -65,7 +65,7 @@ int main(int argc, char ** argv) exit(1); } - len = readlink("/proc/self/cwd", cwd2, sizeof(cwd2)-1); + len = readlink("/proc/self/cwd", cwd2, sizeof(cwd2) - 1); if (len < 0) { fail("can't read cwd symlink"); exit(1); diff --git a/test/zdtm/static/unlink_fifo.c b/test/zdtm/static/unlink_fifo.c index ff36edacf..9cddc0f53 100644 --- a/test/zdtm/static/unlink_fifo.c +++ b/test/zdtm/static/unlink_fifo.c @@ -7,9 +7,9 @@ #include "zdtmtst.h" -const char *test_doc = "Check that we can migrate with a named pipe " - "open and then unlinked"; -const char *test_author = "Roman Kagan <rkagan@parallels.com>"; +const char *test_doc = "Check that we can migrate with a named pipe " + "open and then unlinked"; +const char *test_author = "Roman Kagan <rkagan@parallels.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); diff --git a/test/zdtm/static/unlink_fifo_wronly.c b/test/zdtm/static/unlink_fifo_wronly.c index c5c4b206e..fe4d05847 100644 --- a/test/zdtm/static/unlink_fifo_wronly.c +++ b/test/zdtm/static/unlink_fifo_wronly.c @@ -7,8 +7,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that we can migrate with a named pipe, " - "opened in WRONLY mode and then unlinked"; +const char *test_doc = "Check that we can migrate with a named pipe, " + "opened in WRONLY mode and then unlinked"; char *filename; TEST_OPTION(filename, string, "file name", 1); @@ -26,8 +26,7 @@ int main(int argc, char **argv) fd = open(filename, O_RDONLY | O_NONBLOCK); if (fd < 0) { - pr_perror("open(%s, O_RDONLY | O_NONBLOCK) Failed", - filename); + pr_perror("open(%s, O_RDONLY | O_NONBLOCK) Failed", filename); return 1; } diff --git a/test/zdtm/static/unlink_fstat00.c b/test/zdtm/static/unlink_fstat00.c index 9f8e30188..8a9841bfa 100644 --- a/test/zdtm/static/unlink_fstat00.c +++ b/test/zdtm/static/unlink_fstat00.c @@ -17,7 +17,7 @@ #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY) #endif -const char *test_doc = "Open, unlink, change size, seek, migrate, check size"; +const char *test_doc = "Open, unlink, change size, seek, migrate, check size"; #ifdef UNLINK_FSTAT04 char *dirname; @@ -27,10 +27,10 @@ char *filename; TEST_OPTION(filename, string, "file name", 1); #endif -int main(int argc, char ** argv) +int main(int argc, char **argv) { int fd; - size_t fsize=1000; + size_t fsize = 1000; mode_t mode; uid_t uid; gid_t gid; @@ -125,14 +125,12 @@ int main(int argc, char ** argv) /* Check file size */ if (fst.st_size != fsize) { - fail("(via fstat): file size changed to %ld", - (long)fst.st_size); + fail("(via fstat): file size changed to %ld", (long)fst.st_size); goto failed; } fst.st_size = lseek(fd, 0, SEEK_END); if (fst.st_size != fsize) { - fail("(via lseek): file size changed to %ld", - (long)fst.st_size); + fail("(via lseek): file size changed to %ld", (long)fst.st_size); goto failed; } /* Check mode */ @@ -142,8 +140,7 @@ int main(int argc, char ** argv) } /* Check uid, gid */ if (fst.st_uid != uid || fst.st_gid != gid) { - fail("u(g)id changed: uid=%d(%d), gid=%d(%d)", - fst.st_uid, uid, fst.st_gid, gid); + fail("u(g)id changed: uid=%d(%d), gid=%d(%d)", fst.st_uid, uid, fst.st_gid, gid); goto failed; } diff --git a/test/zdtm/static/unlink_fstat01.c b/test/zdtm/static/unlink_fstat01.c index 43ea6b9f6..bf2341482 100644 --- a/test/zdtm/static/unlink_fstat01.c +++ b/test/zdtm/static/unlink_fstat01.c @@ -8,15 +8,15 @@ #include "zdtmtst.h" -const char *test_doc = "Open, unlink, change size, migrate, check size"; +const char *test_doc = "Open, unlink, change size, migrate, check size"; char *filename; TEST_OPTION(filename, string, "file name", 1); -int main(int argc, char ** argv) +int main(int argc, char **argv) { int fd; - size_t fsize=1000; + size_t fsize = 1000; uint8_t buf[fsize]; struct stat fst; @@ -44,15 +44,15 @@ int main(int argc, char ** argv) } #ifdef UNLINK_OVER -{ - int fdo; - - fdo = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644); - if (fdo < 0) { - pr_perror("can't open %s", filename); - exit(1); + { + int fdo; + + fdo = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644); + if (fdo < 0) { + pr_perror("can't open %s", filename); + exit(1); + } } -} #endif memset(buf, '0', sizeof(buf)); @@ -70,15 +70,13 @@ int main(int argc, char ** argv) } if (fst.st_size != fsize) { - fail("(via fstat): file size changed to %lld", - (long long)fst.st_size); + fail("(via fstat): file size changed to %lld", (long long)fst.st_size); goto failed; } fst.st_size = lseek(fd, 0, SEEK_END); if (fst.st_size != fsize) { - fail("(via lseek): file size changed to %lld", - (long long)fst.st_size); + fail("(via lseek): file size changed to %lld", (long long)fst.st_size); goto failed; } diff --git a/test/zdtm/static/unlink_fstat02.c b/test/zdtm/static/unlink_fstat02.c index 3d75db3e0..613e52bc8 100644 --- a/test/zdtm/static/unlink_fstat02.c +++ b/test/zdtm/static/unlink_fstat02.c @@ -8,16 +8,16 @@ #include "zdtmtst.h" -const char *test_doc = "Open, link, unlink x2, change size, migrate, check size"; +const char *test_doc = "Open, link, unlink x2, change size, migrate, check size"; char *filename; TEST_OPTION(filename, string, "file name", 1); static char link_name[1024]; -int main(int argc, char ** argv) +int main(int argc, char **argv) { int fd[2]; - size_t fsize=1000; + size_t fsize = 1000; uint8_t buf[fsize]; struct stat fst, fst2; @@ -47,8 +47,7 @@ int main(int argc, char ** argv) } if (fst.st_size != 0) { - pr_perror("%s file size eq %lld", - filename, (long long)fst.st_size); + pr_perror("%s file size eq %lld", filename, (long long)fst.st_size); goto failed; } @@ -87,15 +86,13 @@ int main(int argc, char ** argv) } if (fst.st_size != fsize) { - fail("(via fstat): file size changed to %lld", - (long long)fst.st_size); + fail("(via fstat): file size changed to %lld", (long long)fst.st_size); goto failed; } fst.st_size = lseek(fd[0], 0, SEEK_END); if (fst.st_size != fsize) { - fail("(via lseek): file size changed to %lld", - (long long)fst.st_size); + fail("(via lseek): file size changed to %lld", (long long)fst.st_size); goto failed; } diff --git a/test/zdtm/static/unlink_fstat03.c b/test/zdtm/static/unlink_fstat03.c index 64d069970..b46bfc33a 100644 --- a/test/zdtm/static/unlink_fstat03.c +++ b/test/zdtm/static/unlink_fstat03.c @@ -10,16 +10,16 @@ #include "zdtmtst.h" -const char *test_doc = "Open, link, unlink former, change size, migrate, check size"; +const char *test_doc = "Open, link, unlink former, change size, migrate, check size"; char *filename; TEST_OPTION(filename, string, "file name", 1); static char link_name[1024]; -int main(int argc, char ** argv) +int main(int argc, char **argv) { int fd; - size_t fsize=1000; + size_t fsize = 1000; uint8_t buf[fsize]; struct stat fst, fst2; struct statfs fsst; @@ -44,8 +44,7 @@ int main(int argc, char ** argv) } if (fst.st_size != 0) { - pr_perror("%s file size eq %lld", filename, - (long long)fst.st_size); + pr_perror("%s file size eq %lld", filename, (long long)fst.st_size); goto failed; } @@ -85,15 +84,13 @@ int main(int argc, char ** argv) } if (fst2.st_size != fsize) { - fail("(via fstat): file size changed to %lld", - (long long)fst.st_size); + fail("(via fstat): file size changed to %lld", (long long)fst.st_size); goto failed; } fst2.st_size = lseek(fd, 0, SEEK_END); if (fst2.st_size != fsize) { - fail("(via lseek): file size changed to %lld", - (long long)fst.st_size); + fail("(via lseek): file size changed to %lld", (long long)fst.st_size); goto failed; } diff --git a/test/zdtm/static/unlink_largefile.c b/test/zdtm/static/unlink_largefile.c index f47391238..4baacafff 100644 --- a/test/zdtm/static/unlink_largefile.c +++ b/test/zdtm/static/unlink_largefile.c @@ -12,11 +12,11 @@ const char *test_doc = "Checkpointing/restore of big (2Gb) unlinked files"; char *filename; TEST_OPTION(filename, string, "file name", 1); -int main(int argc, char ** argv) +int main(int argc, char **argv) { int fd; char buf[1000000]; - off64_t offset= 0x80002000ULL; + off64_t offset = 0x80002000ULL; size_t count; test_init(argc, argv); @@ -28,8 +28,7 @@ int main(int argc, char ** argv) } if (lseek64(fd, offset, SEEK_SET) < 0) { - pr_perror("can't lseek %s, offset= %llx", filename, - (long long unsigned)offset); + pr_perror("can't lseek %s, offset= %llx", filename, (long long unsigned)offset); goto failed; } diff --git a/test/zdtm/static/unlink_mmap00.c b/test/zdtm/static/unlink_mmap00.c index 03509aabc..405157dac 100644 --- a/test/zdtm/static/unlink_mmap00.c +++ b/test/zdtm/static/unlink_mmap00.c @@ -9,13 +9,13 @@ #include "zdtmtst.h" -const char *test_doc = "Test mmaped and unlinked files"; +const char *test_doc = "Test mmaped and unlinked files"; char *filename; TEST_OPTION(filename, string, "file name", 1); #ifndef PAGE_SIZE -#define PAGE_SIZE 4096 +#define PAGE_SIZE 4096 #endif static void touch_file_page(int fd, unsigned long off, char c) @@ -31,7 +31,7 @@ static void touch_file_page(int fd, unsigned long off, char c) } } -int main(int argc, char ** argv) +int main(int argc, char **argv) { int fd; char *mem_a, *mem_b; @@ -44,7 +44,6 @@ int main(int argc, char ** argv) exit(1); } - touch_file_page(fd, 0, 'a'); touch_file_page(fd, PAGE_SIZE, 'b'); touch_file_page(fd, 2 * PAGE_SIZE - 1, 'c'); /* for aligned file */ diff --git a/test/zdtm/static/unlink_mmap01.c b/test/zdtm/static/unlink_mmap01.c index 66c1bc353..d43246b79 100644 --- a/test/zdtm/static/unlink_mmap01.c +++ b/test/zdtm/static/unlink_mmap01.c @@ -11,14 +11,14 @@ #include "zdtmtst.h" -const char *test_doc = "Test mmaped and unlinked files (2, with hard links)"; +const char *test_doc = "Test mmaped and unlinked files (2, with hard links)"; char *filename; TEST_OPTION(filename, string, "file name", 1); static char linkname[4096]; #ifndef PAGE_SIZE -#define PAGE_SIZE 4096 +#define PAGE_SIZE 4096 #endif static void touch_file_page(int fd, unsigned long off, char c) @@ -34,7 +34,7 @@ static void touch_file_page(int fd, unsigned long off, char c) } } -int main(int argc, char ** argv) +int main(int argc, char **argv) { int fd; char *mem_a, *mem_b; @@ -48,7 +48,7 @@ int main(int argc, char ** argv) } touch_file_page(fd, 0, 'a'); - touch_file_page(fd, PAGE_SIZE - 1, 'b');/* for aligned file */ + touch_file_page(fd, PAGE_SIZE - 1, 'b'); /* for aligned file */ mem_a = mmap(NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE | MAP_FILE, fd, 0); if (mem_a == MAP_FAILED) { diff --git a/test/zdtm/static/unlink_mmap02.c b/test/zdtm/static/unlink_mmap02.c index 85d6b3887..a6b1841b3 100644 --- a/test/zdtm/static/unlink_mmap02.c +++ b/test/zdtm/static/unlink_mmap02.c @@ -9,13 +9,13 @@ #include "zdtmtst.h" -const char *test_doc = "Test mmaped, opened and unlinked files"; +const char *test_doc = "Test mmaped, opened and unlinked files"; char *filename; TEST_OPTION(filename, string, "file name", 1); #ifndef PAGE_SIZE -#define PAGE_SIZE 4096 +#define PAGE_SIZE 4096 #endif static void touch_file_page(int fd, unsigned long off, char c) @@ -31,7 +31,7 @@ static void touch_file_page(int fd, unsigned long off, char c) } } -int main(int argc, char ** argv) +int main(int argc, char **argv) { int fd; char *mem_a, *mem_b; @@ -44,7 +44,6 @@ int main(int argc, char ** argv) exit(1); } - touch_file_page(fd, 2 * PAGE_SIZE - 1, 'c'); /* for aligned file */ /* map with different prots to create 2 regions */ diff --git a/test/zdtm/static/unlink_multiple_largefiles.c b/test/zdtm/static/unlink_multiple_largefiles.c index 2f9248c2f..e475e739f 100644 --- a/test/zdtm/static/unlink_multiple_largefiles.c +++ b/test/zdtm/static/unlink_multiple_largefiles.c @@ -12,10 +12,9 @@ #include <linux/fiemap.h> #include "zdtmtst.h" - -#define FSIZE 0x3B600000ULL -#define NFILES 10 -#define BUFSIZE (1<<20) +#define FSIZE 0x3B600000ULL +#define NFILES 10 +#define BUFSIZE (1 << 20) const char *test_doc = "C/R of ten big (951MiB) unlinked files in root dir"; const char *test_author = "Vitaly Ostrosablin <vostrosablin@virtuozzo.com>"; @@ -86,23 +85,19 @@ void check_extent_map(struct fiemap *map) test_msg("Verifying extent map...\n"); for (i = 0; i < map->fm_mapped_extents; i++) { - test_msg("Extent %d, start %llx, length %llx\n", - i, - (long long) map->fm_extents[i].fe_logical, - (long long) map->fm_extents[i].fe_length); + test_msg("Extent %d, start %llx, length %llx\n", i, (long long)map->fm_extents[i].fe_logical, + (long long)map->fm_extents[i].fe_length); if (i == 0) holesize = map->fm_extents[i].fe_logical; datasize += map->fm_extents[i].fe_length; } if (holesize != FSIZE) { - pr_err("Unexpected hole size %llx != %llx\n", - (long long) holesize, (unsigned long long) FSIZE); + pr_err("Unexpected hole size %llx != %llx\n", (long long)holesize, (unsigned long long)FSIZE); exit(1); } if (datasize != BUFSIZE) { - pr_err("Unexpected data size %llx != %llx\n", - (long long) datasize, (unsigned long long) BUFSIZE); + pr_err("Unexpected data size %llx != %llx\n", (long long)datasize, (unsigned long long)BUFSIZE); exit(1); } } @@ -207,7 +202,7 @@ failed: int main(int argc, char **argv) { - int fd[NFILES] = {0}; + int fd[NFILES] = { 0 }; char links[NFILES][PATH_MAX]; char link[PATH_MAX]; int count = 0; @@ -217,13 +212,11 @@ int main(int argc, char **argv) /* We need to create 10 unlinked files, each is around 1GB in size */ for (count = 0; count < NFILES; count++) { - test_msg("Creating unlinked file %d/%d\n", count + 1, NFILES); tempfd = create_unlinked_file(count); if (tempfd < 0) { - pr_err("Cannot create unlinked file %d/%d\n", - count + 1, NFILES); + pr_err("Cannot create unlinked file %d/%d\n", count + 1, NFILES); return 1; } @@ -248,8 +241,7 @@ int main(int argc, char **argv) read_proc_fd_link(fd[count], &link[0]); if (strcmp(&links[count][0], &link[0])) { - pr_err("Symlink target %s has changed to %s\n", - links[count], link); + pr_err("Symlink target %s has changed to %s\n", links[count], link); return 1; } diff --git a/test/zdtm/static/unlink_regular00.c b/test/zdtm/static/unlink_regular00.c index 383fabbf0..2c93c8986 100644 --- a/test/zdtm/static/unlink_regular00.c +++ b/test/zdtm/static/unlink_regular00.c @@ -11,16 +11,16 @@ #include "zdtmtst.h" const char *test_doc = "Checkpointing/restore of unlinked file inside unlinked directory"; -const char *test_author = "Kirill Tkhai <ktkhai@virtuozzo.com>"; +const char *test_author = "Kirill Tkhai <ktkhai@virtuozzo.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); #define SUBDIR "subdir" -#define FNAME "testfile" -#define MSG "Hello!!!111" +#define FNAME "testfile" +#define MSG "Hello!!!111" -int main(int argc, char ** argv) +int main(int argc, char **argv) { char subdir[PATH_MAX], fname[PATH_MAX], lname[PATH_MAX]; char buf[sizeof(MSG) + 1]; @@ -88,8 +88,7 @@ int main(int argc, char ** argv) } if (strcmp(buf, MSG)) { - fail("content differs: %s, %s, sizeof=%zu", - buf, MSG, sizeof(MSG)); + fail("content differs: %s, %s, sizeof=%zu", buf, MSG, sizeof(MSG)); goto close_file; } diff --git a/test/zdtm/static/unsupported_children_collision.c b/test/zdtm/static/unsupported_children_collision.c index 15e8f3ba0..176f7080c 100644 --- a/test/zdtm/static/unsupported_children_collision.c +++ b/test/zdtm/static/unsupported_children_collision.c @@ -4,8 +4,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check unsupported children collision for mounts"; -const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; +const char *test_doc = "Check unsupported children collision for mounts"; +const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; char *dirname; TEST_OPTION(dirname, string, "directory name", 1); diff --git a/test/zdtm/static/uptime_grow.c b/test/zdtm/static/uptime_grow.c index ce262c4fc..5cb4b8671 100644 --- a/test/zdtm/static/uptime_grow.c +++ b/test/zdtm/static/uptime_grow.c @@ -1,15 +1,12 @@ #include "zdtmtst.h" -const char *test_doc = "test to ensure that monotonic clock doesn't decrease"; +const char *test_doc = "test to ensure that monotonic clock doesn't decrease"; const char *test_author = "Evgeny Antysev <eantyshev@parallels.com>"; #include <time.h> #include <stdlib.h> -# define tv_ge(a, b) \ - (((a)->tv_sec == (b)->tv_sec) ? \ - ((a)->tv_nsec >= (b)->tv_nsec) : \ - ((a)->tv_sec > (b)->tv_sec)) +#define tv_ge(a, b) (((a)->tv_sec == (b)->tv_sec) ? ((a)->tv_nsec >= (b)->tv_nsec) : ((a)->tv_sec > (b)->tv_sec)) int main(int argc, char **argv) { @@ -33,8 +30,7 @@ int main(int argc, char **argv) exit(1); } if (!tv_ge(&tm, &tm_old)) { - diff_nsec = (tm_old.tv_sec - tm.tv_sec) * 1.0E9 +\ - (tm_old.tv_nsec - tm.tv_nsec); + diff_nsec = (tm_old.tv_sec - tm.tv_sec) * 1.0E9 + (tm_old.tv_nsec - tm.tv_nsec); fail("clock step backward for %e nsec", diff_nsec); exit(1); } diff --git a/test/zdtm/static/utsname.c b/test/zdtm/static/utsname.c index 964548a8f..4c96942f2 100644 --- a/test/zdtm/static/utsname.c +++ b/test/zdtm/static/utsname.c @@ -5,12 +5,12 @@ #include "zdtmtst.h" -const char *test_doc = "Check that utsname hasn't changed"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check that utsname hasn't changed"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; static struct utsname after; -#define ZDTM_NODE "zdtm.nodename.ru" +#define ZDTM_NODE "zdtm.nodename.ru" #define ZDTM_DOMAIN "zdtm.nodename.ru" int main(int argc, char **argv) diff --git a/test/zdtm/static/vdso-proxy.c b/test/zdtm/static/vdso-proxy.c index f5ff21bd9..43334974f 100644 --- a/test/zdtm/static/vdso-proxy.c +++ b/test/zdtm/static/vdso-proxy.c @@ -4,17 +4,18 @@ #include "zdtmtst.h" -const char *test_doc = "Compare mappings before/after C/R for vdso/vvar presence. Should run iterative under vdso proxy fault-injection.\n"; -const char *test_author = "Dmitry Safonov <dsafonov@virtuozzo.com>"; +const char *test_doc = + "Compare mappings before/after C/R for vdso/vvar presence. Should run iterative under vdso proxy fault-injection.\n"; +const char *test_author = "Dmitry Safonov <dsafonov@virtuozzo.com>"; -#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) -#define VSYSCALL_START 0xffffffffff600000ULL +#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2 * !!(condition)])) +#define VSYSCALL_START 0xffffffffff600000ULL /* * Use constant MAX_VMAS - to minimize the risk of allocating a new * mapping or changing the size of existent VMA with realloc() */ -#define MAX_VMAS 80 -#define BUF_SIZE 1024 +#define MAX_VMAS 80 +#define BUF_SIZE 1024 /* * After C/R with vdso trampolines insertion, there should @@ -69,8 +70,7 @@ static int parse_maps(struct vm_area *vmas) #endif v->is_vvar_or_vdso |= strstr(buf, "[vdso]") != NULL; v->is_vvar_or_vdso |= strstr(buf, "[vvar]") != NULL; - test_msg("[NOTE]\tVMA: [%#" PRIx64 ", %#" PRIx64 "]\n", - v->start, v->end); + test_msg("[NOTE]\tVMA: [%#" PRIx64 ", %#" PRIx64 "]\n", v->start, v->end); } if (fclose(maps)) { @@ -110,9 +110,8 @@ static int check_vvar_vdso(struct vm_area *before, struct vm_area *after) if (cmp == 0) continue; - if (cmp < 0) {/* Lost mapping */ - test_msg("[NOTE]\tLost mapping: %#" PRIx64 "-%#" PRIx64 "\n", - before[i].start, before[i].end); + if (cmp < 0) { /* Lost mapping */ + test_msg("[NOTE]\tLost mapping: %#" PRIx64 "-%#" PRIx64 "\n", before[i].start, before[i].end); j--; if (before[i].is_vvar_or_vdso) { fail("Lost vvar/vdso mapping"); @@ -121,8 +120,7 @@ static int check_vvar_vdso(struct vm_area *before, struct vm_area *after) continue; } - test_msg("[NOTE]\tNew mapping appeared: %#" PRIx64 "-%#" PRIx64 "\n", - after[j].start, after[j].end); + test_msg("[NOTE]\tNew mapping appeared: %#" PRIx64 "-%#" PRIx64 "\n", after[j].start, after[j].end); i--; } diff --git a/test/zdtm/static/vdso00.c b/test/zdtm/static/vdso00.c index 8ac4ccad9..a9bef4dbd 100644 --- a/test/zdtm/static/vdso00.c +++ b/test/zdtm/static/vdso00.c @@ -7,8 +7,8 @@ #include <sys/types.h> #include "zdtmtst.h" -const char *test_doc = "Check if we can use vDSO after restore\n"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org"; +const char *test_doc = "Check if we can use vDSO after restore\n"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org"; int main(int argc, char *argv[]) { diff --git a/test/zdtm/static/vdso01.c b/test/zdtm/static/vdso01.c index 269688c5e..d8d64155a 100644 --- a/test/zdtm/static/vdso01.c +++ b/test/zdtm/static/vdso01.c @@ -15,67 +15,68 @@ #include "zdtmtst.h" -const char *test_doc = "Check if we can use vDSO using direct vDSO calls\n"; -const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org"; +const char *test_doc = "Check if we can use vDSO using direct vDSO calls\n"; +const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org"; #ifdef __i386__ -# define Ehdr_t Elf32_Ehdr -# define Sym_t Elf32_Sym -# define Phdr_t Elf32_Phdr -# define Word_t Elf32_Word -# define Dyn_t Elf32_Dyn +#define Ehdr_t Elf32_Ehdr +#define Sym_t Elf32_Sym +#define Phdr_t Elf32_Phdr +#define Word_t Elf32_Word +#define Dyn_t Elf32_Dyn -# define ELF_ST_TYPE ELF32_ST_TYPE -# define ELF_ST_BIND ELF32_ST_BIND +#define ELF_ST_TYPE ELF32_ST_TYPE +#define ELF_ST_BIND ELF32_ST_BIND const char elf_ident[] = { - 0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; #else /* non-i386 */ -# define Ehdr_t Elf64_Ehdr -# define Sym_t Elf64_Sym -# define Phdr_t Elf64_Phdr -# define Word_t Elf64_Word -# define Dyn_t Elf64_Dyn +#define Ehdr_t Elf64_Ehdr +#define Sym_t Elf64_Sym +#define Phdr_t Elf64_Phdr +#define Word_t Elf64_Word +#define Dyn_t Elf64_Dyn -# ifndef ELF_ST_TYPE -# define ELF_ST_TYPE ELF64_ST_TYPE -# endif -# ifndef ELF_ST_BIND -# define ELF_ST_BIND ELF64_ST_BIND -# endif +#ifndef ELF_ST_TYPE +#define ELF_ST_TYPE ELF64_ST_TYPE +#endif +#ifndef ELF_ST_BIND +#define ELF_ST_BIND ELF64_ST_BIND +#endif /* * See Elf specification for this magic values. */ const char elf_ident[] = { - 0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; #endif -typedef int (__vdso_clock_gettime_t)(clockid_t clock, struct timespec *ts); -typedef long (__vdso_getcpu_t)(unsigned *cpu, unsigned *node, void *unused); -typedef int (__vdso_gettimeofday_t)(struct timeval *tv, struct timezone *tz); -typedef time_t (__vdso_time_t)(time_t *t); +typedef int(__vdso_clock_gettime_t)(clockid_t clock, struct timespec *ts); +typedef long(__vdso_getcpu_t)(unsigned *cpu, unsigned *node, void *unused); +typedef int(__vdso_gettimeofday_t)(struct timeval *tv, struct timezone *tz); +typedef time_t(__vdso_time_t)(time_t *t); -#define TIME_DELTA_SEC (3) +#define TIME_DELTA_SEC (3) -#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) +#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2 * !!(condition)])) -#define VDSO_BAD_ADDR (-1ul) +#define VDSO_BAD_ADDR (-1ul) struct vdso_symbol { - char name[32]; - unsigned long offset; + char name[32]; + unsigned long offset; }; -#define VDSO_SYMBOL_INIT { .offset = VDSO_BAD_ADDR, } +#define VDSO_SYMBOL_INIT \ + { \ + .offset = VDSO_BAD_ADDR, \ + } /* Check if symbol present in symtable */ static inline bool vdso_symbol_empty(struct vdso_symbol *s) @@ -93,26 +94,24 @@ enum { }; const char *vdso_symbols[VDSO_SYMBOL_MAX] = { - [VDSO_SYMBOL_CLOCK_GETTIME] = "__vdso_clock_gettime", - [VDSO_SYMBOL_GETCPU] = "__vdso_getcpu", - [VDSO_SYMBOL_GETTIMEOFDAY] = "__vdso_gettimeofday", - [VDSO_SYMBOL_TIME] = "__vdso_time", + [VDSO_SYMBOL_CLOCK_GETTIME] = "__vdso_clock_gettime", + [VDSO_SYMBOL_GETCPU] = "__vdso_getcpu", + [VDSO_SYMBOL_GETTIMEOFDAY] = "__vdso_gettimeofday", + [VDSO_SYMBOL_TIME] = "__vdso_time", }; struct vdso_symtable { - unsigned long vma_start; - unsigned long vma_end; - struct vdso_symbol symbols[VDSO_SYMBOL_MAX]; + unsigned long vma_start; + unsigned long vma_end; + struct vdso_symbol symbols[VDSO_SYMBOL_MAX]; }; -#define VDSO_SYMTABLE_INIT \ - { \ - .vma_start = VDSO_BAD_ADDR, \ - .vma_end = VDSO_BAD_ADDR, \ - .symbols = { \ - [0 ... VDSO_SYMBOL_MAX - 1] = \ - (struct vdso_symbol)VDSO_SYMBOL_INIT, \ - }, \ +#define VDSO_SYMTABLE_INIT \ + { \ + .vma_start = VDSO_BAD_ADDR, .vma_end = VDSO_BAD_ADDR, \ + .symbols = { \ + [0 ... VDSO_SYMBOL_MAX - 1] = (struct vdso_symbol)VDSO_SYMBOL_INIT, \ + }, \ } static bool __ptr_oob(void *ptr, void *start, size_t size) @@ -240,8 +239,7 @@ static int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t) bucket = &hash[2]; chain = &hash[nbucket + 2]; - test_msg("nbucket %lu nchain %lu bucket %p chain %p\n", - (long)nbucket, (long)nchain, bucket, chain); + test_msg("nbucket %lu nchain %lu bucket %p chain %p\n", (long)nbucket, (long)nchain, bucket, chain); for (i = 0; i < ARRAY_SIZE(vdso_symbols); i++) { k = elf_hash((const unsigned char *)vdso_symbols[i]); @@ -254,8 +252,7 @@ static int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t) if (__ptr_oob(sym, mem, size)) continue; - if (ELF_ST_TYPE(sym->st_info) != STT_FUNC && - ELF_ST_BIND(sym->st_info) != STB_GLOBAL) + if (ELF_ST_TYPE(sym->st_info) != STT_FUNC && ELF_ST_BIND(sym->st_info) != STB_GLOBAL) continue; name = &dynsymbol_names[sym->st_name]; @@ -327,8 +324,7 @@ static int vdso_clock_gettime_handler(void *func) clock_gettime(CLOCK_REALTIME, &ts1); vdso_clock_gettime(CLOCK_REALTIME, &ts2); - test_msg("clock_gettime: tv_sec %li vdso_clock_gettime: tv_sec %li\n", - ts1.tv_sec, ts2.tv_sec); + test_msg("clock_gettime: tv_sec %li vdso_clock_gettime: tv_sec %li\n", ts1.tv_sec, ts2.tv_sec); if (labs(ts1.tv_sec - ts2.tv_sec) > TIME_DELTA_SEC) { pr_perror("Delta is too big"); @@ -358,8 +354,7 @@ static int vdso_gettimeofday_handler(void *func) gettimeofday(&tv1, &tz); vdso_gettimeofday(&tv2, &tz); - test_msg("gettimeofday: tv_sec %li vdso_gettimeofday: tv_sec %li\n", - tv1.tv_sec, tv2.tv_sec); + test_msg("gettimeofday: tv_sec %li vdso_gettimeofday: tv_sec %li\n", tv1.tv_sec, tv2.tv_sec); if (labs(tv1.tv_sec - tv2.tv_sec) > TIME_DELTA_SEC) { pr_perror("Delta is too big"); @@ -389,12 +384,12 @@ static int vdso_time_handler(void *func) static int call_handlers(struct vdso_symtable *symtable) { - typedef int (handler_t)(void *func); + typedef int(handler_t)(void *func); handler_t *handlers[VDSO_SYMBOL_MAX] = { - [VDSO_SYMBOL_CLOCK_GETTIME] = vdso_clock_gettime_handler, - [VDSO_SYMBOL_GETCPU] = vdso_getcpu_handler, - [VDSO_SYMBOL_GETTIMEOFDAY] = vdso_gettimeofday_handler, - [VDSO_SYMBOL_TIME] = vdso_time_handler, + [VDSO_SYMBOL_CLOCK_GETTIME] = vdso_clock_gettime_handler, + [VDSO_SYMBOL_GETCPU] = vdso_getcpu_handler, + [VDSO_SYMBOL_GETTIMEOFDAY] = vdso_gettimeofday_handler, + [VDSO_SYMBOL_TIME] = vdso_time_handler, }; size_t i; diff --git a/test/zdtm/static/vdso02.c b/test/zdtm/static/vdso02.c index f0047bc2c..ea28c4453 100644 --- a/test/zdtm/static/vdso02.c +++ b/test/zdtm/static/vdso02.c @@ -6,10 +6,11 @@ #include "zdtmtst.h" -const char *test_doc = "Restoring task with unmapped vDSO blob. Poor man's test for C/R on vdso64_enabled=0 booted kernel.\n"; -const char *test_author = "Dmitry Safonov <dsafonov@virtuozzo.com>"; +const char *test_doc = + "Restoring task with unmapped vDSO blob. Poor man's test for C/R on vdso64_enabled=0 booted kernel.\n"; +const char *test_author = "Dmitry Safonov <dsafonov@virtuozzo.com>"; -#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) +#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2 * !!(condition)])) #define VDSO_BAD_ADDR (-1ul) #define VVAR_BAD_ADDR (-1ul) #define BUF_SZ 1024 @@ -34,10 +35,10 @@ static int find_blobs(pid_t pid, struct vm_area *vdso, struct vm_area *vvar) int ret = -1; FILE *maps; - vdso->start = VDSO_BAD_ADDR; - vdso->end = VDSO_BAD_ADDR; - vvar->start = VVAR_BAD_ADDR; - vvar->end = VVAR_BAD_ADDR; + vdso->start = VDSO_BAD_ADDR; + vdso->end = VDSO_BAD_ADDR; + vvar->start = VVAR_BAD_ADDR; + vvar->end = VVAR_BAD_ADDR; if (snprintf(buf, BUF_SZ, "/proc/%d/maps", pid) < 0) { pr_perror("snprintf() failure for path"); @@ -73,28 +74,25 @@ err: * On i386 syscalls for speed are optimized trough vdso, * call raw int80 as vdso is unmapped. */ -#define __NR32_munmap 91 -#define __NR32_kill 37 -#define __NR32_exit 1 +#define __NR32_munmap 91 +#define __NR32_kill 37 +#define __NR32_exit 1 struct syscall_args32 { uint32_t nr, arg0, arg1; }; static inline void do_full_int80(struct syscall_args32 *args) { - asm volatile ( - "int $0x80\n\t" - : "+a" (args->nr), - "+b" (args->arg0), "+c" (args->arg1)); + asm volatile("int $0x80\n\t" : "+a"(args->nr), "+b"(args->arg0), "+c"(args->arg1)); } int sys_munmap(void *addr, size_t len) { - struct syscall_args32 s = {0}; + struct syscall_args32 s = { 0 }; - s.nr = __NR32_munmap; - s.arg0 = (uint32_t)(uintptr_t)addr; - s.arg1 = (uint32_t)len; + s.nr = __NR32_munmap; + s.arg0 = (uint32_t)(uintptr_t)addr; + s.arg1 = (uint32_t)len; do_full_int80(&s); @@ -103,11 +101,11 @@ int sys_munmap(void *addr, size_t len) int sys_kill(pid_t pid, int sig) { - struct syscall_args32 s = {0}; + struct syscall_args32 s = { 0 }; - s.nr = __NR32_kill; - s.arg0 = (uint32_t)pid; - s.arg1 = (uint32_t)sig; + s.nr = __NR32_kill; + s.arg0 = (uint32_t)pid; + s.arg1 = (uint32_t)sig; do_full_int80(&s); @@ -116,10 +114,10 @@ int sys_kill(pid_t pid, int sig) void sys_exit(int status) { - struct syscall_args32 s = {0}; + struct syscall_args32 s = { 0 }; - s.nr = __NR32_exit; - s.arg0 = (uint32_t)status; + s.nr = __NR32_exit; + s.arg0 = (uint32_t)status; do_full_int80(&s); } @@ -152,12 +150,12 @@ static int unmap_blobs(void) return -1; if (vdso.start != VDSO_BAD_ADDR) { - ret = sys_munmap((void*)vdso.start, vdso.end - vdso.start); + ret = sys_munmap((void *)vdso.start, vdso.end - vdso.start); if (ret) return ret; } if (vvar.start != VVAR_BAD_ADDR) { - ret = sys_munmap((void*)vvar.start, vvar.end - vvar.start); + ret = sys_munmap((void *)vvar.start, vvar.end - vvar.start); if (ret) return ret; } @@ -196,8 +194,7 @@ int main(int argc, char *argv[]) } else if (WIFSIGNALED(status)) { int sig = WTERMSIG(status); - pr_err("Child unexpectedly signaled with %d: %s\n", - sig, strsignal(sig)); + pr_err("Child unexpectedly signaled with %d: %s\n", sig, strsignal(sig)); goto out_kill; } else if (!WIFSTOPPED(status) || WSTOPSIG(status) != SIGSTOP) { pr_err("Child is unstoppable or was stopped by other means\n"); diff --git a/test/zdtm/static/vfork00.c b/test/zdtm/static/vfork00.c index 6abc5c6ac..12dd890bc 100644 --- a/test/zdtm/static/vfork00.c +++ b/test/zdtm/static/vfork00.c @@ -9,10 +9,10 @@ #include "zdtmtst.h" -const char *test_doc = "Block migration by a pending (non-exec()-ed) vfork()"; -const char *test_author = "Pavel Emelianov <xemul@sw.ru>"; +const char *test_doc = "Block migration by a pending (non-exec()-ed) vfork()"; +const char *test_author = "Pavel Emelianov <xemul@sw.ru>"; -int main(int argc, char ** argv) +int main(int argc, char **argv) { int ret = 0; pid_t pid; diff --git a/test/zdtm/static/vsx.c b/test/zdtm/static/vsx.c index e7d81b12c..3c1d669a0 100644 --- a/test/zdtm/static/vsx.c +++ b/test/zdtm/static/vsx.c @@ -30,20 +30,21 @@ int main(int argc, char *argv[]) * their content. */ -const char *test_doc = "Test if data in vector registers do survive the c/r"; -const char *test_author = "Laurent Dufour <ldufour@linux.vnet.ibm.com>"; +const char *test_doc = "Test if data in vector registers do survive the c/r"; +const char *test_author = "Laurent Dufour <ldufour@linux.vnet.ibm.com>"; int is_test_doable(void) { unsigned long val; val = getauxval(AT_HWCAP); -#define CHECK_FEATURE(f) do { \ - if (!(val & f)) { \ - test_msg("CPU feature " #f " is missing\n"); \ - return 0; \ - } \ - } while(0) +#define CHECK_FEATURE(f) \ + do { \ + if (!(val & f)) { \ + test_msg("CPU feature " #f " is missing\n"); \ + return 0; \ + } \ + } while (0) CHECK_FEATURE(PPC_FEATURE_64); CHECK_FEATURE(PPC_FEATURE_HAS_ALTIVEC); @@ -53,318 +54,315 @@ int is_test_doable(void) void fill_vsx(uint64_t *pt) { - asm volatile( - "lis 3, 0 \n" - - "lxvd2x 0, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 1, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 2, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 3, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 4, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 5, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 6, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 7, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 8, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 9, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - - "lxvd2x 10, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 11, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 12, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 13, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 14, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 15, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 16, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 17, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 18, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 19, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - - "lxvd2x 20, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 21, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 22, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 23, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 24, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 25, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 26, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 27, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 28, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 29, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - - "lxvd2x 30, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 31, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 32, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 33, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 34, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 35, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 36, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 37, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 38, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 39, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - - "lxvd2x 40, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 41, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 42, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 43, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 44, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 45, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 46, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 47, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 48, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 49, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - - "lxvd2x 50, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 51, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 52, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 53, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 54, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 55, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 56, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 57, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 58, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 59, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - - "lxvd2x 60, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 61, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 62, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "lxvd2x 63, 3, %0 \n" - : /* no output */ - : "r" (pt) - : "3"); + asm volatile("lis 3, 0 \n" + + "lxvd2x 0, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 1, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 2, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 3, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 4, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 5, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 6, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 7, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 8, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 9, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + + "lxvd2x 10, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 11, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 12, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 13, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 14, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 15, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 16, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 17, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 18, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 19, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + + "lxvd2x 20, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 21, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 22, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 23, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 24, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 25, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 26, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 27, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 28, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 29, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + + "lxvd2x 30, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 31, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 32, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 33, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 34, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 35, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 36, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 37, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 38, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 39, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + + "lxvd2x 40, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 41, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 42, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 43, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 44, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 45, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 46, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 47, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 48, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 49, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + + "lxvd2x 50, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 51, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 52, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 53, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 54, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 55, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 56, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 57, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 58, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 59, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + + "lxvd2x 60, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 61, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 62, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "lxvd2x 63, 3, %0 \n" + : /* no output */ + : "r"(pt) + : "3"); } void read_vsx(uint64_t *pt) { - asm volatile( - "lis 3, 0 \n" - - "stxvd2x 0, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 1, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 2, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 3, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 4, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 5, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 6, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 7, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 8, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 9, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - - "stxvd2x 10, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 11, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 12, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 13, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 14, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 15, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 16, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 17, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 18, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 19, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - - "stxvd2x 20, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 21, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 22, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 23, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 24, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 25, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 26, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 27, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 28, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 29, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - - "stxvd2x 30, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 31, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 32, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 33, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 34, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 35, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 36, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 37, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 38, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 39, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - - "stxvd2x 40, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 41, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 42, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 43, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 44, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 45, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 46, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 47, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 48, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 49, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - - "stxvd2x 50, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 51, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 52, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 53, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 54, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 55, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 56, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 57, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 58, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 59, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - - "stxvd2x 60, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 61, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 62, 3, %0 \n" - "addi 3, 3, 16 \n" /* move to the next qword */ - "stxvd2x 63, 3, %0 \n" - - : /* no output */ - : "r" (pt) - : "3"); + asm volatile("lis 3, 0 \n" + + "stxvd2x 0, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 1, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 2, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 3, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 4, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 5, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 6, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 7, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 8, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 9, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + + "stxvd2x 10, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 11, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 12, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 13, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 14, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 15, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 16, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 17, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 18, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 19, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + + "stxvd2x 20, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 21, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 22, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 23, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 24, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 25, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 26, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 27, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 28, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 29, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + + "stxvd2x 30, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 31, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 32, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 33, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 34, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 35, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 36, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 37, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 38, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 39, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + + "stxvd2x 40, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 41, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 42, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 43, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 44, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 45, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 46, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 47, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 48, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 49, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + + "stxvd2x 50, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 51, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 52, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 53, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 54, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 55, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 56, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 57, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 58, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 59, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + + "stxvd2x 60, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 61, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 62, 3, %0 \n" + "addi 3, 3, 16 \n" /* move to the next qword */ + "stxvd2x 63, 3, %0 \n" + + : /* no output */ + : "r"(pt) + : "3"); } int main(int argc, char *argv[]) { /* A random buffer of 1024 bytes (64 * 128bit registers to fill) */ - static const char ibuffer[128/8*64]= - "sahwoleiGun9loosliz0Aech9aiph5eiIengei7Ogh8zu7ye" - "Aeshie6vai0thaehool1ooK6ayaj3Neitahn8yeeh5ahfuiT" - "uCeir1bife4ieceema8choo2Wengaec1seDaidohteipa4ai" - "aequee7AiriejaeJar1giak8Gei2uathloh5uemaeG6EiSoo" - "PhaenaethoPhej8nEecheegeihosho8Zohroo8ea6Juuheif" - "nu2Hahvai1tuf0Zeeeveephu2EitaexiVaekieboac7Nushu" - "aeTh6Quoo3iozeisaudaGheed0aPah2Schoog0eiChaeN5su" - "xoo1phoic1mahXohSai1thoogo0oesooeaxai7eBahHahMue" - "quiloh2ooPahpiujeithae0Dau0shuwicobinaaYooj0ajiw" - "iiheeS4awoh3haevlaiGe8phaev3eiluaChaF6ieng4aith4" - "aif3TooYo1aigoomZiuhai8eesoo4maiLahr3PoM8Eir5ooz" - "Iequ9ahre4Op4bahaiso6ohnah8Shokimooch1Oafahf5aih" - "xohphee1pi5Iecaiaigh7Eisah2uew5acie7wi6Zo0Eelah9" - "woi8QueerohfeiThaBoh5jaic3peiPohAhng0bu5shoop7ca" - "Qui5kodaika8quioahmohreeVe8loquaeeLi5ze3oceiHa0l" - "roh8Ooxae7uish9ioog7ieS3aibeo2thOosiuvaiS5lohp4U" - "emieG0eit6Bien8EzaiwiTh3geighaexshee8eHiec1TooH2" - "Eeceacai0inaejieboo8NeishieweiraHooj9apeecooy0th" - "daThei6aexeisahdsei3keik0diPheejchais6ezo0iep5Ae" - "Wiqu6aepeing4ba8diek3aev9waYooveAebai9eef6Iex6vo" - "Quee9MeitahMighoHuo3seveeMoh3ohtoxaib6ootaiF5EeT" - "Ohb9eijoonoh6ich"; - char obuffer[128/8*64]; + static const char ibuffer[128 / 8 * 64] = "sahwoleiGun9loosliz0Aech9aiph5eiIengei7Ogh8zu7ye" + "Aeshie6vai0thaehool1ooK6ayaj3Neitahn8yeeh5ahfuiT" + "uCeir1bife4ieceema8choo2Wengaec1seDaidohteipa4ai" + "aequee7AiriejaeJar1giak8Gei2uathloh5uemaeG6EiSoo" + "PhaenaethoPhej8nEecheegeihosho8Zohroo8ea6Juuheif" + "nu2Hahvai1tuf0Zeeeveephu2EitaexiVaekieboac7Nushu" + "aeTh6Quoo3iozeisaudaGheed0aPah2Schoog0eiChaeN5su" + "xoo1phoic1mahXohSai1thoogo0oesooeaxai7eBahHahMue" + "quiloh2ooPahpiujeithae0Dau0shuwicobinaaYooj0ajiw" + "iiheeS4awoh3haevlaiGe8phaev3eiluaChaF6ieng4aith4" + "aif3TooYo1aigoomZiuhai8eesoo4maiLahr3PoM8Eir5ooz" + "Iequ9ahre4Op4bahaiso6ohnah8Shokimooch1Oafahf5aih" + "xohphee1pi5Iecaiaigh7Eisah2uew5acie7wi6Zo0Eelah9" + "woi8QueerohfeiThaBoh5jaic3peiPohAhng0bu5shoop7ca" + "Qui5kodaika8quioahmohreeVe8loquaeeLi5ze3oceiHa0l" + "roh8Ooxae7uish9ioog7ieS3aibeo2thOosiuvaiS5lohp4U" + "emieG0eit6Bien8EzaiwiTh3geighaexshee8eHiec1TooH2" + "Eeceacai0inaejieboo8NeishieweiraHooj9apeecooy0th" + "daThei6aexeisahdsei3keik0diPheejchais6ezo0iep5Ae" + "Wiqu6aepeing4ba8diek3aev9waYooveAebai9eef6Iex6vo" + "Quee9MeitahMighoHuo3seveeMoh3ohtoxaib6ootaiF5EeT" + "Ohb9eijoonoh6ich"; + char obuffer[128 / 8 * 64]; int do_test; test_init(argc, argv); diff --git a/test/zdtm/static/vt.c b/test/zdtm/static/vt.c index 6c96fceba..08490584a 100644 --- a/test/zdtm/static/vt.c +++ b/test/zdtm/static/vt.c @@ -9,16 +9,16 @@ #include "zdtmtst.h" -const char *test_doc = "Check c/r of a virtual terminal"; -const char *test_author = "Ruslan Kuprieiev <kupruser@gmail.com>"; +const char *test_doc = "Check c/r of a virtual terminal"; +const char *test_author = "Ruslan Kuprieiev <kupruser@gmail.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); #ifdef __s390x__ -#define MINOR 65 /* ttysclp0 */ +#define MINOR 65 /* ttysclp0 */ #else -#define MINOR 5 +#define MINOR 5 #endif int main(int argc, char **argv) @@ -53,9 +53,7 @@ int main(int argc, char **argv) } if (st1.st_rdev != st2.st_rdev) { - fail("Virtual terminal rdev mismatch %x != %x on %s", - (int)st1.st_rdev, (int)st2.st_rdev, - filename); + fail("Virtual terminal rdev mismatch %x != %x on %s", (int)st1.st_rdev, (int)st2.st_rdev, filename); return 1; } diff --git a/test/zdtm/static/wait00.c b/test/zdtm/static/wait00.c index e16cd5bd7..f2e561742 100644 --- a/test/zdtm/static/wait00.c +++ b/test/zdtm/static/wait00.c @@ -8,10 +8,10 @@ #include "zdtmtst.h" -const char *test_doc = "See if we can wait() for a child after migration"; -const char *test_author = "Roman Kagan <rkagan@parallels.com>"; +const char *test_doc = "See if we can wait() for a child after migration"; +const char *test_author = "Roman Kagan <rkagan@parallels.com>"; -int main(int argc, char ** argv) +int main(int argc, char **argv) { int ret; pid_t pid; diff --git a/test/zdtm/static/write_read00.c b/test/zdtm/static/write_read00.c index 2b7bdd4ad..86ec99c74 100644 --- a/test/zdtm/static/write_read00.c +++ b/test/zdtm/static/write_read00.c @@ -5,13 +5,13 @@ #include "zdtmtst.h" -const char *test_doc = "Write file before migration, read after"; -const char *test_author = "Roman Kagan <rkagan@parallels.com>"; +const char *test_doc = "Write file before migration, read after"; +const char *test_author = "Roman Kagan <rkagan@parallels.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); -int main(int argc, char ** argv) +int main(int argc, char **argv) { int fd; uint32_t crc; diff --git a/test/zdtm/static/write_read01.c b/test/zdtm/static/write_read01.c index abb481117..866067c4b 100644 --- a/test/zdtm/static/write_read01.c +++ b/test/zdtm/static/write_read01.c @@ -5,13 +5,13 @@ #include "zdtmtst.h" -const char *test_doc = "Write and half way read file before migration, complete after"; -const char *test_author = "Roman Kagan <rkagan@parallels.com>"; +const char *test_doc = "Write and half way read file before migration, complete after"; +const char *test_author = "Roman Kagan <rkagan@parallels.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); -int main(int argc, char ** argv) +int main(int argc, char **argv) { int fd; int len; diff --git a/test/zdtm/static/write_read02.c b/test/zdtm/static/write_read02.c index 59ff4ce2f..09b9e5e6d 100644 --- a/test/zdtm/static/write_read02.c +++ b/test/zdtm/static/write_read02.c @@ -5,13 +5,13 @@ #include "zdtmtst.h" -const char *test_doc = "Write file half way before migration, complete and read after"; -const char *test_author = "Roman Kagan <rkagan@parallels.com>"; +const char *test_doc = "Write file half way before migration, complete and read after"; +const char *test_author = "Roman Kagan <rkagan@parallels.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); -int main(int argc, char ** argv) +int main(int argc, char **argv) { int fd, fd1; int len, full_len; diff --git a/test/zdtm/static/write_read10.c b/test/zdtm/static/write_read10.c index f4ef9bb16..fff4b8f95 100644 --- a/test/zdtm/static/write_read10.c +++ b/test/zdtm/static/write_read10.c @@ -8,15 +8,15 @@ #include "zdtmtst.h" -const char *test_doc = "Open r/w and unlink file, and fork before migration;\n" - "check that the child can write to it and the parent\n" - "can read from it after migration"; -const char *test_author = "Roman Kagan <rkagan@parallels.com>"; +const char *test_doc = "Open r/w and unlink file, and fork before migration;\n" + "check that the child can write to it and the parent\n" + "can read from it after migration"; +const char *test_author = "Roman Kagan <rkagan@parallels.com>"; char *filename; TEST_OPTION(filename, string, "file name", 1); -int main(int argc, char ** argv) +int main(int argc, char **argv) { int fd, child_fd, ret; pid_t pid; @@ -51,7 +51,7 @@ int main(int argc, char ** argv) exit(1); } - if (pid == 0) { /* child writes to the unlinked file and returns */ + if (pid == 0) { /* child writes to the unlinked file and returns */ close(fd); task_waiter_complete_current(&t); test_waitsig(); @@ -109,15 +109,13 @@ int main(int argc, char ** argv) goto out; } - if (close(fd)) { fail("close failed"); goto out_noclose; } if (unlink(filename) != -1 || errno != ENOENT) { - fail("file %s should have been deleted before migration: unlink", - filename); + fail("file %s should have been deleted before migration: unlink", filename); goto out_noclose; } diff --git a/test/zdtm/static/xids00.c b/test/zdtm/static/xids00.c index 0e8f324f6..4831d9a37 100644 --- a/test/zdtm/static/xids00.c +++ b/test/zdtm/static/xids00.c @@ -7,8 +7,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that environment didn't change"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Check that environment didn't change"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; int main(int argc, char **argv) { @@ -86,8 +86,8 @@ int main(int argc, char **argv) pr_perror("Unable to wait P2 %d", pid); exit(3); } else if (!WIFEXITED(stat) || WEXITSTATUS(stat)) { - pr_perror("P2 stat %d/%d/%d/%d", WIFEXITED(stat), WEXITSTATUS(stat), - WIFSIGNALED(stat), WTERMSIG(stat)); + pr_perror("P2 stat %d/%d/%d/%d", WIFEXITED(stat), WEXITSTATUS(stat), WIFSIGNALED(stat), + WTERMSIG(stat)); exit(3); } @@ -112,8 +112,8 @@ int main(int argc, char **argv) pr_perror("Unable to wait %d", pids[i]); fail = 1; } else if (!WIFEXITED(stat) || WEXITSTATUS(stat)) { - pr_perror("P%d stat %d/%d/%d/%d", i, WIFEXITED(stat), WEXITSTATUS(stat), - WIFSIGNALED(stat), WTERMSIG(stat)); + pr_perror("P%d stat %d/%d/%d/%d", i, WIFEXITED(stat), WEXITSTATUS(stat), WIFSIGNALED(stat), + WTERMSIG(stat)); fail = 1; } } diff --git a/test/zdtm/static/zombie00.c b/test/zdtm/static/zombie00.c index def2c8892..c40efcadc 100644 --- a/test/zdtm/static/zombie00.c +++ b/test/zdtm/static/zombie00.c @@ -8,8 +8,8 @@ #include "zdtmtst.h" -const char *test_doc = "See if we can wait() for a zombified child after migration"; -const char *test_author = "Roman Kagan <rkagan@parallels.com>"; +const char *test_doc = "See if we can wait() for a zombified child after migration"; +const char *test_author = "Roman Kagan <rkagan@parallels.com>"; struct zombie { int pid; @@ -17,9 +17,9 @@ struct zombie { int exitcode; }; -#define NR_ZOMBIES 4 +#define NR_ZOMBIES 4 -int main(int argc, char ** argv) +int main(int argc, char **argv) { int i, status; struct zombie zombie[NR_ZOMBIES]; @@ -56,8 +56,7 @@ int main(int argc, char ** argv) _exit(13); /* just in case */ } - test_msg("kid %d will %d/%d\n", zombie[i].pid, - zombie[i].exited, zombie[i].exitcode); + test_msg("kid %d will %d/%d\n", zombie[i].pid, zombie[i].exited, zombie[i].exitcode); } /* diff --git a/test/zdtm/static/zombie01.c b/test/zdtm/static/zombie01.c index 6e904c047..8cdb5bf4e 100644 --- a/test/zdtm/static/zombie01.c +++ b/test/zdtm/static/zombie01.c @@ -8,8 +8,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check that zombie pgid is restored"; -const char *test_author = "Kirill Tkhai <ktkhai@virtuozzo.com>"; +const char *test_doc = "Check that zombie pgid is restored"; +const char *test_author = "Kirill Tkhai <ktkhai@virtuozzo.com>"; int main(int argc, char **argv) { @@ -31,7 +31,7 @@ int main(int argc, char **argv) fail("setpgid"); exit(1); } - pid = sys_clone_unified(CLONE_PARENT|SIGCHLD, NULL, NULL, NULL, 0); + pid = sys_clone_unified(CLONE_PARENT | SIGCHLD, NULL, NULL, NULL, 0); if (pid < 0) { fail("fork"); exit(1); @@ -50,7 +50,7 @@ int main(int argc, char **argv) exit(1); } - if (waitid(P_ALL, 0, &info, WEXITED|WNOWAIT) < 0) { + if (waitid(P_ALL, 0, &info, WEXITED | WNOWAIT) < 0) { fail("waitpid"); exit(1); } @@ -58,7 +58,7 @@ int main(int argc, char **argv) test_daemon(); test_waitsig(); - if (waitid(P_ALL, 0, &info, WEXITED|WNOWAIT) < 0) { + if (waitid(P_ALL, 0, &info, WEXITED | WNOWAIT) < 0) { fail("waitpid"); exit(1); } diff --git a/test/zdtm/static/zombie_leader.c b/test/zdtm/static/zombie_leader.c index 1928687cd..e835ba689 100644 --- a/test/zdtm/static/zombie_leader.c +++ b/test/zdtm/static/zombie_leader.c @@ -7,8 +7,8 @@ #include "zdtmtst.h" -const char *test_doc = "Check non-empty session with zombie leader"; -const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; +const char *test_doc = "Check non-empty session with zombie leader"; +const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>"; int child(void) { @@ -44,8 +44,7 @@ int main(int argc, char **argv) test_init(argc, argv); - cpid = (int *)mmap(NULL, sizeof(int), PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_SHARED, -1, 0); + cpid = (int *)mmap(NULL, sizeof(int), PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED, -1, 0); *cpid = 0; pid = fork(); diff --git a/test/zdtm/transition/epoll.c b/test/zdtm/transition/epoll.c index 098eeb1fd..fdd492ab2 100644 --- a/test/zdtm/transition/epoll.c +++ b/test/zdtm/transition/epoll.c @@ -13,9 +13,9 @@ #include "zdtmtst.h" -const char *test_doc = "migrate application using epoll"; +const char *test_doc = "migrate application using epoll"; -#define MAX_SCALE 128 +#define MAX_SCALE 128 enum child_exit_codes { SUCCESS = 0, @@ -25,11 +25,7 @@ enum child_exit_codes { MAX_EXIT_CODE }; -static char *child_fail_reason[] = { - "Success", - "Can't get time", - "Can't write" -}; +static char *child_fail_reason[] = { "Success", "Can't get time", "Can't write" }; int scale = 13; TEST_OPTION(scale, int, "How many children should perform testing", 0); @@ -58,7 +54,7 @@ static void run_child(int num) { int fd = fds[num][1]; uint32_t crc = ~0; - size_t buf_size=512; + size_t buf_size = 512; uint8_t buf[buf_size]; struct timeval tv; struct timespec ts; @@ -80,15 +76,15 @@ static void run_child(int num) ts.tv_nsec = rand() % 999999999; nanosleep(&ts, &ts); if (write(fd, buf, buf_size) < 0 && - (!stop /* signal SIGUSR2 NOT received */ || - (errno != EINTR && errno != EPIPE))) { + (!stop /* signal SIGUSR2 NOT received */ || (errno != EINTR && errno != EPIPE))) { fail("child write"); rv = WRITEERROR; goto out; } } rv = SUCCESS; -out: close(fds[num][1]); +out: + close(fds[num][1]); exit(rv); } @@ -97,11 +93,9 @@ int main(int argc, char **argv) int rv, i; int counter = 0; int efd; - size_t buf_size=512; + size_t buf_size = 512; char buf[buf_size]; - struct epoll_event event = { - .events = EPOLLIN - }, *events; + struct epoll_event event = { .events = EPOLLIN }, *events; test_init(argc, argv); @@ -149,7 +143,7 @@ int main(int argc, char **argv) pids[i] = rv; } - if ((events = (struct epoll_event*) malloc (sizeof(struct epoll_event)*scale)) == NULL) { + if ((events = (struct epoll_event *)malloc(sizeof(struct epoll_event) * scale)) == NULL) { pr_perror("Can't allocate memory"); killall(); exit(1); @@ -164,7 +158,8 @@ int main(int argc, char **argv) exit(1); } for (i = 0; i < rv; i++) { - while (read(events[i].data.fd, buf, buf_size) > 0); + while (read(events[i].data.fd, buf, buf_size) > 0) + ; if (errno != EAGAIN && errno != 0 && errno) { pr_perror("read error"); killall(); @@ -184,8 +179,7 @@ int main(int argc, char **argv) } else { rv = WEXITSTATUS(rv); if (rv < MAX_EXIT_CODE && rv > SUCCESS) { - fail("Child failed: %s (%d)", - child_fail_reason[rv], rv); + fail("Child failed: %s (%d)", child_fail_reason[rv], rv); counter++; } else if (rv != SUCCESS) { fail("Unknown exitcode from child: %d", rv); diff --git a/test/zdtm/transition/fifo_dyn.c b/test/zdtm/transition/fifo_dyn.c index d72e1e6cd..09f337536 100644 --- a/test/zdtm/transition/fifo_dyn.c +++ b/test/zdtm/transition/fifo_dyn.c @@ -12,10 +12,10 @@ #include "zdtmtst.h" -const char *test_doc = "dynamic FIFO test"; +const char *test_doc = "dynamic FIFO test"; -#define PROCS_DEF 2 /* 0 - parent, 1 - child */ -#define BUF_SIZE 256 +#define PROCS_DEF 2 /* 0 - parent, 1 - child */ +#define BUF_SIZE 256 unsigned int num_procs = PROCS_DEF; char *filename; TEST_OPTION(filename, string, "file name", 1); @@ -70,8 +70,7 @@ int main(int argc, char **argv) if (pipe_in2out(readfd, writefd, buf, sizeof(buf)) < 0) /* pass errno as exit code to the parent */ - if (test_go() /* signal NOT delivered */ || - (errno != EINTR && errno != EPIPE)) + if (test_go() /* signal NOT delivered */ || (errno != EINTR && errno != EPIPE)) ret = errno; close(readfd); close(writefd); @@ -138,8 +137,7 @@ int main(int argc, char **argv) wait(&chret); chret = WEXITSTATUS(chret); if (chret) { - fail("child exited with non-zero code %d (%s)", - chret, strerror(chret)); + fail("child exited with non-zero code %d (%s)", chret, strerror(chret)); return 1; } if (!ret) diff --git a/test/zdtm/transition/fifo_loop.c b/test/zdtm/transition/fifo_loop.c index 51f93f645..a8f5e79be 100644 --- a/test/zdtm/transition/fifo_loop.c +++ b/test/zdtm/transition/fifo_loop.c @@ -12,12 +12,14 @@ #include "zdtmtst.h" -const char *test_doc = "Multi-process fifo loop"; -#define BUF_SIZE 256 -#define PROCS_DEF 4 +const char *test_doc = "Multi-process fifo loop"; +#define BUF_SIZE 256 +#define PROCS_DEF 4 unsigned int num_procs = PROCS_DEF; -TEST_OPTION(num_procs, uint, "# processes to create " - "(default " __stringify(PROCS_DEF) ")", 0); +TEST_OPTION(num_procs, uint, + "# processes to create " + "(default " __stringify(PROCS_DEF) ")", + 0); char *filename; TEST_OPTION(filename, string, "file name", 1); @@ -60,7 +62,7 @@ int main(int argc, char **argv) exit(1); } - for (i = 1; i < num_procs; i++) { /* i = 0 - parent */ + for (i = 1; i < num_procs; i++) { /* i = 0 - parent */ pid = test_fork(); if (pid < 0) { pr_perror("Can't fork"); @@ -71,16 +73,14 @@ int main(int argc, char **argv) file_path = path[i - 1]; readfd = open(file_path, O_RDONLY); if (readfd < 0) { - pr_perror("open(%s, O_RDONLY) failed", - file_path); + pr_perror("open(%s, O_RDONLY) failed", file_path); ret = errno; return ret; } file_path = path[i]; writefd = open(file_path, O_WRONLY); if (writefd < 0) { - pr_perror("open(%s, O_WRONLY) failed", - file_path); + pr_perror("open(%s, O_WRONLY) failed", file_path); ret = errno; return ret; } @@ -95,8 +95,7 @@ int main(int argc, char **argv) signal(SIGPIPE, SIG_IGN); if (pipe_in2out(readfd, writefd, buf, sizeof(buf)) < 0) /* pass errno as exit code to the parent */ - if (test_go() /* signal NOT delivered */ || - (errno != EINTR && errno != EPIPE)) + if (test_go() /* signal NOT delivered */ || (errno != EINTR && errno != EPIPE)) ret = errno; close(readfd); close(writefd); @@ -181,11 +180,11 @@ int main(int argc, char **argv) if (kill(0, SIGTERM)) { fail("failed to send SIGTERM to my process group"); - return 1; /* shouldn't wait() in this case */ + return 1; /* shouldn't wait() in this case */ } close(readfd); - for (i = 1; i < num_procs; i++) { /* i = 0 - parent */ + for (i = 1; i < num_procs; i++) { /* i = 0 - parent */ int chret; if (waitpid(pids[i], &chret, 0) < 0) { fail("waitpid error"); @@ -195,8 +194,7 @@ int main(int argc, char **argv) chret = WEXITSTATUS(chret); if (chret) { - fail("child %d exited with non-zero code %d (%s)", - i, chret, strerror(chret)); + fail("child %d exited with non-zero code %d (%s)", i, chret, strerror(chret)); ret = 1; continue; } diff --git a/test/zdtm/transition/file_aio.c b/test/zdtm/transition/file_aio.c index 4a76c9390..74146c918 100644 --- a/test/zdtm/transition/file_aio.c +++ b/test/zdtm/transition/file_aio.c @@ -1,6 +1,6 @@ #include "zdtmtst.h" -const char *test_doc = "test for AIO"; +const char *test_doc = "test for AIO"; const char *test_author = "Andrew Vagin <avagin@parallels.com>"; #include <stdio.h> @@ -20,8 +20,8 @@ int main(int argc, char **argv) char buf[BUF_SIZE]; int fd; struct aiocb aiocb; - const struct aiocb *aioary[1]; - char tmpfname[256]="/tmp/file_aio.XXXXXX"; + const struct aiocb *aioary[1]; + char tmpfname[256] = "/tmp/file_aio.XXXXXX"; int ret; test_init(argc, argv); @@ -62,10 +62,10 @@ int main(int argc, char **argv) } /* Wait for request completion */ aioary[0] = &aiocb; -again: + again: ret = aio_suspend(aioary, 1, NULL); if (ret < 0) { - if ((errno == EINTR) && (! test_go())) + if ((errno == EINTR) && (!test_go())) break; if (errno != EINTR) { pr_perror("aio_suspend failed"); diff --git a/test/zdtm/transition/file_read.c b/test/zdtm/transition/file_read.c index 9b5670c65..7729e9f61 100644 --- a/test/zdtm/transition/file_read.c +++ b/test/zdtm/transition/file_read.c @@ -11,12 +11,12 @@ #include "zdtmtst.h" -const char *test_doc = "Fill/read file continuously to check" - "it's migrated at the right moment"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Fill/read file continuously to check" + "it's migrated at the right moment"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; -#define MAX_SCALE 128 -#define FILE_SIZE (16 * 1024) +#define MAX_SCALE 128 +#define FILE_SIZE (16 * 1024) enum kids_exit_codes { SUCCESS = 0, @@ -31,16 +31,14 @@ enum kids_exit_codes { MAX_EXIT_CODE_VAL }; -static char *kids_fail_reasons[] = { - "Success", - /* 1 */ "File corrupted", - /* 2 */ "Map failed", - /* 3 */ "Open (create) failed", - /* 4 */ "Write failed", - /* 5 */ "Read failed", - /* 6 */ "Fsync failed", - /* 7 */ "Lseek failed" -}; +static char *kids_fail_reasons[] = { "Success", + /* 1 */ "File corrupted", + /* 2 */ "Map failed", + /* 3 */ "Open (create) failed", + /* 4 */ "Write failed", + /* 5 */ "Read failed", + /* 6 */ "Fsync failed", + /* 7 */ "Lseek failed" }; int scale = 13; TEST_OPTION(scale, int, "How many children should perform testing", 0); @@ -120,8 +118,7 @@ static void chew_some_file(int num) int fd, rv; char chew_file[PATH_MAX]; - buf = mmap(NULL, FILE_SIZE, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); + buf = mmap(NULL, FILE_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); rv = MMAP_FAILED; if (buf == MAP_FAILED) goto out_exit; @@ -157,8 +154,7 @@ static void chew_some_file(int num) case -2: rv = SEEK_FAILED; goto out_exit; - case 1: - { + case 1: { int fd1; char str[PATH_MAX]; @@ -170,7 +166,7 @@ static void chew_some_file(int num) pr_perror("can't write %s", str); close(fd1); goto out_exit; - } + } } } rv = SUCCESS; @@ -227,8 +223,7 @@ int main(int argc, char **argv) } else { rv = WEXITSTATUS(rv); if (rv < MAX_EXIT_CODE_VAL && rv > SUCCESS) { - fail("Kid failed: %s (%d)", - kids_fail_reasons[rv], rv); + fail("Kid failed: %s (%d)", kids_fail_reasons[rv], rv); counter++; } else if (rv != SUCCESS) { fail("Unknown exitcode from kid: %d", rv); diff --git a/test/zdtm/transition/fork.c b/test/zdtm/transition/fork.c index 9ab160599..4f0049a29 100644 --- a/test/zdtm/transition/fork.c +++ b/test/zdtm/transition/fork.c @@ -86,7 +86,6 @@ int main(int argc, char **argv) goto out; } } - } pass(); out: diff --git a/test/zdtm/transition/ipc.c b/test/zdtm/transition/ipc.c index be52d7396..0f16dbc68 100644 --- a/test/zdtm/transition/ipc.c +++ b/test/zdtm/transition/ipc.c @@ -14,8 +14,8 @@ #include "zdtmtst.h" -const char *test_doc="Tests ipc sems and shmems migrate fine"; -const char *test_author="Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Tests ipc sems and shmems migrate fine"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; static struct sembuf unlock = { .sem_op = 1, @@ -29,13 +29,13 @@ static struct sembuf lock = { .sem_flg = 0, }; -#define DEF_MEM_SIZE (40960) +#define DEF_MEM_SIZE (40960) unsigned int shmem_size = DEF_MEM_SIZE; TEST_OPTION(shmem_size, uint, "Size of shared memory segment", 0); -#define INIT_CRC (~0) +#define INIT_CRC (~0) -#define POISON 0xac +#define POISON 0xac static inline void poison_area(int *mem) { memset(mem, POISON, shmem_size); @@ -68,7 +68,8 @@ static int child(key_t key) } crc = INIT_CRC; datagen(mem, shmem_size, &crc); - while ((ret = semop(sem, &unlock, 1)) && (errno == EINTR)); + while ((ret = semop(sem, &unlock, 1)) && (errno == EINTR)) + ; if (ret) { fail("Error in semop unlock"); res = errno; @@ -97,7 +98,7 @@ int main(int argc, char **argv) } sem = semget(key, 1, 0777 | IPC_CREAT | IPC_EXCL); - if (sem == -1) { + if (sem == -1) { pr_perror("Can't get sem"); goto out; } @@ -154,13 +155,14 @@ int main(int argc, char **argv) if (datachk(mem, shmem_size, &crc)) { fail_count++; fail("Semaphore protection is broken or " - "shmem pages are messed"); + "shmem pages are messed"); semop(sem, &unlock, 1); break; } poison_area((int *)mem); } - while ((ret = semop(sem, &unlock, 1)) && (errno == EINTR)); + while ((ret = semop(sem, &unlock, 1)) && (errno == EINTR)) + ; if (ret) { fail_count++; fail("Error in semop unlock"); diff --git a/test/zdtm/transition/lazy-thp.c b/test/zdtm/transition/lazy-thp.c index 01075d773..2bf99dc4c 100644 --- a/test/zdtm/transition/lazy-thp.c +++ b/test/zdtm/transition/lazy-thp.c @@ -13,12 +13,12 @@ #define N_PAGES 1024 -const char *test_doc = "Test interaction between THP and lazy-pages"; +const char *test_doc = "Test interaction between THP and lazy-pages"; /* The test is based on example by Adrian Reber <areber@redhat.com> */ -const char *test_author = "Mike Rapoport <rppt@linux.vnet.ibm.com>"; +const char *test_author = "Mike Rapoport <rppt@linux.vnet.ibm.com>"; -int main(int argc, char ** argv) +int main(int argc, char **argv) { char *mem, *org, *m; int count; @@ -44,7 +44,7 @@ int main(int argc, char ** argv) } for (count = 0; count < N_PAGES; count++) { - m = mem+(count*PAGE_SIZE); + m = mem + (count * PAGE_SIZE); org[128] = (count % 2 == 0) ? count : 0x42; if (memcmp(org, m, PAGE_SIZE)) { diff --git a/test/zdtm/transition/maps007.c b/test/zdtm/transition/maps007.c index ee5e7c7f7..8a605cfe0 100644 --- a/test/zdtm/transition/maps007.c +++ b/test/zdtm/transition/maps007.c @@ -15,12 +15,12 @@ #define MAP_SIZE (1UL << 20) #define MEM_SIZE (1UL << 29) -const char *test_doc = "create random mappings and touch memory"; +const char *test_doc = "create random mappings and touch memory"; int sys_process_vm_readv(pid_t pid, void *addr, void *buf, int size) { - struct iovec lvec = {.iov_base = buf, .iov_len = size }; - struct iovec rvec = {.iov_base = addr, .iov_len = size }; + struct iovec lvec = { .iov_base = buf, .iov_len = size }; + struct iovec rvec = { .iov_base = addr, .iov_len = size }; /* workaround bug in glibc with sixth argument of syscall */ char nop[PAGE_SIZE]; @@ -38,7 +38,7 @@ int main(int argc, char **argv) struct { futex_t delta; futex_t stop; - } *shm; + } * shm; uint32_t v; unsigned long long count = 0; int i; @@ -84,8 +84,7 @@ int main(int argc, char **argv) /* shm->delta must be always bigger than MAX_DELTA */ futex_wait_while_lt(&shm->delta, MAX_DELTA + 2); else if (count % 100 == 0) - test_msg("count %llu delta %d\n", - count, futex_get(&shm->delta)); /* heartbeat */ + test_msg("count %llu delta %d\n", count, futex_get(&shm->delta)); /* heartbeat */ if (futex_get(&shm->stop) && atomic_get(&shm->delta.raw) == MAX_DELTA) break; @@ -173,6 +172,6 @@ int main(int argc, char **argv) return 0; err: kill(child, SIGSEGV); - *((volatile int *) 0) = 0; + *((volatile int *)0) = 0; return 1; } diff --git a/test/zdtm/transition/maps008.c b/test/zdtm/transition/maps008.c index 851814c11..e5aa236ef 100644 --- a/test/zdtm/transition/maps008.c +++ b/test/zdtm/transition/maps008.c @@ -62,8 +62,7 @@ static void cont_and_wait_child(pid_t pid) static void *mmap_ashmem(size_t size) { - void *mem = mmap(NULL, size, PROT_WRITE | PROT_READ, - MAP_SHARED | MAP_ANONYMOUS, -1, 0); + void *mem = mmap(NULL, size, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_ANONYMOUS, -1, 0); if (mem == MAP_FAILED) { pr_perror("Can't map shmem %zx", size); exit(1); @@ -71,15 +70,13 @@ static void *mmap_ashmem(size_t size) return mem; } -static void *mmap_proc_mem(pid_t pid, unsigned long addr, - unsigned long size) +static void *mmap_proc_mem(pid_t pid, unsigned long addr, unsigned long size) { int fd; void *mem; char path[PATH_MAX]; - snprintf(path, PATH_MAX, "/proc/%d/map_files/%lx-%lx", - (int)pid, addr, addr + size); + snprintf(path, PATH_MAX, "/proc/%d/map_files/%lx-%lx", (int)pid, addr, addr + size); fd = open(path, O_RDWR); if (fd == -1) { pr_perror("Can't open file %s", path); @@ -100,8 +97,7 @@ static void check_mem_eq(void *addr1, size_t size1, void *addr2, size_t size2) unsigned long min_size = size1 < size2 ? size1 : size2; if (memcmp(addr1, addr2, min_size)) { - pr_err("Mem differs %lx %lx %lx", (unsigned long)addr1, - (unsigned long)addr2, min_size); + pr_err("Mem differs %lx %lx %lx\n", (unsigned long)addr1, (unsigned long)addr2, min_size); exit(1); } } @@ -114,8 +110,7 @@ static void xmunmap(void *map, size_t size) } } -static void chk_proc_mem_eq(pid_t pid1, void *addr1, unsigned long size1, - pid_t pid2, void *addr2, unsigned long size2) +static void chk_proc_mem_eq(pid_t pid1, void *addr1, unsigned long size1, pid_t pid2, void *addr2, unsigned long size2) { void *map1, *map2; @@ -136,14 +131,14 @@ static void chk_proc_mem_eq(pid_t pid1, void *addr1, unsigned long size1, */ #define PROC_CNT 7 -#define PROC1_PGIX 0 -#define PROC11_PGIX 1 -#define PROC12_PGIX 2 -#define PROC13_PGIX 3 +#define PROC1_PGIX 0 +#define PROC11_PGIX 1 +#define PROC12_PGIX 2 +#define PROC13_PGIX 3 #define PROC111_PGIX 4 #define PROC112_PGIX 5 #define PROC131_PGIX 6 -#define ZERO_PGIX 7 +#define ZERO_PGIX 7 /* unused pgix: 8 */ #define MEM_PERIOD (9 * PAGE_SIZE) @@ -278,12 +273,9 @@ static int proc13_func(task_waiter_t *setup_waiter) mems_datachck_each_pgix(PROC13_PGIX); - chk_proc_mem_eq(pstree->proc13, mem1, mem1_size, - pstree->proc131, mem1, mem1_size); - chk_proc_mem_eq(pstree->proc13, mem2, mem2_size, - pstree->proc131, mem2, mem2_size); - chk_proc_mem_eq(pstree->proc13, mem3, mem3_size, - pstree->proc131, mem3, mem3_size); + chk_proc_mem_eq(pstree->proc13, mem1, mem1_size, pstree->proc131, mem1, mem1_size); + chk_proc_mem_eq(pstree->proc13, mem2, mem2_size, pstree->proc131, mem2, mem2_size); + chk_proc_mem_eq(pstree->proc13, mem3, mem3_size, pstree->proc131, mem3, mem3_size); cont_and_wait_child(pstree->proc131); return 0; @@ -368,23 +360,16 @@ static int proc11_func(task_waiter_t *setup_waiter) mems_datachck_each_pgix(PROC11_PGIX); - chk_proc_mem_eq(pstree->proc11, mem1, mem1_size, - pstree->proc111, mem1, mem1_size); - chk_proc_mem_eq(pstree->proc11, mem1, mem1_size, - pstree->proc112, mem1, mem1_size); + chk_proc_mem_eq(pstree->proc11, mem1, mem1_size, pstree->proc111, mem1, mem1_size); + chk_proc_mem_eq(pstree->proc11, mem1, mem1_size, pstree->proc112, mem1, mem1_size); - chk_proc_mem_eq(pstree->proc11, mem2, mem2_size, - pstree->proc111, mem2, mem2_size); - chk_proc_mem_eq(pstree->proc11, mem2, mem2_size, - pstree->proc112, mem2, mem2_size); + chk_proc_mem_eq(pstree->proc11, mem2, mem2_size, pstree->proc111, mem2, mem2_size); + chk_proc_mem_eq(pstree->proc11, mem2, mem2_size, pstree->proc112, mem2, mem2_size); - chk_proc_mem_eq(pstree->proc11, mem3, mem3_size, - pstree->proc111, mem3, mem3_size + MEM3_END_CUT); - chk_proc_mem_eq(pstree->proc11, mem3, mem3_size, - pstree->proc112, mem3, mem3_size + MEM3_END_CUT); + chk_proc_mem_eq(pstree->proc11, mem3, mem3_size, pstree->proc111, mem3, mem3_size + MEM3_END_CUT); + chk_proc_mem_eq(pstree->proc11, mem3, mem3_size, pstree->proc112, mem3, mem3_size + MEM3_END_CUT); - proc1_mem3 = mmap_proc_mem(pstree->proc1, - (unsigned long)mem3_old, mem3_size_old); + proc1_mem3 = mmap_proc_mem(pstree->proc1, (unsigned long)mem3_old, mem3_size_old); check_mem_eq(mem3, mem3_size, proc1_mem3 + MEM3_START_CUT, mem3_size); xmunmap(proc1_mem3, mem3_size_old); @@ -394,7 +379,7 @@ static int proc11_func(task_waiter_t *setup_waiter) } #define MAX(a, b) ((a) > (b) ? (a) : (b)) -#define MB(n) ((n) * (1UL << 20)) +#define MB(n) ((n) * (1UL << 20)) static int proc1_func(void) { @@ -423,8 +408,7 @@ static int proc1_func(void) fork_and_setup(proc13_func); xmunmap(mem1, mem1_size); - if (mremap(mem2, mem2_size, mem1_size, MREMAP_MAYMOVE | MREMAP_FIXED, - mem1) != mem1) { + if (mremap(mem2, mem2_size, mem1_size, MREMAP_MAYMOVE | MREMAP_FIXED, mem1) != mem1) { pr_perror("proc1 mem2 remap"); exit(1); } @@ -441,13 +425,10 @@ static int proc1_func(void) mems_datachck_each_pgix(PROC1_PGIX); - chk_proc_mem_eq(pstree->proc1, mem1, mem1_size, - pstree->proc11, mem2_old, mem2_size); - chk_proc_mem_eq(pstree->proc1, mem1, mem1_size, - pstree->proc12, mem2_old, mem2_size); + chk_proc_mem_eq(pstree->proc1, mem1, mem1_size, pstree->proc11, mem2_old, mem2_size); + chk_proc_mem_eq(pstree->proc1, mem1, mem1_size, pstree->proc12, mem2_old, mem2_size); - chk_proc_mem_eq(pstree->proc1, mem3, mem3_size, - pstree->proc12, mem3, mem3_size); + chk_proc_mem_eq(pstree->proc1, mem3, mem3_size, pstree->proc12, mem3, mem3_size); cont_and_wait_child(pstree->proc11); cont_and_wait_child(pstree->proc12); @@ -490,10 +471,7 @@ static void sigchld_hand(int signo, siginfo_t *info, void *ucontext) int main(int argc, char **argv) { - struct sigaction sa = { - .sa_sigaction = sigchld_hand, - .sa_flags = SA_RESTART | SA_SIGINFO | SA_NOCLDSTOP - }; + struct sigaction sa = { .sa_sigaction = sigchld_hand, .sa_flags = SA_RESTART | SA_SIGINFO | SA_NOCLDSTOP }; sigemptyset(&sa.sa_mask); test_init(argc, argv); diff --git a/test/zdtm/transition/netlink00.c b/test/zdtm/transition/netlink00.c index 8e7d33c95..2bc4aebd3 100644 --- a/test/zdtm/transition/netlink00.c +++ b/test/zdtm/transition/netlink00.c @@ -25,14 +25,14 @@ #undef DEBUG //#define DEBUG -const char *test_doc = "Netlink socket loop"; +const char *test_doc = "Netlink socket loop"; const char *test_author = "Andrew Vagin (avagin@parallels.com)"; //buffer to hold the RTNETLINK request struct { - struct nlmsghdr nl; - struct rtmsg rt; - char buf[8192]; + struct nlmsghdr nl; + struct rtmsg rt; + char buf[8192]; } req; // variables used for @@ -46,7 +46,7 @@ int rtn; // buffer to hold the RTNETLINK reply(ies) char buf[8192]; char dsts[24] = "192.168.0.255"; -int pn = 32;//network prefix +int pn = 32; //network prefix // RTNETLINK message pointers & lengths // used when processing messages @@ -63,8 +63,7 @@ int form_request_del(void); int read_reply(void); typedef int (*cmd_t)(void); #define CMD_NUM 2 -cmd_t cmd[CMD_NUM]={form_request_add, form_request_del}; - +cmd_t cmd[CMD_NUM] = { form_request_add, form_request_del }; int main(int argc, char *argv[]) { @@ -73,7 +72,7 @@ int main(int argc, char *argv[]) test_init(argc, argv); fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); - if (fd<0){ + if (fd < 0) { pr_perror("socket"); goto out; } @@ -82,7 +81,7 @@ int main(int argc, char *argv[]) bzero(&la, sizeof(la)); la.nl_family = AF_NETLINK; la.nl_pid = getpid(); - if (bind(fd, (struct sockaddr*) &la, sizeof(la))){ + if (bind(fd, (struct sockaddr *)&la, sizeof(la))) { pr_perror("bind failed"); goto out; } @@ -93,20 +92,20 @@ int main(int argc, char *argv[]) test_daemon(); - while (test_go()){ - for (i=0; i < CMD_NUM; i++){ + while (test_go()) { + for (i = 0; i < CMD_NUM; i++) { cmd[i](); - if (send_request() < 0){ + if (send_request() < 0) { fail("send_request failed"); goto out; }; - if (recv_reply() < 0){ + if (recv_reply() < 0) { fail("RTNETLINK answers"); goto out; }; #ifdef DEBUG - if (read_reply() < 0){ + if (read_reply() < 0) { fail("read_reply failed"); goto out; } @@ -129,17 +128,17 @@ int send_request(void) // initialize & create the struct msghdr supplied // to the sendmsg() function bzero(&msg, sizeof(msg)); - msg.msg_name = (void *) &pa; + msg.msg_name = (void *)&pa; msg.msg_namelen = sizeof(pa); // place the pointer & size of the RTNETLINK // message in the struct msghdr - iov.iov_base = (void *) &req.nl; + iov.iov_base = (void *)&req.nl; iov.iov_len = req.nl.nlmsg_len; msg.msg_iov = &iov; msg.msg_iovlen = 1; // send the RTNETLINK message to kernel rtn = sendmsg(fd, &msg, 0); - if (rtn<0){ + if (rtn < 0) { pr_perror("sendmsg failed"); return -1; } @@ -155,7 +154,7 @@ int recv_reply(void) // read from the socket until the NLMSG_DONE is // returned in the type of the RTNETLINK message // or if it was a monitoring socket - while(1) { + while (1) { rtn = recv(fd, p, sizeof(buf) - nll, 0); if (rtn < 0) { pr_perror("recv failed"); @@ -167,12 +166,12 @@ int recv_reply(void) return -1; } - nlp = (struct nlmsghdr *) p; - if(nlp->nlmsg_type == NLMSG_DONE) + nlp = (struct nlmsghdr *)p; + if (nlp->nlmsg_type == NLMSG_DONE) return 0; if (nlp->nlmsg_type == NLMSG_ERROR) { - struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(nlp); - errno=-err->error; + struct nlmsgerr *err = (struct nlmsgerr *)NLMSG_DATA(nlp); + errno = -err->error; if (errno) { return -1; } @@ -184,8 +183,7 @@ int recv_reply(void) // increment the total size by the size of // the last received message nll += rtn; - if((la.nl_groups & RTMGRP_IPV4_ROUTE) - == RTMGRP_IPV4_ROUTE) + if ((la.nl_groups & RTMGRP_IPV4_ROUTE) == RTMGRP_IPV4_ROUTE) break; } return 0; @@ -199,14 +197,13 @@ int read_reply(void) // outer loop: loops thru all the NETLINK // headers that also include the route entry // header - nlp = (struct nlmsghdr *) buf; - for(; NLMSG_OK(nlp, nll); nlp = NLMSG_NEXT(nlp, nll)) - { + nlp = (struct nlmsghdr *)buf; + for (; NLMSG_OK(nlp, nll); nlp = NLMSG_NEXT(nlp, nll)) { // get route entry header - rtp = (struct rtmsg *) NLMSG_DATA(nlp); + rtp = (struct rtmsg *)NLMSG_DATA(nlp); // we are only concerned about the // main route table - if(rtp->rtm_table != RT_TABLE_MAIN) + if (rtp->rtm_table != RT_TABLE_MAIN) continue; // init all the strings bzero(dsts, sizeof(dsts)); @@ -215,40 +212,33 @@ int read_reply(void) bzero(ms, sizeof(ms)); // inner loop: loop thru all the attributes of // one route entry - rtap = (struct rtattr *) RTM_RTA(rtp); + rtap = (struct rtattr *)RTM_RTA(rtp); rtl = RTM_PAYLOAD(nlp); - for( ; RTA_OK(rtap, rtl); rtap = RTA_NEXT(rtap,rtl)) - { - switch(rtap->rta_type) - { - // destination IPv4 address - case RTA_DST: - inet_ntop(AF_INET, RTA_DATA(rtap), - dsts, 24); - break; - // next hop IPv4 address - case RTA_GATEWAY: - inet_ntop(AF_INET, RTA_DATA(rtap), - gws, 24); - break; - // unique ID associated with the network - // interface - case RTA_OIF: - sprintf(ifs, "%d", - *((int *) RTA_DATA(rtap))); - default: - break; + for (; RTA_OK(rtap, rtl); rtap = RTA_NEXT(rtap, rtl)) { + switch (rtap->rta_type) { + // destination IPv4 address + case RTA_DST: + inet_ntop(AF_INET, RTA_DATA(rtap), dsts, 24); + break; + // next hop IPv4 address + case RTA_GATEWAY: + inet_ntop(AF_INET, RTA_DATA(rtap), gws, 24); + break; + // unique ID associated with the network + // interface + case RTA_OIF: + sprintf(ifs, "%d", *((int *)RTA_DATA(rtap))); + default: + break; } } sprintf(ms, "%d", rtp->rtm_dst_len); - test_msg("dst %s/%s gw %s if %s\n", - dsts, ms, gws, ifs); + test_msg("dst %s/%s gw %s if %s\n", dsts, ms, gws, ifs); } return 0; } -#define NLMSG_TAIL(nmsg) \ - ((struct rtattr *) (((void *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len))) +#define NLMSG_TAIL(nmsg) ((struct rtattr *)(((void *)(nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len))) int form_request_del(void) { @@ -258,8 +248,7 @@ int form_request_del(void) rtap = NLMSG_TAIL(&req.nl); rtap->rta_type = RTA_DST; rtap->rta_len = RTA_LENGTH(4); - inet_pton(AF_INET, dsts, - ((char *)rtap) + sizeof(struct rtattr)); + inet_pton(AF_INET, dsts, ((char *)rtap) + sizeof(struct rtattr)); req.nl.nlmsg_len = NLMSG_ALIGN(req.nl.nlmsg_len) + RTA_ALIGN(rtap->rta_len); req.nl.nlmsg_flags = NLM_F_CREATE | NLM_F_ACK | NLM_F_REQUEST; req.nl.nlmsg_type = RTM_DELROUTE; @@ -281,15 +270,13 @@ int form_request_add(void) rtap = NLMSG_TAIL(&req.nl); rtap->rta_type = RTA_DST; rtap->rta_len = RTA_LENGTH(4); - inet_pton(AF_INET, dsts, - ((char *)rtap) + sizeof(struct rtattr)); + inet_pton(AF_INET, dsts, ((char *)rtap) + sizeof(struct rtattr)); req.nl.nlmsg_len = NLMSG_ALIGN(req.nl.nlmsg_len) + RTA_ALIGN(rtap->rta_len); rtap = NLMSG_TAIL(&req.nl); - rtap->rta_type = RTA_OIF;//Output interface index + rtap->rta_type = RTA_OIF; //Output interface index rtap->rta_len = RTA_LENGTH(sizeof(int)); - memcpy(((char *)rtap) + sizeof(struct rtattr), - &ifcn, sizeof(int)); + memcpy(((char *)rtap) + sizeof(struct rtattr), &ifcn, sizeof(int)); req.nl.nlmsg_len = NLMSG_ALIGN(req.nl.nlmsg_len) + RTA_ALIGN(rtap->rta_len); req.nl.nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_ACK; diff --git a/test/zdtm/transition/pipe_loop00.c b/test/zdtm/transition/pipe_loop00.c index 73e05e217..fa1f0eee4 100644 --- a/test/zdtm/transition/pipe_loop00.c +++ b/test/zdtm/transition/pipe_loop00.c @@ -10,15 +10,16 @@ #include "zdtmtst.h" -const char *test_doc = "Multi-process pipe loop"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Multi-process pipe loop"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; -#define PROCS_DEF 4 -#define PROCS_MAX 64 +#define PROCS_DEF 4 +#define PROCS_MAX 64 unsigned int num_procs = PROCS_DEF; -TEST_OPTION(num_procs, uint, "# processes to create " - "(default " __stringify(PROCS_DEF) - ", max " __stringify(PROCS_MAX) ")", 0); +TEST_OPTION(num_procs, uint, + "# processes to create " + "(default " __stringify(PROCS_DEF) ", max " __stringify(PROCS_MAX) ")", + 0); volatile sig_atomic_t num_exited = 0; void inc_num_exited(int signo) @@ -53,7 +54,7 @@ int main(int argc, char **argv) exit(1); } - for (i = 1; i < num_procs; i++) { /* i = 0 - parent */ + for (i = 1; i < num_procs; i++) { /* i = 0 - parent */ pid = test_fork(); if (pid < 0) { pr_perror("Can't fork"); @@ -72,11 +73,10 @@ int main(int argc, char **argv) signal(SIGPIPE, SIG_IGN); if (pipe_in2out(pipes[in], pipes[out], buf, sizeof(buf)) < 0) /* pass errno as exit code to the parent */ - if (test_go() /* signal NOT delivered */ || - (errno != EINTR && errno != EPIPE)) + if (test_go() /* signal NOT delivered */ || (errno != EINTR && errno != EPIPE)) ret = errno; - test_waitsig(); /* even if failed, wait for migration to complete */ + test_waitsig(); /* even if failed, wait for migration to complete */ close(pipes[in]); close(pipes[out]); @@ -90,7 +90,7 @@ int main(int argc, char **argv) out = pipes[num_procs * 2 - 1]; /* don't block on writing, _do_ block on reading */ - if (set_nonblock(out,1) < 0) { + if (set_nonblock(out, 1) < 0) { pr_perror("setting O_NONBLOCK failed"); exit(1); } @@ -143,14 +143,14 @@ int main(int argc, char **argv) close(out); - test_waitsig(); /* even if failed, wait for migration to complete */ + test_waitsig(); /* even if failed, wait for migration to complete */ if (kill(0, SIGTERM)) { fail("failed to send SIGTERM to my process group"); - goto out; /* shouldn't wait() in this case */ + goto out; /* shouldn't wait() in this case */ } - for (i = 1; i < num_procs; i++) { /* i = 0 - parent */ + for (i = 1; i < num_procs; i++) { /* i = 0 - parent */ int chret; if (wait(&chret) < 0) { fail("can't wait for a child"); @@ -160,8 +160,7 @@ int main(int argc, char **argv) chret = WEXITSTATUS(chret); if (chret) { - fail("child %d exited with non-zero code %d (%s)", - i, chret, strerror(chret)); + fail("child %d exited with non-zero code %d (%s)", i, chret, strerror(chret)); ret = 1; continue; } diff --git a/test/zdtm/transition/pipe_shared00.c b/test/zdtm/transition/pipe_shared00.c index d1dcd665d..421a8d0bf 100644 --- a/test/zdtm/transition/pipe_shared00.c +++ b/test/zdtm/transition/pipe_shared00.c @@ -10,15 +10,16 @@ #include "zdtmtst.h" -const char *test_doc = "Multi-process pipe split"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Multi-process pipe split"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; -#define PROCS_DEF 4 -#define PROCS_MAX 64 +#define PROCS_DEF 4 +#define PROCS_MAX 64 unsigned int num_procs = PROCS_DEF; -TEST_OPTION(num_procs, uint, "# processes to create " - "(default " __stringify(PROCS_DEF) - ", max " __stringify(PROCS_MAX) ")", 0); +TEST_OPTION(num_procs, uint, + "# processes to create " + "(default " __stringify(PROCS_DEF) ", max " __stringify(PROCS_MAX) ")", + 0); volatile sig_atomic_t num_exited = 0; void inc_num_exited(int signo) @@ -53,7 +54,7 @@ int main(int argc, char **argv) exit(1); } - for (i = 1; i < num_procs; i++) { /* i = 0 - parent */ + for (i = 1; i < num_procs; i++) { /* i = 0 - parent */ pid = test_fork(); if (pid < 0) { pr_perror("can't fork"); @@ -69,7 +70,7 @@ int main(int argc, char **argv) if (rlen == 0) break; else if (rlen < 0) { - ret = errno; /* pass errno as exit code to the parent */ + ret = errno; /* pass errno as exit code to the parent */ break; } @@ -81,7 +82,7 @@ int main(int argc, char **argv) } } - test_waitsig(); /* even if failed, wait for migration to complete */ + test_waitsig(); /* even if failed, wait for migration to complete */ close(pipes[0]); exit(ret); @@ -99,23 +100,23 @@ int main(int argc, char **argv) test_daemon(); memset(buf, SND_CHR, sizeof(buf)); - while(test_go()) + while (test_go()) if (write(pipes[1], buf, sizeof(buf)) < 0 && - (errno != EINTR || test_go())) { /* only SIGTERM may stop us */ + (errno != EINTR || test_go())) { /* only SIGTERM may stop us */ fail("write failed"); ret = 1; break; } close(pipes[1]); - test_waitsig(); /* even if failed, wait for migration to complete */ + test_waitsig(); /* even if failed, wait for migration to complete */ if (kill(0, SIGTERM)) { fail("failed to send SIGTERM to my process group"); - goto out; /* shouldn't wait() in this case */ + goto out; /* shouldn't wait() in this case */ } - for (i = 1; i < num_procs; i++) { /* i = 0 - parent */ + for (i = 1; i < num_procs; i++) { /* i = 0 - parent */ int chret; if (wait(&chret) < 0) { fail("can't wait for a child"); @@ -125,8 +126,7 @@ int main(int argc, char **argv) chret = WEXITSTATUS(chret); if (chret) { - fail("child exited with non-zero code %d (%s)", - chret, strerror(chret)); + fail("child exited with non-zero code %d (%s)", chret, strerror(chret)); ret = 1; continue; } diff --git a/test/zdtm/transition/ptrace.c b/test/zdtm/transition/ptrace.c index 29e2e01d9..bf6344f1c 100644 --- a/test/zdtm/transition/ptrace.c +++ b/test/zdtm/transition/ptrace.c @@ -15,7 +15,7 @@ const char *test_doc = "Tests that ptraced thread do not escape from tracing"; const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; -#define NR_THREADS 2 +#define NR_THREADS 2 unsigned int nr_threads = NR_THREADS; TEST_OPTION(nr_threads, uint, "Number of threads", 0); @@ -30,17 +30,15 @@ static void *thread(void *arg) int main(int argc, char **argv) { int pid, status, i, stopped; -#define PT_REGS_SIZE 4096 /* big enough for any arch */ -#define PT_REGS_ALIGN 16 /* big enough for any arch */ +#define PT_REGS_SIZE 4096 /* big enough for any arch */ +#define PT_REGS_ALIGN 16 /* big enough for any arch */ char regs[PT_REGS_SIZE] __attribute__((aligned(PT_REGS_ALIGN))); int *pids; test_init(argc, argv); - pids = (int *)mmap(NULL, sizeof(int) * nr_threads, - PROT_READ | PROT_WRITE, - MAP_SHARED | MAP_ANONYMOUS, 0, 0); + pids = (int *)mmap(NULL, sizeof(int) * nr_threads, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); if (pids == MAP_FAILED) { pr_perror("Can't map"); exit(1); @@ -62,8 +60,8 @@ int main(int argc, char **argv) } } thread(pids + i); -out_th: - for (i--; i >=0; i--) { + out_th: + for (i--; i >= 0; i--) { pthread_kill(pt[i], SIGKILL); pthread_join(pt[i], NULL); } diff --git a/test/zdtm/transition/shmem.c b/test/zdtm/transition/shmem.c index 39ccfbe9b..bca0f06c8 100644 --- a/test/zdtm/transition/shmem.c +++ b/test/zdtm/transition/shmem.c @@ -7,9 +7,9 @@ #include "zdtmtst.h" -const char *test_author = "Andrei Vagin <avagin@virtuozzo.com>"; +const char *test_author = "Andrei Vagin <avagin@virtuozzo.com>"; -#define MEM_SIZE (1<<25) +#define MEM_SIZE (1 << 25) int main(int argc, char **argv) { diff --git a/test/zdtm/transition/socket_loop00.c b/test/zdtm/transition/socket_loop00.c index 85dba1155..5a13ecb34 100644 --- a/test/zdtm/transition/socket_loop00.c +++ b/test/zdtm/transition/socket_loop00.c @@ -11,15 +11,16 @@ #include "zdtmtst.h" -const char *test_doc = "Multi-process socket loop"; -const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; +const char *test_doc = "Multi-process socket loop"; +const char *test_author = "Pavel Emelianov <xemul@parallels.com>"; -#define PROCS_DEF 4 -#define PROCS_MAX 64 +#define PROCS_DEF 4 +#define PROCS_MAX 64 unsigned int num_procs = PROCS_DEF; -TEST_OPTION(num_procs, uint, "# processes to create " - "(default " __stringify(PROCS_DEF) - ", max " __stringify(PROCS_MAX) ")", 0); +TEST_OPTION(num_procs, uint, + "# processes to create " + "(default " __stringify(PROCS_DEF) ", max " __stringify(PROCS_MAX) ")", + 0); volatile sig_atomic_t num_exited = 0; void inc_num_exited(int signo) @@ -54,7 +55,7 @@ int main(int argc, char **argv) exit(1); } - for (i = 1; i < num_procs; i++) { /* i = 0 - parent */ + for (i = 1; i < num_procs; i++) { /* i = 0 - parent */ pid = test_fork(); if (pid < 0) { pr_perror("Can't fork"); @@ -74,11 +75,10 @@ int main(int argc, char **argv) if (pipe_in2out(socks[in], socks[out], buf, sizeof(buf)) < 0) /* pass errno as exit code to the parent */ if (test_go() /* signal NOT delivered */ || - (errno != EINTR && errno != EPIPE - && errno != ECONNRESET)) + (errno != EINTR && errno != EPIPE && errno != ECONNRESET)) ret = errno; - test_waitsig(); /* even if failed, wait for migration to complete */ + test_waitsig(); /* even if failed, wait for migration to complete */ close(socks[in]); close(socks[out]); @@ -92,7 +92,7 @@ int main(int argc, char **argv) out = socks[num_procs * 2 - 1]; /* don't block on writing, _do_ block on reading */ - if (set_nonblock(out,1) < 0) { + if (set_nonblock(out, 1) < 0) { pr_perror("setting O_NONBLOCK failed"); exit(1); } @@ -143,15 +143,14 @@ int main(int argc, char **argv) } } - - test_waitsig(); /* even if failed, wait for migration to complete */ + test_waitsig(); /* even if failed, wait for migration to complete */ /* We expect that write(2) in child may return error only after signal * has been received. Thus, send signal before closing parent fds. */ if (kill(0, SIGTERM)) { fail("failed to send SIGTERM to my process group"); - goto out; /* shouldn't wait() in this case */ + goto out; /* shouldn't wait() in this case */ } if (close(out)) fail("Failed to close parent fd 'out'"); @@ -162,7 +161,7 @@ int main(int argc, char **argv) if (close(in)) fail("failed to close parent fd 'in'"); - for (i = 1; i < num_procs; i++) { /* i = 0 - parent */ + for (i = 1; i < num_procs; i++) { /* i = 0 - parent */ int chret; if (wait(&chret) < 0) { fail("can't wait for a child"); @@ -172,8 +171,7 @@ int main(int argc, char **argv) chret = WEXITSTATUS(chret); if (chret) { - fail("child %d exited with non-zero code %d (%s)", - i, chret, strerror(chret)); + fail("child %d exited with non-zero code %d (%s)", i, chret, strerror(chret)); ret = 1; continue; } diff --git a/test/zdtm/transition/thread-bomb.c b/test/zdtm/transition/thread-bomb.c index c1b825be7..c101f85d4 100644 --- a/test/zdtm/transition/thread-bomb.c +++ b/test/zdtm/transition/thread-bomb.c @@ -8,8 +8,7 @@ #include "zdtmtst.h" -#define exit_group(code) \ - syscall(__NR_exit_group, code) +#define exit_group(code) syscall(__NR_exit_group, code) static pthread_attr_t attr; /* Having in mind setup with 64 Kb large pages */ diff --git a/test/zdtm/transition/unix_sock.c b/test/zdtm/transition/unix_sock.c index 1fb61139d..caa5a4a57 100644 --- a/test/zdtm/transition/unix_sock.c +++ b/test/zdtm/transition/unix_sock.c @@ -13,20 +13,21 @@ #include "zdtmtst.h" -const char *test_doc = "Multi-client - server app"; -const char *test_author = "Roman Kagan <rkagan@parallels.com>"; +const char *test_doc = "Multi-client - server app"; +const char *test_author = "Roman Kagan <rkagan@parallels.com>"; -#define PROCS_DEF 4 -#define PROCS_MAX 64 +#define PROCS_DEF 4 +#define PROCS_MAX 64 unsigned int num_procs = PROCS_DEF; -TEST_OPTION(num_procs, uint, "# processes to create " - "(default " __stringify(PROCS_DEF) - ", max " __stringify(PROCS_MAX) ")", 0); +TEST_OPTION(num_procs, uint, + "# processes to create " + "(default " __stringify(PROCS_DEF) ", max " __stringify(PROCS_MAX) ")", + 0); char *filename; TEST_OPTION(filename, string, "file name", 1); -#define ACCEPT_TIMEOUT 100 /* max delay for the child to connect */ +#define ACCEPT_TIMEOUT 100 /* max delay for the child to connect */ static int fill_sock_name(struct sockaddr_un *name, const char *filename) { @@ -54,7 +55,7 @@ static int setup_srv_sock(void) return -1; } - if (bind(sock, (struct sockaddr *) &name, SUN_LEN(&name)) < 0) { + if (bind(sock, (struct sockaddr *)&name, SUN_LEN(&name)) < 0) { pr_perror("can't bind to socket \"%s\"", filename); goto err; } @@ -121,7 +122,7 @@ static int setup_clnt_sock(void) return ret; } - if (connect(sock, (struct sockaddr *) &name, SUN_LEN(&name)) < 0) { + if (connect(sock, (struct sockaddr *)&name, SUN_LEN(&name)) < 0) { ret = -errno; pr_perror("can't connect"); goto err; @@ -150,10 +151,8 @@ static int child(void) signal(SIGPIPE, SIG_IGN); while (test_go()) { datagen(buf, sizeof(buf), &crc); - if (write(sock, buf, sizeof(buf)) < 0 && - (test_go() /* signal NOT received */ || - (errno != EINTR && errno != EPIPE && \ - errno != ECONNRESET))) { + if (write(sock, buf, sizeof(buf)) < 0 && (test_go() /* signal NOT received */ || + (errno != EINTR && errno != EPIPE && errno != ECONNRESET))) { ret = errno; fail("child write"); goto out; @@ -212,13 +211,12 @@ int main(int argc, char **argv) FD_SET(child_desc[nproc].sock, &active_fds); } - close(sock); /* no more connections */ + close(sock); /* no more connections */ test_daemon(); while (test_go()) { read_fds = active_fds; - if (select(FD_SETSIZE, &read_fds, NULL, NULL, NULL) < 0 && - errno != EINTR) { + if (select(FD_SETSIZE, &read_fds, NULL, NULL, NULL) < 0 && errno != EINTR) { fail("error waiting for data"); goto out; } @@ -226,7 +224,7 @@ int main(int argc, char **argv) for (i = 0; i < num_procs; i++) if (FD_ISSET(child_desc[i].sock, &read_fds)) { if (read(child_desc[i].sock, buf, sizeof(buf)) < 0) { - if(errno == EINTR) /* we're asked to stop */ + if (errno == EINTR) /* we're asked to stop */ break; else { fail("error reading data from socket"); @@ -241,13 +239,12 @@ int main(int argc, char **argv) } } - out: test_waitsig(); if (kill(0, SIGTERM)) { fail("failed to send SIGTERM to my process group"); - goto cleanup; /* shouldn't wait() in this case */ + goto cleanup; /* shouldn't wait() in this case */ } while (nproc-- > 0) { @@ -258,7 +255,7 @@ out: * signal to child, child has checked for signal & found none * (not yet delivered), then called write(), blocking forever. */ - if(close(child_desc[nproc].sock)) + if (close(child_desc[nproc].sock)) fail("Can't close server socket"); if (wait(&chret) < 0) { @@ -268,8 +265,7 @@ out: chret = WEXITSTATUS(chret); if (chret) { - fail("child exited with non-zero code %d (%s)", - chret, strerror(chret)); + fail("child exited with non-zero code %d (%s)", chret, strerror(chret)); goto cleanup; } } |