For v2003.06.01 Release $Revision: 1.53 $ Support: ------------- Language : Java Features : Component Testing - Code Coverage - Performance Profiling - Memory Profiling - Trace Tested Against: ------------------------ Host Machine : Windows 2000 - Sun Solaris 2.8 - Linux RedHat 7.2 - Linux RedHat 7.3 - Linux RedHat 8.0 - Linux Suse 8.1 - RS 6000 AIX 4.3 - RS 6000 5.L v5.2 Compiler : Java Compiler 1.3.1 Linker : Java Archive Tool 1.3.1 Debugger : Java Debugger 1.3.1 OS : Native Target : Native java jar -g DEFAULT_BOOTCLASSPATH <Windows: Read and set from the registry when saved > ENV_PATH <Windows: Read and set from the registry when saved > COMPILER javac VIRTUALMACHINE java JAR jar DEBUGGER jdb Compiles the classes in the classes subdirectory. sub atl_cc($$$$\@\@) { my ( $lang,$src,$outDir,$cflags,$Defines,$Includes) = @_; # build the classpath my $separator = ($OSNAME eq "win32") ? ";" : ":"; my $classpath = &BuildCompleteJavaClassPath("-classpath ", $separator, ""); my $COMP = $Ini{'COMPILER'}; if ( !$COMP ) { print "Error: no compiler known for target (lang:\"$lang\")\n"; return 1; } &CreateDirectory( "$outDir/classes" ); my $status=0; $status=SystemP( "$COMP -d $outDir/classes $classpath \"$src\" $cflags" ); return $status; } 1; Build the jar file with the classes found in the classes subdirectory. sub atl_link($\@$\@$) { my ($OutputFile,$Objects,$Manifest,$JarOtherDir,$OutputDir) = @_; # Build jar file: my $JAR = $Ini{'JAR'}; if ( !$JAR ) { print "Error: no jar command known for target\n"; return 1; } $status=SystemP( "$JAR cfm \"$OutputFile\" $Manifest -C \"$OutputDir/classes\" ." ); return $status if ($status > 0); foreach $res (@$JarOtherDir) { $status=SystemP( "$JAR uf \"$OutputFile\" -C \"$res\" ." ); return $status if ($status > 0); } return $status; } 1; sub atl_exec($$$) { my ($JarFile,$MainClass,$Parameters) = @_; # build the classpath my $separator = ($OSNAME eq "win32") ? ";" : ":"; my $application = $JAVA_BUILDJARFILE ? $JarFile : "$INTDIR/classes"; my $classpath = &BuildCompleteJavaClassPath("-classpath ", $separator, $application); # build the JVMPI args and path if any my $jvmpi_args = &BuildJvmpiArgs("-Xint -Xrun", ""); my $jvmpi_path = &GetJvmpiPath; my $Vm = $Ini{'VIRTUALMACHINE'}; my $status = 0; if ($jvmpi_path) { if ($OSNAME eq "win32") { $ENV{'PATH'} = "$ENV{'PATH'};$jvmpi_path"; } else { $ENV{'LD_LIBRARY_PATH'} = "$ENV{'LD_LIBRARY_PATH'}:$jvmpi_path"; } } $status = SystemP( "$Vm $classpath $jvmpi_args $VIRTUAL_MACHINE_ARGUMENTS $MainClass $Parameters" ); return $status; } sub atl_execdbg($$$) { my ($JarFile,$MainClass,$Parameters) = @_; # build the classpath my $separator = ($OSNAME eq "win32") ? ";" : ":"; my $application = $JAVA_BUILDJARFILE ? $JarFile : "$INTDIR/classes"; my $classpath = &BuildCompleteJavaClassPath("-classpath ", $separator, $application); # build the JVMPI args and path if any my $jvmpi_args = &BuildJvmpiArgs("-Xint -Xrun", ""); my $jvmpi_path = &GetJvmpiPath; my $Vm = $Ini{'VIRTUALMACHINE'}; my $Debugger = $Ini{'DEBUGGER'}; if ($jvmpi_path) { if ($OSNAME eq "win32") { $ENV{'PATH'} = "$ENV{'PATH'};$jvmpi_path"; } else { $ENV{'LD_LIBRARY_PATH'} = "$ENV{'LD_LIBRARY_PATH'}:$jvmpi_path"; } } if ($OSNAME eq "win32") { SystemP( "$ENV{'COMSPEC'} /C START $Vm -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y $classpath $jvmpi_args $VIRTUAL_MACHINE_ARGUMENTS $MainClass" ); SystemP( "$ENV{'COMSPEC'} /C START $Debugger -attach 8000" ); } else { SystemP( "$Vm -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y $classpath $jvmpi_args $VIRTUAL_MACHINE_ARGUMENTS $MainClass &" ); SystemP( "xterm -e $Debugger -attach 8000" ); } return 0; } 1; If you want to change the javic instrumenter written in perl, simply copy the contents of the lib/scripts/javic_j.pl here then modify it. die "Environment variable TESTRTDIR not found. Exiting.\n" if(!defined($ENV{'TESTRTDIR'})); # NO TRANSLATION require "$ENV{'TESTRTDIR'}/lib/scripts/javic_j.pl"; 1; use File::Copy; sub postGen() { my $d=shift; my $JavaHome; eval { require Win32::TieRegistry; import Win32::TieRegistry; my $Key = $Registry->{"HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3"}; return unless($Key); $JavaHome=$Key->{"JavaHome"}; }; return if($@); return unless($JavaHome ne ""); # Patch the tp.ini file. my $atl_cc_in = $d ."\\tp.ini"; my $atl_cc_out = $d ."\\tp.ini.out"; open (IN, $atl_cc_in) or print "Can't open \"$atl_cc_in\"\n"; open (OUT, ">".$atl_cc_out) or print "Can't open \"$atl_cc_out\"\n"; while (<IN>) { s/DEFAULT_BOOTCLASSPATH=\"<Windows: Read and set from the registry when saved >\"/DEFAULT_BOOTCLASSPATH=\"$JavaHome\\jre\\lib\\rt.jar\"/; s/ENV_PATH=\"<Windows: Read and set from the registry when saved >\"/ENV_PATH=\"$JavaHome\\bin;\$ENV{'PATH'}\"/; print OUT; } close (IN); close (OUT); # Rename the out file as the infile unlink ($atl_cc_in); rename ($atl_cc_out, $atl_cc_in); } 1; import java.io.*; JAVA_USR static { // Nothing to do } JAVA_USR static String UTF_8_unsupported = null; public static void waitForThreads() { Thread tab[] = new Thread[Products.max_threads]; while ( true ) { Thread current = Thread.currentThread ( ); current.yield(); int count = Thread.enumerate ( tab ); //System.err.println ( "Waiting for " + count + " threads" ); boolean wait = false; for ( int i = 0; i < tab.length; i++ ) { if ( tab[i] == null ) continue; if ( ( tab[i] != current ) && ( ! tab[i].isDaemon ( ) ) && ( tab[i].isAlive ( ) ) ) { wait = true; break; } } if ( wait ) { try { current.sleep(1000); } catch(InterruptedException E) { } } else { break; } } //System.err.println ( "All threads are there." ); } public static byte [] threadName() { String name = Thread.currentThread().getName ( ); if ( name != null ) { try { return name.getBytes ( "UTF-8" ); } catch ( java.io.UnsupportedEncodingException e ) { if ( UTF_8_unsupported == null ) { UTF_8_unsupported = new String ( "<UTF-8 unsupported>" ); } return ( UTF_8_unsupported.getBytes ( ) ); } } return null; } JAVA_USR public static java.io.OutputStream out_testrt = null; public static void outOpen() { try { out_testrt = new FileOutputStream ( Products.out_file ); } catch ( IOException e ) { System.err.println ( "TestRT: java.io.IOException in com.rational.testrealtime.Custom.outOpen()" ); } } public static void outWrite(byte[] buffer, int index) { if ( out_testrt == null ) { return; } try { out_testrt.write ( buffer, 0, index ); } catch ( IOException e ) { System.err.println ( "TestRT: java.io.IOException in com.rational.testrealtime.Custom.outWrite()" ); } } public static void outClose() { if ( out_testrt == null ) { return; } try { out_testrt.close ( ); } catch ( IOException e ) { System.err.println ( "TestRT: java.io.IOException in com.rational.testrealtime.Custom.outClose()" ); } } public static void pushError ( String msg ) { System.err.println ( msg ); } JAVA_USR static byte clock_unit[] = { (byte)'m', (byte)'s' }; public static long getClock() { return java.lang.System.currentTimeMillis ( ); } public static byte[] getClockUnit() { return clock_unit; } /* Add any extra includes or code */ JVMPI_STD JVMPI_USR int void *jvmpi_usr_malloc(JVMPI_SIZE_T size) { /* Code here the memory allocation function */ void *ptr=0; return(ptr); } void jvmpi_usr_free(void *ptr) { /* Code here the free function */ } JVMPI_STD JVMPI_USR FILE * JVMPI_FILE_TYPE jvmpi_usr_open(char *fileName) { /* Code here the open function */ JVMPI_FILE_TYPE f=(JVMPI_FILE_TYPE)0; return(f); } void *jvmpi_usr_write(JVMPI_FILE_TYPE file,char *buffer,int len) { /* Code here the write function */ } void *jvmpi_usr_close(JVMPI_FILE_TYPE file) { /* Code here the close function */ } JVMPI_STD JVMPI_USR void *jvmpi_usr_error(char *message) { /* Code here the error-print function */ printf("%s\n",message); } JVMPI_STD JVMPI_USR int jvmpi_usr_strncmp(const char *s1, const char *s2,JVMPI_SIZE_T n) { /* Code here the strncmp function */ return(0); } char *jvmpi_usr_strcmp(const char *s1, const char *s2) { /* Code here the strcmp function */ return(0); } int jvmpi_usr_strcpy(char *dest,const char *src) { /* Code here the strcpy function */ return(0); } char *jvmpi_usr_strstr(const char *haystack, const char *needle) { /* Code here the strstr function */ return(0); } JVMPI_SIZE_T jvmpi_usr_strlen(const char *s) { /* Code here the strlen function */ return(0); } JVMPI_STD JVMPI_USR unsigned long jvmpi_usr_getDateInMilliSec(void) { /* Code here the getDate function and return milliseconds */ } JVMPI_STD JVMPI_USR JVMPI_NONE int JVMPI_SOCKET_ID jvmpi_usr_connect(char *address,char *port) { /* Code here the connect function */ JVMPI_SOCKET_ID f; return(f); } int jvmpi_usr_recv(JVMPI_SOCKET_ID s,char *buffer,int len) { /* Code here the receive function */ return(0); } int jvmpi_usr_send(JVMPI_SOCKET_ID s,char *buffer,int len) { /* Code here the send function */ } int jvmpi_usr_socket_close(JVMPI_SOCKET_ID s) { /* Code here the close function */ return(0); } /* Add any extra code */ make