PAPI  5.6.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 <stdio.h>
20 #include <stdlib.h>
21 #include <unistd.h>
22 #include <sys/wait.h>
23 
24 #include "papi.h"
25 #include "papi_test.h"
26 
27 
28 int
29 main( int argc, char **argv )
30 {
31  int retval;
32  int status;
33 
34  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
35 
37  if ( retval != PAPI_VER_CURRENT )
38  test_fail( __FILE__, __LINE__, "main PAPI_library_init", retval );
39 
40  if ( fork( ) == 0 ) {
42  if ( retval != PAPI_VER_CURRENT )
43  test_fail( __FILE__, __LINE__, "forked PAPI_library_init", retval );
44  exit( 0 );
45  } else {
46  wait( &status );
47  if ( WEXITSTATUS( status ) != 0 )
48  test_fail( __FILE__, __LINE__, "fork", WEXITSTATUS( status ) );
49  }
50 
51  test_pass( __FILE__ );
52 
53  return 0;
54 
55 }
void test_pass(const char *filename)
Definition: test_utils.c:432
int int argc
Definition: iozone.c:1609
Return codes and api definitions.
char ** argv
Definition: iozone.c:1610
int PAPI_library_init(int version)
Definition: papi.c:500
int wait()
long long status
Definition: iozone.c:1335
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:225
int main(int argc, char **argv)
List all appio events codes and names.
void exit()