Ignore:
Timestamp:
Sep 16, 2016, 10:58:06 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
e814a23
Parents:
610b9ef
git-author:
Sebastian Huber <sebastian.huber@…> (09/16/16 10:58:06)
git-committer:
Sebastian Huber <sebastian.huber@…> (09/19/16 05:52:33)
Message:

termios: Use IMFS nodes for new Termios devices

This makes the new Termios devices independent of device major/minor
numbers. It enables BSP independent Termios device drivers which may
reside in the cpukit domain. These drivers require an IMFS and do not
work with the device file system. However, the device file system
should go away in the future.

File:
1 edited

Legend:

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

    r610b9ef r55e0be36  
    1919#include <fcntl.h>
    2020#include <limits.h>
     21#include <unistd.h>
    2122#include <sys/errno.h>
     23#include <sys/stat.h>
    2224
    2325const char rtems_test_name[] = "TERMIOS 1";
     
    523525} device_context;
    524526
    525 static rtems_status_code test_early_device_install_remove(
     527static rtems_status_code test_early_device_install(
    526528  rtems_device_major_number major,
    527529  rtems_device_minor_number minor,
     
    529531)
    530532{
     533  static const rtems_termios_device_handler handler;
     534  static const char dev[] = "/foobar";
     535
    531536  rtems_resource_snapshot snapshot;
    532537  rtems_status_code sc;
     538  int fd;
     539  int rv;
    533540
    534541  rtems_resource_snapshot_take( &snapshot );
    535542
    536   sc = rtems_termios_device_install( "/", 0, 0, NULL, NULL, NULL );
    537   rtems_test_assert( sc == RTEMS_INCORRECT_STATE );
    538 
    539   sc = rtems_termios_device_remove( "/", 0, 0 );
    540   rtems_test_assert( sc == RTEMS_INCORRECT_STATE );
     543  sc = rtems_termios_device_install( &dev[0], &handler, NULL, NULL );
     544  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
     545
     546  errno = 0;
     547  fd = open( &dev[0], O_RDWR );
     548  rtems_test_assert( fd == -1 );
     549  rtems_test_assert( errno == ENXIO );
     550
     551  rv = unlink( &dev[0] );
     552  rtems_test_assert( rv == 0 );
    541553
    542554  rtems_test_assert( rtems_resource_snapshot_check( &snapshot ) );
     
    548560{
    549561  static const rtems_termios_device_handler handler;
    550   static const rtems_device_major_number major = 123456789;
    551   static const rtems_device_minor_number minor = 0xdeadbeef;
    552562  static const char dev[] = "/foobar";
    553563
     
    555565  rtems_status_code sc;
    556566  void *greedy;
    557   rtems_libio_t iop;
    558   rtems_libio_open_close_args_t args;
    559 
    560   memset( &iop, 0, sizeof( iop ) );
    561   memset( &args, 0, sizeof( args ) );
    562   args.iop = &iop;
     567  int rv;
    563568
    564569  rtems_resource_snapshot_take( &snapshot );
     
    566571  greedy = rtems_heap_greedy_allocate( NULL, 0 );
    567572
    568   sc = rtems_termios_device_install( "/", major, minor, &handler, NULL, NULL );
     573  sc = rtems_termios_device_install( "/", &handler, NULL, NULL );
    569574  rtems_test_assert( sc == RTEMS_NO_MEMORY );
    570575
     
    573578  rtems_test_assert( rtems_resource_snapshot_check( &snapshot ) );
    574579
    575   sc = rtems_termios_device_install(
    576     NULL,
    577     major,
    578     minor,
    579     &handler,
    580     NULL,
    581     NULL
    582   );
     580  sc = rtems_termios_device_install( "/", &handler, NULL, NULL );
     581  rtems_test_assert( sc == RTEMS_UNSATISFIED );
     582
     583  rtems_test_assert( rtems_resource_snapshot_check( &snapshot ) );
     584
     585  sc = rtems_termios_device_install( &dev[0], &handler, NULL, NULL );
    583586  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
    584587
    585   sc = rtems_termios_device_install(
    586     NULL,
    587     major,
    588     minor,
    589     &handler,
    590     NULL,
    591     NULL
    592   );
    593   rtems_test_assert( sc == RTEMS_RESOURCE_IN_USE );
    594 
    595   sc = rtems_termios_device_remove( NULL, major, minor );
    596   rtems_test_assert( sc == RTEMS_SUCCESSFUL );
    597 
    598   rtems_test_assert( rtems_resource_snapshot_check( &snapshot ) );
    599 
    600   sc = rtems_termios_device_install( "/", major, minor, &handler, NULL, NULL );
    601   rtems_test_assert( sc == RTEMS_UNSATISFIED );
    602 
    603   rtems_test_assert( rtems_resource_snapshot_check( &snapshot ) );
    604 
    605   sc = rtems_termios_device_remove( NULL, major, minor );
    606   rtems_test_assert( sc == RTEMS_INVALID_ID );
    607 
    608   sc = rtems_termios_device_install(
    609     &dev[0],
    610     major,
    611     minor,
    612     &handler,
    613     NULL,
    614     NULL
    615   );
    616   rtems_test_assert( sc == RTEMS_SUCCESSFUL );
    617 
    618   sc = rtems_termios_device_remove( "/barfoo", major, minor );
    619   rtems_test_assert( sc == RTEMS_UNSATISFIED );
    620 
    621   sc = rtems_termios_device_open( major, minor, &args );
    622   rtems_test_assert( sc == RTEMS_SUCCESSFUL );
    623 
    624   sc = rtems_termios_device_remove( &dev[0], major, minor );
    625   rtems_test_assert( sc == RTEMS_RESOURCE_IN_USE );
    626 
    627   sc = rtems_termios_device_close( &args );
    628   rtems_test_assert( sc == RTEMS_SUCCESSFUL );
    629 
    630   sc = rtems_termios_device_remove( &dev[0], major, minor );
    631   rtems_test_assert( sc == RTEMS_SUCCESSFUL );
     588  rv = unlink( &dev[0] );
     589  rtems_test_assert( rv == 0 );
    632590
    633591  rtems_test_assert( rtems_resource_snapshot_check( &snapshot ) );
     
    657615    .first_open = first_open_error
    658616  };
    659   static const rtems_device_major_number major = 123456789;
    660   static const rtems_device_minor_number minor = 0xdeadbeef;
    661617  static const char dev[] = "/foobar";
    662618
    663619  rtems_resource_snapshot snapshot;
    664620  rtems_status_code sc;
    665   rtems_libio_t iop;
    666   rtems_libio_open_close_args_t args;
     621  int fd;
     622  int rv;
    667623  device_context ctx = {
    668624    .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER( "abc" ),
     
    672628  rtems_resource_snapshot_take( &snapshot );
    673629
    674   sc = rtems_termios_device_install(
    675     &dev[0],
    676     major,
    677     minor,
    678     &handler,
    679     NULL,
    680     &ctx.base
    681   );
     630  sc = rtems_termios_device_install( &dev[0], &handler, NULL, &ctx.base );
    682631  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
    683632
    684   memset( &iop, 0, sizeof( iop ) );
    685   memset( &args, 0, sizeof( args ) );
    686   args.iop = &iop;
    687 
    688633  rtems_test_assert( !ctx.done );
    689   sc = rtems_termios_device_open( major, minor, &args );
    690   rtems_test_assert( sc == RTEMS_NO_MEMORY );
     634  errno = 0;
     635  fd = open( &dev[0], O_RDWR );
     636  rtems_test_assert( fd == -1 );
     637  rtems_test_assert( errno == ENOMEM );
    691638  rtems_test_assert( ctx.done );
    692639
    693   sc = rtems_termios_device_remove( &dev[0], major, minor );
    694   rtems_test_assert( sc == RTEMS_SUCCESSFUL );
     640  rv = unlink( &dev[0] );
     641  rtems_test_assert( rv == 0 );
    695642
    696643  rtems_test_assert( rtems_resource_snapshot_check( &snapshot ) );
     
    716663    .set_attributes = set_attributes_error
    717664  };
    718   static const rtems_device_major_number major = 123456789;
    719   static const rtems_device_minor_number minor = 0xdeadbeef;
    720665  static const char dev[] = "/foobar";
    721666
    722667  rtems_resource_snapshot snapshot;
    723668  rtems_status_code sc;
    724   rtems_libio_t iop;
    725   rtems_libio_open_close_args_t oc_args;
    726   rtems_libio_ioctl_args_t io_args;
    727669  struct termios term;
    728670  device_context ctx = {
     
    730672    .done = false
    731673  };
     674  int fd;
     675  int rv;
    732676
    733677  rtems_resource_snapshot_take( &snapshot );
    734678
    735   sc = rtems_termios_device_install(
    736     &dev[0],
    737     major,
    738     minor,
    739     &handler,
    740     NULL,
    741     &ctx.base
    742   );
     679  sc = rtems_termios_device_install( &dev[0], &handler, NULL, &ctx.base );
    743680  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
    744681
    745   memset( &iop, 0, sizeof( iop ) );
    746   memset( &oc_args, 0, sizeof( oc_args ) );
    747   oc_args.iop = &iop;
    748 
    749   sc = rtems_termios_device_open( major, minor, &oc_args );
    750   rtems_test_assert( sc == RTEMS_SUCCESSFUL );
    751 
    752   memset( &io_args, 0, sizeof( io_args ) );
    753   io_args.iop = &iop;
    754   io_args.command = RTEMS_IO_SET_ATTRIBUTES;
    755   io_args.buffer = &term;
     682  fd = open( &dev[0], O_RDWR );
     683  rtems_test_assert( fd >= 0 );
    756684
    757685  rtems_test_assert( !ctx.done );
    758   sc = rtems_termios_ioctl( &io_args );
    759   rtems_test_assert( sc == RTEMS_IO_ERROR );
     686  errno = 0;
     687  rv = ioctl( fd, RTEMS_IO_SET_ATTRIBUTES, &term );
     688  rtems_test_assert( rv == -1 );
     689  rtems_test_assert( errno == EIO );
    760690  rtems_test_assert( ctx.done );
    761691
    762   sc = rtems_termios_device_close( &oc_args );
    763   rtems_test_assert( sc == RTEMS_SUCCESSFUL );
    764 
    765   sc = rtems_termios_device_remove( &dev[0], major, minor );
    766   rtems_test_assert( sc == RTEMS_SUCCESSFUL );
     692  rv = close( fd );
     693  rtems_test_assert( rv == 0 );
     694
     695  rv = unlink( &dev[0] );
     696  rtems_test_assert( rv == 0 );
    767697
    768698  rtems_test_assert( rtems_resource_snapshot_check( &snapshot ) );
     
    983913
    984914#define CONFIGURE_APPLICATION_PREREQUISITE_DRIVERS \
    985   { .initialization_entry = test_early_device_install_remove }
     915  { .initialization_entry = test_early_device_install }
    986916
    987917#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
Note: See TracChangeset for help on using the changeset viewer.