Changeset 5005bfc in rtems for testsuites


Ignore:
Timestamp:
Aug 3, 2018, 7:19:19 PM (16 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
6f34f13
Parents:
117f7b1
git-author:
Sebastian Huber <sebastian.huber@…> (08/03/18 19:19:19)
git-committer:
Sebastian Huber <sebastian.huber@…> (08/07/18 05:17:17)
Message:

libtests/block09: Use rtems_blkdev_create()

Update #3358.

File:
1 edited

Legend:

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

    r117f7b1 r5005bfc  
    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
     
    2727#include "tmacros.h"
    2828
     29#include <sys/stat.h>
    2930#include <assert.h>
    3031#include <errno.h>
     32#include <fcntl.h>
    3133#include <stdlib.h>
     34#include <unistd.h>
    3235
    3336#include <rtems.h>
    3437#include <rtems/bdbuf.h>
    35 #include <rtems/diskdevs.h>
    3638#include <rtems/test.h>
    3739
     
    3941
    4042const char rtems_test_name[] = "BLOCK 9";
    41 
    42 /* forward declarations to avoid warnings */
    43 static rtems_task Init(rtems_task_argument argument);
    4443
    4544#define ASSERT_SC(sc) assert((sc) == RTEMS_SUCCESSFUL)
     
    5453#define BLOCK_WRITE_IO_ERROR 3
    5554
     55#define DISK_PATH "/disk"
     56
    5657static char disk_data [BLOCK_COUNT];
    57 
    58 static const rtems_driver_address_table disk_ops = {
    59   .initialization_entry = NULL,
    60   RTEMS_GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES
    61 };
    6258
    6359static int disk_ioctl(rtems_disk_device *dd, uint32_t req, void *arg)
     
    124120}
    125121
    126 static rtems_status_code disk_register(
     122static void disk_register(
    127123  uint32_t block_size,
    128124  rtems_blkdev_bnum block_count,
    129   dev_t *dev_ptr
     125  rtems_disk_device **dd
    130126)
    131127{
    132   rtems_status_code sc = RTEMS_SUCCESSFUL;
    133   rtems_device_major_number major = 0;
    134   dev_t dev = 0;
    135 
    136   sc = rtems_io_register_driver(0, &disk_ops, &major);
    137   ASSERT_SC(sc);
    138 
    139   dev = rtems_filesystem_make_dev_t(major, 0);
    140 
    141   sc = rtems_disk_create_phys(
    142     dev,
     128  rtems_status_code sc;
     129  int fd;
     130  int rv;
     131
     132  sc = rtems_blkdev_create(
     133    DISK_PATH,
    143134    block_size,
    144135    block_count,
    145136    disk_ioctl,
    146     NULL,
    147137    NULL
    148138  );
    149139  ASSERT_SC(sc);
    150140
    151   *dev_ptr = dev;
    152 
    153   return RTEMS_SUCCESSFUL;
     141  fd = open(DISK_PATH, O_RDWR);
     142  rtems_test_assert(fd >= 0);
     143
     144  rv = rtems_disk_fd_get_disk_device(fd, dd);
     145  rtems_test_assert(rv == 0);
     146
     147  rv = close(fd);
     148  rtems_test_assert(rv == 0);
    154149}
    155150
     
    176171  rtems_status_code sc = RTEMS_SUCCESSFUL;
    177172  rtems_bdbuf_buffer *bd = NULL;
    178   dev_t dev = 0;
    179173  rtems_disk_device *dd = NULL;
    180174
    181175  TEST_BEGIN();
    182176
    183   sc = rtems_disk_io_initialize();
    184   ASSERT_SC(sc);
    185 
    186   sc = disk_register(BLOCK_SIZE, BLOCK_COUNT, &dev);
    187   ASSERT_SC(sc);
    188 
    189   dd = rtems_disk_obtain(dev);
    190   assert(dd != NULL);
     177  disk_register(BLOCK_SIZE, BLOCK_COUNT, &dd);
    191178
    192179  check_read(dd, BLOCK_READ_IO_ERROR, RTEMS_IO_ERROR);
     
    218205  ASSERT_SC(sc);
    219206
    220   sc = rtems_disk_delete(dev);
     207  sc = unlink(DISK_PATH);
    221208  ASSERT_SC(sc);
    222209
    223210  sc = rtems_bdbuf_sync(bd);
    224   ASSERT_SC(sc);
    225 
    226   sc = rtems_disk_release(dd);
    227211  ASSERT_SC(sc);
    228212
     
    238222#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
    239223
     224#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
     225
    240226#define CONFIGURE_MAXIMUM_TASKS 1
    241 #define CONFIGURE_MAXIMUM_DRIVERS 4
    242227
    243228#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
Note: See TracChangeset for help on using the changeset viewer.