Changeset a14b982 in rtems


Ignore:
Timestamp:
Nov 1, 2010, 5:33:08 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, 5, master
Children:
16b1546e
Parents:
5f925685
Message:

2010-11-01 Alin Rus <alin.codejunkie@…>

  • psxaio01/init.c, psxaio02/init.c: Improve coverage.
Location:
testsuites/psxtests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • testsuites/psxtests/ChangeLog

    r5f925685 ra14b982  
     12010-11-01      Alin Rus <alin.codejunkie@gmail.com>
     2
     3        * psxaio01/init.c, psxaio02/init.c: Improve coverage.
     4
    152010-10-21      Joel Sherrill <joel.sherrill@oarcorp.com>
    26
  • testsuites/psxtests/psxaio01/init.c

    r5f925685 ra14b982  
    2525
    2626struct aiocb *
    27 create_aiocb (void)
     27create_aiocb (int fd)
    2828{
    2929  struct aiocb *aiocbp;
     
    3535  aiocbp->aio_offset = 0;
    3636  aiocbp->aio_reqprio = 0;
    37   aiocbp->aio_fildes = open ("aio_fildes", O_RDWR | O_CREAT);
     37  aiocbp->aio_fildes = fd;
    3838
    3939  return aiocbp;
     
    5050POSIX_Init (void *argument)
    5151{
    52   int result, policy;
     52  int result, fd;
    5353  struct aiocb *aiocbp;
    54   rtems_status_code status;
    55   struct sched_param param;
     54  int status;
     55
     56  rtems_aio_init ();
     57
     58  status = mkdir ("/tmp", S_IRWXU);
     59  rtems_test_assert (!status);
     60 
     61  fd = open ("/tmp/aio_fildes", O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO);
     62  rtems_test_assert ( fd != -1);
    5663
    5764  puts ("\n\n*** POSIX AIO TEST 01 ***");
    5865
    59   puts ("\n*** POSIX aio_write() test ***");
     66  puts (" Init: EBADF TESTS ");
    6067
    61   /* Request canceled */
    62   puts ("Init: aio_write - ECANCELED");
    63 
    64   aiocbp = create_aiocb ();
    65   aio_write (aiocbp);
    66   aio_cancel (aiocbp->aio_fildes, aiocbp);
    67   result = aio_return (aiocbp);
    68   rtems_test_assert (result != -1);
    69   status = aio_error (aiocbp);
    70   rtems_test_assert (status != ECANCELED);
    71   free_aiocb (aiocbp);
    72 
    73   /* Successfull added request to queue */
    74   puts ("Init: aio_write - SUCCESSFUL");
    75   aiocbp = create_aiocb ();
    76   aiocbp->aio_fildes = WRONG_FD;
     68  aiocbp = create_aiocb (WRONG_FD);
    7769  status = aio_write (aiocbp);
    78   rtems_test_assert (!status);
    79 
    80   pthread_getschedparam (pthread_self (), &policy, &param);
    81   policy = SCHED_RR;
    82   param.sched_priority = 30;
    83   pthread_setschedparam (pthread_self (), policy, &param);
    84   sleep (1);
    85 
    86   while (aio_error (aiocbp) == EINPROGRESS);
     70  rtems_test_assert (status == -1);
    8771
    8872  /* Bad file descriptor */
     
    9074
    9175  result = aio_return (aiocbp);
    92   rtems_test_assert (result != -1);
     76  rtems_test_assert (result == -1);
    9377  status = aio_error (aiocbp);
    94   rtems_test_assert (status != EBADF);
     78  rtems_test_assert (status == EBADF);
     79
     80  status = aio_read (aiocbp);
     81  rtems_test_assert (status == -1);
     82
     83  /* Bad file descriptor */
     84  puts ("Init: aio_read() - EBADF ");
     85
     86  result = aio_return (aiocbp);
     87  rtems_test_assert (result == -1);
     88  status = aio_error (aiocbp);
     89  rtems_test_assert (status == EBADF);
     90
     91  status = aio_cancel (WRONG_FD, NULL);
     92  rtems_test_assert (status == -1);
     93
     94  /* Bad file descriptor */
     95  puts ("Init: aio_cancel() - EBADF ");
     96 
     97  result = aio_return (aiocbp);
     98  rtems_test_assert (result == -1);
     99  status = aio_error (aiocbp);
     100  rtems_test_assert (status == EBADF);
     101
     102  status = aio_fsync (O_SYNC, aiocbp);
     103  rtems_test_assert (status == -1);
     104 
     105  /* Bad file descriptor */
     106  puts ("Init: aio_fsync() - EBADF ");
     107
     108  result = aio_return (aiocbp);
     109  rtems_test_assert (result == -1);
     110  status = aio_error (aiocbp);
     111  rtems_test_assert (status == EBADF);
     112 
    95113  free_aiocb (aiocbp);
    96114
     
    98116  puts ("Init: aio_write() - EINVAL [aio_offset]");
    99117
    100   aiocbp = create_aiocb ();
     118  aiocbp = create_aiocb (fd);
    101119  aiocbp->aio_offset = -1;
    102   aio_write (aiocbp);
    103   sleep (1);
    104 
    105   while (aio_error (aiocbp) == EINPROGRESS);
     120  status = aio_write (aiocbp);
     121  rtems_test_assert (status == -1);
    106122
    107123  result = aio_return (aiocbp);
    108   rtems_test_assert (result != -1);
     124  rtems_test_assert (result == -1);
    109125  status = aio_error (aiocbp);
    110   rtems_test_assert (status != EINVAL);
     126  rtems_test_assert (status == EINVAL);
     127
     128    /* Invalid offset */
     129  puts ("Init: aio_read() - EINVAL [aio_offset]");
     130
     131  status = aio_read (aiocbp);
     132  rtems_test_assert (status == -1);
     133
     134  result = aio_return (aiocbp);
     135  rtems_test_assert (result == -1);
     136  status = aio_error (aiocbp);
     137  rtems_test_assert (status == EINVAL);
     138
    111139  free_aiocb (aiocbp);
    112140
     
    114142  puts ("Init: aio_write() - EINVAL [aio_reqprio]");
    115143
    116   aiocbp = create_aiocb ();
     144  aiocbp = create_aiocb (fd);
    117145  aiocbp->aio_reqprio = AIO_PRIO_DELTA_MAX + 1;
    118   aio_write (aiocbp);
    119   sleep (1);
    120 
    121   while (aio_error (aiocbp) == EINPROGRESS);
     146  status = aio_write (aiocbp);
     147  rtems_test_assert (status == -1);
    122148
    123149  result = aio_return (aiocbp);
    124   rtems_test_assert (result != -1);
     150  rtems_test_assert (result == -1);
    125151  status = aio_error (aiocbp);
    126   rtems_test_assert (status != EINVAL);
    127   free_aiocb (aiocbp);
     152  rtems_test_assert (status == EINVAL);
    128153
    129   /* aio_nbytes > 0 and aio_offset >= SEEK_END */
    130   puts ("Init: aio_write() - EFBIG");
    131   aiocbp = create_aiocb ();
    132   aiocbp->aio_nbytes = 1;
    133   aiocbp->aio_offset = lseek (aiocbp->aio_fildes, 0, SEEK_END) + 1;
    134   aio_write (aiocbp);
    135   sleep (1);
     154   /* Invalid request priority */
     155  puts ("Init: aio_read() - EINVAL [aio_reqprio]");
    136156
    137   while (aio_error (aiocbp) == EINPROGRESS);
     157  status = aio_read (aiocbp);
     158  rtems_test_assert (status == -1);
    138159
    139160  result = aio_return (aiocbp);
    140   rtems_test_assert (result != -1);
     161  rtems_test_assert (result == -1);
    141162  status = aio_error (aiocbp);
    142   rtems_test_assert (status != EFBIG);
     163  rtems_test_assert (status == EINVAL);
     164
     165  /* Invalid request aio_cancel */
     166  puts ("Init: aio_cancel() - EINVAL ");
     167
     168  status = aio_cancel (WRONG_FD, aiocbp);
     169  rtems_test_assert (status == -1);
     170
     171  result = aio_return (aiocbp);
     172  rtems_test_assert (result == -1);
     173  status = aio_error (aiocbp);
     174  rtems_test_assert (status == EINVAL);
     175
     176  /* Invalid operation to aio_fsync */
     177  puts ("Init: aio_fsync() - EINVAL ");
     178  status = aio_fsync (-1, aiocbp);
     179  rtems_test_assert (status == -1);
     180
     181  result = aio_return (aiocbp);
     182  rtems_test_assert (result == -1);
     183  status = aio_error (aiocbp);
     184  rtems_test_assert (status == EINVAL);
     185
    143186  free_aiocb (aiocbp);
    144187
    145188  puts ("*** END OF POSIX AIO TEST 01 ***");
    146189
     190  close (fd);
    147191  rtems_test_exit (0);
    148192
  • testsuites/psxtests/psxaio02/init.c

    r5f925685 ra14b982  
    2020#include <sched.h>
    2121#include <fcntl.h>
     22#include <rtems/chain.h>
    2223
    23 #define BUFSIZE 512
    24 #define WRONG_FD 404
     24#define BUFSIZE 32
     25#define MAX 7
    2526
    2627struct aiocb *
    27 create_aiocb (void)
     28create_aiocb (int fd)
    2829{
    2930  struct aiocb *aiocbp;
     
    3536  aiocbp->aio_offset = 0;
    3637  aiocbp->aio_reqprio = 0;
    37   aiocbp->aio_fildes = open ("aio_fildes", O_RDWR | O_CREAT);
     38  aiocbp->aio_fildes = fd;
    3839
    3940  return aiocbp;
     
    5051POSIX_Init (void *argument)
    5152{
    52   int result, policy;
    53   struct aiocb *aiocbp;
    54   rtems_status_code status;
    55   struct sched_param param;
     53  int fd[MAX];
     54  struct aiocb *aiocbp[MAX+2];
     55  int status, i;
     56  char filename[BUFSIZE];
     57
     58  status = rtems_aio_init ();
     59  rtems_test_assert (status == 0);
     60 
     61  status = mkdir ("/tmp", S_IRWXU);
     62  rtems_test_assert (!status);
     63 
     64  puts ("\n\n*** POSIX AIO TEST 02 ***");
     65 
     66  puts (" Init: Open files ");
     67
     68  for (i=0; i<MAX; i++)
     69    {
     70      sprintf (filename, "/tmp/aio_fildes%d",i);
     71      fd[i] = open (filename, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO);
     72      rtems_test_assert ( fd[i] != -1);
     73    }
     74 
     75  puts (" Init: [WQ] aio_write on 1st file ");
     76  aiocbp[0] = create_aiocb (fd[0]);
     77  status = aio_write (aiocbp[0]);
     78  rtems_test_assert (status != -1);
     79
     80  puts (" Init: [WQ] aio_write on 2nd file ");
     81  aiocbp[1] = create_aiocb (fd[1]);
     82  status = aio_write (aiocbp[1]);
     83  rtems_test_assert (status != -1);
     84 
     85  puts (" Init: [WQ] aio_read on 2nd file add by priority ");
     86  aiocbp[2] = create_aiocb (fd[1]);
     87  status = aio_read (aiocbp[2]);
     88  rtems_test_assert (status != -1);
     89 
     90  puts (" Init: [WQ] aio_write on 3rd file ");
     91  aiocbp[3] = create_aiocb (fd[2]);
     92  status = aio_write (aiocbp[3]);
     93  rtems_test_assert (status != -1);
     94 
     95  puts (" Init: [WQ] aio_write on 4th file ");
     96  aiocbp[4] = create_aiocb (fd[3]);
     97  status = aio_write (aiocbp[4]);
     98  rtems_test_assert (status != -1);
     99 
     100  puts (" Init: [WQ] aio_write on 5th file  -- [WQ] full ");
     101  aiocbp[5] = create_aiocb (fd[4]);
     102  status = aio_write (aiocbp[5]);
     103  rtems_test_assert (status != -1);
     104 
     105  puts (" Init: [IQ] aio_write on 6th file ");
     106  aiocbp[6] = create_aiocb (fd[5]);
     107  status = aio_write (aiocbp[6]);
     108  rtems_test_assert (status != -1);
     109 
     110  puts (" Init: [IQ] aio_write on 7th file ");
     111  aiocbp[7] = create_aiocb (fd[6]);
     112  status = aio_write (aiocbp[7]);
     113  rtems_test_assert (status != -1);
     114
     115  puts (" Init: [IQ] aio_read on 7th file add by priority ");
     116  aiocbp[8] = create_aiocb (fd[6]);
     117  status = aio_read (aiocbp[8]);
     118  rtems_test_assert (status != -1);
    56119
    57120  puts ("\n\n*** POSIX AIO TEST 02 ***");
    58121
    59   puts ("\n*** POSIX aio_read() test ***");
    60 
    61   /* Request canceled */
    62   puts ("Init: aio_read - ECANCELED");
    63 
    64   aiocbp = create_aiocb ();
    65   aio_read (aiocbp);
    66   aio_cancel (aiocbp->aio_fildes, aiocbp);
    67   result = aio_return (aiocbp);
    68   rtems_test_assert (result != -1);
    69   status = aio_error (aiocbp);
    70   rtems_test_assert (status != ECANCELED);
    71   free_aiocb (aiocbp);
    72 
    73   /* Successfull added request to queue */
    74   puts ("Init: aio_read - SUCCESSFUL");
    75   aiocbp = create_aiocb ();
    76   aiocbp->aio_fildes = WRONG_FD;
    77   status = aio_read (aiocbp);
    78   rtems_test_assert (!status);
    79 
    80   pthread_getschedparam (pthread_self (), &policy, &param);
    81   policy = SCHED_RR;
    82   param.sched_priority = 30;
    83   pthread_setschedparam (pthread_self (), policy, &param);
    84   sleep (1);
    85 
    86   while (aio_error (aiocbp) == EINPROGRESS);
    87 
    88   /* Bad file descriptor */
    89   puts ("Init: aio_read() - EBADF ");
    90 
    91   result = aio_return (aiocbp);
    92   rtems_test_assert (result != -1);
    93   status = aio_error (aiocbp);
    94   rtems_test_assert (status != EBADF);
    95   free_aiocb (aiocbp);
    96 
    97   /* Invalid offset */
    98   puts ("Init: aio_read() - EINVAL [aio_offset]");
    99 
    100   aiocbp = create_aiocb ();
    101   aiocbp->aio_offset = -1;
    102   aio_read (aiocbp);
    103   sleep (1);
    104 
    105   while (aio_error (aiocbp) == EINPROGRESS);
    106 
    107   result = aio_return (aiocbp);
    108   rtems_test_assert (result != -1);
    109   status = aio_error (aiocbp);
    110   rtems_test_assert (status != EINVAL);
    111   free_aiocb (aiocbp);
    112 
    113   /* Invalid request priority */
    114   puts ("Init: aio_read() - EINVAL [aio_reqprio]");
    115 
    116   aiocbp = create_aiocb ();
    117   aiocbp->aio_reqprio = AIO_PRIO_DELTA_MAX + 1;
    118   aio_read (aiocbp);
    119   sleep (1);
    120 
    121   while (aio_error (aiocbp) == EINPROGRESS);
    122 
    123   result = aio_return (aiocbp);
    124   rtems_test_assert (result != -1);
    125   status = aio_error (aiocbp);
    126   rtems_test_assert (status != EINVAL);
    127   free_aiocb (aiocbp);
    128 
    129   /* aio_nbytes > 0 && aio_nbytes + aio_offset > max offset of aio_fildes */
    130   puts ("Init: aio_read() - OVERFLOW");
    131   aiocbp = create_aiocb ();
    132   aiocbp->aio_nbytes = 10;
    133   aiocbp->aio_offset = lseek (aiocbp->aio_fildes, 0, SEEK_END);
    134   aio_read (aiocbp);
    135   sleep (1);
    136 
    137   while (aio_error (aiocbp) == EINPROGRESS);
    138 
    139   result = aio_return (aiocbp);
    140   rtems_test_assert (result != -1);
    141   status = aio_error (aiocbp);
    142   rtems_test_assert (status != EFBIG);
    143   free_aiocb (aiocbp);
    144 
    145122  puts ("*** END OF POSIX AIO TEST 01 ***");
    146123
     124  for (i = 0; i < MAX; i++)
     125    {
     126      close (fd[i]);
     127      free_aiocb (aiocbp[i]);     
     128    }
     129  free_aiocb (aiocbp[i]);
     130  free_aiocb (aiocbp[i+1]);
    147131  rtems_test_exit (0);
    148132
Note: See TracChangeset for help on using the changeset viewer.