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