|
PAPI
5.3.0.0
|
00001 /* 00002 * File: forkexec.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 PAPI_shutdown() 00013 fork() 00014 / \ 00015 parent child 00016 wait() execlp() 00017 PAPI_library_init() 00018 00019 */ 00020 00021 #include "papi_test.h" 00022 #include <sys/wait.h> 00023 00024 int 00025 main( int argc, char **argv ) 00026 { 00027 int retval; 00028 int status; 00029 00030 tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */ 00031 00032 if ( ( argc > 1 ) && ( strcmp( argv[1], "xxx" ) == 0 ) ) { 00033 retval = PAPI_library_init( PAPI_VER_CURRENT ); 00034 if ( retval != PAPI_VER_CURRENT ) 00035 test_fail( __FILE__, __LINE__, "execed PAPI_library_init", retval ); 00036 } else { 00037 retval = PAPI_library_init( PAPI_VER_CURRENT ); 00038 if ( retval != PAPI_VER_CURRENT ) 00039 test_fail( __FILE__, __LINE__, "main PAPI_library_init", retval ); 00040 00041 PAPI_shutdown( ); 00042 00043 if ( fork( ) == 0 ) { 00044 if ( execlp( argv[0], argv[0], "xxx", NULL ) == -1 ) 00045 test_fail( __FILE__, __LINE__, "execlp", PAPI_ESYS ); 00046 } else { 00047 wait( &status ); 00048 if ( WEXITSTATUS( status ) != 0 ) 00049 test_fail( __FILE__, __LINE__, "fork", WEXITSTATUS( status ) ); 00050 } 00051 } 00052 00053 test_pass( __FILE__, NULL, 0 ); 00054 exit( 1 ); 00055 }