|
PAPI
5.0.1.0
|
00001 /* 00002 * File: disable_component.c 00003 * Author: Vince Weaver 00004 * vweaver1@eecs.utk.edu 00005 */ 00006 00007 /* 00008 This tests the functionality of PAPI_disable_component() 00009 */ 00010 00011 00012 #include "papi_test.h" 00013 00014 00015 int 00016 main( int argc, char **argv ) 00017 { 00018 int retval; 00019 const PAPI_component_info_t* cmpinfo; 00020 int numcmp, cid, active_components=0; 00021 00022 /* Set TESTS_QUIET variable */ 00023 tests_quiet( argc, argv ); 00024 00025 /* Disable All Compiled-in Components */ 00026 numcmp = PAPI_num_components( ); 00027 00028 if (!TESTS_QUIET) printf("Compiled-in components:\n"); 00029 for( cid = 0; cid < numcmp; cid++ ) { 00030 cmpinfo = PAPI_get_component_info( cid ); 00031 00032 if (!TESTS_QUIET) { 00033 printf( "Name: %-23s %s\n", cmpinfo->name, cmpinfo->description); 00034 } 00035 00036 retval=PAPI_disable_component( cid ); 00037 if (retval!=PAPI_OK) { 00038 test_fail(__FILE__,__LINE__,"Error disabling component",retval); 00039 } 00040 } 00041 00042 00043 /* Initialize the library */ 00044 retval = PAPI_library_init( PAPI_VER_CURRENT ); 00045 if ( retval != PAPI_VER_CURRENT ) { 00046 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval ); 00047 } 00048 00049 /* Try to disable after init, should fail */ 00050 retval=PAPI_disable_component( 0 ); 00051 if (retval==PAPI_OK) { 00052 test_fail( __FILE__, __LINE__, "PAPI_disable_component should fail", 00053 retval ); 00054 } 00055 00056 if (!TESTS_QUIET) printf("\nAfter init components:\n"); 00057 for( cid = 0; cid < numcmp; cid++ ) { 00058 00059 cmpinfo = PAPI_get_component_info( cid ); 00060 00061 if (!TESTS_QUIET) { 00062 printf( "%d %d Name: %-23s %s\n", 00063 cid, 00064 PAPI_get_component_index((char *)cmpinfo->name), 00065 cmpinfo->name ,cmpinfo->description); 00066 00067 } 00068 00069 if (cid!=PAPI_get_component_index((char *)cmpinfo->name)) { 00070 test_fail( __FILE__, __LINE__, "PAPI_get_component_index mismatch", 00071 2 ); 00072 } 00073 00074 00075 if (cmpinfo->disabled) { 00076 if (!TESTS_QUIET) { 00077 printf(" \\-> Disabled: %s\n",cmpinfo->disabled_reason); 00078 } 00079 } else { 00080 active_components++; 00081 } 00082 } 00083 00084 if (active_components>0) { 00085 test_fail( __FILE__, __LINE__, "too many active components", retval ); 00086 } 00087 00088 test_pass( __FILE__, NULL, 0 ); 00089 00090 return PAPI_OK; 00091 }