Changeset 73dfaf8 in rtems


Ignore:
Timestamp:
Jul 23, 2009, 1:29:49 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, master
Children:
48751ab
Parents:
2d730043
Message:

2009-07-23 Santosh G Vattam <vattam.santosh@…>

  • psxcancel/Makefile.am, psxcancel/init.c, psxcancel/psxcancel.scn: Add multiple cases which complete coverage of thread cancellation.
  • psxcancel/psxcancel.doc: New file.
Location:
testsuites/psxtests
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • testsuites/psxtests/ChangeLog

    r2d730043 r73dfaf8  
     12009-07-23      Santosh G Vattam <vattam.santosh@gmail.com>
     2
     3        * psxcancel/Makefile.am, psxcancel/init.c, psxcancel/psxcancel.scn: Add
     4        multiple cases which complete coverage of thread cancellation.
     5        * psxcancel/psxcancel.doc: New file.
     6
    172009-07-22      Joel Sherrill <joel.sherrill@oarcorp.com>
    28
  • testsuites/psxtests/psxcancel/Makefile.am

    r2d730043 r73dfaf8  
    99
    1010dist_rtems_tests_DATA = psxcancel.scn
     11dist_rtems_tests_DATA += psxcancel.doc
    1112
    1213include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
  • testsuites/psxtests/psxcancel/init.c

    r2d730043 r73dfaf8  
    66 *  $Id$
    77 */
    8 
    98
    109#include <stdio.h>
     
    1615#include <sched.h>
    1716
     17#if defined(__rtems__)
     18  #include <rtems.h>
     19  #include <bsp.h>
     20  #include <pmacros.h>
     21#endif
    1822
    19 #if defined(__rtems__)
    20 #include <rtems.h>
    21 #include <bsp.h>
    22 #include <pmacros.h>
    23 #endif
     23volatile bool countTask_handler;
     24
     25void countTask_cancel_handler(void *ignored)
     26{
     27  countTask_handler = true;
     28}
    2429
    2530void *countTaskDeferred(void *ignored)
     
    2732  int i=0;
    2833  int type,state;
    29 
     34 
    3035  pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &type);
    3136  pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &state);
     
    4449  pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &type);
    4550  pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &state);
     51  pthread_cleanup_push(countTask_cancel_handler, NULL);
    4652  while (1) {
    4753    printf("countTaskAsync: elapsed time (second): %2d\n", i++ );
    4854    sleep(1);
     55  }
     56  countTask_handler = false;
     57  pthread_cleanup_pop(1);
     58  if ( countTask_handler == false ){
     59    puts("countTask_cancel_handler not executed");
     60    rtems_test_exit(0);
    4961  }
    5062}
     
    5769{
    5870  pthread_t task;
    59   int taskparameter = 0;
     71  int       taskparameter = 0;
     72  int       sc;
     73  int       old;
    6074
    6175  puts( "\n\n*** POSIX CANCEL TEST ***" );
    6276
     77  /* generate some error conditions */
     78  puts( "Init - pthread_setcancelstate - NULL oldstate - EINVAL" );
     79  sc = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
     80  fatal_posix_service_status( sc, EINVAL, "cancel state EINVAL" );
     81
     82  puts( "Init - pthread_setcancelstate - bad state - EINVAL" );
     83  sc = pthread_setcancelstate(12, &old);
     84  fatal_posix_service_status( sc, EINVAL, "cancel state EINVAL" );
     85
     86  puts( "Init - pthread_setcanceltype - NULL oldtype - EINVAL" );
     87  sc = pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
     88  fatal_posix_service_status( sc, EINVAL, "cancel type EINVAL" );
     89
     90  puts( "Init - pthread_setcanceltype - bad type - EINVAL" );
     91  sc = pthread_setcanceltype(12, &old);
     92  fatal_posix_service_status( sc, EINVAL, "cancel type EINVAL" );
     93
    6394  /* Start countTask deferred */
    6495  {
    65     int task_ret;
    66     task_ret = pthread_create(&task, NULL, countTaskDeferred, &taskparameter);
    67     if (task_ret) {
     96    sc = pthread_create(&task, NULL, countTaskDeferred, &taskparameter);
     97    if (sc) {
    6898      perror("pthread_create: countTask");
    6999      rtems_test_exit(EXIT_FAILURE);
     
    77107  /* Start countTask asynchronous */
    78108  {
    79     int task_ret;
    80     task_ret = pthread_create(&task, NULL, countTaskAsync, &taskparameter);
    81     if (task_ret) {
     109    sc = pthread_create(&task, NULL, countTaskAsync, &taskparameter);
     110    if (sc) {
    82111      perror("pthread_create: countTask");
    83112      rtems_test_exit(EXIT_FAILURE);
  • testsuites/psxtests/psxcancel/psxcancel.scn

    r2d730043 r73dfaf8  
    1 
    2 
    31*** POSIX CANCEL TEST ***
     2Init - pthread_setcancelstate - NULL oldstate - EINVAL
     3Init - pthread_setcancelstate - bad state - EINVAL
     4Init - pthread_setcanceltype - NULL oldtype - EINVAL
     5Init - pthread_setcanceltype - bad type - EINVAL
    46countTaskDeferred: elapsed time (second):  0
    57countTaskDeferred: elapsed time (second):  1
Note: See TracChangeset for help on using the changeset viewer.