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.

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.

00019 {
00020     int retval,cid,numcmp;
00021     int total_events=0;
00022     int code;
00023     char event_name[PAPI_MAX_STR_LEN];
00024     int r;
00025     const PAPI_component_info_t *cmpinfo = NULL;
00026 
00027     /* Set TESTS_QUIET variable */
00028     tests_quiet( argc, argv );
00029 
00030     /* PAPI Initialization */
00031     retval = PAPI_library_init( PAPI_VER_CURRENT );
00032     if ( retval != PAPI_VER_CURRENT ) {
00033         test_fail(__FILE__, __LINE__,"PAPI_library_init failed\n",retval);
00034     }
00035 
00036     if (!TESTS_QUIET) {
00037         printf("Listing all net events\n");
00038     }
00039 
00040     numcmp = PAPI_num_components();
00041 
00042     for(cid=0; cid<numcmp; cid++) {
00043 
00044         if ( (cmpinfo = PAPI_get_component_info(cid)) == NULL) {
00045             test_fail(__FILE__, __LINE__,"PAPI_get_component_info failed\n",-1);
00046         }
00047 
00048         if ( strstr(cmpinfo->name, "net") == NULL) {
00049             continue;
00050         }
00051 
00052         if (!TESTS_QUIET) {
00053             printf("Component %d (%d) - %d events - %s\n",
00054                 cid, cmpinfo->CmpIdx,
00055                 cmpinfo->num_native_events, cmpinfo->name);
00056         }
00057 
00058         code = PAPI_NATIVE_MASK;
00059 
00060         r = PAPI_enum_cmp_event( &code, PAPI_ENUM_FIRST, cid );
00061         while ( r == PAPI_OK ) {
00062 
00063             retval = PAPI_event_code_to_name( code, event_name );
00064             if ( retval != PAPI_OK ) {
00065                 test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
00066             }
00067 
00068             if (!TESTS_QUIET) {
00069                 printf("%#x %s\n", code, event_name);
00070             }
00071 
00072             total_events++;
00073 
00074             r = PAPI_enum_cmp_event( &code, PAPI_ENUM_EVENTS, cid );
00075         }
00076 
00077     }
00078 
00079     if (total_events==0) {
00080         test_skip(__FILE__,__LINE__,"No net events found", 0);
00081     }
00082 
00083     test_pass( __FILE__, NULL, 0 );
00084 
00085     return 0;
00086 }

Here is the call graph for this function:


Generated on 8 Sep 2016 for PAPI by  doxygen 1.6.1