summaryrefslogtreecommitdiffstats
path: root/testsuites/libtests/block07
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-07-30 06:39:09 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-08-07 07:17:16 +0200
commit24b94c47713bbaadd8b8a876a2e7c7f3a9def5d8 (patch)
treeefcbf3a2cd173820310dea2b7b7677329bc1a4e4 /testsuites/libtests/block07
parentrfs: Remove erroneous call of rtems_disk_release() (diff)
downloadrtems-24b94c47713bbaadd8b8a876a2e7c7f3a9def5d8.tar.bz2
ramdisk: Use rtems_blkdev_create()
Update #3358.
Diffstat (limited to 'testsuites/libtests/block07')
-rw-r--r--testsuites/libtests/block07/init.c53
1 files changed, 33 insertions, 20 deletions
diff --git a/testsuites/libtests/block07/init.c b/testsuites/libtests/block07/init.c
index 914dd35a90..e0f7ecc031 100644
--- a/testsuites/libtests/block07/init.c
+++ b/testsuites/libtests/block07/init.c
@@ -7,12 +7,13 @@
*/
/*
- * Copyright (c) 2009
- * embedded brains GmbH
- * Obere Lagerstr. 30
- * D-82178 Puchheim
- * Germany
- * <rtems@embedded-brains.de>
+ * Copyright (c) 2009, 2018 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
@@ -27,19 +28,16 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <unistd.h>
#include "tmacros.h"
#include <rtems.h>
#include <rtems/ramdisk.h>
#include <rtems/bdbuf.h>
-#include <rtems/diskdevs.h>
const char rtems_test_name[] = "BLOCK 7";
-/* forward declarations to avoid warnings */
-static rtems_task Init(rtems_task_argument argument);
-
#define ASSERT_SC(sc) rtems_test_assert((sc) == RTEMS_SUCCESSFUL)
#define PRIORITY_INIT 1
@@ -158,23 +156,39 @@ static void task_high(rtems_task_argument arg)
rtems_task_delete(RTEMS_SELF);
}
+static void do_ramdisk_register(
+ uint32_t media_block_size,
+ rtems_blkdev_bnum media_block_count,
+ const char *disk,
+ rtems_disk_device **dd
+)
+{
+ rtems_status_code sc;
+ int fd;
+ int rv;
+
+ sc = ramdisk_register(media_block_size, media_block_count, false, disk);
+ ASSERT_SC(sc);
+
+ fd = open(disk, O_RDWR);
+ rtems_test_assert(fd >= 0);
+
+ rv = rtems_disk_fd_get_disk_device(fd, dd);
+ rtems_test_assert(rv == 0);
+
+ rv = close(fd);
+ rtems_test_assert(rv == 0);
+}
+
static rtems_task Init(rtems_task_argument argument)
{
rtems_status_code sc = RTEMS_SUCCESSFUL;
rtems_task_priority cur_prio = 0;
rtems_bdbuf_buffer *bd = NULL;
- dev_t dev = 0;
TEST_BEGIN();
- sc = rtems_disk_io_initialize();
- ASSERT_SC(sc);
-
- sc = ramdisk_register(BLOCK_SIZE_A, BLOCK_COUNT, false, "/dev/rda", &dev);
- ASSERT_SC(sc);
-
- dd = rtems_disk_obtain(dev);
- rtems_test_assert(dd != NULL);
+ do_ramdisk_register(BLOCK_SIZE_A, BLOCK_COUNT, "/dev/rda", &dd);
sc = rtems_task_create(
rtems_build_name(' ', 'L', 'O', 'W'),
@@ -265,7 +279,6 @@ static rtems_task Init(rtems_task_argument argument)
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
#define CONFIGURE_MAXIMUM_TASKS 4
-#define CONFIGURE_MAXIMUM_DRIVERS 2
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION