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