8154470: defines.h confused about PROGNAME and JAVA_ARGS

Fiddle with const_progname initializations

Reviewed-by: ksrini, alanb
This commit is contained in:
Martin Buchholz 2016-04-18 09:38:38 -07:00
parent 402c448d0a
commit dc9721e592
13 changed files with 78 additions and 89 deletions

@ -45,7 +45,11 @@
#ifdef JAVA_ARGS
#define HAS_JAVA_ARGS JNI_TRUE
static const char* const_progname = "java";
#ifdef PROGNAME
static const char* const_progname = PROGNAME;
#else
static char* const_progname = NULL;
#endif
static const char* const_jargs[] = JAVA_ARGS;
/*
* ApplicationHome is prepended to each of these entries; the resulting
@ -59,11 +63,7 @@ static const char* const_appclasspath[] = APP_CLASSPATH;
#endif /* APP_CLASSPATH */
#else /* !JAVA_ARGS */
#define HAS_JAVA_ARGS JNI_FALSE
#ifdef PROGNAME
static const char* const_progname = PROGNAME;
#else
static char* const_progname = NULL;
#endif
static const char* const_progname = "java";
static const char** const_jargs = NULL;
static const char* const_appclasspath[] = { NULL };
#endif /* JAVA_ARGS */

@ -489,7 +489,7 @@ public class Arrrghs extends TestHelper {
return;
}
TestResult tr = null;
TestResult tr;
// a missing class
createJar("MIA", new File("some.jar"), new File("Foo"),
@ -592,7 +592,7 @@ public class Arrrghs extends TestHelper {
if (!isEnglishLocale()) { // only english version
return;
}
TestResult tr = null;
TestResult tr;
// a missing class
createJar("MIA", new File("some.jar"), new File("Foo"),
(String[])null);

@ -41,7 +41,7 @@ public class DefaultLocaleTestRun extends TestHelper {
System.out.println("Test passes vacuously on non-windows");
return;
}
TestResult tr = null;
TestResult tr;
tr = doExec(javaCmd,
"-cp", TEST_CLASSES_DIR.getAbsolutePath(),
"DefaultLocaleTest", "-w", "x.out");

@ -120,15 +120,14 @@ public class ExecutionEnvironment extends TestHelper {
*/
@Test
void testEcoFriendly() {
TestResult tr = null;
Map<String, String> env = new HashMap<>();
for (String x : LD_PATH_STRINGS) {
String pairs[] = x.split("=");
env.put(pairs[0], pairs[1]);
}
tr = doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
TestResult tr =
doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
if (!tr.isNotZeroOutput()) {
flagError(tr, "Error: No output at all. Did the test execute ?");
@ -180,7 +179,7 @@ public class ExecutionEnvironment extends TestHelper {
*/
@Test
void testJavaLibraryPath() {
TestResult tr = null;
TestResult tr;
Map<String, String> env = new HashMap<>();
@ -240,17 +239,14 @@ public class ExecutionEnvironment extends TestHelper {
*/
@Test
void testVmSelection() {
TestResult tr = null;
if (haveClientVM) {
tr = doExec(javaCmd, "-client", "-version");
TestResult tr = doExec(javaCmd, "-client", "-version");
if (!tr.matches(".*Client VM.*")) {
flagError(tr, "the expected vm -client did not launch");
}
}
if (haveServerVM) {
tr = doExec(javaCmd, "-server", "-version");
TestResult tr = doExec(javaCmd, "-server", "-version");
if (!tr.matches(".*Server VM.*")) {
flagError(tr, "the expected vm -server did not launch");
}

@ -239,7 +239,7 @@ public class FXLauncherTest extends TestHelper {
createFile(ManifestFile, createManifestContents(StdMainClass, fxMC));
createJar(FXtestJar, ManifestFile);
String sTestJar = FXtestJar.getAbsolutePath();
TestResult tr;
final TestResult tr;
if (useCP) {
tr = doExec(javaCmd, "-cp", sTestJar, StdMainClass, APP_PARMS[0], APP_PARMS[1]);
} else {
@ -290,7 +290,7 @@ public class FXLauncherTest extends TestHelper {
createFile(ManifestFile, createManifestContents(ExtMainClass, fxMC));
createJar(FXtestJar, ManifestFile);
String sTestJar = FXtestJar.getAbsolutePath();
TestResult tr;
final TestResult tr;
if (useCP) {
tr = doExec(javaCmd, "-cp", sTestJar, ExtMainClass, APP_PARMS[0], APP_PARMS[1]);
} else {
@ -359,7 +359,7 @@ public class FXLauncherTest extends TestHelper {
createFile(ManifestFile, createManifestContents(NonFXMainClass, null));
createJar(FXtestJar, ManifestFile);
String sTestJar = FXtestJar.getAbsolutePath();
TestResult tr;
final TestResult tr;
if (useCP) {
tr = doExec(javaCmd, "-verbose:class", "-cp", sTestJar, NonFXMainClass, APP_PARMS[0], APP_PARMS[1]);

@ -60,7 +60,7 @@ public class I18NTest extends TestHelper {
// compile the generate code using the javac compiler vs. the api, to
// as a bonus point to see if the argument is passed correctly
TestResult tr = null;
TestResult tr;
tr = doExec(javacCmd, fileName + JAVA_FILE_EXT);
if (!tr.isOK()) {
System.out.println(tr);

@ -23,7 +23,7 @@
/*
* @test
* @bug 6856415 8154212
* @bug 6856415 8154212 8154470
* @summary Miscellaneous tests, Exceptions
* @compile -XDignore.symbol.file MiscTests.java
* @run main MiscTests
@ -95,30 +95,34 @@ public class MiscTests extends TestHelper {
TestResult tr = doExec(javaCmd,
"-Djava.security.manager", "-jar", testJar.getName(), "foo.bak");
for (String s : tr.testOutput) {
System.out.println(s);
}
if (!tr.contains("java.security.AccessControlException:" +
" access denied (\"java.lang.RuntimePermission\"" +
" \"accessClassInPackage.sun.security.pkcs11\")")) {
System.out.println(tr.status);
System.out.println(tr);
}
}
static void testJLDEnvWithTool() {
final Map<String, String> envMap = new HashMap<>();
envMap.put("_JAVA_LAUNCHER_DEBUG", "true");
TestResult tr = doExec(envMap, javacCmd, "-version");
tr.checkPositive();
if (!tr.isOK()) {
System.out.println(tr);
static void testJLDEnv() {
final Map<String, String> envToSet = new HashMap<>();
envToSet.put("_JAVA_LAUNCHER_DEBUG", "true");
for (String cmd : new String[] { javaCmd, javacCmd }) {
TestResult tr = doExec(envToSet, cmd, "-version");
tr.checkPositive();
String javargs = cmd.equals(javacCmd) ? "on" : "off";
String progname = cmd.equals(javacCmd) ? "javac" : "java";
if (!tr.isOK()
|| !tr.matches("\\s*debug:on$")
|| !tr.matches("\\s*javargs:" + javargs + "$")
|| !tr.matches("\\s*program name:" + progname + "$")) {
System.out.println(tr);
}
}
}
public static void main(String... args) throws IOException {
testWithClassPathSetViaProperty();
test6856415();
testJLDEnvWithTool();
testJLDEnv();
if (testExitValue != 0) {
throw new Error(testExitValue + " tests failed");
}

@ -55,9 +55,9 @@ public class Settings extends TestHelper {
}
}
static void checkNoContains(TestResult tr, String str) {
if (tr.contains(str)) {
System.out.println(tr.status);
static void checkNotContains(TestResult tr, String str) {
if (!tr.notContains(str)) {
System.out.println(tr);
throw new RuntimeException(str + " found");
}
}
@ -77,84 +77,77 @@ public class Settings extends TestHelper {
if (getArch().equals("ppc64") || getArch().equals("ppc64le")) {
stackSize = "800";
}
TestResult tr = null;
TestResult tr;
tr = doExec(javaCmd, "-Xms64m", "-Xmx512m",
"-Xss" + stackSize + "k", "-XshowSettings", "-jar", testJar.getAbsolutePath());
containsAllOptions(tr);
if (!tr.isOK()) {
System.out.println(tr.status);
System.out.println(tr);
throw new RuntimeException("test fails");
}
tr = doExec(javaCmd, "-Xms65536k", "-Xmx712m",
"-Xss" + stackSize + "000", "-XshowSettings", "-jar", testJar.getAbsolutePath());
containsAllOptions(tr);
if (!tr.isOK()) {
System.out.println(tr.status);
System.out.println(tr);
throw new RuntimeException("test fails");
}
}
static void runTestOptionAll() throws IOException {
init();
TestResult tr = null;
tr = doExec(javaCmd, "-XshowSettings:all");
TestResult tr = doExec(javaCmd, "-XshowSettings:all");
containsAllOptions(tr);
}
static void runTestOptionVM() throws IOException {
TestResult tr = null;
tr = doExec(javaCmd, "-XshowSettings:vm");
TestResult tr = doExec(javaCmd, "-XshowSettings:vm");
checkContains(tr, VM_SETTINGS);
checkNoContains(tr, PROP_SETTINGS);
checkNoContains(tr, LOCALE_SETTINGS);
checkNotContains(tr, PROP_SETTINGS);
checkNotContains(tr, LOCALE_SETTINGS);
}
static void runTestOptionProperty() throws IOException {
TestResult tr = null;
tr = doExec(javaCmd, "-XshowSettings:properties");
checkNoContains(tr, VM_SETTINGS);
TestResult tr = doExec(javaCmd, "-XshowSettings:properties");
checkNotContains(tr, VM_SETTINGS);
checkContains(tr, PROP_SETTINGS);
checkNoContains(tr, LOCALE_SETTINGS);
checkNotContains(tr, LOCALE_SETTINGS);
}
static void runTestOptionLocale() throws IOException {
TestResult tr = null;
tr = doExec(javaCmd, "-XshowSettings:locale");
checkNoContains(tr, VM_SETTINGS);
checkNoContains(tr, PROP_SETTINGS);
TestResult tr = doExec(javaCmd, "-XshowSettings:locale");
checkNotContains(tr, VM_SETTINGS);
checkNotContains(tr, PROP_SETTINGS);
checkContains(tr, LOCALE_SETTINGS);
}
static void runTestBadOptions() throws IOException {
TestResult tr = null;
tr = doExec(javaCmd, "-XshowSettingsBadOption");
checkNoContains(tr, VM_SETTINGS);
checkNoContains(tr, PROP_SETTINGS);
checkNoContains(tr, LOCALE_SETTINGS);
TestResult tr = doExec(javaCmd, "-XshowSettingsBadOption");
checkNotContains(tr, VM_SETTINGS);
checkNotContains(tr, PROP_SETTINGS);
checkNotContains(tr, LOCALE_SETTINGS);
checkContains(tr, "Unrecognized option: -XshowSettingsBadOption");
}
static void runTest7123582() throws IOException {
TestResult tr = null;
tr = doExec(javaCmd, "-XshowSettings", "-version");
TestResult tr = doExec(javaCmd, "-XshowSettings", "-version");
if (!tr.isOK()) {
System.out.println(tr.status);
System.out.println(tr);
throw new RuntimeException("test fails");
}
containsAllOptions(tr);
}
public static void main(String... args) {
try {
runTestOptionAll();
runTestOptionDefault();
runTestOptionVM();
runTestOptionProperty();
runTestOptionLocale();
runTestBadOptions();
runTest7123582();
} catch (IOException ioe) {
throw new RuntimeException(ioe);
public static void main(String... args) throws IOException {
runTestOptionAll();
runTestOptionDefault();
runTestOptionVM();
runTestOptionProperty();
runTestOptionLocale();
runTestBadOptions();
runTest7123582();
if (testExitValue != 0) {
throw new Error(testExitValue + " tests failed");
}
}
}

@ -603,23 +603,23 @@ public class TestHelper {
return true;
}
boolean matches(String stringToMatch) {
boolean matches(String regexToMatch) {
for (String x : testOutput) {
if (x.matches(stringToMatch)) {
if (x.matches(regexToMatch)) {
return true;
}
}
appendError("string <" + stringToMatch + "> not found");
appendError("regex <" + regexToMatch + "> not matched");
return false;
}
boolean notMatches(String stringToMatch) {
boolean notMatches(String regexToMatch) {
for (String x : testOutput) {
if (!x.matches(stringToMatch)) {
if (!x.matches(regexToMatch)) {
return true;
}
}
appendError("string <" + stringToMatch + "> found");
appendError("regex <" + regexToMatch + "> matched");
return false;
}
}

@ -241,7 +241,7 @@ public class TestSpecialArgs extends TestHelper {
@Test
void testNMArgumentProcessing() throws FileNotFoundException {
TestResult tr = null;
TestResult tr;
// the direct invokers of the VM
String options[] = {
"-version", "-fullversion", "-help", "-?", "-X"

@ -85,11 +85,10 @@ public class TooSmallStackSize extends TestHelper {
*/
static String checkStack(String stackSize) {
String min_stack_allowed;
TestResult tr;
if (verbose)
System.out.println("*** Testing " + stackSize);
tr = doExec(javaCmd, "-Xss" + stackSize, "-version");
TestResult tr = doExec(javaCmd, "-Xss" + stackSize, "-version");
if (verbose)
printTestOutput(tr);
@ -114,11 +113,9 @@ public class TooSmallStackSize extends TestHelper {
* Run the JVM with the minimum allowed stack size. This should always succeed.
*/
static void checkMinStackAllowed(String stackSize) {
TestResult tr = null;
if (verbose)
System.out.println("*** Testing " + stackSize);
tr = doExec(javaCmd, "-Xss" + stackSize, "-version");
TestResult tr = doExec(javaCmd, "-Xss" + stackSize, "-version");
if (verbose)
printTestOutput(tr);

@ -149,7 +149,7 @@ public class ToolsOpts extends TestHelper {
*/
static void runTestOptions() throws IOException {
init();
TestResult tr = null;
TestResult tr;
int jpos = -1;
for (String arg[] : optionPatterns) {
jpos = indexOfJoption(arg);

@ -151,12 +151,11 @@ public class VersionCheck extends TestHelper {
* of the -version output as they are inconsistent.
*/
static boolean testToolVersion() {
TestResult tr = null;
TestHelper.testExitValue = 0;
for (File f : new File(JAVA_BIN).listFiles(new ToolFilter(BLACKLIST_VERSION))) {
String x = f.getAbsolutePath();
System.out.println("Testing (-version): " + x);
tr = doExec(x, "-version");
TestResult tr = doExec(x, "-version");
tr.checkPositive();
}
return TestHelper.testExitValue == 0;