|
Lines 3237-3246
Link Here
|
| 3237 |
getExprChangedCount() == 0); |
3237 |
getExprChangedCount() == 0); |
| 3238 |
} |
3238 |
} |
| 3239 |
|
3239 |
|
| 3240 |
private IExpressionDMContext[] getChildren(IExpressionDMContext parentDmc, String[] expectedValues) throws Throwable { |
3240 |
// This method tests IExspressions.getSubExpressions(IExpressionDMC, DRM); |
| 3241 |
return getChildren(parentDmc, -1, -1, expectedValues ); |
3241 |
private IExpressionDMContext[] getChildren( |
|
|
3242 |
final IExpressionDMContext parentDmc, |
| 3243 |
String[] expectedValues) throws Throwable { |
| 3244 |
|
| 3245 |
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); |
| 3246 |
|
| 3247 |
fExpService.getExecutor().submit(new Runnable() { |
| 3248 |
@Override |
| 3249 |
public void run() { |
| 3250 |
|
| 3251 |
fExpService.getSubExpressions(parentDmc, |
| 3252 |
new DataRequestMonitor<IExpressionDMContext[]>(fExpService.getExecutor(), null) { |
| 3253 |
@Override |
| 3254 |
protected void handleCompleted() { |
| 3255 |
if (isSuccess()) { |
| 3256 |
wait.setReturnInfo(getData()); |
| 3257 |
} |
| 3258 |
wait.waitFinished(getStatus()); |
| 3259 |
} |
| 3260 |
}); |
| 3261 |
} |
| 3262 |
}); |
| 3263 |
|
| 3264 |
wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); |
| 3265 |
assertTrue(wait.getMessage(), wait.isOK()); |
| 3266 |
|
| 3267 |
IExpressionDMContext[] childDmcs = |
| 3268 |
(IExpressionDMContext[]) wait.getReturnInfo(); |
| 3269 |
|
| 3270 |
String[] childExpressions = new String[childDmcs.length]; |
| 3271 |
MIExpressionDMCAccessor[] childDmcsAccessor = new MIExpressionDMCAccessor[childDmcs.length]; |
| 3272 |
|
| 3273 |
// Convert to a MIExpressionDMCAccessor to be able to call getRelativeExpression |
| 3274 |
// Also convert to String[] to be able to use Arrays.toString() |
| 3275 |
for (int i = 0; i < childExpressions.length; i++) { |
| 3276 |
childDmcsAccessor[i] = new MIExpressionDMCAccessor(childDmcs[i]); |
| 3277 |
childExpressions[i] = childDmcsAccessor[i].getRelativeExpression(); |
| 3278 |
} |
| 3279 |
assertTrue("Expected " + Arrays.toString(expectedValues) + " but got " + Arrays.toString(childExpressions), |
| 3280 |
expectedValues.length == childExpressions.length); |
| 3281 |
|
| 3282 |
for (int i = 0; i < childDmcsAccessor.length; i++) { |
| 3283 |
assertTrue("Expected: " + expectedValues[i] + " got: " + childDmcsAccessor[i].getRelativeExpression(), |
| 3284 |
childDmcsAccessor[i].getRelativeExpression().equals(expectedValues[i])); |
| 3285 |
} |
| 3286 |
|
| 3287 |
return childDmcs; |
| 3242 |
} |
3288 |
} |
| 3243 |
|
3289 |
|
|
|
3290 |
// This method tests IExpressions.getSubExpressions(IExpressionDMC, int, int, DRM); |
| 3244 |
private IExpressionDMContext[] getChildren( |
3291 |
private IExpressionDMContext[] getChildren( |
| 3245 |
final IExpressionDMContext parentDmc, |
3292 |
final IExpressionDMContext parentDmc, |
| 3246 |
final int startIndex, |
3293 |
final int startIndex, |
|
Lines 3363-3371
Link Here
|
| 3363 |
expectedValues[j] = String.format("array_foo[%d]", i*100 + j); |
3410 |
expectedValues[j] = String.format("array_foo[%d]", i*100 + j); |
| 3364 |
} |
3411 |
} |
| 3365 |
IExpressionDMContext[] arrayFooChildren = getChildren(ctx, expectedValues); |
3412 |
IExpressionDMContext[] arrayFooChildren = getChildren(ctx, expectedValues); |
| 3366 |
for (IExpressionDMContext fooCtx : arrayFooChildren) { |
3413 |
// check the children of a couple of children |
| 3367 |
getChildren(fooCtx, new String[] {"bar", "bar2", "a", "b", "c"}); |
3414 |
getChildren(arrayFooChildren[0], new String[] {"bar", "bar2", "a", "b", "c"}); |
| 3368 |
} |
3415 |
getChildren(arrayFooChildren[80], new String[] {"bar", "bar2", "a", "b", "c"}); |
| 3369 |
|
3416 |
|
| 3370 |
// get parts of the children array |
3417 |
// get parts of the children array |
| 3371 |
expectedValues = new String[] { String.format("array_foo[%d]", i*100 + 3), String.format("array_foo[%d]", i*100 + 4) }; |
3418 |
expectedValues = new String[] { String.format("array_foo[%d]", i*100 + 3), String.format("array_foo[%d]", i*100 + 4) }; |
|
Lines 3374-3379
Link Here
|
| 3374 |
} |
3421 |
} |
| 3375 |
} |
3422 |
} |
| 3376 |
|
3423 |
|
|
|
3424 |
/** |
| 3425 |
* This test verifies that large double arrays are properly partitioned |
| 3426 |
*/ |
| 3427 |
@Test |
| 3428 |
public void testLargeDoubleArray() throws Throwable { |
| 3429 |
MIStoppedEvent stoppedEvent = SyncUtil.runToLocation("testArrays"); |
| 3430 |
|
| 3431 |
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); |
| 3432 |
|
| 3433 |
// char array_double_large[111][210] |
| 3434 |
IExpressionDMContext arrayDoubleLargeExprDMC = SyncUtil.createExpression(frameDmc, "array_double_large"); |
| 3435 |
|
| 3436 |
getChildrenCount(arrayDoubleLargeExprDMC, 2); |
| 3437 |
|
| 3438 |
// get top level partitions: [0-99], [100-110] |
| 3439 |
IExpressionDMContext[] arrayTopPartitions = |
| 3440 |
getChildren(arrayDoubleLargeExprDMC, new String[] {"*((array_double_large)+0)@100", "*((array_double_large)+100)@11"}); |
| 3441 |
assertTrue(String.format("Invalid number of partition: expected 2 got %d", arrayTopPartitions.length), arrayTopPartitions.length == 2); |
| 3442 |
|
| 3443 |
// get children child array_double_large[100-110] |
| 3444 |
IExpressionDMContext arrayDoubleLargeChildExprDMC = arrayTopPartitions[1]; |
| 3445 |
|
| 3446 |
getChildrenCount(arrayDoubleLargeChildExprDMC, 11); |
| 3447 |
|
| 3448 |
String[] expectedValues = new String[11]; |
| 3449 |
for(int i = 0; i < expectedValues.length; ++i) { |
| 3450 |
expectedValues[i] = String.format("array_double_large[%d]", 100 +i); |
| 3451 |
} |
| 3452 |
IExpressionDMContext[] arrayChild = getChildren(arrayDoubleLargeChildExprDMC, expectedValues); |
| 3453 |
|
| 3454 |
// get second level partitions: array_double_large[101][0-99], [100-199], [200-209] |
| 3455 |
IExpressionDMContext arrayDoubleLargeChildExprDMC2 = arrayChild[1]; |
| 3456 |
|
| 3457 |
getChildrenCount(arrayDoubleLargeChildExprDMC2, 3); |
| 3458 |
|
| 3459 |
IExpressionDMContext[] arraySecondLevelPartitions = |
| 3460 |
getChildren(arrayDoubleLargeChildExprDMC2, new String[] {"*((array_double_large[101])+0)@100", |
| 3461 |
"*((array_double_large[101])+100)@100", |
| 3462 |
"*((array_double_large[101])+200)@10"}); |
| 3463 |
assertTrue(String.format("Invalid number of partition: expected 3 got %d", arraySecondLevelPartitions.length), arraySecondLevelPartitions.length == 3); |
| 3464 |
|
| 3465 |
// get children of array_double_large[101][0-99] |
| 3466 |
IExpressionDMContext arrayDoubleLargeChildExprDMC3 = arraySecondLevelPartitions[0]; |
| 3467 |
|
| 3468 |
getChildrenCount(arrayDoubleLargeChildExprDMC3, 100); |
| 3469 |
|
| 3470 |
expectedValues = new String[100]; |
| 3471 |
for(int i = 0; i < expectedValues.length; ++i) { |
| 3472 |
expectedValues[i] = String.format("array_double_large[101][%d]", i); |
| 3473 |
} |
| 3474 |
IExpressionDMContext[] arrayChild2 = getChildren(arrayDoubleLargeChildExprDMC3, expectedValues); |
| 3475 |
|
| 3476 |
// No more children for array_double_large[101][*] |
| 3477 |
for (IExpressionDMContext ctx : arrayChild2) |
| 3478 |
getChildren(ctx, new String[0]); |
| 3479 |
|
| 3480 |
// get some parts of the children array |
| 3481 |
getChildren(arrayDoubleLargeChildExprDMC3, 3, 2, new String[] { "array_double_large[101][3]", "array_double_large[101][4]" }); |
| 3482 |
getChildren(arrayDoubleLargeChildExprDMC3, 98, 3, new String[] { "array_double_large[101][98]","array_double_large[101][99]" }); |
| 3483 |
} |
| 3484 |
|
| 3485 |
/** |
| 3486 |
* This test verifies that "small" double arrays is not affected by partitions. |
| 3487 |
*/ |
| 3488 |
@Test |
| 3489 |
public void testSmallDoubleArray() throws Throwable { |
| 3490 |
MIStoppedEvent stoppedEvent = SyncUtil.runToLocation("testArrays"); |
| 3491 |
|
| 3492 |
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); |
| 3493 |
|
| 3494 |
// int array_double_small[11][21]; |
| 3495 |
IExpressionDMContext arrayDoubleSmallExprDMC = SyncUtil.createExpression(frameDmc, "array_double_small"); |
| 3496 |
|
| 3497 |
getChildrenCount(arrayDoubleSmallExprDMC, 11); |
| 3498 |
|
| 3499 |
// get all children of array_double_small |
| 3500 |
String[] expectedValues = new String[11]; |
| 3501 |
for (int i = 0; i < expectedValues.length; ++i) { |
| 3502 |
expectedValues[i] = String.format("array_double_small[%d]", i); |
| 3503 |
} |
| 3504 |
IExpressionDMContext[] arrayDoubleSmallChildren = getChildren(arrayDoubleSmallExprDMC, expectedValues); |
| 3505 |
|
| 3506 |
// get all children of array_double_small[3] |
| 3507 |
IExpressionDMContext arrayDoubleSmallChildExprDMC = arrayDoubleSmallChildren[3]; |
| 3508 |
|
| 3509 |
getChildrenCount(arrayDoubleSmallChildExprDMC, 21); |
| 3510 |
|
| 3511 |
expectedValues = new String[21]; |
| 3512 |
for (int i = 0; i < expectedValues.length; ++i) { |
| 3513 |
expectedValues[i] = arrayDoubleSmallChildExprDMC.getExpression() + "[" + i +"]"; |
| 3514 |
} |
| 3515 |
IExpressionDMContext[] arrayDoubleSmallGrandChildren = getChildren(arrayDoubleSmallChildExprDMC, expectedValues); |
| 3516 |
|
| 3517 |
// No more children for array_double_small[3][*] |
| 3518 |
for (IExpressionDMContext ctx : arrayDoubleSmallGrandChildren) |
| 3519 |
getChildren(ctx, new String[0]); |
| 3520 |
|
| 3521 |
// get some parts of the children array |
| 3522 |
getChildren(arrayDoubleSmallChildExprDMC, 3, 2, new String[] { "array_double_small[3][3]", "array_double_small[3][4]" }); |
| 3523 |
getChildren(arrayDoubleSmallChildExprDMC, 19, 3, new String[] { "array_double_small[3][19]","array_double_small[3][20]" }); |
| 3524 |
} |
| 3525 |
|
| 3377 |
private int getChildrenCount(final IExpressionDMContext parentDmc, final int expectedCount) throws Throwable { |
3526 |
private int getChildrenCount(final IExpressionDMContext parentDmc, final int expectedCount) throws Throwable { |
| 3378 |
|
3527 |
|
| 3379 |
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); |
3528 |
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); |