/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This class provides some common utilities for the launcher tests.
*/
public class TestHelper {
// commonly used jtreg constants
static final boolean isWindows =
static final boolean isMacOSX =
static final boolean is64Bit =
static final boolean is32Bit =
static final boolean isSolaris =
static final boolean isLinux =
// make a note of the golden default locale
static {
throw new Error("property test.classes not defined ??");
}
throw new Error("property test.src not defined ??");
}
throw new RuntimeException("arch model cannot be both 32 and 64 bit");
}
throw new RuntimeException("arch model is not 32 or 64 bit ?");
}
if (!javaCmdFile.canExecute()) {
"> must exist and should be executable");
}
if (!jarCmdFile.canExecute()) {
"> must exist and should be executable");
}
if (isWindows) {
if (!javawCmdFile.canExecute()) {
"> must exist and should be executable");
}
} else {
}
if (!javacCmdFile.canExecute()) {
"> must exist and should be executable");
}
if (isSolaris) {
} else {
}
} else {
}
}
: null;
? m.isAnnotationPresent(Test.class)
if (selected) {
try {
passed++;
failed++;
}
}
}
if (failed > 0) {
}
throw new AssertionError("No test(s) selected: passed = " +
}
}
/*
* is a dual mode available in the test jdk
*/
static boolean dualModePresent() {
}
/*
*/
}
/*
* get the complementary jre arch ie. if sparc then return sparcv9 and
* vice-versa.
*/
switch (arch) {
case "sparc":
return "sparcv9";
case "sparcv9":
return "sparc";
case "x86":
return "amd64";
case "amd64":
return "i386";
}
}
return null;
}
/*
* A convenience method to create a jar with jar file name and defs
*/
throws FileNotFoundException{
}
/*
* A convenience method to create a java file, compile and jar it up, using
* the sole class file name in the jar, as the Main-Class attribute value.
*/
throws FileNotFoundException {
}
/*
* A convenience method to compile java files.
*/
for (String x : compilerArgs) {
}
}
}
/*
* A generic jar file creator to create a java file, compile it
* and jar it up, a specific Main-Class entry name in the
* manifest can be specified or a null to use the sole class file name
* as the Main-Class attribute value.
*/
}
}
}
}
String compileArgs[] = {
mainClass + ".java"
};
}
}
};
}
}
throw new RuntimeException(message);
}
}
}
}
/**
* Attempt to create a file at the given location. If an IOException
* occurs then back off for a moment and try again. When a number of
* attempts fail, give up and throw an exception.
*/
try {
/*
* report attempts and errors that were encountered
* for diagnostic purposes
*/
" attempts");
}
return;
} catch (IOException ioe) {
// chain the exceptions so they all get reported for diagnostics
} else {
}
}
try {
} catch (InterruptedException ie) {
// cause should alway be non-null here
}
}
}
}
}
return;
}
try {
} catch (IOException ex) {
return FileVisitResult.TERMINATE;
}
return FileVisitResult.CONTINUE;
}
try {
} catch (IOException ex) {
return FileVisitResult.TERMINATE;
}
return FileVisitResult.CONTINUE;
}
});
}
}
}
/*
* A method which executes a java cmd and returns the results in a container
*/
}
if (envToRemove != null) {
}
}
}
try {
pb.redirectErrorStream(true);
}
p.waitFor();
p.destroy();
}
}
return new FileFilter() {
return true;
}
return false;
}
};
}
static boolean isEnglishLocale() {
}
/*
* A class to encapsulate the test results and stuff, with some ease
* of use methods to check the test results.
*/
static class TestResult {
int exitValue;
Throwable t;
boolean testStatus;
sw = new StringWriter();
testOutput = oList;
this.t = t;
testStatus = true;
}
testStatus = false;
}
}
void checkNegative() {
if (exitValue == 0) {
appendError("test must not return 0 exit value");
}
}
void checkPositive() {
if (exitValue != 0) {
appendError("test did not return 0 exit value");
}
}
boolean isOK() {
return exitValue == 0;
}
boolean isZeroOutput() {
if (!testOutput.isEmpty()) {
appendError("No message from cmd please");
return false;
}
return true;
}
boolean isNotZeroOutput() {
if (testOutput.isEmpty()) {
appendError("Missing message");
return false;
}
return true;
}
}
for (String x : testOutput) {
indentStatus(x);
}
for (StackTraceElement e : t.getStackTrace()) {
indentStatus(e.toString());
}
return out;
}
for (String x : testOutput) {
return true;
}
}
return false;
}
for (String x : testOutput) {
if (x.matches(stringToMatch)) {
return true;
}
}
return false;
}
}
/**
* Indicates that the annotated method is a test method.
*/
public @interface Test {}
}