diff options
author | Gluster Ant <bugzilla-bot@gluster.org> | 2018-09-12 17:52:45 +0530 |
---|---|---|
committer | Nigel Babu <nigelb@redhat.com> | 2018-09-12 17:52:45 +0530 |
commit | e16868dede6455cab644805af6fe1ac312775e13 (patch) | |
tree | 15aebdb4fff2d87cf8a72f836816b3aa634da58d /tests/bugs/quick-read/bz1523599 | |
parent | 45a71c0548b6fd2c757aa2e7b7671a1411948894 (diff) |
Land part 2 of clang-format changes
Change-Id: Ia84cc24c8924e6d22d02ac15f611c10e26db99b4
Signed-off-by: Nigel Babu <nigelb@redhat.com>
Diffstat (limited to 'tests/bugs/quick-read/bz1523599')
-rw-r--r-- | tests/bugs/quick-read/bz1523599/test_bz1523599.c | 322 |
1 files changed, 162 insertions, 160 deletions
diff --git a/tests/bugs/quick-read/bz1523599/test_bz1523599.c b/tests/bugs/quick-read/bz1523599/test_bz1523599.c index 843408680a7..5076a9447f3 100644 --- a/tests/bugs/quick-read/bz1523599/test_bz1523599.c +++ b/tests/bugs/quick-read/bz1523599/test_bz1523599.c @@ -1,7 +1,8 @@ /* * ./test_bz1523599 0 vm140-111 gv0 test211 log * ./test_bz1523599 1 vm140-111 gv0 test211 log - * Open - Discard - Read - Then check read information to see if the initial TEST_STR_LEN/2 bytes read zero + * Open - Discard - Read - Then check read information to see if the initial + * TEST_STR_LEN/2 bytes read zero */ #define _GNU_SOURCE @@ -15,182 +16,183 @@ #define TEST_STR_LEN 2048 enum fallocate_flag { - TEST_WRITE, - TEST_DISCARD, - TEST_ZEROFILL, + TEST_WRITE, + TEST_DISCARD, + TEST_ZEROFILL, }; -void print_str(char *str, int len) +void +print_str(char *str, int len) { - int i, addr; - - printf("%07x\t", 0); - for (i = 0; i < len; i++) { - printf("%02x", str[i]); - if (i) { - if ((i + 1) % 16 == 0) - printf("\n%07x\t", i+1); - else if ((i + 1) % 4 == 0) - printf(" "); - } - } - printf("\n"); + int i, addr; + + printf("%07x\t", 0); + for (i = 0; i < len; i++) { + printf("%02x", str[i]); + if (i) { + if ((i + 1) % 16 == 0) + printf("\n%07x\t", i + 1); + else if ((i + 1) % 4 == 0) + printf(" "); + } + } + printf("\n"); } int test_read(char *str, int total_length, int len_zero) { - int i; - int ret = 0; - - for (i = 0; i < len_zero; i++) { - if (str[i]) { - fprintf(stderr, "char at position %d not zeroed out\n", - i); - ret = -EIO; - goto out; - } - } - - for (i = len_zero; i < total_length; i++) { - if (str[i] != 0x11) { - fprintf(stderr, - "char at position %d does not contain pattern\n", - i); - ret = -EIO; - goto out; - } - } + int i; + int ret = 0; + + for (i = 0; i < len_zero; i++) { + if (str[i]) { + fprintf(stderr, "char at position %d not zeroed out\n", i); + ret = -EIO; + goto out; + } + } + + for (i = len_zero; i < total_length; i++) { + if (str[i] != 0x11) { + fprintf(stderr, "char at position %d does not contain pattern\n", + i); + ret = -EIO; + goto out; + } + } out: - return ret; + return ret; } -int main(int argc, char *argv[]) +int +main(int argc, char *argv[]) { - int opcode; - char *host_name, *volume_name, *file_path, *glfs_log_path; - glfs_t *fs = NULL; - glfs_fd_t *fd = NULL; - off_t offset = 0; - size_t len_zero = TEST_STR_LEN / 2; - char writestr[TEST_STR_LEN]; - char readstr[TEST_STR_LEN]; - struct iovec iov = {&readstr, TEST_STR_LEN}; - int i; - int ret = 1; - - for (i = 0; i < TEST_STR_LEN; i++) - writestr[i] = 0x11; - for (i = 0; i < TEST_STR_LEN; i++) - readstr[i] = 0x22; - - if (argc != 6) { - fprintf(stderr, - "Syntax: %s <test type> <host> <volname> <file-path> <log-file>\n", - argv[0]); - return 1; - } - - opcode = atoi(argv[1]); - host_name = argv[2]; - volume_name = argv[3]; - file_path = argv[4]; - glfs_log_path = argv[5]; - - fs = glfs_new(volume_name); - if (!fs) { - perror("glfs_new"); - return 1; - } - - ret = glfs_set_volfile_server(fs, "tcp", host_name, 24007); - if (ret != 0) { - perror("glfs_set_volfile_server"); - goto out; - } - - ret = glfs_set_logging(fs, glfs_log_path, 7); - if (ret != 0) { - perror("glfs_set_logging"); - goto out; - } - - ret = glfs_init(fs); - if (ret != 0) { - perror("glfs_init"); - goto out; - } - - fd = glfs_creat(fs, file_path, O_RDWR, 0777); - if (fd == NULL) { - perror("glfs_creat"); - ret = -1; - goto out; - } - - switch (opcode) { - case TEST_WRITE: - fprintf(stderr, "Test Write\n"); - ret = glfs_write(fd, writestr, TEST_STR_LEN, 0); - if (ret < 0) { - perror("glfs_write"); - goto out; - } else if (ret != TEST_STR_LEN) { - fprintf(stderr, "insufficient data written %d \n", ret); - ret = -EIO; - goto out; - } - ret = 0; - goto out; - case TEST_DISCARD: - fprintf(stderr, "Test Discard\n"); - ret = glfs_discard(fd, offset, len_zero); - if (ret < 0) { - if (errno == EOPNOTSUPP) { - fprintf(stderr, "Operation not supported\n"); - ret = 0; - goto out; - } - perror("glfs_discard"); - goto out; - } - goto test_read; - case TEST_ZEROFILL: - fprintf(stderr, "Test Zerofill\n"); - ret = glfs_zerofill(fd, offset, len_zero); - if (ret < 0) { - if (errno == EOPNOTSUPP) { - fprintf(stderr, "Operation not supported\n"); - ret = 0; - goto out; - } - perror("glfs_zerofill"); - goto out; - } - goto test_read; - default: - ret = -1; - fprintf(stderr, "Incorrect test code %d\n", opcode); - goto out; - } + int opcode; + char *host_name, *volume_name, *file_path, *glfs_log_path; + glfs_t *fs = NULL; + glfs_fd_t *fd = NULL; + off_t offset = 0; + size_t len_zero = TEST_STR_LEN / 2; + char writestr[TEST_STR_LEN]; + char readstr[TEST_STR_LEN]; + struct iovec iov = {&readstr, TEST_STR_LEN}; + int i; + int ret = 1; + + for (i = 0; i < TEST_STR_LEN; i++) + writestr[i] = 0x11; + for (i = 0; i < TEST_STR_LEN; i++) + readstr[i] = 0x22; + + if (argc != 6) { + fprintf( + stderr, + "Syntax: %s <test type> <host> <volname> <file-path> <log-file>\n", + argv[0]); + return 1; + } + + opcode = atoi(argv[1]); + host_name = argv[2]; + volume_name = argv[3]; + file_path = argv[4]; + glfs_log_path = argv[5]; + + fs = glfs_new(volume_name); + if (!fs) { + perror("glfs_new"); + return 1; + } + + ret = glfs_set_volfile_server(fs, "tcp", host_name, 24007); + if (ret != 0) { + perror("glfs_set_volfile_server"); + goto out; + } + + ret = glfs_set_logging(fs, glfs_log_path, 7); + if (ret != 0) { + perror("glfs_set_logging"); + goto out; + } + + ret = glfs_init(fs); + if (ret != 0) { + perror("glfs_init"); + goto out; + } + + fd = glfs_creat(fs, file_path, O_RDWR, 0777); + if (fd == NULL) { + perror("glfs_creat"); + ret = -1; + goto out; + } + + switch (opcode) { + case TEST_WRITE: + fprintf(stderr, "Test Write\n"); + ret = glfs_write(fd, writestr, TEST_STR_LEN, 0); + if (ret < 0) { + perror("glfs_write"); + goto out; + } else if (ret != TEST_STR_LEN) { + fprintf(stderr, "insufficient data written %d \n", ret); + ret = -EIO; + goto out; + } + ret = 0; + goto out; + case TEST_DISCARD: + fprintf(stderr, "Test Discard\n"); + ret = glfs_discard(fd, offset, len_zero); + if (ret < 0) { + if (errno == EOPNOTSUPP) { + fprintf(stderr, "Operation not supported\n"); + ret = 0; + goto out; + } + perror("glfs_discard"); + goto out; + } + goto test_read; + case TEST_ZEROFILL: + fprintf(stderr, "Test Zerofill\n"); + ret = glfs_zerofill(fd, offset, len_zero); + if (ret < 0) { + if (errno == EOPNOTSUPP) { + fprintf(stderr, "Operation not supported\n"); + ret = 0; + goto out; + } + perror("glfs_zerofill"); + goto out; + } + goto test_read; + default: + ret = -1; + fprintf(stderr, "Incorrect test code %d\n", opcode); + goto out; + } test_read: - ret = glfs_readv(fd, &iov, 1, 0); - if (ret < 0) { - perror("glfs_readv"); - goto out; - } + ret = glfs_readv(fd, &iov, 1, 0); + if (ret < 0) { + perror("glfs_readv"); + goto out; + } - /* printf("Read str\n"); print_str(readstr, TEST_STR_LEN); printf("\n"); */ - ret = test_read(readstr, TEST_STR_LEN, len_zero); + /* printf("Read str\n"); print_str(readstr, TEST_STR_LEN); printf("\n"); */ + ret = test_read(readstr, TEST_STR_LEN, len_zero); out: - if (fd) - glfs_close(fd); - glfs_fini(fs); + if (fd) + glfs_close(fd); + glfs_fini(fs); - if (ret) - return -1; + if (ret) + return -1; - return 0; + return 0; } |