Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:42

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*  Test1
0004  *
0005  *  This test uses a hack to disable suto-extend then checks to see only the
0006  *  requested number of objects are allocated.
0007  *
0008  *  Input parameters:  NONE
0009  *
0010  *  Output parameters:  NONE
0011  *
0012  *  COPYRIGHT (c) 1989-1997.
0013  *  On-Line Applications Research Corporation (OAR).
0014  *
0015  * Redistribution and use in source and binary forms, with or without
0016  * modification, are permitted provided that the following conditions
0017  * are met:
0018  * 1. Redistributions of source code must retain the above copyright
0019  *    notice, this list of conditions and the following disclaimer.
0020  * 2. Redistributions in binary form must reproduce the above copyright
0021  *    notice, this list of conditions and the following disclaimer in the
0022  *    documentation and/or other materials provided with the distribution.
0023  *
0024  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0025  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0026  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0027  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0028  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0029  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0030  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0031  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0032  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0033  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0034  * POSSIBILITY OF SUCH DAMAGE.
0035  */
0036 
0037 #ifdef HAVE_CONFIG_H
0038 #include "config.h"
0039 #endif
0040 
0041 #include <inttypes.h>
0042 #include <stdio.h>
0043 #include <stdlib.h>
0044 
0045 #include "system.h"
0046 #include "tmacros.h"
0047 
0048 #include <rtems/score/objectimpl.h>
0049 
0050 void test1()
0051 {
0052   Objects_Maximum      objects_per_block;
0053   rtems_status_code    result;
0054   uint32_t             task_count = 0;
0055   Objects_Information *the_information;
0056 
0057   char              c1 = 'a';
0058   char              c2 = 'a';
0059   char              c3 = '0';
0060   char              c4 = '0';
0061 
0062   printf( "\n TEST1 : auto-extend disabled.\n" );
0063 
0064   /*
0065    * This is a major hack and only recommended for a test. Doing this
0066    * saves having another test.
0067    */
0068 
0069   the_information =
0070     _Objects_Information_table[OBJECTS_CLASSIC_API][OBJECTS_RTEMS_TASKS];
0071   objects_per_block = the_information->objects_per_block;
0072   the_information->objects_per_block = 0;
0073   the_information->allocate = _Objects_Allocate_static;
0074 
0075   while (task_count < MAX_TASKS)
0076   {
0077     rtems_name name;
0078 
0079     printf(" TEST1 : creating task '%c%c%c%c', ", c1, c2, c3, c4);
0080 
0081     name = rtems_build_name(c1, c2, c3, c4);
0082 
0083     result = rtems_task_create(name,
0084                                10,
0085                                RTEMS_MINIMUM_STACK_SIZE,
0086                                RTEMS_DEFAULT_ATTRIBUTES,
0087                                RTEMS_LOCAL,
0088                                &task_id[task_count]);
0089 
0090     if (status_code_bad(result))
0091       break;
0092 
0093     printf("number = %3" PRIi32 ", id = %08" PRIxrtems_id ", starting, ", task_count, task_id[task_count]);
0094 
0095     fflush(stdout);
0096     result = rtems_task_start(task_id[task_count],
0097                               test_task,
0098                               (rtems_task_argument) task_count);
0099 
0100     if (status_code_bad(result))
0101       break;
0102 
0103     /*
0104      *  Update the name.
0105      */
0106 
0107     NEXT_TASK_NAME(c1, c2, c3, c4);
0108 
0109     task_count++;
0110   }
0111 
0112   if (task_count >= MAX_TASKS)
0113     printf( "\nMAX_TASKS too small for work-space size, please make larger !!\n\n" );
0114 
0115   if (task_count != (TASK_ALLOCATION_SIZE - 1)) {
0116     printf( " FAIL1 : the number of tasks does not equal the expected size -\n"
0117             "           task created = %" PRIi32 ", required number = %i\n",
0118             task_count, TASK_ALLOCATION_SIZE);
0119     exit( 1 );
0120   }
0121 
0122   destroy_all_tasks("TEST1");
0123 
0124   the_information->objects_per_block = objects_per_block;
0125   the_information->allocate = _Thread_Allocate_unlimited;
0126 
0127   printf( " TEST1 : completed\n" );
0128 }