Skip to content

Commit

Permalink
Handle missing classes.jar in sharedClassesTestData
Browse files Browse the repository at this point in the history
- ensure the presence of classes.jar , if doesnt exist regenerate it.

resolves: eclipse-openj9/openj9#19582

Signed-off-by: Anna Babu Palathingal <[email protected]>
  • Loading branch information
annaibm committed Dec 4, 2024
1 parent 748831f commit a0c6914
Showing 1 changed file with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import static net.adoptopenjdk.stf.extensions.core.StfCoreExtension.Echo.ECHO_ON;

import java.io.File;
import java.util.ArrayList;

import net.adoptopenjdk.stf.environment.DirectoryRef;
Expand Down Expand Up @@ -192,13 +193,15 @@ public void setUp(StfCoreExtension test, StfSharedClassesExtension sharedClasses
int found = 0;
for (int i = 0 ; (i < prereqRoots.size()) && ( found == 0 ); i++ ) {
sharedClassesDataDir = prereqRoots.get(i).childDirectory(dataSubdir);
if (!sharedClassesDataDir.exists()) {
System.out.println(sharedClassesDataDir.getSpec() + " does not exist");
}
else {
System.out.println(sharedClassesDataDir.getSpec() + " exists");
FileRef sharedClassesJar = sharedClassesDataDir.childFile("classes.jar");
if (sharedClassesJar.exists()) {
System.out.println(sharedClassesDataDir.getSpec() + " exists and contains classes.jar");
found = 1;
}
break;
} else {
System.out.println(sharedClassesDataDir.getSpec() + "/classes.jar does not exist.");
deleteDirectory(sharedClassesDataDir.asJavaFile());
}
}

if ( found == 0 ) {
Expand Down Expand Up @@ -275,4 +278,23 @@ public void tearDown(StfCoreExtension test, StfSharedClassesExtension sharedClas
sharedClasses.doDestroySpecificCache("Destroy cache", "-Xshareclasses:name=" + SCSoftmxTestUtil.CACHE_NAME + ",cacheDir=" + cacheDir + "${cacheOperation}", SCSoftmxTestUtil.CACHE_NAME, cacheDir);
sharedClasses.doDestroySpecificNonPersistentCache("Destroy cache", "-Xshareclasses:name=" + SCSoftmxTestUtil.CACHE_NAME + ",cacheDir=" + cacheDir + "${cacheOperation}", SCSoftmxTestUtil.CACHE_NAME, cacheDir);
}

public void deleteDirectory(File directory) {
if (directory.exists()) {
File[] files = directory.listFiles();
if (files != null) {
for (File file : files) {
if (file.isDirectory()) {
deleteDirectory(file);
} else {
file.delete();
}
}
}
directory.delete();
} else {
System.out.println("Directory does not exist: " + directory.getAbsolutePath());
}
}

}

0 comments on commit a0c6914

Please sign in to comment.