PAPI  5.3.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
fork2.c
Go to the documentation of this file.
1 /*
2 * File: fork2.c
3 * CVS: $Id$
4 * Author: Philip Mucci
5 * mucci@cs.utk.edu
6 * Mods: <your name here>
7 * <your email address>
8 */
9 
10 /* This file performs the following test:
11 
12  PAPI_library_init()
13  fork();
14  / \
15  parent child
16  wait() PAPI_shutdown()
17  PAPI_library_init()
18 
19  */
20 
21 
22 #include "papi_test.h"
23 #include <sys/wait.h>
24 
25 int
26 main( int argc, char **argv )
27 {
28  int retval;
29  int status;
30 
31  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
32 
34  if ( retval != PAPI_VER_CURRENT )
35  test_fail( __FILE__, __LINE__, "main PAPI_library_init", retval );
36 
37  if ( fork( ) == 0 ) {
38  PAPI_shutdown();
39 
41  if ( retval != PAPI_VER_CURRENT )
42  test_fail( __FILE__, __LINE__, "forked PAPI_library_init", retval );
43  exit( 0 );
44  } else {
45  wait( &status );
46  if ( WEXITSTATUS( status ) != 0 )
47  test_fail( __FILE__, __LINE__, "fork", WEXITSTATUS( status ) );
48  }
49 
50  test_pass( __FILE__, NULL, 0 );
51  exit( 1 );
52 }
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:4344
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()