mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 369034 - TestTXMgr has error and leaks object; (Dv1) Fix and reorder printf()s.
r=peterv.
This commit is contained in:
parent
5c2f8c4d8c
commit
8168d78122
@ -1066,7 +1066,7 @@ quick_test(TestTransactionFactory *factory)
|
||||
result = mgr->SetMaxTransactionCount(10);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
printf("ERROR: SetMaxTransactionCount(0) failed. (%d)\n", result);
|
||||
printf("ERROR: SetMaxTransactionCount(10) failed. (%d)\n", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1421,7 +1421,7 @@ quick_test(TestTransactionFactory *factory)
|
||||
result = mgr->GetNumberOfRedoItems(&numitems);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
printf("ERROR: GetNumberOfRedoItems() on empty redo stack failed. (%d)\n",
|
||||
printf("ERROR: GetNumberOfRedoItems() on redo stack with 4 items failed. (%d)\n",
|
||||
result);
|
||||
return result;
|
||||
}
|
||||
@ -1530,7 +1530,7 @@ quick_test(TestTransactionFactory *factory)
|
||||
result = mgr->GetNumberOfRedoItems(&numitems);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
printf("ERROR: GetNumberOfRedoItems() on redo stack with 0 items failed. (%d)\n",
|
||||
printf("ERROR: GetNumberOfRedoItems() on empty redo stack failed. (%d)\n",
|
||||
result);
|
||||
return result;
|
||||
}
|
||||
@ -1611,7 +1611,7 @@ quick_test(TestTransactionFactory *factory)
|
||||
result = mgr->GetNumberOfRedoItems(&numitems);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
printf("ERROR: GetNumberOfRedoItems() on empty cleared stack failed. (%d)\n",
|
||||
printf("ERROR: GetNumberOfRedoItems() on cleared redo stack failed. (%d)\n",
|
||||
result);
|
||||
return result;
|
||||
}
|
||||
@ -2067,7 +2067,7 @@ quick_test(TestTransactionFactory *factory)
|
||||
result = mgr->GetNumberOfRedoItems(&numitems);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
printf("ERROR: GetNumberOfRedoItems() on empty redo stack. (%d)\n",
|
||||
printf("ERROR: GetNumberOfRedoItems() on redo stack with 2 items failed. (%d)\n",
|
||||
result);
|
||||
return result;
|
||||
}
|
||||
@ -2106,7 +2106,7 @@ quick_test(TestTransactionFactory *factory)
|
||||
}
|
||||
|
||||
if (numitems != 0) {
|
||||
printf("ERROR: GetNumberOfUndoItems() expected 1 got %d. (%d)\n",
|
||||
printf("ERROR: GetNumberOfUndoItems() expected 0 got %d. (%d)\n",
|
||||
numitems, result);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -2158,7 +2158,7 @@ quick_test(TestTransactionFactory *factory)
|
||||
}
|
||||
|
||||
if (numitems != 0) {
|
||||
printf("ERROR: GetNumberOfUndoItems() expected 1 got %d. (%d)\n",
|
||||
printf("ERROR: GetNumberOfUndoItems() expected 0 got %d. (%d)\n",
|
||||
numitems, result);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -2193,7 +2193,7 @@ quick_test(TestTransactionFactory *factory)
|
||||
result = mgr->SetMaxTransactionCount(-1);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
printf("ERROR: SetMaxTransactionCount(0) failed. (%d)\n", result);
|
||||
printf("ERROR: SetMaxTransactionCount(-1) failed. (%d)\n", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -2226,14 +2226,14 @@ quick_test(TestTransactionFactory *factory)
|
||||
result = mgr->GetNumberOfUndoItems(&numitems);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
printf("ERROR: GetNumberOfUndoItems() on empty undo stack failed. (%d)\n",
|
||||
result);
|
||||
printf("ERROR: GetNumberOfUndoItems() on undo stack with %d items failed. (%d)\n",
|
||||
i, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (numitems != i) {
|
||||
printf("ERROR: GetNumberOfUndoItems() expected 1 got %d. (%d)\n",
|
||||
numitems, result);
|
||||
printf("ERROR: GetNumberOfUndoItems() expected %d got %d. (%d)\n",
|
||||
i, numitems, result);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@ -2406,7 +2406,7 @@ quick_test(TestTransactionFactory *factory)
|
||||
result = mgr->SetMaxTransactionCount(15);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
printf("ERROR: SetMaxTransactionCount(25) failed. (%d)\n", result);
|
||||
printf("ERROR: SetMaxTransactionCount(15) failed. (%d)\n", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -2441,13 +2441,13 @@ quick_test(TestTransactionFactory *factory)
|
||||
result = mgr->GetNumberOfUndoItems(&numitems);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
printf("ERROR: GetNumberOfUndoItems() on undo stack with 10 items failed. (%d)\n",
|
||||
printf("ERROR: GetNumberOfUndoItems() on undo stack with 5 items failed. (%d)\n",
|
||||
result);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (numitems != 5) {
|
||||
printf("ERROR: GetNumberOfUndoItems() expected 10 got %d. (%d)\n",
|
||||
printf("ERROR: GetNumberOfUndoItems() expected 5 got %d. (%d)\n",
|
||||
numitems, result);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -2501,7 +2501,7 @@ quick_test(TestTransactionFactory *factory)
|
||||
result = mgr->SetMaxTransactionCount(5);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
printf("ERROR: SetMaxTransactionCount(25) failed. (%d)\n", result);
|
||||
printf("ERROR: SetMaxTransactionCount(5) failed. (%d)\n", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -2575,7 +2575,7 @@ quick_test(TestTransactionFactory *factory)
|
||||
result = mgr->SetMaxTransactionCount(-1);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
printf("ERROR: SetMaxTransactionCount(0) failed. (%d)\n", result);
|
||||
printf("ERROR: SetMaxTransactionCount(-1) failed. (%d)\n", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -2608,14 +2608,14 @@ quick_test(TestTransactionFactory *factory)
|
||||
result = mgr->GetNumberOfUndoItems(&numitems);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
printf("ERROR: GetNumberOfUndoItems() on empty undo stack failed. (%d)\n",
|
||||
result);
|
||||
printf("ERROR: GetNumberOfUndoItems() on undo stack with %d items failed. (%d)\n",
|
||||
i, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (numitems != i) {
|
||||
printf("ERROR: GetNumberOfUndoItems() expected 1 got %d. (%d)\n",
|
||||
numitems, result);
|
||||
printf("ERROR: GetNumberOfUndoItems() expected %d got %d. (%d)\n",
|
||||
i, numitems, result);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@ -2645,7 +2645,7 @@ quick_test(TestTransactionFactory *factory)
|
||||
result = mgr->GetNumberOfUndoItems(&numitems);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
printf("ERROR: GetNumberOfUndoItems() on empty undo stack with 10 items failed. (%d)\n",
|
||||
printf("ERROR: GetNumberOfUndoItems() on undo stack with 10 items failed. (%d)\n",
|
||||
result);
|
||||
return result;
|
||||
}
|
||||
@ -2719,12 +2719,12 @@ simple_test()
|
||||
*
|
||||
*******************************************************************/
|
||||
|
||||
SimpleTransactionFactory factory;
|
||||
|
||||
printf("\n-----------------------------------------------------\n");
|
||||
printf("- Begin Simple Transaction Test:\n");
|
||||
printf("-----------------------------------------------------\n");
|
||||
|
||||
SimpleTransactionFactory factory;
|
||||
|
||||
return quick_test(&factory);
|
||||
}
|
||||
|
||||
@ -2749,12 +2749,12 @@ aggregation_test()
|
||||
*
|
||||
*******************************************************************/
|
||||
|
||||
AggregateTransactionFactory factory(3,2);
|
||||
|
||||
printf("\n-----------------------------------------------------\n");
|
||||
printf("- Begin Aggregate Transaction Test:\n");
|
||||
printf("-----------------------------------------------------\n");
|
||||
|
||||
AggregateTransactionFactory factory(3, 2);
|
||||
|
||||
return quick_test(&factory);
|
||||
}
|
||||
|
||||
@ -3274,7 +3274,7 @@ quick_batch_test(TestTransactionFactory *factory)
|
||||
}
|
||||
|
||||
if (numitems != 2) {
|
||||
printf("ERROR: GetNumberOfUndoItems() expected 1 got %d. (%d)\n",
|
||||
printf("ERROR: GetNumberOfUndoItems() expected 2 got %d. (%d)\n",
|
||||
numitems, result);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -3369,7 +3369,7 @@ quick_batch_test(TestTransactionFactory *factory)
|
||||
}
|
||||
|
||||
if (numitems != 0) {
|
||||
printf("ERROR: GetNumberOfRedoItems() expected 2 got %d. (%d)\n",
|
||||
printf("ERROR: GetNumberOfRedoItems() expected 0 got %d. (%d)\n",
|
||||
numitems, result);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -3609,7 +3609,7 @@ quick_batch_test(TestTransactionFactory *factory)
|
||||
result = mgr->GetNumberOfRedoItems(&numitems);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
printf("ERROR: GetNumberOfRedoItems() on redo stack with 1 items failed. (%d)\n",
|
||||
printf("ERROR: GetNumberOfRedoItems() on redo stack with 1 item failed. (%d)\n",
|
||||
result);
|
||||
return result;
|
||||
}
|
||||
@ -3692,7 +3692,7 @@ quick_batch_test(TestTransactionFactory *factory)
|
||||
result = mgr->GetNumberOfRedoItems(&numitems);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
printf("ERROR: GetNumberOfRedoItems() on redo stack with 1 items failed. (%d)\n",
|
||||
printf("ERROR: GetNumberOfRedoItems() on redo stack with 1 item failed. (%d)\n",
|
||||
result);
|
||||
return result;
|
||||
}
|
||||
@ -3804,13 +3804,13 @@ quick_batch_test(TestTransactionFactory *factory)
|
||||
result = mgr->GetNumberOfUndoItems(&numitems);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
printf("ERROR: GetNumberOfUndoItems() on undo stack with 5 items failed. (%d)\n",
|
||||
printf("ERROR: GetNumberOfUndoItems() on undo stack with 1 item failed. (%d)\n",
|
||||
result);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (numitems != 1) {
|
||||
printf("ERROR: GetNumberOfUndoItems() expected 5 got %d. (%d)\n",
|
||||
printf("ERROR: GetNumberOfUndoItems() expected 1 got %d. (%d)\n",
|
||||
numitems, result);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -3818,7 +3818,7 @@ quick_batch_test(TestTransactionFactory *factory)
|
||||
result = mgr->GetNumberOfRedoItems(&numitems);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
printf("ERROR: GetNumberOfRedoItems() on empty redo stack. (%d)\n",
|
||||
printf("ERROR: GetNumberOfRedoItems() on redo stack with 1 item failed. (%d)\n",
|
||||
result);
|
||||
return result;
|
||||
}
|
||||
@ -4128,7 +4128,7 @@ quick_batch_test(TestTransactionFactory *factory)
|
||||
result = mgr->GetNumberOfRedoItems(&numitems);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
printf("ERROR: GetNumberOfRedoItems() on empty redo stack. (%d)\n",
|
||||
printf("ERROR: GetNumberOfRedoItems() on redo stack with 2 items failed. (%d)\n",
|
||||
result);
|
||||
return result;
|
||||
}
|
||||
@ -4167,7 +4167,7 @@ quick_batch_test(TestTransactionFactory *factory)
|
||||
}
|
||||
|
||||
if (numitems != 0) {
|
||||
printf("ERROR: GetNumberOfUndoItems() expected 1 got %d. (%d)\n",
|
||||
printf("ERROR: GetNumberOfUndoItems() expected 0 got %d. (%d)\n",
|
||||
numitems, result);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -4233,7 +4233,7 @@ quick_batch_test(TestTransactionFactory *factory)
|
||||
}
|
||||
|
||||
if (numitems != 0) {
|
||||
printf("ERROR: GetNumberOfUndoItems() expected 1 got %d. (%d)\n",
|
||||
printf("ERROR: GetNumberOfUndoItems() expected 0 got %d. (%d)\n",
|
||||
numitems, result);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -4314,14 +4314,14 @@ quick_batch_test(TestTransactionFactory *factory)
|
||||
result = mgr->GetNumberOfUndoItems(&numitems);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
printf("ERROR: GetNumberOfUndoItems() on empty undo stack failed. (%d)\n",
|
||||
result);
|
||||
printf("ERROR: GetNumberOfUndoItems() on undo stack with %d items failed. (%d)\n",
|
||||
i, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (numitems != i) {
|
||||
printf("ERROR: GetNumberOfUndoItems() expected 1 got %d. (%d)\n",
|
||||
numitems, result);
|
||||
printf("ERROR: GetNumberOfUndoItems() expected %d got %d. (%d)\n",
|
||||
i, numitems, result);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@ -4426,12 +4426,12 @@ simple_batch_test()
|
||||
*
|
||||
*******************************************************************/
|
||||
|
||||
SimpleTransactionFactory factory;
|
||||
|
||||
printf("\n-----------------------------------------------------\n");
|
||||
printf("- Begin Batch Transaction Test:\n");
|
||||
printf("-----------------------------------------------------\n");
|
||||
|
||||
SimpleTransactionFactory factory;
|
||||
|
||||
return quick_batch_test(&factory);
|
||||
}
|
||||
|
||||
@ -4456,12 +4456,12 @@ aggregation_batch_test()
|
||||
*
|
||||
*******************************************************************/
|
||||
|
||||
AggregateTransactionFactory factory(3,2,BATCH_FLAG);
|
||||
|
||||
printf("\n-----------------------------------------------------\n");
|
||||
printf("- Begin Batch Aggregate Transaction Test:\n");
|
||||
printf("-----------------------------------------------------\n");
|
||||
|
||||
AggregateTransactionFactory factory(3, 2, BATCH_FLAG);
|
||||
|
||||
return quick_batch_test(&factory);
|
||||
}
|
||||
|
||||
@ -4472,15 +4472,15 @@ aggregation_batch_test()
|
||||
nsresult
|
||||
stress_test(TestTransactionFactory *factory, PRInt32 iterations)
|
||||
{
|
||||
printf("Stress test (may take a while) ... ");
|
||||
fflush(stdout);
|
||||
|
||||
/*******************************************************************
|
||||
*
|
||||
* Create a transaction manager:
|
||||
*
|
||||
*******************************************************************/
|
||||
|
||||
printf("Stress test (may take a while) ... ");
|
||||
fflush(stdout);
|
||||
|
||||
PRInt32 i, j;
|
||||
nsCOMPtr<nsITransactionManager> mgr;
|
||||
nsITransaction *tx = 0;
|
||||
@ -4503,21 +4503,22 @@ stress_test(TestTransactionFactory *factory, PRInt32 iterations)
|
||||
TestTransaction *tximpl = factory->create(mgr, NONE_FLAG);
|
||||
|
||||
if (!tximpl) {
|
||||
printf("ERROR: Failed to allocate transaction %d.\n", j);
|
||||
printf("ERROR: Failed to allocate transaction %d-%d.\n", i, j);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
tx = 0;
|
||||
result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx);
|
||||
if (NS_FAILED(result)) {
|
||||
printf("ERROR: QueryInterface() failed for transaction %d. (%d)\n",
|
||||
i, result);
|
||||
printf("ERROR: QueryInterface() failed for transaction %d-%d. (%d)\n",
|
||||
i, j, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = mgr->DoTransaction(tx);
|
||||
if (NS_FAILED(result)) {
|
||||
printf("ERROR: Failed to execute transaction %d. (%d)\n", i, result);
|
||||
printf("ERROR: Failed to execute transaction %d-%d. (%d)\n",
|
||||
i, j, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -4605,12 +4606,12 @@ simple_stress_test()
|
||||
*
|
||||
*******************************************************************/
|
||||
|
||||
SimpleTransactionFactory factory;
|
||||
|
||||
printf("\n-----------------------------------------------------\n");
|
||||
printf("- Simple Transaction Stress Test:\n");
|
||||
printf("-----------------------------------------------------\n");
|
||||
|
||||
SimpleTransactionFactory factory;
|
||||
|
||||
//
|
||||
// 1500 iterations sends 1,125,750 transactions through the system!!
|
||||
//
|
||||
@ -4634,12 +4635,12 @@ aggregation_stress_test()
|
||||
*
|
||||
*******************************************************************/
|
||||
|
||||
AggregateTransactionFactory factory(3,4);
|
||||
|
||||
printf("\n-----------------------------------------------------\n");
|
||||
printf("- Aggregate Transaction Stress Test:\n");
|
||||
printf("-----------------------------------------------------\n");
|
||||
|
||||
AggregateTransactionFactory factory(3, 4);
|
||||
|
||||
//
|
||||
// 500 iterations sends 2,630,250 transactions through the system!!
|
||||
//
|
||||
@ -4663,12 +4664,12 @@ aggregation_batch_stress_test()
|
||||
*
|
||||
*******************************************************************/
|
||||
|
||||
AggregateTransactionFactory factory(3,4,BATCH_FLAG);
|
||||
|
||||
printf("\n-----------------------------------------------------\n");
|
||||
printf("- Aggregate Batch Transaction Stress Test:\n");
|
||||
printf("-----------------------------------------------------\n");
|
||||
|
||||
AggregateTransactionFactory factory(3, 4, BATCH_FLAG);
|
||||
|
||||
//
|
||||
// 500 iterations sends 2,630,250 transactions through the system!!
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user