PAPI  5.3.2.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
forkexec3.c
Go to the documentation of this file.
1 /*
2 * File: forkexec3.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() PAPI_library_init()
17  **unlike forkexec2, no shutdown here**
18  execlp()
19  PAPI_library_init()
20 
21  */
22 
23 #include "papi_test.h"
24 #include <sys/wait.h>
25 
26 int
27 main( int argc, char **argv )
28 {
29  int retval;
30  int status;
31 
32  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
33 
34  if ( ( argc > 1 ) && ( strcmp( argv[1], "xxx" ) == 0 ) ) {
36  if ( retval != PAPI_VER_CURRENT )
37  test_fail( __FILE__, __LINE__, "execed PAPI_library_init", retval );
38  } else {
40  if ( retval != PAPI_VER_CURRENT )
41  test_fail( __FILE__, __LINE__, "main PAPI_library_init", retval );
42 
43  PAPI_shutdown( );
44 
45  if ( fork( ) == 0 ) {
47  if ( retval != PAPI_VER_CURRENT )
48  test_fail( __FILE__, __LINE__, "forked PAPI_library_init",
49  retval );
50 
51  if ( execlp( argv[0], argv[0], "xxx", NULL ) == -1 )
52  test_fail( __FILE__, __LINE__, "execlp", PAPI_ESYS );
53  } else {
54  wait( &status );
55  if ( WEXITSTATUS( status ) != 0 )
56  test_fail( __FILE__, __LINE__, "fork", WEXITSTATUS( status ) );
57  }
58  }
59 
60  test_pass( __FILE__, NULL, 0 );
61  exit( 1 );
62 }
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:495
void PAPI_shutdown(void)
Definition: papi.c:4357
int wait()
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
#define PAPI_ESYS
Definition: fpapi.h:108
long long status
Definition: iozone.c:1335
ssize_t retval
Definition: libasync.c:338
int main(int argc, char **argv)
List all appio events codes and names.
void exit()