PAPI  5.4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
forkexec.c
Go to the documentation of this file.
1 /*
2 * File: forkexec.c
3 * Author: Philip Mucci
4 * mucci@cs.utk.edu
5 * Mods: <your name here>
6 * <your email address>
7 */
8 
9 /* This file performs the following test:
10 
11  PAPI_library_init();
12  PAPI_shutdown()
13  fork()
14  / \
15  parent child
16  wait() execlp()
17  PAPI_library_init()
18 
19  */
20 
21 #include "papi_test.h"
22 #include <sys/wait.h>
23 
24 int
25 main( int argc, char **argv )
26 {
27  int retval;
28  int status;
29 
30  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
31 
32  if ( ( argc > 1 ) && ( strcmp( argv[1], "xxx" ) == 0 ) ) {
34  if ( retval != PAPI_VER_CURRENT )
35  test_fail( __FILE__, __LINE__, "execed PAPI_library_init", retval );
36  } else {
38  if ( retval != PAPI_VER_CURRENT )
39  test_fail( __FILE__, __LINE__, "main PAPI_library_init", retval );
40 
41  PAPI_shutdown( );
42 
43  if ( fork( ) == 0 ) {
44  if ( execlp( argv[0], argv[0], "xxx", NULL ) == -1 )
45  test_fail( __FILE__, __LINE__, "execlp", PAPI_ESYS );
46  } else {
47  wait( &status );
48  if ( WEXITSTATUS( status ) != 0 )
49  test_fail( __FILE__, __LINE__, "fork", WEXITSTATUS( status ) );
50  }
51  }
52 
53  test_pass( __FILE__, NULL, 0 );
54  exit( 1 );
55 }
tests_quiet(argc, argv)
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
char ** argv
Definition: iozone.c:1610
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:497
void PAPI_shutdown(void)
Definition: papi.c:4400
int wait()
#define PAPI_ESYS
Definition: papi.h:253
long long status
Definition: iozone.c:1335
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:223
int main(int argc, char **argv)
List all appio events codes and names.
void exit()