PAPI  5.3.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
net_list_events.c File Reference
Include dependency graph for net_list_events.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 List all net events codes and names. More...
 

Function Documentation

int main ( int  argc,
char **  argv 
)
Author
Jose Pedro Oliveira

test case for the linux-net component

Definition at line 18 of file net_list_events.c.

19 {
20  int retval,cid,numcmp;
21  int total_events=0;
22  int code;
24  int r;
25  const PAPI_component_info_t *cmpinfo = NULL;
26 
27  /* Set TESTS_QUIET variable */
28  tests_quiet( argc, argv );
29 
30  /* PAPI Initialization */
32  if ( retval != PAPI_VER_CURRENT ) {
33  test_fail(__FILE__, __LINE__,"PAPI_library_init failed\n",retval);
34  }
35 
36  if (!TESTS_QUIET) {
37  printf("Listing all net events\n");
38  }
39 
40  numcmp = PAPI_num_components();
41 
42  for(cid=0; cid<numcmp; cid++) {
43 
44  if ( (cmpinfo = PAPI_get_component_info(cid)) == NULL) {
45  test_fail(__FILE__, __LINE__,"PAPI_get_component_info failed\n",-1);
46  }
47 
48  if ( strstr(cmpinfo->name, "net") == NULL) {
49  continue;
50  }
51 
52  if (!TESTS_QUIET) {
53  printf("Component %d (%d) - %d events - %s\n",
54  cid, cmpinfo->CmpIdx,
55  cmpinfo->num_native_events, cmpinfo->name);
56  }
57 
58  code = PAPI_NATIVE_MASK;
59 
60  r = PAPI_enum_cmp_event( &code, PAPI_ENUM_FIRST, cid );
61  while ( r == PAPI_OK ) {
62 
63  retval = PAPI_event_code_to_name( code, event_name );
64  if ( retval != PAPI_OK ) {
65  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
66  }
67 
68  if (!TESTS_QUIET) {
69  printf("%#x %s\n", code, event_name);
70  }
71 
72  total_events++;
73 
74  r = PAPI_enum_cmp_event( &code, PAPI_ENUM_EVENTS, cid );
75  }
76 
77  }
78 
79  if (total_events==0) {
80  test_skip(__FILE__,__LINE__,"No net events found", 0);
81  }
82 
83  test_pass( __FILE__, NULL, 0 );
84 
85  return 0;
86 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:23
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:625
#define PAPI_NATIVE_MASK
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
Definition: papi.c:803
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
void test_skip(char *file, int line, char *call, int retval)
Definition: test_utils.c:614
int PAPI_num_components(void)
Definition: papi.c:4272
return PAPI_OK
Definition: linux-nvml.c:458
tests_quiet(argc, argv)
#define printf
Definition: papi_test.h:125
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
int TESTS_QUIET
Definition: test_utils.c:11
char ** argv
Definition: iozone.c:1610
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:495
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
int PAPI_enum_cmp_event(int *EventCode, int modifier, int cidx)
Definition: papi.c:1305
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:920
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function: