PAPI  5.6.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 21 of file net_list_events.c.

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

Here is the call graph for this function: