PAPI 7.1.0.0
Loading...
Searching...
No Matches
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

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 18 of file disable_component.c.

19{
20 int retval;
21 const PAPI_component_info_t* cmpinfo;
22 int numcmp, cid, active_components=0;
23
24 /* Set TESTS_QUIET variable */
25 tests_quiet( argc, argv );
26
27 /* Disable All Compiled-in Components */
28 numcmp = PAPI_num_components( );
29
30 if (!TESTS_QUIET) printf("Compiled-in components:\n");
31 for( cid = 0; cid < numcmp; cid++ ) {
32 cmpinfo = PAPI_get_component_info( cid );
33
34 if (!TESTS_QUIET) {
35 printf( "Name: %-23s %s\n", cmpinfo->name, cmpinfo->description);
36 }
37
39 if (retval!=PAPI_OK) {
40 test_fail(__FILE__,__LINE__,"Error disabling component",retval);
41 }
42 }
43
44
45 /* Initialize the library */
47 if ( retval != PAPI_VER_CURRENT ) {
48 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
49 }
50
51 /* Try to disable after init, should fail */
53 if (retval==PAPI_OK) {
54 test_fail( __FILE__, __LINE__, "PAPI_disable_component should fail",
55 retval );
56 }
57
58 if (!TESTS_QUIET) printf("\nAfter init components:\n");
59 for( cid = 0; cid < numcmp; cid++ ) {
60
61 cmpinfo = PAPI_get_component_info( cid );
62
63 if (!TESTS_QUIET) {
64 printf( "%d %d Name: %-23s %s\n",
65 cid,
66 PAPI_get_component_index((char *)cmpinfo->name),
67 cmpinfo->name ,cmpinfo->description);
68
69 }
70
71 if (cid!=PAPI_get_component_index((char *)cmpinfo->name)) {
72 test_fail( __FILE__, __LINE__, "PAPI_get_component_index mismatch",
73 2 );
74 }
75
76
77 if (cmpinfo->disabled) {
78 if (!TESTS_QUIET) {
79 printf(" \\-> Disabled: %s\n",cmpinfo->disabled_reason);
80 }
81 } else {
82 active_components++;
83 }
84 }
85
86 if (active_components>0) {
87 test_fail( __FILE__, __LINE__, "too many active components", retval );
88 }
89
90 test_pass( __FILE__ );
91
92 return PAPI_OK;
93}
disables the specified component
returns the component index for the named component
get information about a specific software component
initialize the PAPI library.
Get the number of components available on the system.
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
int TESTS_QUIET
Definition: test_utils.c:18
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:491
void PAPI_NORETURN test_pass(const char *filename)
Definition: test_utils.c:432
char description[PAPI_MAX_STR_LEN]
Definition: papi.h:630
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:627
char disabled_reason[PAPI_HUGE_STR_LEN]
Definition: papi.h:634
int retval
Definition: zero_fork.c:53
Here is the call graph for this function: