Sorry, the commit is huge, I just did not have time to split it.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
* check this.
*/
if (argc < 2) {
- __errmsg(test, __func__, __LINE__,
+ __errorm(test, __func__, __LINE__,
"UBI character device node is not specified");
return -1;
}
}
if (dev_info.avail_lebs < MIN_AVAIL_EBS) {
- __errmsg(test, __func__, __LINE__,
+ __errorm(test, __func__, __LINE__,
"insufficient available eraseblocks %d on UBI "
"device, required %d",
dev_info.avail_lebs, MIN_AVAIL_EBS);
}
if (dev_info.vol_count != 0) {
- __errmsg(test, __func__, __LINE__,
+ __errorm(test, __func__, __LINE__,
"device %s is not empty", argv[1]);
goto close;
}
}
/**
- * __errmsg - print a message to stderr.
+ * __errorm - print a message to stderr.
*
* @test test name
* @func function name
* @line line number
* @fmt format string
*/
-void __errmsg(const char *test, const char *func, int line,
+void __errorm(const char *test, const char *func, int line,
const char *fmt, ...)
{
va_list args;
}
if (req->alignment != vol_info.alignment) {
- __errmsg(test, func, line,
+ __errorm(test, func, line,
"bad alignment: requested %d, got %d",
req->alignment, vol_info.alignment);
return -1;
}
if (req->vol_type != vol_info.type) {
- __errmsg(test, func, line, "bad type: requested %d, got %d",
+ __errorm(test, func, line, "bad type: requested %d, got %d",
req->vol_type, vol_info.type);
return -1;
}
if (strlen(req->name) != strlen(vol_info.name) ||
strcmp(req->name, vol_info.name) != 0) {
- __errmsg(test, func, line,
+ __errorm(test, func, line,
"bad name: requested \"%s\", got \"%s\"",
req->name, vol_info.name);
return -1;
}
if (vol_info.corrupted) {
- __errmsg(test, func, line, "corrupted new volume");
+ __errorm(test, func, line, "corrupted new volume");
return -1;
}
leb_size = dev_info->leb_size - (dev_info->leb_size % req->alignment);
if (leb_size != vol_info.leb_size) {
- __errmsg(test, func, line,
+ __errorm(test, func, line,
"bad usable LEB size %d, should be %d",
vol_info.leb_size, leb_size);
return -1;
rsvd_bytes += leb_size - (rsvd_bytes % leb_size);
if (rsvd_bytes != vol_info.rsvd_bytes) {
- __errmsg(test, func, line,
+ __errorm(test, func, line,
"bad reserved bytes %lld, should be %lld",
vol_info.rsvd_bytes, rsvd_bytes);
return -1;
fd = open(node, O_RDONLY);
if (fd == -1) {
__failed(test, func, line, "open");
- __errmsg(test, func, line, "cannot open \"%s\"\n", node);
+ __errorm(test, func, line, "cannot open \"%s\"\n", node);
return -1;
}
ret = read(fd, buf, 512);
if (ret == -1) {
__failed(test, func, line, "read");
- __errmsg(test, func, line, "bytes = %lld, ret = %d",
+ __errorm(test, func, line, "bytes = %lld, ret = %d",
bytes, ret);
goto close;
}
if (ret == 0 && bytes + ret < vol_info.data_bytes) {
- __errmsg(test, func, line,
+ __errorm(test, func, line,
"EOF, but read only %lld bytes of %lld",
bytes + ret, vol_info.data_bytes);
goto close;
for (i = 0; i < ret; i++)
if (buf[i] != byte) {
- __errmsg(test, func, line,
+ __errorm(test, func, line,
"byte at %lld is not %#x but %#x",
bytes + i, byte, (int)buf[i]);
goto close;
fd = open(node, O_RDWR);
if (fd == -1) {
__failed(test, func, line, "open");
- __errmsg(test, func, line, "cannot open \"%s\"\n", node);
+ __errorm(test, func, line, "cannot open \"%s\"\n", node);
return -1;
}
if (ubi_update_start(libubi, fd, bytes)) {
__failed(test, func, line, "ubi_update_start");
- __errmsg(test, func, line, "bytes = %lld", bytes);
+ __errorm(test, func, line, "bytes = %lld", bytes);
goto close;
}
ret = write(fd, buf, 512);
if (ret == -1) {
__failed(test, func, line, "write");
- __errmsg(test, func, line, "written = %lld, ret = %d",
+ __errorm(test, func, line, "written = %lld, ret = %d",
written, ret);
goto close;
}
written += ret;
if (written > bytes) {
- __errmsg(test, func, line, "update length %lld bytes, "
+ __errorm(test, func, line, "update length %lld bytes, "
"but %lld bytes are already written",
bytes, written);
goto close;
#define MIN_AVAIL_EBS 5
#define PAGE_SIZE 4096
-#define min(a, b) ((a) < (b) ? (a) : (b))
-
-/* Normal messages */
-#define normsg(fmt, ...) do { \
- printf(TESTNAME ": " fmt "\n", ##__VA_ARGS__); \
-} while(0)
-
-#define errmsg(fmt, ...) ({ \
- __errmsg(TESTNAME, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__); \
+#define errorm(fmt, ...) ({ \
+ __errorm(PROGRAM_NAME, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__); \
-1; \
})
#define failed(name) ({ \
- __failed(TESTNAME, __FUNCTION__, __LINE__, name); \
+ __failed(PROGRAM_NAME, __FUNCTION__, __LINE__, name); \
-1; \
})
#define initial_check(argc, argv) \
- __initial_check(TESTNAME, argc, argv)
+ __initial_check(PROGRAM_NAME, argc, argv)
#define check_volume(vol_id, req) \
- __check_volume(libubi, &dev_info, TESTNAME, __FUNCTION__, \
+ __check_volume(libubi, &dev_info, PROGRAM_NAME, __FUNCTION__, \
__LINE__, vol_id, req)
#define check_vol_patt(node, byte) \
- __check_vol_patt(libubi, TESTNAME, __FUNCTION__, __LINE__, node, byte)
+ __check_vol_patt(libubi, PROGRAM_NAME, __FUNCTION__, __LINE__, node, byte)
#define update_vol_patt(node, bytes, byte) \
- __update_vol_patt(libubi, TESTNAME, __FUNCTION__, __LINE__, \
+ __update_vol_patt(libubi, PROGRAM_NAME, __FUNCTION__, __LINE__, \
node, bytes, byte)
#define check_failed(ret, error, func, fmt, ...) ({ \
- int __ret; \
+ int __ret = 0; \
\
if (!ret) { \
- errmsg("%s() returned success but should have failed", func); \
- errmsg(fmt, ##__VA_ARGS__); \
+ errorm("%s() returned success but should have failed", func); \
+ errorm(fmt, ##__VA_ARGS__); \
__ret = -1; \
- } \
- if (errno != (error)) { \
- errmsg("%s failed with error %d (%s), expected %d (%s)", \
+ } else if (errno != (error)) { \
+ errorm("%s failed with error %d (%s), expected %d (%s)", \
func, errno, strerror(errno), error, strerror(error)); \
- errmsg(fmt, ##__VA_ARGS__); \
+ errorm(fmt, ##__VA_ARGS__); \
__ret = -1; \
} \
- __ret = 0; \
+ __ret; \
})
/* Alignments to test, @s is eraseblock size */
extern int seed_random_generator(void);
-extern void __errmsg(const char *test, const char *func, int line,
+extern void __errorm(const char *test, const char *func, int line,
const char *fmt, ...);
extern void __failed(const char *test, const char *func, int line,
const char *failed);
#include <sys/stat.h>
#include "libubi.h"
+#define PROGRAM_NAME "integ"
+#include "common.h"
#include "helpers.h"
struct erase_block_info;
#include <sys/stat.h>
#include <fcntl.h>
#include "libubi.h"
-#define TESTNAME "io_basic"
+#define PROGRAM_NAME "io_basic"
+#include "common.h"
#include "helpers.h"
static libubi_t libubi;
static int test_basic(int type)
{
struct ubi_mkvol_request req;
- const char *name = TESTNAME ":test_basic()";
+ const char *name = PROGRAM_NAME ":test_basic()";
char vol_node[strlen(UBI_VOLUME_PATTERN) + 100];
req.vol_id = UBI_VOL_NUM_AUTO;
{
unsigned int i, ebsz;
struct ubi_mkvol_request req;
- const char *name = TESTNAME ":test_aligned()";
+ const char *name = PROGRAM_NAME ":test_aligned()";
char vol_node[strlen(UBI_VOLUME_PATTERN) + 100];
int alignments[] = ALIGNMENTS(dev_info.leb_size);
* 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>
#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
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;
}
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;
}
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;
}
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;
}
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;
}
}
if (memcmp(wbuf, rbuf, bytes)) {
- errmsg("written and read data are different");
+ errorm("written and read data are different");
goto err_close;
}
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;
}
}
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++) {
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;
}
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;
}
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;
}
}
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)
#include <sys/stat.h>
#include <fcntl.h>
#include "libubi.h"
-#define TESTNAME "io_basic"
+#define PROGRAM_NAME "io_basic"
+#include "common.h"
#include "helpers.h"
static libubi_t libubi;
static int test_static(void)
{
struct ubi_mkvol_request req;
- const char *name = TESTNAME ":io_basic()";
+ const char *name = PROGRAM_NAME ":io_basic()";
char vol_node[strlen(UBI_VOLUME_PATTERN) + 100];
struct ubi_vol_info vol_info;
int fd, ret;
fd = open(vol_node, O_RDWR);
if (fd == -1) {
failed("open");
- errmsg("cannot open \"%s\"\n", node);
+ errorm("cannot open \"%s\"\n", node);
goto remove;
}
/* Make sure new static volume contains no data */
if (vol_info.data_bytes != 0) {
- errmsg("data_bytes = %lld, not zero", vol_info.data_bytes);
+ errorm("data_bytes = %lld, not zero", vol_info.data_bytes);
goto close;
}
goto close;
}
if (ret != 0) {
- errmsg("read data from free static volume");
+ errorm("read data from free static volume");
goto close;
}
goto close;
}
if (ret != 10) {
- errmsg("written %d bytes", ret);
+ errorm("written %d bytes", ret);
goto close;
}
goto close;
}
if (ret != 10) {
- errmsg("read %d bytes", ret);
+ errorm("read %d bytes", ret);
goto close;
}
if (lseek(fd, off, SEEK_SET) != off) {
failed("seek");
- errmsg("len = %d", len);
+ errorm("len = %d", len);
return -1;
}
if (read(fd, buf, len) != len1) {
failed("read");
- errmsg("len = %d", len);
+ errorm("len = %d", len);
return -1;
}
if (new_off == -1)
failed("lseek");
else
- errmsg("read %d bytes from %lld, but resulting "
+ errorm("read %d bytes from %lld, but resulting "
"offset is %lld", len1, (long long) off, (long long) new_off);
return -1;
}
ck_buf[i] = (unsigned char)(off + i);
if (memcmp(buf, ck_buf, len1)) {
- errmsg("incorrect data read from offset %lld",
+ errorm("incorrect data read from offset %lld",
(long long)off);
- errmsg("len = %d", len);
+ errorm("len = %d", len);
return -1;
}
for (i = 0; i < sizeof(offsets)/sizeof(off_t); i++) {
if (test_read3(vol_info, len, offsets[i])) {
- errmsg("offset = %d", offsets[i]);
+ errorm("offset = %d", offsets[i]);
return -1;
}
}
fd = open(vol_node, O_RDWR);
if (fd == -1) {
failed("open");
- errmsg("cannot open \"%s\"\n", node);
+ errorm("cannot open \"%s\"\n", node);
return -1;
}
/* Write some pattern to the volume */
if (ubi_update_start(libubi, fd, vol_info->rsvd_bytes)) {
failed("ubi_update_start");
- errmsg("bytes = %lld", vol_info->rsvd_bytes);
+ errorm("bytes = %lld", vol_info->rsvd_bytes);
goto close;
}
ret = write(fd, buf, 512);
if (ret == -1) {
failed("write");
- errmsg("written = %d, ret = %d", written, ret);
+ errorm("written = %d, ret = %d", written, ret);
goto close;
}
written += ret;
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;
}
for (i = 0; i < sizeof(lengthes)/sizeof(int); i++) {
if (test_read2(vol_info, lengthes[i])) {
- errmsg("length = %d", lengthes[i]);
+ errorm("length = %d", lengthes[i]);
goto close;
}
}
*/
static int test_read(int type)
{
- const char *name = TESTNAME ":test_read()";
+ const char *name = PROGRAM_NAME ":test_read()";
int alignments[] = ALIGNMENTS(dev_info.leb_size);
char vol_node[strlen(UBI_VOLUME_PATTERN) + 100];
struct ubi_mkvol_request req;
}
if (test_read1(&vol_info)) {
- errmsg("alignment = %d", req.alignment);
+ errorm("alignment = %d", req.alignment);
goto remove;
}
#include <libubi.h>
#include <mtd/ubi-user.h>
-#define TESTNAME "io_update"
+#define PROGRAM_NAME "io_update"
+#include "common.h"
#include "helpers.h"
static libubi_t libubi;
fd = open(vol_node, O_RDWR);
if (fd == -1) {
failed("open");
- errmsg("cannot open \"%s\"\n", node);
+ errorm("cannot open \"%s\"\n", node);
return -1;
}
ret = write(fd, buf + off, len);
if (ret < 0) {
failed("write");
- errmsg("failed to write %d bytes at offset "
+ errorm("failed to write %d bytes at offset "
"%lld", len, (long long)off);
goto close;
}
len = l;
if (ret != len) {
- errmsg("failed to write %d bytes at offset "
+ errorm("failed to write %d bytes at offset "
"%lld, wrote %d", len, (long long)off, ret);
goto close;
}
/* Check data */
if ((ret = lseek(fd, 0, SEEK_SET)) != 0) {
failed("lseek");
- errmsg("cannot seek to 0");
+ errorm("cannot seek to 0");
goto close;
}
ret = read(fd, buf1, test_len);
if (ret < 0) {
failed("read");
- errmsg("failed to read %d bytes", test_len);
+ errorm("failed to read %d bytes", test_len);
goto close;
}
if (ret != test_len) {
- errmsg("failed to read %d bytes, read %d", test_len, ret);
+ errorm("failed to read %d bytes, read %d", test_len, ret);
goto close;
}
if (memcmp(buf, buf1, test_len)) {
- errmsg("data corruption");
+ errorm("data corruption");
goto close;
}
}
static int test_update(int type)
{
struct ubi_mkvol_request req;
- const char *name = TESTNAME ":io_update()";
+ const char *name = PROGRAM_NAME ":io_update()";
int alignments[] = ALIGNMENTS(dev_info.leb_size);
struct ubi_vol_info vol_info;
char vol_node[strlen(UBI_VOLUME_PATTERN) + 100];
}
if (test_update1(&vol_info, 0)) {
- errmsg("alignment = %d", req.alignment);
+ errorm("alignment = %d", req.alignment);
goto remove;
}
if (vol_info.type != UBI_STATIC_VOLUME) {
if (test_update1(&vol_info, 1)) {
- errmsg("alignment = %d", req.alignment);
+ errorm("alignment = %d", req.alignment);
goto remove;
}
}
#include <errno.h>
#include <stdio.h>
#include "libubi.h"
-#define TESTNAME "mkvol_bad"
+#define PROGRAM_NAME "mkvol_bad"
+#include "common.h"
#include "helpers.h"
static libubi_t libubi;
{
int ret, i;
struct ubi_mkvol_request req;
- const char *name = TESTNAME ":test_mkvol()";
+ const char *name = PROGRAM_NAME ":test_mkvol()";
req.alignment = 1;
req.bytes = dev_info.avail_bytes;
if (errno == ENFILE)
break;
failed("ubi_mkvol");
- errmsg("vol_id %d", i);
+ errorm("vol_id %d", i);
goto remove;
}
}
{
int ret;
struct ubi_mkvol_request req;
- const char *name = TESTNAME ":test_rmvol()";
+ const char *name = PROGRAM_NAME ":test_rmvol()";
/* Bad vol_id */
ret = ubi_rmvol(libubi, node, -1);
#include <errno.h>
#include <string.h>
#include "libubi.h"
-#define TESTNAME "mkvol_basic"
+#define PROGRAM_NAME "mkvol_basic"
+#include "common.h"
#include "helpers.h"
static libubi_t libubi;
{
struct ubi_mkvol_request req;
int i, vol_id, ebsz;
- const char *name = TESTNAME ":mkvol_alignment()";
+ const char *name = PROGRAM_NAME ":mkvol_alignment()";
int alignments[] = ALIGNMENTS(dev_info.leb_size);
for (i = 0; i < sizeof(alignments)/sizeof(int); i++) {
if (ubi_mkvol(libubi, node, &req)) {
failed("ubi_mkvol");
- errmsg("alignment %d", req.alignment);
+ errorm("alignment %d", req.alignment);
return -1;
}
struct ubi_mkvol_request req;
struct ubi_vol_info vol_info;
int vol_id, ret;
- const char *name = TESTNAME ":mkvol_basic()";
+ const char *name = PROGRAM_NAME ":mkvol_basic()";
/* Create dynamic volume of maximum size */
req.vol_id = UBI_VOL_NUM_AUTO;
/* Make sure volume does not exist */
ret = ubi_get_vol_info1(libubi, dev_info.dev_num, vol_id, &vol_info);
if (ret == 0) {
- errmsg("removed volume %d exists", vol_id);
+ errorm("removed volume %d exists", vol_id);
goto remove;
}
{
struct ubi_mkvol_request req;
int i, ret, max = dev_info.max_vol_count;
- const char *name = TESTNAME ":mkvol_multiple()";
+ const char *name = PROGRAM_NAME ":mkvol_multiple()";
/* Create maximum number of volumes */
for (i = 0; i < max; i++) {
break;
}
failed("ubi_mkvol");
- errmsg("vol_id %d", i);
+ errorm("vol_id %d", i);
goto remove;
}
if (check_volume(req.vol_id, &req)) {
- errmsg("vol_id %d", i);
+ errorm("vol_id %d", i);
goto remove;
}
}
/* Make sure volume does not exist */
ret = ubi_get_vol_info1(libubi, dev_info.dev_num, i, &vol_info);
if (ret == 0) {
- errmsg("removed volume %d exists", i);
+ errorm("removed volume %d exists", i);
goto remove;
}
}
#include <string.h>
#include <pthread.h>
#include "libubi.h"
-#define TESTNAME "mkvol_paral"
+#define PROGRAM_NAME "mkvol_paral"
+#include "common.h"
#include "helpers.h"
#define THREADS_NUM 4
{
int n = (long)ptr, iter = iterations;
struct ubi_mkvol_request req;
- const char *name = TESTNAME ":the_thread()";
+ const char *name = PROGRAM_NAME ":the_thread()";
char nm[strlen(name) + 50];
req.alignment = 1;
#include <sys/stat.h>
#include <fcntl.h>
#include "libubi.h"
-#define TESTNAME "rsvol"
+#define PROGRAM_NAME "rsvol"
+#include "common.h"
#include "helpers.h"
static libubi_t libubi;
static int test_basic(int type)
{
struct ubi_mkvol_request req;
- const char *name = TESTNAME ":test_basic()";
+ const char *name = PROGRAM_NAME ":test_basic()";
req.vol_id = UBI_VOL_NUM_AUTO;
req.alignment = 1;
}
if (vol_info1.rsvd_bytes != bytes) {
- errmsg("rsvd_bytes %lld, must be %lld",
+ errorm("rsvd_bytes %lld, must be %lld",
vol_info1.rsvd_bytes, bytes);
return -1;
}
if (vol_info1.rsvd_lebs != vol_info->rsvd_lebs - 1) {
- errmsg("rsvd_lebs %d, must be %d",
+ errorm("rsvd_lebs %d, must be %d",
vol_info1.rsvd_lebs, vol_info->rsvd_lebs - 1);
return -1;
}
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;
}
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;
}
for (i = 0; i < bytes; i++) {
if (buf[i] != (unsigned char)i) {
- errmsg("bad data");
+ errorm("bad data");
goto close;
}
}
*/
static int test_rsvol(int type)
{
- const char *name = TESTNAME "test_rsvol:()";
+ const char *name = PROGRAM_NAME "test_rsvol:()";
int alignments[] = ALIGNMENTS(dev_info.leb_size);
char vol_node[strlen(UBI_VOLUME_PATTERN) + 100];
struct ubi_mkvol_request req;
}
if (test_rsvol1(&vol_info)) {
- errmsg("alignment = %d", req.alignment);
+ errorm("alignment = %d", req.alignment);
goto remove;
}
#include <fcntl.h>
#include <unistd.h>
#include "libubi.h"
-#define TESTNAME "rmvol"
+#define PROGRAM_NAME "rmvol"
+#include "common.h"
#include "helpers.h"
#define SYSFS_FILE "/sys/class/ubi/ubi%d_%d/usable_eb_size"
sprintf(fname, SYSFS_FILE, dev_info.dev_num, req.vol_id);
fd = open(fname, O_RDONLY);
if (fd == -1) {
- errmsg("cannot open %s", fname);
+ errorm("cannot open %s", fname);
failed("open");
goto out_rmvol;
}
/* Try to read from the file, this should fail */
ret = read(fd, tmp, 100);
if (ret != -1) {
- errmsg("read returned %d, expected -1", ret);
+ errorm("read returned %d, expected -1", ret);
failed("read");
goto out_close;
}
close(fd);
fd = open(fname, O_RDONLY);
if (fd != -1) {
- errmsg("opened %s again, open returned %d, expected -1",
+ errorm("opened %s again, open returned %d, expected -1",
fname, fd);
failed("open");
goto out_libubi;