109
110 /**
111 * Combines given arguments with default JTReg arguments for a jvm running a test.
112 * This is the combination of JTReg arguments test.vm.opts and test.java.opts
113 * @return The combination of JTReg test java options and user args.
114 */
115 public static String[] addTestJavaOpts(String... userArgs) {
116 List<String> opts = new ArrayList<String>();
117 Collections.addAll(opts, getTestJavaOpts());
118 Collections.addAll(opts, userArgs);
119 return opts.toArray(new String[0]);
120 }
121
122 /**
123 * Removes any options specifying which GC to use, for example "-XX:+UseG1GC".
124 * Removes any options matching: -XX:(+/-)Use*GC
125 * Used when a test need to set its own GC version. Then any
126 * GC specified by the framework must first be removed.
127 * @return A copy of given opts with all GC options removed.
128 */
129 private static final Pattern useGcPattern = Pattern.compile("\\-XX\\:[\\+\\-]Use.+GC");
130 public static List<String> removeGcOpts(List<String> opts) {
131 List<String> optsWithoutGC = new ArrayList<String>();
132 for (String opt : opts) {
133 if (useGcPattern.matcher(opt).matches()) {
134 System.out.println("removeGcOpts: removed " + opt);
135 } else {
136 optsWithoutGC.add(opt);
137 }
138 }
139 return optsWithoutGC;
140 }
141
142 /**
143 * Splits a string by white space.
144 * Works like String.split(), but returns an empty array
145 * if the string is null or empty.
146 */
147 private static String[] safeSplitString(String s) {
148 if (s == null || s.trim().isEmpty()) {
149 return new String[] {};
|
109
110 /**
111 * Combines given arguments with default JTReg arguments for a jvm running a test.
112 * This is the combination of JTReg arguments test.vm.opts and test.java.opts
113 * @return The combination of JTReg test java options and user args.
114 */
115 public static String[] addTestJavaOpts(String... userArgs) {
116 List<String> opts = new ArrayList<String>();
117 Collections.addAll(opts, getTestJavaOpts());
118 Collections.addAll(opts, userArgs);
119 return opts.toArray(new String[0]);
120 }
121
122 /**
123 * Removes any options specifying which GC to use, for example "-XX:+UseG1GC".
124 * Removes any options matching: -XX:(+/-)Use*GC
125 * Used when a test need to set its own GC version. Then any
126 * GC specified by the framework must first be removed.
127 * @return A copy of given opts with all GC options removed.
128 */
129 private static final Pattern useGcPattern = Pattern.compile("(?:\\-XX\\:[\\+\\-]Use.+GC)|(?:\\-Xconcgc)");
130 public static List<String> removeGcOpts(List<String> opts) {
131 List<String> optsWithoutGC = new ArrayList<String>();
132 for (String opt : opts) {
133 if (useGcPattern.matcher(opt).matches()) {
134 System.out.println("removeGcOpts: removed " + opt);
135 } else {
136 optsWithoutGC.add(opt);
137 }
138 }
139 return optsWithoutGC;
140 }
141
142 /**
143 * Splits a string by white space.
144 * Works like String.split(), but returns an empty array
145 * if the string is null or empty.
146 */
147 private static String[] safeSplitString(String s) {
148 if (s == null || s.trim().isEmpty()) {
149 return new String[] {};
|