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

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 16 of file disable_component.c.

17 {
18  int retval;
19  const PAPI_component_info_t* cmpinfo;
20  int numcmp, cid, active_components=0;
21 
22  /* Set TESTS_QUIET variable */
23  tests_quiet( argc, argv );
24 
25  /* Disable All Compiled-in Components */
26  numcmp = PAPI_num_components( );
27 
28  if (!TESTS_QUIET) printf("Compiled-in components:\n");
29  for( cid = 0; cid < numcmp; cid++ ) {
30  cmpinfo = PAPI_get_component_info( cid );
31 
32  if (!TESTS_QUIET) {
33  printf( "Name: %-23s %s\n", cmpinfo->name, cmpinfo->description);
34  }
35 
36  retval=PAPI_disable_component( cid );
37  if (retval!=PAPI_OK) {
38  test_fail(__FILE__,__LINE__,"Error disabling component",retval);
39  }
40  }
41 
42 
43  /* Initialize the library */
45  if ( retval != PAPI_VER_CURRENT ) {
46  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
47  }
48 
49  /* Try to disable after init, should fail */
50  retval=PAPI_disable_component( 0 );
51  if (retval==PAPI_OK) {
52  test_fail( __FILE__, __LINE__, "PAPI_disable_component should fail",
53  retval );
54  }
55 
56  if (!TESTS_QUIET) printf("\nAfter init components:\n");
57  for( cid = 0; cid < numcmp; cid++ ) {
58 
59  cmpinfo = PAPI_get_component_info( cid );
60 
61  if (!TESTS_QUIET) {
62  printf( "%d %d Name: %-23s %s\n",
63  cid,
64  PAPI_get_component_index((char *)cmpinfo->name),
65  cmpinfo->name ,cmpinfo->description);
66 
67  }
68 
69  if (cid!=PAPI_get_component_index((char *)cmpinfo->name)) {
70  test_fail( __FILE__, __LINE__, "PAPI_get_component_index mismatch",
71  2 );
72  }
73 
74 
75  if (cmpinfo->disabled) {
76  if (!TESTS_QUIET) {
77  printf(" \\-> Disabled: %s\n",cmpinfo->disabled_reason);
78  }
79  } else {
80  active_components++;
81  }
82  }
83 
84  if (active_components>0) {
85  test_fail( __FILE__, __LINE__, "too many active components", retval );
86  }
87 
88  test_pass( __FILE__, NULL, 0 );
89 
90  return PAPI_OK;
91 }
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:626
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
Definition: papi.c:807
int PAPI_num_components(void)
Definition: papi.c:4326
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
int PAPI_disable_component(int cidx)
Definition: papi.c:6592
char disabled_reason[PAPI_MAX_STR_LEN]
Definition: papi.h:633
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:497
int PAPI_get_component_index(char *name)
Definition: papi.c:6536
char description[PAPI_MAX_STR_LEN]
Definition: papi.h:629
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:223

Here is the call graph for this function: