summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-08-03 22:30:55 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-08-07 07:17:18 +0200
commitbf802790255aa5e155effdb97fc28010ddd82c26 (patch)
tree54ddbf8769f6e6c6d7aa3eada1706ca354a639f3
parentlibtests/block14: Use rtems_blkdev_create() (diff)
downloadrtems-bf802790255aa5e155effdb97fc28010ddd82c26.tar.bz2
libtests/block15: Use rtems_blkdev_create()
Update #3358.
-rw-r--r--testsuites/libtests/block15/init.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/testsuites/libtests/block15/init.c b/testsuites/libtests/block15/init.c
index cf9ec5fc0c..925a772842 100644
--- a/testsuites/libtests/block15/init.c
+++ b/testsuites/libtests/block15/init.c
@@ -18,11 +18,14 @@
#include "tmacros.h"
+#include <sys/stat.h>
+#include <assert.h>
#include <errno.h>
-#include <stdio.h>
+#include <fcntl.h>
#include <inttypes.h>
+#include <stdlib.h>
+#include <unistd.h>
-#include <rtems/blkdev.h>
#include <rtems/bdbuf.h>
const char rtems_test_name[] = "BLOCK 15";
@@ -41,6 +44,8 @@ const char rtems_test_name[] = "BLOCK 15";
#define BLOCK_SIZE 4
+#define DISK_PATH "/disk"
+
static const rtems_blkdev_bnum action_sequence [ACTION_COUNT] = {
2, 1, 0, 4, 5, 6, 7, 9
};
@@ -90,8 +95,7 @@ static int test_disk_ioctl(rtems_disk_device *dd, uint32_t req, void *arg)
} else if (req == RTEMS_BLKIO_CAPABILITIES) {
*(uint32_t *) arg = RTEMS_BLKDEV_CAP_MULTISECTOR_CONT;
} else {
- errno = EINVAL;
- rv = -1;
+ rv = rtems_blkdev_ioctl(dd, req, arg);
}
return rv;
@@ -126,32 +130,32 @@ static void test_write_requests(rtems_disk_device *dd)
static void test(void)
{
rtems_status_code sc;
- dev_t dev = 0;
rtems_disk_device *dd;
+ int fd;
+ int rv;
- sc = rtems_disk_io_initialize();
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
-
- sc = rtems_disk_create_phys(
- dev,
+ sc = rtems_blkdev_create(
+ DISK_PATH,
MEDIA_BLOCK_SIZE,
BLOCK_COUNT,
test_disk_ioctl,
- NULL,
NULL
);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
- dd = rtems_disk_obtain(dev);
- rtems_test_assert(dd != NULL);
+ fd = open(DISK_PATH, O_RDWR);
+ rtems_test_assert(fd >= 0);
- test_write_requests(dd);
+ rv = rtems_disk_fd_get_disk_device(fd, &dd);
+ rtems_test_assert(rv == 0);
- sc = rtems_disk_release(dd);
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+ rv = close(fd);
+ rtems_test_assert(rv == 0);
- sc = rtems_disk_delete(dev);
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+ test_write_requests(dd);
+
+ rv = unlink(DISK_PATH);
+ rtems_test_assert(rv == 0);
}
static void Init(rtems_task_argument arg)
@@ -169,6 +173,8 @@ static void Init(rtems_task_argument arg)
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
+#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
+
#define CONFIGURE_BDBUF_BUFFER_MIN_SIZE 1
#define CONFIGURE_BDBUF_BUFFER_MAX_SIZE 4
#define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE (BLOCK_COUNT * BLOCK_SIZE)