File indexing completed on 2025-05-11 08:24:46
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 #ifdef HAVE_CONFIG_H
0041 #include "config.h"
0042 #endif
0043
0044 #define CONFIGURE_INIT
0045 #include <rtems.h>
0046 #include <stdlib.h>
0047 #include <stdio.h>
0048 #include <assert.h>
0049 #include "system.h"
0050
0051 const char rtems_test_name[] = "SPCPUSET 1";
0052
0053 static void test_cpu_zero_case_1(void)
0054 {
0055 size_t i;
0056
0057
0058
0059
0060 puts( "Exercise CPU_ZERO, CPU_ISSET, and CPU_COUNT" );
0061 CPU_ZERO(&set3);
0062
0063
0064 for (i=0 ; i<CPU_SETSIZE ; i++) {
0065 rtems_test_assert( CPU_ISSET(i, &set3) == 0 );
0066 }
0067 rtems_test_assert( CPU_COUNT(&set3) == 0 );
0068
0069 }
0070
0071 static void test_cpu_fill_case_1(void)
0072 {
0073 size_t i;
0074
0075
0076
0077
0078 puts( "Exercise CPU_FILL, CPU_ISSET, and CPU_COUNT" );
0079 CPU_FILL(&set1);
0080
0081
0082 for (i=0 ; i<CPU_SETSIZE ; i++) {
0083 rtems_test_assert( CPU_ISSET(i, &set1) == 1 );
0084 }
0085 rtems_test_assert( CPU_COUNT(&set1) == _NCPUBITS );
0086 }
0087
0088 static void test_cpu_equal_case_1(void)
0089 {
0090
0091
0092
0093 puts( "Exercise CPU_ZERO, CPU_EQUAL, CPU_CMP, and CPU_EMPTY" );
0094 CPU_ZERO(&set1);
0095 CPU_ZERO(&set2);
0096
0097
0098 rtems_test_assert( CPU_EQUAL(&set1, &set2) );
0099
0100
0101 rtems_test_assert( !CPU_CMP(&set1, &set2) );
0102
0103
0104 rtems_test_assert( CPU_EMPTY(&set1) );
0105 }
0106
0107 static void test_cpu_set_case_1(size_t cpu)
0108 {
0109 size_t i;
0110
0111
0112
0113
0114 DPRINT( "Exercise CPU_ZERO, CPU_SET(%zu), and CPU_ISSET\n", cpu );
0115 CPU_ZERO(&set1);
0116 CPU_SET(cpu, &set1);
0117
0118
0119 for (i=0 ; i<CPU_SETSIZE ; i++) {
0120 if (i==cpu)
0121 rtems_test_assert( CPU_ISSET(i, &set1) == 1 );
0122 else
0123 rtems_test_assert( CPU_ISSET(i, &set1) == 0 );
0124
0125 rtems_test_assert( ! CPU_EMPTY(&set1) );
0126 }
0127 }
0128
0129 static void test_cpu_clr_case_1(size_t cpu)
0130 {
0131 size_t i;
0132
0133
0134
0135
0136 DPRINT( "Exercise CPU_FILL, CPU_CLR(%zu), and CPU_ISSET\n", cpu );
0137 CPU_FILL(&set1);
0138 CPU_CLR(cpu, &set1);
0139
0140
0141 for (i=0 ; i<CPU_SETSIZE ; i++) {
0142 if (i==cpu)
0143 rtems_test_assert( CPU_ISSET(i, &set1) == 0 );
0144 else
0145 rtems_test_assert( CPU_ISSET(i, &set1) == 1 );
0146 }
0147 }
0148
0149 static void test_cpu_copy_case_1(void)
0150 {
0151 size_t i;
0152
0153
0154
0155
0156 puts( "Exercise CPU_ZERO, CPU_COPY, and CPU_ISSET" );
0157 CPU_ZERO(&set1);
0158 CPU_FILL(&set2);
0159
0160 CPU_COPY(&set1, &set2);
0161
0162
0163 for (i=0 ; i<CPU_SETSIZE ; i++) {
0164 rtems_test_assert( CPU_ISSET(i, &set2) == 0 );
0165 }
0166 }
0167
0168 rtems_task Init(
0169 rtems_task_argument ignored
0170 )
0171 {
0172 size_t i;
0173
0174 TEST_BEGIN();
0175
0176 test_cpu_zero_case_1();
0177 test_cpu_fill_case_1();
0178 test_cpu_equal_case_1();
0179 test_cpu_copy_case_1();
0180
0181 for (i=0 ; i<CPU_SETSIZE ; i++) {
0182 test_cpu_set_case_1(i);
0183 test_cpu_clr_case_1(i);
0184 }
0185
0186 cpuset_logic_test();
0187
0188 TEST_END();
0189 exit( 0 );
0190 }