Changeset 117f7b1 in rtems


Ignore:
Timestamp:
Aug 3, 2018, 4:18:56 PM (15 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
5005bfc
Parents:
bde8be2
git-author:
Sebastian Huber <sebastian.huber@…> (08/03/18 16:18:56)
git-committer:
Sebastian Huber <sebastian.huber@…> (08/07/18 05:17:17)
Message:

libtests/block08: Use rtems_blkdev_create()

Update #3358.

Location:
testsuites/libtests/block08
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • testsuites/libtests/block08/bdbuf_tests.c

    rbde8be2 r117f7b1  
    1414#endif
    1515
     16#include <sys/stat.h>
    1617#include <stdio.h>
    1718#include <string.h>
    1819#include <errno.h>
     20#include <fcntl.h>
     21#include <unistd.h>
    1922
    2023#include <rtems.h>
    2124#include <rtems/io.h>
    22 #include <rtems/diskdevs.h>
    2325#include <rtems/bdbuf.h>
    2426#include <rtems/inttypes.h>
    2527#include "bdbuf_tests.h"
    2628
     29#include <tmacros.h>
    2730
    2831struct bdbuf_test_descr {
     
    106109run_bdbuf_tests()
    107110{
    108     rtems_disk_device  *disk;
    109     rtems_status_code   sc;
    110     dev_t               dev = -1;
    111     dev_t               test_dev;
    112     unsigned int        i;
    113 
    114     rtems_device_major_number  major;
    115     rtems_driver_address_table testdisk = {
    116         test_disk_initialize,
    117         RTEMS_GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES
    118     };
     111    rtems_status_code sc;
     112    unsigned int      i;
     113    int               fd;
     114    int               rv;
    119115
    120116    /* Create a message queue to get events from disk driver. */
     
    131127    }
    132128
    133     /* Register a disk device that is used in tests */
    134     sc = rtems_io_register_driver(0, &testdisk, &major);
    135     if (sc != RTEMS_SUCCESSFUL)
    136     {
    137         printf("Failed to register TEST DEVICE: %d\n", sc);
    138         return;
    139     }
    140 
    141     test_dev = -1;
    142     while ((disk = rtems_disk_next(dev)) != NULL)
    143     {
    144         printf(
    145           "DEV: %s [%" PRIdrtems_blkdev_bnum "]\n",
    146          disk->name,
    147           disk->size
    148         );
    149         dev = disk->dev;
    150         if (strcmp(disk->name, TEST_DISK_NAME) == 0)
    151             test_dev = dev;
    152         rtems_disk_release(disk);
    153     }
    154 
    155     if (test_dev == (dev_t)-1)
    156     {
    157         printf("Failed to find %s disk\n", TEST_DISK_NAME);
    158         return;
    159     }
    160 
    161     test_dd = rtems_disk_obtain(test_dev);
    162     if (test_dd == NULL)
    163     {
    164         printf("Failed to obtain %s disk\n", TEST_DISK_NAME);
    165         return;
    166     }
     129    sc = test_disk_initialize();
     130    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     131
     132    fd = open(TEST_DISK_NAME, O_RDWR);
     133    rtems_test_assert(fd >= 0);
     134
     135    rv = rtems_disk_fd_get_disk_device(fd, &test_dd);
     136    rtems_test_assert(rv == 0);
     137
     138    rv = close(fd);
     139    rtems_test_assert(rv == 0);
    167140
    168141    /*
  • testsuites/libtests/block08/bdbuf_tests.h

    rbde8be2 r117f7b1  
    1818#include <errno.h>
    1919#include <rtems/bspIo.h>
    20 #include <rtems/diskdevs.h>
    2120#include <rtems/bdbuf.h>
    2221
     
    4746extern void bdbuf_test4_3_main(void);
    4847
    49 extern rtems_device_driver
    50 test_disk_initialize(
    51     rtems_device_major_number major,
    52     rtems_device_minor_number minor,
    53     void *arg);
     48extern rtems_status_code test_disk_initialize(void);
    5449
    5550#define ARRAY_NUM(a_) (sizeof(a_) / sizeof(a_[0]))
  • testsuites/libtests/block08/system.h

    rbde8be2 r117f7b1  
    2525#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
    2626
     27#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
     28
    2729#define CONFIGURE_MAXIMUM_TASKS               28
    2830#define CONFIGURE_MAXIMUM_TIMERS              10
     
    4143#define CONFIGURE_BDBUF_BUFFER_MAX_SIZE     (512)
    4244
    43 /*
    44  * Define it here in order to be able to register
    45  * test driver after RTEMS initialization phase
    46  * (on test start-up).
    47  */
    48 #define CONFIGURE_MAXIMUM_DRIVERS 5
    49 
    5045#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
    5146
  • testsuites/libtests/block08/test_disk.c

    rbde8be2 r117f7b1  
    2222#include <inttypes.h>
    2323
    24 #include "rtems/blkdev.h"
    25 #include "rtems/diskdevs.h"
     24#include <rtems/blkdev.h>
    2625
    2726#include "bdbuf_tests.h"
     
    5958
    6059        default:
    61             printf("%s() Unexpected request comes %" PRIu32 "\n",
    62                    __FUNCTION__, req);
    63             return -1;
     60            return rtems_blkdev_ioctl (dd, req, argp);
    6461    }
    6562
     
    108105}
    109106
    110 rtems_device_driver
    111 test_disk_initialize(
    112     rtems_device_major_number major,
    113     rtems_device_minor_number minor,
    114     void *arg)
     107rtems_status_code
     108test_disk_initialize(void)
    115109{
    116110    rtems_status_code rc;
    117     dev_t             dev;
    118111
    119     rc = rtems_disk_io_initialize();
    120     if (rc != RTEMS_SUCCESSFUL)
    121         return rc;
    122 
    123     dev = rtems_filesystem_make_dev_t(major, minor);
    124     rc = rtems_disk_create_phys(dev,
    125                                 TEST_DISK_BLOCK_SIZE, TEST_DISK_BLOCK_NUM,
    126                                 test_disk_ioctl,
    127                                 NULL,
    128                                 TEST_DISK_NAME);
     112    rc = rtems_blkdev_create(TEST_DISK_NAME,
     113                             TEST_DISK_BLOCK_SIZE, TEST_DISK_BLOCK_NUM,
     114                             test_disk_ioctl,
     115                             NULL);
    129116    if (rc != RTEMS_SUCCESSFUL)
    130117    {
Note: See TracChangeset for help on using the changeset viewer.