Skip to content

Commit eb501b8

Browse files
committed
moved test layout checks to inside each class
1 parent e8b5f0f commit eb501b8

File tree

1 file changed

+126
-93
lines changed

1 file changed

+126
-93
lines changed

test/hotspot/jtreg/runtime/contended/MixedPrimitives.java

Lines changed: 126 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -138,97 +138,15 @@ public static int getSize(Field field) {
138138
public static void main(String[] args) throws Exception {
139139
int failures = 0;
140140

141-
// --------------- INSTANCE FIELDS ---------------------
142-
143-
if (arePaddedPairwise(Test1.class, "long1", "int1") ||
144-
arePaddedPairwise(Test1.class, "long1", "short1") ||
145-
arePaddedPairwise(Test1.class, "int1", "short1") ||
146-
isPadded(Test1.class, "long1") ||
147-
isPadded(Test1.class, "int1") ||
148-
isPadded(Test1.class, "short1")) {
149-
System.err.println("Test1 failed");
150-
failures += 1;
151-
}
152-
153-
if (!arePaddedPairwise(Test2.class, "long1", "int1") ||
154-
!arePaddedPairwise(Test2.class, "long1", "short1") ||
155-
arePaddedPairwise(Test2.class, "int1", "short1") ||
156-
!isPadded(Test2.class, "long1") ||
157-
isPadded(Test2.class, "int1") ||
158-
isPadded(Test2.class, "short1")) {
159-
System.err.println("Test2 failed");
160-
failures += 1;
161-
}
162-
163-
if (!arePaddedPairwise(Test3.class, "long1", "int1") ||
164-
!arePaddedPairwise(Test3.class, "long1", "short1") ||
165-
!arePaddedPairwise(Test3.class, "int1", "short1") ||
166-
!isPadded(Test3.class, "long1") ||
167-
!isPadded(Test3.class, "int1") ||
168-
!isPadded(Test3.class, "short1")) {
169-
System.err.println("Test3 failed");
170-
failures += 1;
171-
}
172-
173-
if (arePaddedPairwise(Test4.class, "long1", "int1") ||
174-
arePaddedPairwise(Test4.class, "long1", "short1") ||
175-
arePaddedPairwise(Test4.class, "int1", "short1") ||
176-
!isPadded(Test4.class, "long1") ||
177-
!isPadded(Test4.class, "int1") ||
178-
!isPadded(Test4.class, "short1")) {
179-
System.err.println("Test4 failed");
180-
failures += 1;
181-
}
182-
183-
if (!arePaddedPairwise(Test5.class, "long1", "int1") ||
184-
!arePaddedPairwise(Test5.class, "long1", "short1") ||
185-
!arePaddedPairwise(Test5.class, "int1", "short1") ||
186-
!isPadded(Test5.class, "long1") ||
187-
!isPadded(Test5.class, "int1") ||
188-
!isPadded(Test5.class, "short1")) {
189-
System.err.println("Test5 failed");
190-
failures += 1;
191-
}
192-
193-
if (!arePaddedPairwise(Test6.class, "long1", "int1") ||
194-
!arePaddedPairwise(Test6.class, "long1", "short1") ||
195-
!arePaddedPairwise(Test6.class, "int1", "short1") ||
196-
!isPadded(Test6.class, "long1") ||
197-
!isPadded(Test6.class, "int1") ||
198-
!isPadded(Test6.class, "short1")) {
199-
System.err.println("Test6 failed");
200-
failures += 1;
201-
}
202-
203-
if (arePaddedPairwise(Test7.class, "long1", "int1") ||
204-
arePaddedPairwise(Test7.class, "long1", "short1") ||
205-
arePaddedPairwise(Test7.class, "int1", "short1") ||
206-
!isPadded(Test7.class, "long1") ||
207-
!isPadded(Test7.class, "int1") ||
208-
!isPadded(Test7.class, "short1")) {
209-
System.err.println("Test7 failed");
210-
failures += 1;
211-
}
212-
213-
if (!arePaddedPairwise(Test8.class, "long1", "int1") ||
214-
!arePaddedPairwise(Test8.class, "long1", "short1") ||
215-
arePaddedPairwise(Test8.class, "int1", "short1") ||
216-
!isPadded(Test8.class, "long1") ||
217-
!isPadded(Test8.class, "int1") ||
218-
!isPadded(Test8.class, "short1")) {
219-
System.err.println("Test8 failed");
220-
failures += 1;
221-
}
222-
223-
if (!arePaddedPairwise(Test9.class, "long1", "int1") ||
224-
!arePaddedPairwise(Test9.class, "long1", "short1") ||
225-
arePaddedPairwise(Test9.class, "int1", "short1") ||
226-
!isPadded(Test9.class, "long1") ||
227-
!isPadded(Test9.class, "int1") ||
228-
!isPadded(Test9.class, "short1")) {
229-
System.err.println("Test9 failed");
230-
failures += 1;
231-
}
141+
failures += Test1.checkLayout();
142+
failures += Test2.checkLayout();
143+
failures += Test3.checkLayout();
144+
failures += Test4.checkLayout();
145+
failures += Test5.checkLayout();
146+
failures += Test6.checkLayout();
147+
failures += Test7.checkLayout();
148+
failures += Test8.checkLayout();
149+
failures += Test9.checkLayout();
232150

233151
if (!sameLayout(Test4.class, Test7.class)) {
234152
System.err.println("Test4 and Test7 have different layouts");
@@ -251,48 +169,124 @@ public static void main(String[] args) throws Exception {
251169
}
252170
}
253171

254-
// ----------------------------------- INSTANCE FIELDS -----------------------------------------
255-
256172
// naturally packed
257173
public static class Test1 {
258174
private long long1;
259175
private int int1;
260176
private short short1;
177+
178+
public static int checkLayout() throws Exception {
179+
if (arePaddedPairwise(Test1.class, "long1", "int1") ||
180+
arePaddedPairwise(Test1.class, "long1", "short1") ||
181+
arePaddedPairwise(Test1.class, "int1", "short1") ||
182+
isPadded(Test1.class, "long1") ||
183+
isPadded(Test1.class, "int1") ||
184+
isPadded(Test1.class, "short1")) {
185+
System.err.println("Test1 failed");
186+
return 1;
187+
}
188+
return 0;
189+
}
261190
}
262191

263192
// long1 is padded
264193
public static class Test2 {
265194
@Contended private long long1;
266195
private int int1;
267196
private short short1;
197+
198+
public static int checkLayout() throws Exception {
199+
if (!arePaddedPairwise(Test2.class, "long1", "int1") ||
200+
!arePaddedPairwise(Test2.class, "long1", "short1") ||
201+
arePaddedPairwise(Test2.class, "int1", "short1") ||
202+
!isPadded(Test2.class, "long1") ||
203+
isPadded(Test2.class, "int1") ||
204+
isPadded(Test2.class, "short1")) {
205+
System.err.println("Test2 failed");
206+
return 1;
207+
}
208+
return 0;
209+
}
268210
}
269211

270212
// both fields are padded
271213
public static class Test3 {
272214
@Contended private long long1;
273215
@Contended private int int1;
274216
@Contended private short short1;
217+
218+
public static int checkLayout() throws Exception {
219+
if (!arePaddedPairwise(Test3.class, "long1", "int1") ||
220+
!arePaddedPairwise(Test3.class, "long1", "short1") ||
221+
!arePaddedPairwise(Test3.class, "int1", "short1") ||
222+
!isPadded(Test3.class, "long1") ||
223+
!isPadded(Test3.class, "int1") ||
224+
!isPadded(Test3.class, "short1")) {
225+
System.err.println("Test3 failed");
226+
return 1;
227+
}
228+
return 0;
229+
}
275230
}
276231

277232
// fields are padded in the singular group
278233
public static class Test4 {
279234
@Contended("sameGroup") private long long1;
280235
@Contended("sameGroup") private int int1;
281236
@Contended("sameGroup") private short short1;
237+
238+
public static int checkLayout() throws Exception {
239+
if (arePaddedPairwise(Test4.class, "long1", "int1") ||
240+
arePaddedPairwise(Test4.class, "long1", "short1") ||
241+
arePaddedPairwise(Test4.class, "int1", "short1") ||
242+
!isPadded(Test4.class, "long1") ||
243+
!isPadded(Test4.class, "int1") ||
244+
!isPadded(Test4.class, "short1")) {
245+
System.err.println("Test4 failed");
246+
return 1;
247+
}
248+
return 0;
249+
}
282250
}
283251

284252
// fields are padded in disjoint groups
285253
public static class Test5 {
286254
@Contended("diffGroup1") private long long1;
287255
@Contended("diffGroup2") private int int1;
288256
@Contended("diffGroup3") private short short1;
257+
258+
public static int checkLayout() throws Exception {
259+
if (!arePaddedPairwise(Test5.class, "long1", "int1") ||
260+
!arePaddedPairwise(Test5.class, "long1", "short1") ||
261+
!arePaddedPairwise(Test5.class, "int1", "short1") ||
262+
!isPadded(Test5.class, "long1") ||
263+
!isPadded(Test5.class, "int1") ||
264+
!isPadded(Test5.class, "short1")) {
265+
System.err.println("Test5 failed");
266+
return 1;
267+
}
268+
return 0;
269+
}
289270
}
290271

291272
// fields are padded in disjoint groups
292273
public static class Test6 {
293274
@Contended private long long1;
294275
@Contended("diffGroup2") private int int1;
295276
@Contended("diffGroup3") private short short1;
277+
278+
public static int checkLayout() throws Exception {
279+
if (!arePaddedPairwise(Test6.class, "long1", "int1") ||
280+
!arePaddedPairwise(Test6.class, "long1", "short1") ||
281+
!arePaddedPairwise(Test6.class, "int1", "short1") ||
282+
!isPadded(Test6.class, "long1") ||
283+
!isPadded(Test6.class, "int1") ||
284+
!isPadded(Test6.class, "short1")) {
285+
System.err.println("Test6 failed");
286+
return 1;
287+
}
288+
return 0;
289+
}
296290
}
297291

298292
// fields are padded in the singular group
@@ -301,6 +295,19 @@ public static class Test7 {
301295
private long long1;
302296
private int int1;
303297
private short short1;
298+
299+
public static int checkLayout() throws Exception {
300+
if (arePaddedPairwise(Test7.class, "long1", "int1") ||
301+
arePaddedPairwise(Test7.class, "long1", "short1") ||
302+
arePaddedPairwise(Test7.class, "int1", "short1") ||
303+
!isPadded(Test7.class, "long1") ||
304+
!isPadded(Test7.class, "int1") ||
305+
!isPadded(Test7.class, "short1")) {
306+
System.err.println("Test7 failed");
307+
return 1;
308+
}
309+
return 0;
310+
}
304311
}
305312

306313
// all fields are padded as the group, and one field is padded specifically
@@ -309,6 +316,19 @@ public static class Test8 {
309316
@Contended private long long1;
310317
private int int1;
311318
private short short1;
319+
320+
public static int checkLayout() throws Exception {
321+
if (!arePaddedPairwise(Test8.class, "long1", "int1") ||
322+
!arePaddedPairwise(Test8.class, "long1", "short1") ||
323+
arePaddedPairwise(Test8.class, "int1", "short1") ||
324+
!isPadded(Test8.class, "long1") ||
325+
!isPadded(Test8.class, "int1") ||
326+
!isPadded(Test8.class, "short1")) {
327+
System.err.println("Test8 failed");
328+
return 1;
329+
}
330+
return 0;
331+
}
312332
}
313333

314334
// all fields are padded as the group, and one field is padded specifically
@@ -317,6 +337,19 @@ public static class Test9 {
317337
@Contended("group") private long long1;
318338
private int int1;
319339
private short short1;
340+
341+
public static int checkLayout() throws Exception {
342+
if (!arePaddedPairwise(Test9.class, "long1", "int1") ||
343+
!arePaddedPairwise(Test9.class, "long1", "short1") ||
344+
arePaddedPairwise(Test9.class, "int1", "short1") ||
345+
!isPadded(Test9.class, "long1") ||
346+
!isPadded(Test9.class, "int1") ||
347+
!isPadded(Test9.class, "short1")) {
348+
System.err.println("Test9 failed");
349+
return 1;
350+
}
351+
return 0;
352+
}
320353
}
321354

322355
}

0 commit comments

Comments
 (0)