|
PAPI
5.3.0.0
|
00001 /* 00002 * File: fork.c 00003 * Author: Philip Mucci 00004 * mucci@cs.utk.edu 00005 * Mods: <your name here> 00006 * <your email address> 00007 */ 00008 00009 /* This file performs the following test: 00010 00011 PAPI_library_init() 00012 fork(); 00013 / \ 00014 parent child 00015 wait() PAPI_library_init() 00016 00017 */ 00018 00019 #include "papi_test.h" 00020 #include <sys/wait.h> 00021 00022 int 00023 main( int argc, char **argv ) 00024 { 00025 int retval; 00026 int status; 00027 00028 tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */ 00029 00030 retval = PAPI_library_init( PAPI_VER_CURRENT ); 00031 if ( retval != PAPI_VER_CURRENT ) 00032 test_fail( __FILE__, __LINE__, "main PAPI_library_init", retval ); 00033 00034 if ( fork( ) == 0 ) { 00035 retval = PAPI_library_init( PAPI_VER_CURRENT ); 00036 if ( retval != PAPI_VER_CURRENT ) 00037 test_fail( __FILE__, __LINE__, "forked PAPI_library_init", retval ); 00038 exit( 0 ); 00039 } else { 00040 wait( &status ); 00041 if ( WEXITSTATUS( status ) != 0 ) 00042 test_fail( __FILE__, __LINE__, "fork", WEXITSTATUS( status ) ); 00043 } 00044 00045 test_pass( __FILE__, NULL, 0 ); 00046 exit( 1 ); 00047 }