Ignore:
Timestamp:
Jul 30, 2018, 4:39:09 AM (16 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
16f3f10
Parents:
d56e68b
git-author:
Sebastian Huber <sebastian.huber@…> (07/30/18 04:39:09)
git-committer:
Sebastian Huber <sebastian.huber@…> (08/07/18 05:17:16)
Message:

ramdisk: Use rtems_blkdev_create()

Update #3358.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/libtests/block02/init.c

    rd56e68b r24b94c4  
    88
    99/*
    10  * Copyright (c) 2009-2012 embedded brains GmbH.  All rights reserved.
     10 * Copyright (c) 2009, 2018 embedded brains GmbH.  All rights reserved.
    1111 *
    1212 *  embedded brains GmbH
    13  *  Obere Lagerstr. 30
     13 *  Dornierstr. 4
    1414 *  82178 Puchheim
    1515 *  Germany
     
    3131#include <rtems/ramdisk.h>
    3232#include <rtems/bdbuf.h>
    33 #include <rtems/diskdevs.h>
     33
     34#include <sys/stat.h>
     35#include <fcntl.h>
     36#include <unistd.h>
    3437
    3538const char rtems_test_name[] = "BLOCK 2";
    36 
    37 /* forward declarations to avoid warnings */
    38 static rtems_task Init(rtems_task_argument argument);
    3939
    4040#define ASSERT_SC(sc) rtems_test_assert((sc) == RTEMS_SUCCESSFUL)
     
    131131}
    132132
     133static void do_ramdisk_register(
     134  uint32_t media_block_size,
     135  rtems_blkdev_bnum media_block_count,
     136  const char *disk,
     137  rtems_disk_device **dd
     138)
     139{
     140  rtems_status_code sc;
     141  int fd;
     142  int rv;
     143
     144  sc = ramdisk_register(media_block_size, media_block_count, false, disk);
     145  ASSERT_SC(sc);
     146
     147  fd = open(disk, O_RDWR);
     148  rtems_test_assert(fd >= 0);
     149
     150  rv = rtems_disk_fd_get_disk_device(fd, dd);
     151  rtems_test_assert(rv == 0);
     152
     153  rv = close(fd);
     154  rtems_test_assert(rv == 0);
     155}
     156
    133157static rtems_task Init(rtems_task_argument argument)
    134158{
    135159  rtems_status_code sc = RTEMS_SUCCESSFUL;
    136160  rtems_bdbuf_buffer *bd = NULL;
    137   dev_t dev_a = 0;
    138   dev_t dev_b = 0;
    139161
    140162  TEST_BEGIN();
    141163
    142   sc = rtems_disk_io_initialize();
    143   ASSERT_SC(sc);
    144 
    145   sc = ramdisk_register(BLOCK_SIZE_A, BLOCK_COUNT_A, false, "/dev/rda", &dev_a);
    146   ASSERT_SC(sc);
    147 
    148   sc = ramdisk_register(BLOCK_SIZE_B, BLOCK_COUNT_B, false, "/dev/rdb", &dev_b);
    149   ASSERT_SC(sc);
    150 
    151   dd_a = rtems_disk_obtain(dev_a);
    152   rtems_test_assert(dd_a != NULL);
    153 
    154   dd_b = rtems_disk_obtain(dev_b);
    155   rtems_test_assert(dd_b != NULL);
     164  do_ramdisk_register(BLOCK_SIZE_A, BLOCK_COUNT_A, "/dev/rda", &dd_a);
     165  do_ramdisk_register(BLOCK_SIZE_B, BLOCK_COUNT_B, "/dev/rdb", &dd_b);
    156166
    157167  sc = rtems_task_create(
     
    201211#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
    202212
     213#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
     214
    203215#define CONFIGURE_MAXIMUM_TASKS 3
    204 #define CONFIGURE_MAXIMUM_DRIVERS 3
    205216
    206217#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
Note: See TracChangeset for help on using the changeset viewer.