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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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