Changeset 85d62357 in rtems


Ignore:
Timestamp:
Jan 13, 2000, 7:26:38 PM (20 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
3e7a0fd
Parents:
53fb837a
Message:

Changed error checking macros for POSIX.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • c/src/tests/psxtests/psxsem01/init.c

    r53fb837a r85d62357  
    2626    status = sem_init(&sems[i], 0, i);
    2727    sprintf(failure_msg, "sem_init %d", i );
    28     fatal_directive_status( status, 0, failure_msg);
     28    fatal_posix_service_status( status, 0, failure_msg);
    2929  }
    3030  puts( "Init: sem_init - UNSUCCESSFUL (ENOSPC)" );
    3131  status = sem_init(&sem2, 0, 1);
    32   fatal_directive_status( status, -1, "sem_init error return status");
    33   fatal_directive_status( errno, ENOSPC, "sem_init errorno ENOSPC" );
     32  fatal_posix_service_status( status, -1, "sem_init error return status");
     33  fatal_posix_service_status( errno, ENOSPC, "sem_init errorno ENOSPC" );
    3434 
    3535  puts( "Init: sem_init - UNSUCCESSFUL (ENOSYS -- pshared not supported)" );
    3636  status = sem_init(&sem2, 1, 1);
    37   fatal_directive_status( status, -1, "sem_init error return status");
    38   fatal_directive_status( errno, ENOSYS, "sem_init errno set to ENOSYS");
     37  fatal_posix_service_status( status, -1, "sem_init error return status");
     38  fatal_posix_service_status( errno, ENOSYS, "sem_init errno set to ENOSYS");
    3939 
    4040  puts( "Init: sem_getvalue - SUCCESSFUL ");
     
    4242    status = sem_getvalue(&sems[i], &value);
    4343    sprintf( failure_msg, "sem_getvalue %d", i );
    44     fatal_directive_status( status, 0, failure_msg );
    45     fatal_directive_status( value, i, "sem_getvalue correct value" );
     44    fatal_posix_service_status( status, 0, failure_msg );
     45    fatal_posix_service_status( value, i, "sem_getvalue correct value" );
    4646  }
    4747  puts( "Init: sem_getvalue - UNSUCCESSFUL ");
    4848  status = sem_getvalue(&sem2, &value);
    49   fatal_directive_status( status, -1, "sem_getvalue error return status");
    50   fatal_directive_status( errno, EINVAL, "sem_getvalue errno EINVAL");
     49  fatal_posix_service_status( status, -1, "sem_getvalue error return status");
     50  fatal_posix_service_status( errno, EINVAL, "sem_getvalue errno EINVAL");
    5151
    5252  puts( "Init: sem_destroy - SUCCESSFUL" );
    5353  status = sem_destroy(&sems[0]);
    54   fatal_directive_status( status, 0, "sem_destroy semaphore 0");
     54  fatal_posix_service_status( status, 0, "sem_destroy semaphore 0");
    5555
    5656  puts( "Init: sem_destroy - UNSUCCESSFUL (EINVAL)" );
    5757  status = sem_destroy(&sem2);
    58   fatal_directive_status( status, -1, "sem_destroy error return status");
    59   fatal_directive_status( errno, EINVAL, "sem_destroy errno EINVAL");
     58  fatal_posix_service_status( status, -1, "sem_destroy error return status");
     59  fatal_posix_service_status( errno, EINVAL, "sem_destroy errno EINVAL");
    6060
    6161  puts( "Init: sem_wait - SUCCESSFUL" );
    6262  status = sem_wait(&sems[1]);
    63   fatal_directive_status( status, 0, "sem_wait semaphore 1");
     63  fatal_posix_service_status( status, 0, "sem_wait semaphore 1");
    6464
    6565  puts( "Init: sem_wait - UNSUCCESSFUL (EINVAL)" );
    6666  status = sem_wait(&sem2);
    67   fatal_directive_status( status, -1, "sem_wait error return status");
    68   fatal_directive_status( errno, EINVAL, "sem_wait errno EINVAL");
     67  fatal_posix_service_status( status, -1, "sem_wait error return status");
     68  fatal_posix_service_status( errno, EINVAL, "sem_wait errno EINVAL");
    6969
    7070  puts( "Init: sem_post - SUCCESSFUL" );
    7171  status = sem_post(&sems[1]);
    72   fatal_directive_status( status, 0, "sem_post semaphore 1");
     72  fatal_posix_service_status( status, 0, "sem_post semaphore 1");
    7373
    7474  puts( "Init: sem_wait - SUCCESSFUL (after a sem_post)" );
    7575  status = sem_wait(&sems[1]);
    76   fatal_directive_status( status, 0, "sem_wait semaphore 1");
     76  fatal_posix_service_status( status, 0, "sem_wait semaphore 1");
    7777
    7878  puts( "Init: sem_trywait - SUCCESSFUL" );
    7979  status = sem_trywait(&sems[2]);
    80   fatal_directive_status( status, 0, "sem_trywait semaphore 2");
     80  fatal_posix_service_status( status, 0, "sem_trywait semaphore 2");
    8181
    8282  puts( "Init: sem_trywait - UNSUCCESSFUL (EAGAIN)" );
    8383  status = sem_trywait(&sems[1]);
    84   fatal_directive_status( status, -1, "sem_trywait error return status");
    85   fatal_directive_status( errno, EAGAIN, "sem_trywait errno EAGAIN");
     84  fatal_posix_service_status( status, -1, "sem_trywait error return status");
     85  fatal_posix_service_status( errno, EAGAIN, "sem_trywait errno EAGAIN");
    8686
    8787  puts( "Init: sem_trywait - UNSUCCESSFUL (EINVAL)" );
    8888  status = sem_trywait(&sem2);
    89   fatal_directive_status( status, -1, "sem_trywait error return status");
    90   fatal_directive_status( errno, EINVAL, "sem_trywait errno EINVAL");
     89  fatal_posix_service_status( status, -1, "sem_trywait error return status");
     90  fatal_posix_service_status( errno, EINVAL, "sem_trywait errno EINVAL");
    9191
    9292  puts( "Init: sem_timedwait - SUCCESSFUL" );
     
    9494  waittime.tv_nsec = 100;
    9595  status = sem_timedwait(&sems[2], &waittime);
    96   fatal_directive_status( status, 0, "sem_timedwait semaphore 2");
     96  fatal_posix_service_status( status, 0, "sem_timedwait semaphore 2");
    9797
    9898  puts( "Init: sem_timedwait - UNSUCCESSFUL (ETIMEDOUT)" );
    9999  status = sem_timedwait(&sems[1], &waittime);
    100   fatal_directive_status( status, -1, "sem_timedwait error return status");
    101   fatal_directive_status( errno, ETIMEDOUT, "sem_timedwait errno ETIMEDOUT");
     100  fatal_posix_service_status( status, -1, "sem_timedwait error return status");
     101  fatal_posix_service_status( errno, ETIMEDOUT, "sem_timedwait errno ETIMEDOUT");
    102102
    103103  puts( "Init: sem_timedwait - UNSUCCESSFUL (EINVAL)" );
    104104  status = sem_timedwait(&sem2, &waittime);
    105   fatal_directive_status( status, -1, "sem_timedwait error return status");
    106   fatal_directive_status( errno, EINVAL, "sem_init errno EINVAL");
     105  fatal_posix_service_status( status, -1, "sem_timedwait error return status");
     106  fatal_posix_service_status( errno, EINVAL, "sem_init errno EINVAL");
    107107
    108108  puts( "Init: sem_post - UNSUCCESSFUL (EINVAL)" );
    109109  status = sem_post(&sem2);
    110   fatal_directive_status( status, -1, "sem_post error return status");
    111   fatal_directive_status( errno, EINVAL, "sem_post errno EINVAL");
     110  fatal_posix_service_status( status, -1, "sem_post error return status");
     111  fatal_posix_service_status( errno, EINVAL, "sem_post errno EINVAL");
    112112
    113113  puts( "Init: sem_destroy - SUCCESSFUL" );
     
    115115    status = sem_destroy(&sems[i]);
    116116    sprintf( failure_msg, "sem_destroy %d", i );
    117     fatal_directive_status( status, 0, failure_msg );
     117    fatal_posix_service_status( status, 0, failure_msg );
    118118  }
    119119
     
    130130  puts( "Init: sem_open - Create an Existing sem (EEXIST)" );
    131131  n_sem2 = sem_open("sem1", O_CREAT | O_EXCL, 00777, 1);
    132   fatal_directive_status(
     132  fatal_posix_service_status(
    133133    (int) n_sem2, (int ) SEM_FAILED, "sem_open error return status" );
    134   fatal_directive_status( errno, EEXIST,  "sem_open errno EEXIST");
     134  fatal_posix_service_status( errno, EEXIST,  "sem_open errno EEXIST");
    135135
    136136  puts( "Init: sem_open - Open new sem without create flag (ENOENT)" );
    137137  n_sem2 = sem_open("sem3", O_EXCL, 00777, 1);
    138   fatal_directive_status(
     138  fatal_posix_service_status(
    139139    (int) n_sem2, (int ) SEM_FAILED, "sem_open error return status" );
    140   fatal_directive_status( errno, ENOENT,  "sem_open errno EEXIST");
     140  fatal_posix_service_status( errno, ENOENT,  "sem_open errno EEXIST");
    141141
    142142  /*
     
    153153  puts( "Init: sem_wait on sem1" );
    154154  status = sem_wait(n_sem1);
    155   fatal_directive_status( status, 0, "sem_wait opened semaphore");
     155  fatal_posix_service_status( status, 0, "sem_wait opened semaphore");
    156156
    157157  /*
     
    161161  puts( "Init: sem_open - Open an existing sem ( same id )" );
    162162  n_sem2 = sem_open("sem1", 0 );
    163   fatal_directive_status(
     163  fatal_posix_service_status(
    164164    (int) n_sem2, (int ) n_sem1, "sem_open error return status" );
    165165 
     
    171171  puts( "Init: sem_unlink - sem1 SUCCESSFUL" );
    172172  status = sem_unlink( "sem1" );
    173   fatal_directive_status( status, 0, "sem_unlink locked semaphore");
     173  fatal_posix_service_status( status, 0, "sem_unlink locked semaphore");
    174174
    175175  puts( "Init: sem_open - Reopen sem1 SUCCESSFUL with a different id" );
     
    184184  puts( "Init: sem_close (1) - SUCCESSFUL" );
    185185  status = sem_close( n_sem1 );
    186   fatal_directive_status( status, 0, "sem_close semaphore");
     186  fatal_posix_service_status( status, 0, "sem_close semaphore");
    187187
    188188
     
    194194  puts( "Init: sem_close (2) - SUCCESSFUL" );
    195195  status = sem_close( n_sem2 );
    196   fatal_directive_status( status, 0, "sem_close semaphore");
     196  fatal_posix_service_status( status, 0, "sem_close semaphore");
    197197
    198198  puts( "Init: sem_unlink - sem1 (2) SUCCESSFUL" );
    199199  status = sem_unlink( "sem1" );
    200   fatal_directive_status( status, 0, "sem_unlink locked semaphore");
     200  fatal_posix_service_status( status, 0, "sem_unlink locked semaphore");
    201201
    202202  puts( "Init: sem_close - UNSUCCESSFUL (EINVAL)" );
    203203  status = sem_close(n_sem2);
    204   fatal_directive_status( status, -1, "sem_close error return status");
    205   fatal_directive_status( errno, EINVAL, "sem_close errno EINVAL");
     204  fatal_posix_service_status( status, -1, "sem_close error return status");
     205  fatal_posix_service_status( errno, EINVAL, "sem_close errno EINVAL");
    206206
    207207  puts( "Init: sem_unlink - UNSUCCESSFUL (ENOENT)" );
    208208  status = sem_unlink("sem1");
    209   fatal_directive_status( status, -1, "sem_unlink error return status");
    210   fatal_directive_status( errno, ENOENT, "sem_close errno EINVAL");
     209  fatal_posix_service_status( status, -1, "sem_unlink error return status");
     210  fatal_posix_service_status( errno, ENOENT, "sem_close errno EINVAL");
    211211
    212212
     
    217217  puts( "Init: sem_unlink (NULL) - EINVAL" );
    218218  status = sem_unlink( NULL );
    219   fatal_directive_status( status, -1, "sem_unlink error return status");
    220   fatal_directive_status( errno, EINVAL, "sem_unlink errno value");
     219  fatal_posix_service_status( status, -1, "sem_unlink error return status");
     220  fatal_posix_service_status( errno, EINVAL, "sem_unlink errno value");
    221221
    222222  puts( "Init: sem_unlink (\"\") - EINVAL" );
    223223  status = sem_unlink( "" );
    224   fatal_directive_status( status, -1, "sem_unlink error return status");
    225   fatal_directive_status( errno, EINVAL, "sem_unlink errno value");
     224  fatal_posix_service_status( status, -1, "sem_unlink error return status");
     225  fatal_posix_service_status( errno, EINVAL, "sem_unlink errno value");
    226226
    227227  /*
     
    232232  puts( "Init: sem_unlink - UNSUCCESSFUL (ENOENT)" );
    233233  status = sem_unlink("sem2");
    234   fatal_directive_status( status, -1, "sem_unlink error return status");
    235   fatal_directive_status( errno, ENOENT, "sem_unlink errno ENOENT");
     234  fatal_posix_service_status( status, -1, "sem_unlink error return status");
     235  fatal_posix_service_status( errno, ENOENT, "sem_unlink errno ENOENT");
    236236  assert( (status == -1) && (errno == ENOENT) );
    237237
  • c/src/tests/support/include/tmacros.h

    r53fb837a r85d62357  
    2525#include <stdio.h>
    2626#include <stdlib.h>
     27#include <string.h>
    2728#include <assert.h>
    2829#include <rtems/error.h>
     
    4849  } while ( 0 )
    4950
     51/*
     52 *  These macros properly report errors within the Classic API
     53 */
     54
    5055#define directive_failed( _dirstat, _failmsg )  \
    5156 fatal_directive_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg )
     
    6873    } \
    6974  } while ( 0 )
     75
     76/*
     77 *  These macros properly report errors from the POSIX API
     78 */
     79
     80#define posix_service_failed( _dirstat, _failmsg )  \
     81 fatal_posix_service_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg )
     82
     83#define posix_service_failed_with_level( _dirstat, _failmsg, _level )  \
     84 fatal_posix_service_status_with_level( \
     85      _dirstat, RTEMS_SUCCESSFUL, _failmsg, _level )
     86
     87#define fatal_posix_service_status( _stat, _desired, _msg ) \
     88  fatal_posix_service_status_with_level( _stat, _desired, _msg, 0 )
     89
     90#define fatal_posix_service_status_with_level( _stat, _desired, _msg, _level ) \
     91  do { \
     92    check_dispatch_disable_level( _level ); \
     93    if ( (_stat) != (_desired) ) { \
     94      printf( "\n%s FAILED -- expected (%s) got (%s)\n", \
     95              (_msg), strerror(_desired), strerror(_stat) ); \
     96      fflush(stdout); \
     97      exit( _stat ); \
     98    } \
     99  } while ( 0 )
     100
     101/*
     102 *  Generic integer version of the error reporting
     103 */
     104
     105#define int_service_failed( _dirstat, _failmsg )  \
     106 fatal_int_service_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg )
     107
     108#define int_service_failed_with_level( _dirstat, _failmsg, _level )  \
     109 fatal_int_service_status_with_level( \
     110      _dirstat, RTEMS_SUCCESSFUL, _failmsg, _level )
     111
     112#define fatal_int_service_status( _stat, _desired, _msg ) \
     113  fatal_int_service_status_with_level( _stat, _desired, _msg, 0 )
     114
     115#define fatal_int_service_status_with_level( _stat, _desired, _msg, _level ) \
     116  do { \
     117    check_dispatch_disable_level( _level ); \
     118    if ( (_stat) != (_desired) ) { \
     119      printf( "\n%s FAILED -- expected (%d) got (%d)\n", \
     120              (_msg), (_desired), (_stat) ); \
     121      fflush(stdout); \
     122      exit( _stat ); \
     123    } \
     124  } while ( 0 )
     125
     126
     127/*
     128 *  Print the time
     129 */
    70130
    71131#define sprint_time(_str, _s1, _tb, _s2) \
  • testsuites/psxtests/psxsem01/init.c

    r53fb837a r85d62357  
    2626    status = sem_init(&sems[i], 0, i);
    2727    sprintf(failure_msg, "sem_init %d", i );
    28     fatal_directive_status( status, 0, failure_msg);
     28    fatal_posix_service_status( status, 0, failure_msg);
    2929  }
    3030  puts( "Init: sem_init - UNSUCCESSFUL (ENOSPC)" );
    3131  status = sem_init(&sem2, 0, 1);
    32   fatal_directive_status( status, -1, "sem_init error return status");
    33   fatal_directive_status( errno, ENOSPC, "sem_init errorno ENOSPC" );
     32  fatal_posix_service_status( status, -1, "sem_init error return status");
     33  fatal_posix_service_status( errno, ENOSPC, "sem_init errorno ENOSPC" );
    3434 
    3535  puts( "Init: sem_init - UNSUCCESSFUL (ENOSYS -- pshared not supported)" );
    3636  status = sem_init(&sem2, 1, 1);
    37   fatal_directive_status( status, -1, "sem_init error return status");
    38   fatal_directive_status( errno, ENOSYS, "sem_init errno set to ENOSYS");
     37  fatal_posix_service_status( status, -1, "sem_init error return status");
     38  fatal_posix_service_status( errno, ENOSYS, "sem_init errno set to ENOSYS");
    3939 
    4040  puts( "Init: sem_getvalue - SUCCESSFUL ");
     
    4242    status = sem_getvalue(&sems[i], &value);
    4343    sprintf( failure_msg, "sem_getvalue %d", i );
    44     fatal_directive_status( status, 0, failure_msg );
    45     fatal_directive_status( value, i, "sem_getvalue correct value" );
     44    fatal_posix_service_status( status, 0, failure_msg );
     45    fatal_posix_service_status( value, i, "sem_getvalue correct value" );
    4646  }
    4747  puts( "Init: sem_getvalue - UNSUCCESSFUL ");
    4848  status = sem_getvalue(&sem2, &value);
    49   fatal_directive_status( status, -1, "sem_getvalue error return status");
    50   fatal_directive_status( errno, EINVAL, "sem_getvalue errno EINVAL");
     49  fatal_posix_service_status( status, -1, "sem_getvalue error return status");
     50  fatal_posix_service_status( errno, EINVAL, "sem_getvalue errno EINVAL");
    5151
    5252  puts( "Init: sem_destroy - SUCCESSFUL" );
    5353  status = sem_destroy(&sems[0]);
    54   fatal_directive_status( status, 0, "sem_destroy semaphore 0");
     54  fatal_posix_service_status( status, 0, "sem_destroy semaphore 0");
    5555
    5656  puts( "Init: sem_destroy - UNSUCCESSFUL (EINVAL)" );
    5757  status = sem_destroy(&sem2);
    58   fatal_directive_status( status, -1, "sem_destroy error return status");
    59   fatal_directive_status( errno, EINVAL, "sem_destroy errno EINVAL");
     58  fatal_posix_service_status( status, -1, "sem_destroy error return status");
     59  fatal_posix_service_status( errno, EINVAL, "sem_destroy errno EINVAL");
    6060
    6161  puts( "Init: sem_wait - SUCCESSFUL" );
    6262  status = sem_wait(&sems[1]);
    63   fatal_directive_status( status, 0, "sem_wait semaphore 1");
     63  fatal_posix_service_status( status, 0, "sem_wait semaphore 1");
    6464
    6565  puts( "Init: sem_wait - UNSUCCESSFUL (EINVAL)" );
    6666  status = sem_wait(&sem2);
    67   fatal_directive_status( status, -1, "sem_wait error return status");
    68   fatal_directive_status( errno, EINVAL, "sem_wait errno EINVAL");
     67  fatal_posix_service_status( status, -1, "sem_wait error return status");
     68  fatal_posix_service_status( errno, EINVAL, "sem_wait errno EINVAL");
    6969
    7070  puts( "Init: sem_post - SUCCESSFUL" );
    7171  status = sem_post(&sems[1]);
    72   fatal_directive_status( status, 0, "sem_post semaphore 1");
     72  fatal_posix_service_status( status, 0, "sem_post semaphore 1");
    7373
    7474  puts( "Init: sem_wait - SUCCESSFUL (after a sem_post)" );
    7575  status = sem_wait(&sems[1]);
    76   fatal_directive_status( status, 0, "sem_wait semaphore 1");
     76  fatal_posix_service_status( status, 0, "sem_wait semaphore 1");
    7777
    7878  puts( "Init: sem_trywait - SUCCESSFUL" );
    7979  status = sem_trywait(&sems[2]);
    80   fatal_directive_status( status, 0, "sem_trywait semaphore 2");
     80  fatal_posix_service_status( status, 0, "sem_trywait semaphore 2");
    8181
    8282  puts( "Init: sem_trywait - UNSUCCESSFUL (EAGAIN)" );
    8383  status = sem_trywait(&sems[1]);
    84   fatal_directive_status( status, -1, "sem_trywait error return status");
    85   fatal_directive_status( errno, EAGAIN, "sem_trywait errno EAGAIN");
     84  fatal_posix_service_status( status, -1, "sem_trywait error return status");
     85  fatal_posix_service_status( errno, EAGAIN, "sem_trywait errno EAGAIN");
    8686
    8787  puts( "Init: sem_trywait - UNSUCCESSFUL (EINVAL)" );
    8888  status = sem_trywait(&sem2);
    89   fatal_directive_status( status, -1, "sem_trywait error return status");
    90   fatal_directive_status( errno, EINVAL, "sem_trywait errno EINVAL");
     89  fatal_posix_service_status( status, -1, "sem_trywait error return status");
     90  fatal_posix_service_status( errno, EINVAL, "sem_trywait errno EINVAL");
    9191
    9292  puts( "Init: sem_timedwait - SUCCESSFUL" );
     
    9494  waittime.tv_nsec = 100;
    9595  status = sem_timedwait(&sems[2], &waittime);
    96   fatal_directive_status( status, 0, "sem_timedwait semaphore 2");
     96  fatal_posix_service_status( status, 0, "sem_timedwait semaphore 2");
    9797
    9898  puts( "Init: sem_timedwait - UNSUCCESSFUL (ETIMEDOUT)" );
    9999  status = sem_timedwait(&sems[1], &waittime);
    100   fatal_directive_status( status, -1, "sem_timedwait error return status");
    101   fatal_directive_status( errno, ETIMEDOUT, "sem_timedwait errno ETIMEDOUT");
     100  fatal_posix_service_status( status, -1, "sem_timedwait error return status");
     101  fatal_posix_service_status( errno, ETIMEDOUT, "sem_timedwait errno ETIMEDOUT");
    102102
    103103  puts( "Init: sem_timedwait - UNSUCCESSFUL (EINVAL)" );
    104104  status = sem_timedwait(&sem2, &waittime);
    105   fatal_directive_status( status, -1, "sem_timedwait error return status");
    106   fatal_directive_status( errno, EINVAL, "sem_init errno EINVAL");
     105  fatal_posix_service_status( status, -1, "sem_timedwait error return status");
     106  fatal_posix_service_status( errno, EINVAL, "sem_init errno EINVAL");
    107107
    108108  puts( "Init: sem_post - UNSUCCESSFUL (EINVAL)" );
    109109  status = sem_post(&sem2);
    110   fatal_directive_status( status, -1, "sem_post error return status");
    111   fatal_directive_status( errno, EINVAL, "sem_post errno EINVAL");
     110  fatal_posix_service_status( status, -1, "sem_post error return status");
     111  fatal_posix_service_status( errno, EINVAL, "sem_post errno EINVAL");
    112112
    113113  puts( "Init: sem_destroy - SUCCESSFUL" );
     
    115115    status = sem_destroy(&sems[i]);
    116116    sprintf( failure_msg, "sem_destroy %d", i );
    117     fatal_directive_status( status, 0, failure_msg );
     117    fatal_posix_service_status( status, 0, failure_msg );
    118118  }
    119119
     
    130130  puts( "Init: sem_open - Create an Existing sem (EEXIST)" );
    131131  n_sem2 = sem_open("sem1", O_CREAT | O_EXCL, 00777, 1);
    132   fatal_directive_status(
     132  fatal_posix_service_status(
    133133    (int) n_sem2, (int ) SEM_FAILED, "sem_open error return status" );
    134   fatal_directive_status( errno, EEXIST,  "sem_open errno EEXIST");
     134  fatal_posix_service_status( errno, EEXIST,  "sem_open errno EEXIST");
    135135
    136136  puts( "Init: sem_open - Open new sem without create flag (ENOENT)" );
    137137  n_sem2 = sem_open("sem3", O_EXCL, 00777, 1);
    138   fatal_directive_status(
     138  fatal_posix_service_status(
    139139    (int) n_sem2, (int ) SEM_FAILED, "sem_open error return status" );
    140   fatal_directive_status( errno, ENOENT,  "sem_open errno EEXIST");
     140  fatal_posix_service_status( errno, ENOENT,  "sem_open errno EEXIST");
    141141
    142142  /*
     
    153153  puts( "Init: sem_wait on sem1" );
    154154  status = sem_wait(n_sem1);
    155   fatal_directive_status( status, 0, "sem_wait opened semaphore");
     155  fatal_posix_service_status( status, 0, "sem_wait opened semaphore");
    156156
    157157  /*
     
    161161  puts( "Init: sem_open - Open an existing sem ( same id )" );
    162162  n_sem2 = sem_open("sem1", 0 );
    163   fatal_directive_status(
     163  fatal_posix_service_status(
    164164    (int) n_sem2, (int ) n_sem1, "sem_open error return status" );
    165165 
     
    171171  puts( "Init: sem_unlink - sem1 SUCCESSFUL" );
    172172  status = sem_unlink( "sem1" );
    173   fatal_directive_status( status, 0, "sem_unlink locked semaphore");
     173  fatal_posix_service_status( status, 0, "sem_unlink locked semaphore");
    174174
    175175  puts( "Init: sem_open - Reopen sem1 SUCCESSFUL with a different id" );
     
    184184  puts( "Init: sem_close (1) - SUCCESSFUL" );
    185185  status = sem_close( n_sem1 );
    186   fatal_directive_status( status, 0, "sem_close semaphore");
     186  fatal_posix_service_status( status, 0, "sem_close semaphore");
    187187
    188188
     
    194194  puts( "Init: sem_close (2) - SUCCESSFUL" );
    195195  status = sem_close( n_sem2 );
    196   fatal_directive_status( status, 0, "sem_close semaphore");
     196  fatal_posix_service_status( status, 0, "sem_close semaphore");
    197197
    198198  puts( "Init: sem_unlink - sem1 (2) SUCCESSFUL" );
    199199  status = sem_unlink( "sem1" );
    200   fatal_directive_status( status, 0, "sem_unlink locked semaphore");
     200  fatal_posix_service_status( status, 0, "sem_unlink locked semaphore");
    201201
    202202  puts( "Init: sem_close - UNSUCCESSFUL (EINVAL)" );
    203203  status = sem_close(n_sem2);
    204   fatal_directive_status( status, -1, "sem_close error return status");
    205   fatal_directive_status( errno, EINVAL, "sem_close errno EINVAL");
     204  fatal_posix_service_status( status, -1, "sem_close error return status");
     205  fatal_posix_service_status( errno, EINVAL, "sem_close errno EINVAL");
    206206
    207207  puts( "Init: sem_unlink - UNSUCCESSFUL (ENOENT)" );
    208208  status = sem_unlink("sem1");
    209   fatal_directive_status( status, -1, "sem_unlink error return status");
    210   fatal_directive_status( errno, ENOENT, "sem_close errno EINVAL");
     209  fatal_posix_service_status( status, -1, "sem_unlink error return status");
     210  fatal_posix_service_status( errno, ENOENT, "sem_close errno EINVAL");
    211211
    212212
     
    217217  puts( "Init: sem_unlink (NULL) - EINVAL" );
    218218  status = sem_unlink( NULL );
    219   fatal_directive_status( status, -1, "sem_unlink error return status");
    220   fatal_directive_status( errno, EINVAL, "sem_unlink errno value");
     219  fatal_posix_service_status( status, -1, "sem_unlink error return status");
     220  fatal_posix_service_status( errno, EINVAL, "sem_unlink errno value");
    221221
    222222  puts( "Init: sem_unlink (\"\") - EINVAL" );
    223223  status = sem_unlink( "" );
    224   fatal_directive_status( status, -1, "sem_unlink error return status");
    225   fatal_directive_status( errno, EINVAL, "sem_unlink errno value");
     224  fatal_posix_service_status( status, -1, "sem_unlink error return status");
     225  fatal_posix_service_status( errno, EINVAL, "sem_unlink errno value");
    226226
    227227  /*
     
    232232  puts( "Init: sem_unlink - UNSUCCESSFUL (ENOENT)" );
    233233  status = sem_unlink("sem2");
    234   fatal_directive_status( status, -1, "sem_unlink error return status");
    235   fatal_directive_status( errno, ENOENT, "sem_unlink errno ENOENT");
     234  fatal_posix_service_status( status, -1, "sem_unlink error return status");
     235  fatal_posix_service_status( errno, ENOENT, "sem_unlink errno ENOENT");
    236236  assert( (status == -1) && (errno == ENOENT) );
    237237
  • testsuites/support/include/tmacros.h

    r53fb837a r85d62357  
    2525#include <stdio.h>
    2626#include <stdlib.h>
     27#include <string.h>
    2728#include <assert.h>
    2829#include <rtems/error.h>
     
    4849  } while ( 0 )
    4950
     51/*
     52 *  These macros properly report errors within the Classic API
     53 */
     54
    5055#define directive_failed( _dirstat, _failmsg )  \
    5156 fatal_directive_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg )
     
    6873    } \
    6974  } while ( 0 )
     75
     76/*
     77 *  These macros properly report errors from the POSIX API
     78 */
     79
     80#define posix_service_failed( _dirstat, _failmsg )  \
     81 fatal_posix_service_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg )
     82
     83#define posix_service_failed_with_level( _dirstat, _failmsg, _level )  \
     84 fatal_posix_service_status_with_level( \
     85      _dirstat, RTEMS_SUCCESSFUL, _failmsg, _level )
     86
     87#define fatal_posix_service_status( _stat, _desired, _msg ) \
     88  fatal_posix_service_status_with_level( _stat, _desired, _msg, 0 )
     89
     90#define fatal_posix_service_status_with_level( _stat, _desired, _msg, _level ) \
     91  do { \
     92    check_dispatch_disable_level( _level ); \
     93    if ( (_stat) != (_desired) ) { \
     94      printf( "\n%s FAILED -- expected (%s) got (%s)\n", \
     95              (_msg), strerror(_desired), strerror(_stat) ); \
     96      fflush(stdout); \
     97      exit( _stat ); \
     98    } \
     99  } while ( 0 )
     100
     101/*
     102 *  Generic integer version of the error reporting
     103 */
     104
     105#define int_service_failed( _dirstat, _failmsg )  \
     106 fatal_int_service_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg )
     107
     108#define int_service_failed_with_level( _dirstat, _failmsg, _level )  \
     109 fatal_int_service_status_with_level( \
     110      _dirstat, RTEMS_SUCCESSFUL, _failmsg, _level )
     111
     112#define fatal_int_service_status( _stat, _desired, _msg ) \
     113  fatal_int_service_status_with_level( _stat, _desired, _msg, 0 )
     114
     115#define fatal_int_service_status_with_level( _stat, _desired, _msg, _level ) \
     116  do { \
     117    check_dispatch_disable_level( _level ); \
     118    if ( (_stat) != (_desired) ) { \
     119      printf( "\n%s FAILED -- expected (%d) got (%d)\n", \
     120              (_msg), (_desired), (_stat) ); \
     121      fflush(stdout); \
     122      exit( _stat ); \
     123    } \
     124  } while ( 0 )
     125
     126
     127/*
     128 *  Print the time
     129 */
    70130
    71131#define sprint_time(_str, _s1, _tb, _s2) \
Note: See TracChangeset for help on using the changeset viewer.