diff options
author | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2012-11-16 09:56:52 +0200 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2012-11-16 10:09:54 +0200 |
commit | 7343528e5821c69224000ed7cfd3e8aaf47b7a93 (patch) | |
tree | 8f283ceefef028996c0ce1b5de9bf5214ed8752c /tests/ubi-tests/io_paral.c | |
parent | 98ed9f3360bb5cbfb02d2cb82ee3167fce437772 (diff) |
ubi-tests: switch to using common.h from the top level
Sorry, the commit is huge, I just did not have time to split it.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'tests/ubi-tests/io_paral.c')
-rw-r--r-- | tests/ubi-tests/io_paral.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/tests/ubi-tests/io_paral.c b/tests/ubi-tests/io_paral.c index 4764255..becbb52 100644 --- a/tests/ubi-tests/io_paral.c +++ b/tests/ubi-tests/io_paral.c @@ -20,7 +20,6 @@ * This test does a lot of I/O to volumes in parallel. */ -#define _XOPEN_SOURCE 500 #include <stdio.h> #include <errno.h> #include <string.h> @@ -31,7 +30,8 @@ #include <sys/stat.h> #include <fcntl.h> #include "libubi.h" -#define TESTNAME "io_paral" +#define PROGRAM_NAME "io_paral" +#include "common.h" #include "helpers.h" #define THREADS_NUM 4 @@ -59,7 +59,7 @@ static int update_volume(int vol_id, int bytes) fd = open(vol_node, O_RDWR); if (fd == -1) { failed("open"); - errmsg("cannot open \"%s\"\n", vol_node); + errorm("cannot open \"%s\"\n", vol_node); return -1; } @@ -70,7 +70,7 @@ static int update_volume(int vol_id, int bytes) ret = ubi_update_start(libubi, fd, bytes); if (ret) { failed("ubi_update_start"); - errmsg("volume id is %d", vol_id); + errorm("volume id is %d", vol_id); goto err_close; } @@ -83,10 +83,10 @@ static int update_volume(int vol_id, int bytes) ret = write(fd, wbuf + written, to_write); if (ret != to_write) { failed("write"); - errmsg("failed to write %d bytes at offset %d " + errorm("failed to write %d bytes at offset %d " "of volume %d", to_write, written, vol_id); - errmsg("update: %d bytes", bytes); + errorm("update: %d bytes", bytes); goto err_close; } @@ -98,7 +98,7 @@ static int update_volume(int vol_id, int bytes) fd = open(vol_node, O_RDONLY); if (fd == -1) { failed("open"); - errmsg("cannot open \"%s\"\n", node); + errorm("cannot open \"%s\"\n", node); return -1; } @@ -112,7 +112,7 @@ static int update_volume(int vol_id, int bytes) ret = read(fd, rbuf + rd, to_read); if (ret != to_read) { failed("read"); - errmsg("failed to read %d bytes at offset %d " + errorm("failed to read %d bytes at offset %d " "of volume %d", to_read, rd, vol_id); goto err_close; } @@ -121,7 +121,7 @@ static int update_volume(int vol_id, int bytes) } if (memcmp(wbuf, rbuf, bytes)) { - errmsg("written and read data are different"); + errorm("written and read data are different"); goto err_close; } @@ -146,13 +146,13 @@ static void *update_thread(void *ptr) ret = ubi_rmvol(libubi, node, vol_id); if (ret) { failed("ubi_rmvol"); - errmsg("cannot remove volume %d", vol_id); + errorm("cannot remove volume %d", vol_id); return NULL; } ret = ubi_mkvol(libubi, node, &reqests[vol_id]); if (ret) { failed("ubi_mkvol"); - errmsg("cannot create volume %d", vol_id); + errorm("cannot create volume %d", vol_id); return NULL; } } @@ -175,14 +175,14 @@ static void *write_thread(void *ptr) fd = open(vol_node, O_RDWR); if (fd == -1) { failed("open"); - errmsg("cannot open \"%s\"\n", vol_node); + errorm("cannot open \"%s\"\n", vol_node); return NULL; } ret = ubi_set_property(fd, UBI_VOL_PROP_DIRECT_WRITE, 1); if (ret) { failed("ubi_set_property"); - errmsg("cannot set property for \"%s\"\n", vol_node); + errorm("cannot set property for \"%s\"\n", vol_node); } for (i = 0; i < ITERATIONS * VOL_LEBS; i++) { @@ -192,7 +192,7 @@ static void *write_thread(void *ptr) ret = ubi_leb_unmap(fd, leb); if (ret) { failed("ubi_leb_unmap"); - errmsg("cannot unmap LEB %d", leb); + errorm("cannot unmap LEB %d", leb); break; } @@ -203,7 +203,7 @@ static void *write_thread(void *ptr) ret = pwrite(fd, wbuf, dev_info.leb_size, offs); if (ret != dev_info.leb_size) { failed("pwrite"); - errmsg("cannot write %d bytes to offs %lld, wrote %d", + errorm("cannot write %d bytes to offs %lld, wrote %d", dev_info.leb_size, offs, ret); break; } @@ -212,14 +212,14 @@ static void *write_thread(void *ptr) ret = pread(fd, rbuf, dev_info.leb_size, offs); if (ret != dev_info.leb_size) { failed("read"); - errmsg("failed to read %d bytes at offset %d " + errorm("failed to read %d bytes at offset %d " "of volume %d", dev_info.leb_size, offs, vol_id); break; } if (memcmp(wbuf, rbuf, dev_info.leb_size)) { - errmsg("written and read data are different"); + errorm("written and read data are different"); break; } } @@ -259,7 +259,7 @@ int main(int argc, char * const argv[]) reqests[i].alignment = 1; reqests[i].bytes = vol_size; reqests[i].vol_id = i; - sprintf(vol_name[i], TESTNAME":%d", i); + sprintf(vol_name[i], PROGRAM_NAME":%d", i); reqests[i].name = vol_name[i]; reqests[i].vol_type = UBI_DYNAMIC_VOLUME; if (i == THREADS_NUM) |