summaryrefslogtreecommitdiffstats
path: root/testsuites/libtests/block09
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2012-02-28 17:19:49 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2012-03-13 12:24:18 +0100
commit796967c3df40a51a9028bc83d1a4b6dbeae07c3f (patch)
treeedd7251883f74506a69f76e6e9fbf173de195f50 /testsuites/libtests/block09
parentlibblock: Documentation (diff)
downloadrtems-796967c3df40a51a9028bc83d1a4b6dbeae07c3f.tar.bz2
libblock: Change bdbuf API
The functions o rtems_bdbuf_get(), o rtems_bdbuf_read(), o rtems_bdbuf_syncdev(), and o rtems_bdbuf_purge_dev(), use now the disk device instead of the device identifier. This makes bdbuf independent of rtems_disk_obtain() and rtems_disk_release(). It is the responsiblity of the file system to obtain the disk device. This also reduces the overhead to get a buffer. The key for the AVL tree uses now the disk device instead of the device identifier. The pointer is interpreted as an unsigned integer. This reduces the memory overhead and makes the comparison operation a bit faster. Removed function rtems_bdbuf_purge_major(). This function was too destructive and could have unpredictable side effects.
Diffstat (limited to 'testsuites/libtests/block09')
-rw-r--r--testsuites/libtests/block09/init.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/testsuites/libtests/block09/init.c b/testsuites/libtests/block09/init.c
index 5d7a8b7e69..b7426c36c2 100644
--- a/testsuites/libtests/block09/init.c
+++ b/testsuites/libtests/block09/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-2012 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * 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
@@ -108,7 +109,7 @@ static int disk_ioctl(rtems_disk_device *dd, uint32_t req, void *arg)
}
}
-rtems_status_code disk_register(
+static rtems_status_code disk_register(
uint32_t block_size,
rtems_blkdev_bnum block_count,
dev_t *dev_ptr
@@ -139,7 +140,7 @@ rtems_status_code disk_register(
}
static void check_read(
- dev_t dev,
+ const rtems_disk_device *dd,
rtems_blkdev_bnum block,
rtems_status_code expected_sc
)
@@ -147,7 +148,7 @@ static void check_read(
rtems_status_code sc = RTEMS_SUCCESSFUL;
rtems_bdbuf_buffer *bd = NULL;
- sc = rtems_bdbuf_read(dev, block, &bd);
+ sc = rtems_bdbuf_read(dd, block, &bd);
assert(sc == expected_sc);
if (sc == RTEMS_SUCCESSFUL) {
@@ -161,6 +162,7 @@ static rtems_task Init(rtems_task_argument argument)
rtems_status_code sc = RTEMS_SUCCESSFUL;
rtems_bdbuf_buffer *bd = NULL;
dev_t dev = 0;
+ rtems_disk_device *dd = NULL;
printk("\n\n*** TEST BLOCK 9 ***\n");
@@ -170,14 +172,17 @@ static rtems_task Init(rtems_task_argument argument)
sc = disk_register(BLOCK_SIZE, BLOCK_COUNT, &dev);
ASSERT_SC(sc);
- check_read(dev, BLOCK_READ_IO_ERROR, RTEMS_IO_ERROR);
- check_read(dev, BLOCK_READ_UNSATISFIED, RTEMS_UNSATISFIED);
- check_read(dev, BLOCK_READ_SUCCESSFUL, RTEMS_SUCCESSFUL);
- check_read(dev, BLOCK_WRITE_IO_ERROR, RTEMS_SUCCESSFUL);
+ dd = rtems_disk_obtain(dev);
+ assert(dd != NULL);
+
+ check_read(dd, BLOCK_READ_IO_ERROR, RTEMS_IO_ERROR);
+ check_read(dd, BLOCK_READ_UNSATISFIED, RTEMS_UNSATISFIED);
+ check_read(dd, BLOCK_READ_SUCCESSFUL, RTEMS_SUCCESSFUL);
+ check_read(dd, BLOCK_WRITE_IO_ERROR, RTEMS_SUCCESSFUL);
/* Check write IO error */
- sc = rtems_bdbuf_read(dev, BLOCK_WRITE_IO_ERROR, &bd);
+ sc = rtems_bdbuf_read(dd, BLOCK_WRITE_IO_ERROR, &bd);
ASSERT_SC(sc);
bd->buffer [0] = 1;
@@ -185,7 +190,7 @@ static rtems_task Init(rtems_task_argument argument)
sc = rtems_bdbuf_sync(bd);
ASSERT_SC(sc);
- sc = rtems_bdbuf_read(dev, BLOCK_WRITE_IO_ERROR, &bd);
+ sc = rtems_bdbuf_read(dd, BLOCK_WRITE_IO_ERROR, &bd);
ASSERT_SC(sc);
assert(bd->buffer [0] == 0);
@@ -195,7 +200,7 @@ static rtems_task Init(rtems_task_argument argument)
/* Check write to deleted disk */
- sc = rtems_bdbuf_read(dev, BLOCK_READ_SUCCESSFUL, &bd);
+ sc = rtems_bdbuf_read(dd, BLOCK_READ_SUCCESSFUL, &bd);
ASSERT_SC(sc);
sc = rtems_disk_delete(dev);
@@ -204,6 +209,9 @@ static rtems_task Init(rtems_task_argument argument)
sc = rtems_bdbuf_sync(bd);
ASSERT_SC(sc);
+ sc = rtems_disk_release(dd);
+ ASSERT_SC(sc);
+
printk("*** END OF TEST BLOCK 9 ***\n");
exit(0);