PAPI  5.3.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
fork.c
Go to the documentation of this file.
1 /*
2 * File: fork.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  fork();
13  / \
14  parent child
15  wait() PAPI_library_init()
16 
17  */
18 
19 #include "papi_test.h"
20 #include <sys/wait.h>
21 
22 int
23 main( int argc, char **argv )
24 {
25  int retval;
26  int status;
27 
28  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
29 
31  if ( retval != PAPI_VER_CURRENT )
32  test_fail( __FILE__, __LINE__, "main PAPI_library_init", retval );
33 
34  if ( fork( ) == 0 ) {
36  if ( retval != PAPI_VER_CURRENT )
37  test_fail( __FILE__, __LINE__, "forked PAPI_library_init", retval );
38  exit( 0 );
39  } else {
40  wait( &status );
41  if ( WEXITSTATUS( status ) != 0 )
42  test_fail( __FILE__, __LINE__, "fork", WEXITSTATUS( status ) );
43  }
44 
45  test_pass( __FILE__, NULL, 0 );
46  exit( 1 );
47 }
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
int wait()
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
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()