PAPI  5.7.0.0
failed_events.c File Reference
Include dependency graph for failed_events.c:

Go to the source code of this file.

Macros

#define LARGE_NAME_SIZE   4096
 

Functions

int main (int argc, char **argv)
 

Variables

char large_name [LARGE_NAME_SIZE]
 

Macro Definition Documentation

◆ LARGE_NAME_SIZE

#define LARGE_NAME_SIZE   4096

Definition at line 19 of file failed_events.c.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 24 of file failed_events.c.

25 {
26 
27  int i, k, err_count = 0;
28  int retval;
29  PAPI_event_info_t info, info1;
30  const PAPI_component_info_t* cmpinfo;
31  int numcmp, cid;
32  int quiet;
33 
34  int EventSet = PAPI_NULL;
35 
36  /* Set quiet variable */
37  quiet=tests_quiet( argc, argv );
38 
39  /* Init PAPI library */
41  if ( retval != PAPI_VER_CURRENT ) {
42  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
43  }
44 
45  if (!quiet) {
46  printf("Test adding invalid events.\n");
47  }
48 
49  /* Create an eventset */
51  if ( retval != PAPI_OK ) {
52  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
53  }
54 
55 
56  /* Simple Event */
57  if (!quiet) {
58  printf("+ Simple invalid event\t");
59  }
60 
61  retval=PAPI_add_named_event(EventSet,"INVALID_EVENT");
62  if (retval==PAPI_OK) {
63  if (!quiet) {
64  printf("Unexpectedly opened!\n");
65  err_count++;
66  }
67  }
68  else {
69  if (!quiet) printf("OK\n");
70  }
71 
72  /* Extra Colons */
73  if (!quiet) {
74  printf("+ Extra colons\t");
75  }
76 
77  retval=PAPI_add_named_event(EventSet,"INV::::AL:ID:::_E=3V::E=NT");
78  if (retval==PAPI_OK) {
79  if (!quiet) {
80  printf("Unexpectedly opened!\n");
81  err_count++;
82  }
83  }
84  else {
85  if (!quiet) printf("OK\n");
86  }
87 
88 
89  /* Large Invalid Event */
90  if (!quiet) {
91  printf("+ Large invalid event\t");
92  }
93 
94  memset(large_name,'A',LARGE_NAME_SIZE);
96 
98  if (retval==PAPI_OK) {
99  if (!quiet) {
100  printf("Unexpectedly opened!\n");
101  err_count++;
102  }
103  }
104  else {
105  if (!quiet) printf("OK\n");
106  }
107 
108  /* Large Unterminated Invalid Event */
109  if (!quiet) {
110  printf("+ Large unterminated invalid event\t");
111  }
112 
113  memset(large_name,'A',LARGE_NAME_SIZE);
114 
116  if (retval==PAPI_OK) {
117  if (!quiet) {
118  printf("Unexpectedly opened!\n");
119  err_count++;
120  }
121  }
122  else {
123  if (!quiet) printf("OK\n");
124  }
125 
126 
127  /* Randomly modifying valid events */
128  if (!quiet) {
129  printf("+ Randomly modifying valid events\t");
130  }
131 
132  numcmp = PAPI_num_components( );
133 
134  /* Loop through all components */
135  for( cid = 0; cid < numcmp; cid++ ) {
136 
137 
138  cmpinfo = PAPI_get_component_info( cid );
139  if (cmpinfo == NULL) {
140  test_fail( __FILE__, __LINE__, "PAPI_get_component_info", 2 );
141  }
142 
143  /* Include disabled components */
144  if (cmpinfo->disabled) {
145  // continue;
146  }
147 
148 
149  /* For platform independence, always ASK FOR the first event */
150  /* Don't just assume it'll be the first numeric value */
151  i = 0 | PAPI_NATIVE_MASK;
153 
154  do {
155  retval = PAPI_get_event_info( i, &info );
156 
157  k = i;
159  do {
160  retval = PAPI_get_event_info( k, &info1 );
161 
162 
163 
164  /* Skip perf_raw event as it is hard to error out */
165  if (strstr(info1.symbol,"perf_raw")) {
166  break;
167  }
168 
169 // printf("%s\n",info1.symbol);
170 
171  if (strlen(info1.symbol)>5) {
172  info1.symbol[strlen(info1.symbol)-4]^=0xa5;
173 
175  if (retval==PAPI_OK) {
176  if (!quiet) {
177  printf("Unexpectedly opened %s!\n",
178  info1.symbol);
179  err_count++;
180  }
181  }
182  }
183  } while ( PAPI_enum_cmp_event( &k, PAPI_NTV_ENUM_UMASKS, cid ) == PAPI_OK );
184  } else {
185  /* Event didn't have any umasks */
186 
187 // printf("%s\n",info1.symbol);
188  if (strlen(info1.symbol)>5) {
189  info1.symbol[strlen(info1.symbol)-4]^=0xa5;
190 
192  if (retval==PAPI_OK) {
193  if (!quiet) {
194  printf("Unexpectedly opened %s!\n",
195  info1.symbol);
196  err_count++;
197  }
198  }
199  }
200  }
201 
202  } while ( PAPI_enum_cmp_event( &i, PAPI_ENUM_EVENTS, cid ) == PAPI_OK );
203 
204  }
205 
206 
207 
208  if ( err_count ) {
209  if (!quiet) {
210  printf( "%d Invalid events added.\n", err_count );
211  }
212  test_fail( __FILE__, __LINE__, "Invalid events added", 1 );
213  }
214 
215  test_pass( __FILE__ );
216 
217  return 0;
218 }
#define PAPI_OK
Definition: fpapi.h:105
#define PAPI_NATIVE_MASK
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
Definition: papi.c:796
void test_pass(const char *filename)
Definition: test_utils.c:432
int PAPI_num_components(void)
Definition: papi.c:4387
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
char large_name[LARGE_NAME_SIZE]
Definition: failed_events.c:21
int EventSet
int retval
Definition: zero_fork.c:53
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:835
int PAPI_add_named_event(int EventSet, const char *EventName)
Definition: papi.c:1876
int PAPI_library_init(int version)
Definition: papi.c:500
int quiet
Definition: rapl_overflow.c:18
#define LARGE_NAME_SIZE
Definition: failed_events.c:19
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:967
#define PAPI_NULL
Definition: fpapi.h:13
int PAPI_enum_cmp_event(int *EventCode, int modifier, int cidx)
Definition: papi.c:1357
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1464
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
int i
Definition: fileop.c:140
Here is the call graph for this function:

Variable Documentation

◆ large_name

char large_name[LARGE_NAME_SIZE]

Definition at line 21 of file failed_events.c.