////////// // // #03 - Delete everything in pieces and in chains // ////// bool iivvmt_testSll4_3(u64 lnHandleLog, SLL4** root) { SLL4Callback cb; u64 lnSha1As64Bit; u32 lnSha1As32Bit; u8 sha20Bytes[20]; u8 context[92]; SLL4* ll4x1; SLL4* ll4x2; SLL4* ll4x3; SLL4* ll4x4; SLL4* ll4x5; SLL4* ll4w1; SLL4* ll4w2; SLL4* ll4e1; SLL4* ll4e2; SLL4* ll4n1; SLL4* ll4n2; SLL4* ll4s1; SLL4* ll4s2; ////////// // Tell them which test we're running ////// vvm_resourcePrintf(IDS_VVM_TEST_SLL4_DELETE); /////////// // Verify we still have our root setup properly ////// // Check w2..root if (!(*root)->west || !(*root)->west->west || !(*root)->west->west->west) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_CORRUPT_ROOT_STRUCTURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Check root..e2 if (!(*root)->east || !(*root)->east->east || (*root)->east->east->east) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_CORRUPT_ROOT_STRUCTURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Check root..n2 if (!(*root)->north || !(*root)->north->north || (*root)->north->north->north) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_CORRUPT_ROOT_STRUCTURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Check root..s2 if (!(*root)->south || !(*root)->south->south || (*root)->south->south->south) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_CORRUPT_ROOT_STRUCTURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Grab w2 by navigation the chain ll4x1 = vvm_ll4_getLastNode(*root, _LL4_WEST); if (ll4x1 != (*root)->west->west->west) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_NAVIGATE_CHAIN); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Grab w2 ll4w2 = ll4x1->east; if (ll4w2 != (*root)->west->west) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_NAVIGATE_CHAIN); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Grab w1 ll4w1 = ll4w2->east; if (ll4w1 != (*root)->west) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_NAVIGATE_CHAIN); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Grab e2 by navigation the chain ll4e2 = vvm_ll4_getLastNode(*root, _LL4_EAST); if (ll4e2 != (*root)->east->east) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_NAVIGATE_CHAIN); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Grab e1 ll4e1 = ll4e2->west; if (ll4e1 != (*root)->east) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_NAVIGATE_CHAIN); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Grab n2 by navigation the chain ll4n2 = vvm_ll4_getLastNode(*root, _LL4_NORTH); if (ll4n2 != (*root)->north->north) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_NAVIGATE_CHAIN); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Grab n1 ll4n1 = ll4n2->south; if (ll4n1 != (*root)->north) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_NAVIGATE_CHAIN); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Grab s2 by navigation the chain ll4s2 = vvm_ll4_getLastNode(*root, _LL4_SOUTH); if (ll4s2 != (*root)->south->south) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_NAVIGATE_CHAIN); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Grab s1 ll4s1 = ll4s2->north; if (ll4s1 != (*root)->south) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_NAVIGATE_CHAIN); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Grab each item down from ll4x1 if (!ll4x1->south || !ll4x1->south->south || !ll4x1->south->south->south || !ll4x1->south->south->south->south) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_NAVIGATE_CHAIN); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } ll4x2 = ll4x1->south; ll4x3 = ll4x2->south; ll4x4 = ll4x3->south; ll4x5 = ll4x4->south; ////////// // Delete x2 ////// vvm_ll4_delete(ll4x2); vvm_sha1ComputeSha1_Start(context); cb._func = (u64)&i3vvmt_testSll4_1_sha1Callback; cb.node = ll4x1; cb.extra1 = (u64)&context[0]; cb.extra2 = (u64)&sha20Bytes[0]; vvm_ll4_iterateViaCallback(&cb, _LL4_SOUTH); cb.node = ll4x5; vvm_ll4_iterateViaCallback(&cb, _LL4_NORTH); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTest2Ll43NodeSha1As64Bit || lnSha1As32Bit != cgnTest2Ll43NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_SHA1_FAILURE_AFTER_DELETE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Delete x5 ////// vvm_ll4_delete(ll4x5); vvm_sha1ComputeSha1_Start(context); cb._func = (u64)&i3vvmt_testSll4_1_sha1Callback; cb.node = ll4x1; vvm_ll4_iterateViaCallback(&cb, _LL4_SOUTH); cb.node = ll4x4; vvm_ll4_iterateViaCallback(&cb, _LL4_NORTH); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTest2Ll44NodeSha1As64Bit || lnSha1As32Bit != cgnTest2Ll44NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_SHA1_FAILURE_AFTER_DELETE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Delete x3 ////// vvm_ll4_delete(ll4x3); vvm_sha1ComputeSha1_Start(context); cb._func = (u64)&i3vvmt_testSll4_1_sha1Callback; cb.node = ll4x1; vvm_ll4_iterateViaCallback(&cb, _LL4_SOUTH); cb.node = ll4x4; vvm_ll4_iterateViaCallback(&cb, _LL4_NORTH); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTest2Ll45NodeSha1As64Bit || lnSha1As32Bit != cgnTest2Ll45NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_SHA1_FAILURE_AFTER_DELETE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Delete x4 ////// vvm_ll4_delete(ll4x4); vvm_sha1ComputeSha1_Start(context); cb._func = (u64)&i3vvmt_testSll4_1_sha1Callback; cb.node = ll4x1; vvm_ll4_iterateViaCallback(&cb, _LL4_SOUTH); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTest2Ll46NodeSha1As64Bit || lnSha1As32Bit != cgnTest2Ll46NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_SHA1_FAILURE_AFTER_DELETE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Delete x1 ////// vvm_ll4_delete(ll4x1); vvm_sha1ComputeSha1_Start(context); cb._func = (u64)&i3vvmt_testSll4_1_sha1Callback; cb.node = ll4e2; vvm_ll4_iterateViaCallback(&cb, _LL4_WEST); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTest2Ll47NodeSha1As64Bit || lnSha1As32Bit != cgnTest2Ll47NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_SHA1_FAILURE_AFTER_DELETE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Delete e2 ////// vvm_ll4_delete(ll4e2); vvm_sha1ComputeSha1_Start(context); cb._func = (u64)&i3vvmt_testSll4_1_sha1Callback; cb.node = ll4e1; vvm_ll4_iterateViaCallback(&cb, _LL4_WEST); cb.node = ll4w2; vvm_ll4_iterateViaCallback(&cb, _LL4_EAST); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTest2Ll48NodeSha1As64Bit || lnSha1As32Bit != cgnTest2Ll48NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_SHA1_FAILURE_AFTER_DELETE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Delete w1 ////// vvm_ll4_delete(ll4w1); vvm_sha1ComputeSha1_Start(context); cb._func = (u64)&i3vvmt_testSll4_1_sha1Callback; cb.node = ll4e1; vvm_ll4_iterateViaCallback(&cb, _LL4_WEST); cb.node = ll4w2; vvm_ll4_iterateViaCallback(&cb, _LL4_EAST); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTest2Ll49NodeSha1As64Bit || lnSha1As32Bit != cgnTest2Ll49NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_SHA1_FAILURE_AFTER_DELETE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Delete e1 and chain east ////// vvm_ll4_deleteChain(&ll4e1, _LL4_EAST); vvm_sha1ComputeSha1_Start(context); cb._func = (u64)&i3vvmt_testSll4_1_sha1Callback; cb.node = *root; vvm_ll4_iterateViaCallback(&cb, _LL4_WEST); cb.node = ll4w2; vvm_ll4_iterateViaCallback(&cb, _LL4_EAST); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTest2Ll410NodeSha1As64Bit || lnSha1As32Bit != cgnTest2Ll410NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_SHA1_FAILURE_AFTER_DELETE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Delete w2 and chain west ////// vvm_ll4_deleteChain(&ll4w2, _LL4_WEST); vvm_sha1ComputeSha1_Start(context); cb._func = (u64)&i3vvmt_testSll4_1_sha1Callback; cb.node = *root; vvm_ll4_iterateViaCallback(&cb, _LL4_WEST); vvm_ll4_iterateViaCallback(&cb, _LL4_EAST); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTest2Ll411NodeSha1As64Bit || lnSha1As32Bit != cgnTest2Ll411NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_SHA1_FAILURE_AFTER_DELETE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Delete n1 and chain north ////// vvm_ll4_deleteChain(&ll4n1, _LL4_NORTH); vvm_sha1ComputeSha1_Start(context); cb._func = (u64)&i3vvmt_testSll4_1_sha1Callback; cb.node = ll4s2; vvm_ll4_iterateViaCallback(&cb, _LL4_NORTH); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTest2Ll412NodeSha1As64Bit || lnSha1As32Bit != cgnTest2Ll412NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_SHA1_FAILURE_AFTER_DELETE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Delete s1 and chain south ////// vvm_ll4_deleteChain(&ll4s1, _LL4_SOUTH); vvm_sha1ComputeSha1_Start(context); cb._func = (u64)&i3vvmt_testSll4_1_sha1Callback; cb.node = *root; vvm_ll4_iterateViaCallback(&cb, _LL4_SOUTH); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTest2Ll413NodeSha1As64Bit || lnSha1As32Bit != cgnTest2Ll413NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_SHA1_FAILURE_AFTER_DELETE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Delete root and chain south ////// vvm_ll4_deleteChain(root, _LL4_SOUTH); if (*root) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_SHA1_FAILURE_AFTER_DELETE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good // If we get here, we're good vvm_resourcePrintf(IDS_VVM_TEST_PASS); return(true); }
////////// // #04 - Search for nodes, attributes, and data ////// bool iivvmt_testBxml_4(u64 lnHandleLog, SBxml* bxml) { u64 lnSha1As64Bit; u32 lnSha1As32Bit, lnCount, lnCountAttributes, lnDataCount; void* x; u8 sha20Bytes[_SHA1_NUMBER_SIZE]; u8 context[_SHA1_CONTEXT_SIZE]; SBxml* bxmlReference; SDatum wildcardSearch; SDatum wildcardSearchAttributes; SDatum wildcardSearchData; SStartEnd bxmlFinds; SStartEnd bxmlaFinds; SStartEnd bxmlDataFinds; ////////// // Tell which test we're running ////// printf("\tSearch nodes, attributes, data..."); ////////// // Initialize ////// wildcardSearch.data._cs8 = cgcTestBxml4FindChildNode; wildcardSearch.length = sizeof(cgcTestBxml4FindChildNode) - 1; wildcardSearchAttributes.data._cs8 = cgcTestBxml4FindAttributes; wildcardSearchAttributes.length = sizeof(cgcTestBxml4FindAttributes) - 1; wildcardSearchData.data._cs8 = cgcTestBxml4FindData; wildcardSearchData.length = sizeof(cgcTestBxml4FindData) - 1; x = NULL; lnCount = -1; lnDataCount = -1; memset(&bxmlFinds, 0, sizeof(bxmlFinds)); memset(&bxmlaFinds, 0, sizeof(bxmlaFinds)); memset(&bxmlDataFinds, 0, sizeof (bxmlDataFinds)); ////////// // Find our first *child* reference ////// if (!vvm_bxmlFindFirst(bxml, &bxmlReference, NULL, &wildcardSearch, true, false, &x)) { // Was not found, error vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } vvm_sha1ComputeSha1(bxmlReference->_name.data._s8, (u32)bxmlReference->_name.length, sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTestBxml41_Sha1As64Bit || lnSha1As32Bit != cgnTestBxml41_Sha1As32Bit) { // The file does not match the expected SHA-1 value vvm_resourcePrintf(IDS_VVM_TEST_BXML_RELOAD_DOES_NOT_MATCH); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } ////////// // Get the count of how many items are found in total ////// u32 lnFinds = 1; while (vvm_bxmlFindContinue(x)) ++lnFinds; // We should've found 13 separate instances throughout looking for "*child*" (includes child, grandchild, ggrandchild, child2, etc.) if (lnFinds != 13) { // The appropriate number was not found vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } ////////// // Get the node and attribute name finds as lists, compute their SHA-1 values ////// vvm_sha1ComputeSha1_Start(context); vvm_bxmlFindAllAsStartEndLists(bxml, &bxmlFinds, NULL, &wildcardSearch, &lnCount, true, true); vvm_bxmlFindAllAsStartEndLists(bxml, NULL, &bxmlaFinds, &wildcardSearchAttributes, &lnCountAttributes, true, true); // Compute SHA-1 of bxml node finds SStartEndCallback cb; cb._func = (u64)&iivvmt_testBxml_computeSha1CallbackBxml; cb.extra = (u64)&context[0]; vvm_SEChain_iterateThroughForCallback(&bxmlFinds, &cb); vvm_SEChain_delete(&bxmlFinds, 0, 0, false); // And continue by computing SHA-1 of bxmla attribute name finds on top of the just computed SHA-1 from bxml node finds cb._func = (u64)&iivvmt_testBxml_computeSha1CallbackBxmla; vvm_SEChain_iterateThroughForCallback(&bxmlaFinds, &cb); vvm_SEChain_delete(&bxmlaFinds, 0, 0, false); // Determine the SHA-1 based on the finds vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, true); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTestBxml42_Sha1As64Bit || lnSha1As32Bit != cgnTestBxml42_Sha1As32Bit) { // The file does not match the expected SHA-1 value vvm_resourcePrintf(IDS_VVM_TEST_BXML_RELOAD_DOES_NOT_MATCH); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } ////////// // Get the attribute data finds as lists, compute their sha1 values ////// vvm_sha1ComputeSha1_Start(context); vvm_bxmlDataFindAllAsStartEndList(bxml, &bxmlaFinds, &wildcardSearchData, &lnDataCount, true); // Compute SHA-1 of bxmla attribute data finds cb._func = (u64)&iivvmt_testBxml_computeSha1CallbackBxmlaData; vvm_SEChain_iterateThroughForCallback(&bxmlDataFinds, &cb); vvm_SEChain_delete(&bxmlDataFinds, 0, 0, false); // Determine the SHA-1 based on the finds vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, true); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTestBxml43_Sha1As64Bit || lnSha1As32Bit != cgnTestBxml43_Sha1As32Bit) { // The file does not match the expected SHA-1 value vvm_resourcePrintf(IDS_VVM_TEST_BXML_RELOAD_DOES_NOT_MATCH); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good vvm_resourcePrintf(IDS_VVM_TEST_PASS); return(true); }
////////// // // The 4-way link-list will be of the w2..e2 and n2..s2 form. This process creates a north/south // chain and inserts it west of w2, calling it x1..x5. After doing this, it deletes x2, then x5, // then x3, then x4, leaving x1. Then it deletes x1, e2, w1, then the chain east from e1, and west // from w2. Then it deletes the chain north from n1, and south from s1, leaving only root. // // ____ north // | n2 | // |____| // | n1 | // ____ ____ ____|____|____ ____ // | x1 | w2 | w1 |root| e1 | e2 | // |____|____|____|____|____|____| // | x2 |west | s1 | east // |____| |____| // | x3 | | s2 | // |____| |____| // | x4 | south // |____| // | x5 | // |____| // ////// bool iivvmt_testSll4_2(u64 lnHandleLog, SLL4* root) { SLL4Callback cb; u64 lnSha1As64Bit; u32 lnSha1As32Bit; u8 sha20Bytes[20]; u8 context[92]; u32 lnCount; SLL4* ll4x1; SLL4* ll4w1; SLL4* ll4w2; SLL4* ll4e1; SLL4* ll4e2; SLL4* ll4n1; SLL4* ll4n2; SLL4* ll4s1; SLL4* ll4s2; ////////// // Tell them which test we're running ////// vvm_resourcePrintf(IDS_VVM_TEST_SLL4_APPEND); /////////// // Verify we still have our root setup properly ////// // Check w2..root if (!root->west || !root->west->west || root->west->west->west) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_CORRUPT_ROOT_STRUCTURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Check root..e2 if (!root->east || !root->east->east || root->east->east->east) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_CORRUPT_ROOT_STRUCTURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Check root..n2 if (!root->north || !root->north->north || root->north->north->north) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_CORRUPT_ROOT_STRUCTURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Check root..s2 if (!root->south || !root->south->south || root->south->south->south) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_CORRUPT_ROOT_STRUCTURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Grab w2 by navigation the chain ll4w2 = vvm_ll4_getLastNode(root, _LL4_WEST); if (ll4w2 != root->west->west) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_NAVIGATE_CHAIN); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Grab w1 ll4w1 = ll4w2->east; if (ll4w1 != root->west) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_NAVIGATE_CHAIN); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Grab e2 by navigation the chain ll4e2 = vvm_ll4_getLastNode(root, _LL4_EAST); if (ll4e2 != root->east->east) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_NAVIGATE_CHAIN); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Grab e1 ll4e1 = ll4e2->west; if (ll4e1 != root->east) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_NAVIGATE_CHAIN); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Grab n2 by navigation the chain ll4n2 = vvm_ll4_getLastNode(root, _LL4_NORTH); if (ll4n2 != root->north->north) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_NAVIGATE_CHAIN); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Grab n1 ll4n1 = ll4n2->south; if (ll4n1 != root->north) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_NAVIGATE_CHAIN); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Grab s2 by navigation the chain ll4s2 = vvm_ll4_getLastNode(root, _LL4_SOUTH); if (ll4s2 != root->south->south) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_NAVIGATE_CHAIN); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Grab s1 ll4s1 = ll4s2->north; if (ll4s1 != root->south) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_NAVIGATE_CHAIN); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } ////////// // Create the chain ////// lnCount = 5; ll4x1 = vvm_ll4_createChain(cgnLl4BufferSize, &lnCount, _LL4_SOUTH); if (lnCount != 5 || !ll4x1) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_CREATE_CHAIN); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } ////////// // Populate the chain with known data ////// cb._func = (u64)&i3vvmt_testSll4_initiallyPopulateCallback; cb.node = ll4x1; cb.extra1 = (u64)&context[0]; cb.extra2 = (u64)&sha20Bytes[0]; vvm_ll4_iterateViaCallback(&cb, _LL4_SOUTH); ////////// // Validate that it was setup and populated correctly ////// vvm_sha1ComputeSha1_Start(context); cb._func = (u64)&i3vvmt_testSll4_1_sha1Callback; cb.node = ll4x1; vvm_ll4_iterateViaCallback(&cb, _LL4_SOUTH); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTest2Ll41NodeSha1As64Bit || lnSha1As32Bit != cgnTest2Ll41NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_SHA1_FAILURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Attach x1 onto w2's west, and validate it's on there good ////// vvm_ll4_insertWestEast(ll4x1, ll4w2, false); vvm_sha1ComputeSha1_Start(context); cb._func = (u64)&i3vvmt_testSll4_1_sha1Callback; cb.node = ll4e2; vvm_ll4_iterateViaCallback(&cb, _LL4_WEST); cb.node = ll4x1; vvm_ll4_iterateViaCallback(&cb, _LL4_SOUTH); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTest2Ll42NodeSha1As64Bit || lnSha1As32Bit != cgnTest2Ll42NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_SHA1_FAILURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good // If we get here, we're good, only root remains vvm_resourcePrintf(IDS_VVM_TEST_PASS); return(true); }
////////// // // The 4-way link-list test builds everything off the root. It first adds the "2" nodes, // which initially occupy the positions immediate off root. It then adds the "1" nodes, which // are inserted between the "2" nodes and root in each direction. // // ____ north // | n2 | // |____| // | n1 | // ____ ____|____|____ ____ // | w2 | w1 |root| e1 | e2 | // |____|____|____|____|____| // west | s1 | east // |____| // | s2 | // |____| // south ////// bool iivvmt_testSll4_1(u64 lnHandleLog, SLL4** root) { SLL4Callback cb; u64 lnSha1As64Bit; u32 lnSha1As32Bit; u8 sha20Bytes[20]; u8 context[92]; SLL4* nodeNorth2; SLL4* nodeSouth2; SLL4* nodeWest2; SLL4* nodeEast2; SLL4* nodeNorth1; SLL4* nodeSouth1; SLL4* nodeWest1; SLL4* nodeEast1; ////////// // Tell them which test we're running ////// vvm_resourcePrintf(IDS_VVM_TEST_SLL4_CREATE); ////////// // Create a single node ////// *root = i3vvmt_testSll4_1_createSll4(cgnLl4BufferSize); if (!*root) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_CREATE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // Initialize our callback data cb._func = (u64)&i3vvmt_testSll4_1_sha1Callback; cb.extra1 = (u64)&context[0]; cb.extra2 = (u64)&sha20Bytes[0]; ////////// // Determine the SHA-1 on that one node ////// vvm_sha1ComputeSha1_Start(context); cb.node = *root; vvm_ll4_iterateViaCallback(&cb, _LL4_EAST); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTest1Ll41NodeSha1As64Bit || lnSha1As32Bit != cgnTest1Ll41NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_SHA1_FAILURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Create a node to go to the west ////// nodeWest2 = i3vvmt_testSll4_1_createSll4(cgnLl4BufferSize); if (!nodeWest2) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_CREATE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } ////////// // Create a node to go to the east ////// nodeEast2 = i3vvmt_testSll4_1_createSll4(cgnLl4BufferSize); if (!nodeEast2) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_CREATE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } ////////// // Create a node to go to the north ////// nodeNorth2 = i3vvmt_testSll4_1_createSll4(cgnLl4BufferSize); if (!nodeNorth2) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_CREATE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } ////////// // Create a node to go to the south ////// nodeSouth2 = i3vvmt_testSll4_1_createSll4(cgnLl4BufferSize); if (!nodeSouth2) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_CREATE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } ////////// // Insert the node to the west ////// vvm_ll4_insertWestEast(nodeWest2, *root, false); ////////// // Determine the SHA-1 on the two nodes ////// vvm_sha1ComputeSha1_Start(context); cb.node = nodeWest2; vvm_ll4_iterateViaCallback(&cb, _LL4_EAST); cb.node = *root; vvm_ll4_iterateViaCallback(&cb, _LL4_WEST); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTest1Ll42NodeSha1As64Bit || lnSha1As32Bit != cgnTest1Ll42NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_SHA1_FAILURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Insert the node to the east ////// vvm_ll4_insertWestEast(nodeEast2, *root, true); ////////// // Determine the SHA-1 on the three nodes ////// vvm_sha1ComputeSha1_Start(context); cb.node = nodeWest2; vvm_ll4_iterateViaCallback(&cb, _LL4_EAST); cb.node = nodeEast2; vvm_ll4_iterateViaCallback(&cb, _LL4_WEST); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTest1Ll43NodeSha1As64Bit || lnSha1As32Bit != cgnTest1Ll43NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_SHA1_FAILURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Insert the node to the north ////// vvm_ll4_insertNorthSouth(nodeNorth2, *root, false); ////////// // Determine the SHA-1 on the two nodes ////// vvm_sha1ComputeSha1_Start(context); cb.node = nodeNorth2; vvm_ll4_iterateViaCallback(&cb, _LL4_SOUTH); cb.node = *root; vvm_ll4_iterateViaCallback(&cb, _LL4_NORTH); cb.node = nodeWest2; vvm_ll4_iterateViaCallback(&cb, _LL4_EAST); cb.node = nodeEast2; vvm_ll4_iterateViaCallback(&cb, _LL4_WEST); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTest1Ll44NodeSha1As64Bit || lnSha1As32Bit != cgnTest1Ll44NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_SHA1_FAILURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Insert the node to the south ////// vvm_ll4_insertNorthSouth(nodeSouth2, *root, true); ////////// // Determine the SHA-1 on the three nodes ////// vvm_sha1ComputeSha1_Start(context); cb.node = nodeNorth2; vvm_ll4_iterateViaCallback(&cb, _LL4_SOUTH); cb.node = nodeSouth2; vvm_ll4_iterateViaCallback(&cb, _LL4_NORTH); cb.node = nodeWest2; vvm_ll4_iterateViaCallback(&cb, _LL4_EAST); cb.node = nodeEast2; vvm_ll4_iterateViaCallback(&cb, _LL4_WEST); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTest1Ll45NodeSha1As64Bit || lnSha1As32Bit != cgnTest1Ll45NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_SHA1_FAILURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Create a node to go to the west ////// nodeWest1 = i3vvmt_testSll4_1_createSll4(cgnLl4BufferSize); if (!nodeWest1) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_CREATE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } ////////// // Create a node to go to the east ////// nodeEast1 = i3vvmt_testSll4_1_createSll4(cgnLl4BufferSize); if (!nodeEast1) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_CREATE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } ////////// // Create a node to go to the north ////// nodeNorth1 = i3vvmt_testSll4_1_createSll4(cgnLl4BufferSize); if (!nodeNorth1) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_CREATE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } ////////// // Create a node to go to the south ////// nodeSouth1 = i3vvmt_testSll4_1_createSll4(cgnLl4BufferSize); if (!nodeSouth1) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_UNABLE_TO_CREATE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } ////////// // Insert the node to the west ////// vvm_ll4_insertWestEast(nodeWest1, *root, false); ////////// // Determine the SHA-1 on the two nodes ////// vvm_sha1ComputeSha1_Start(context); cb.node = nodeNorth2; vvm_ll4_iterateViaCallback(&cb, _LL4_SOUTH); cb.node = nodeSouth2; vvm_ll4_iterateViaCallback(&cb, _LL4_NORTH); cb.node = nodeWest2; vvm_ll4_iterateViaCallback(&cb, _LL4_EAST); cb.node = nodeEast2; vvm_ll4_iterateViaCallback(&cb, _LL4_WEST); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTest1Ll46NodeSha1As64Bit || lnSha1As32Bit != cgnTest1Ll46NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_SHA1_FAILURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Insert the node to the east ////// vvm_ll4_insertWestEast(nodeEast1, *root, true); ////////// // Determine the SHA-1 on the three nodes ////// vvm_sha1ComputeSha1_Start(context); cb.node = nodeNorth2; vvm_ll4_iterateViaCallback(&cb, _LL4_SOUTH); cb.node = nodeSouth2; vvm_ll4_iterateViaCallback(&cb, _LL4_NORTH); cb.node = nodeWest2; vvm_ll4_iterateViaCallback(&cb, _LL4_EAST); cb.node = nodeEast2; vvm_ll4_iterateViaCallback(&cb, _LL4_WEST); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTest1Ll47NodeSha1As64Bit || lnSha1As32Bit != cgnTest1Ll47NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_SHA1_FAILURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Insert the node to the north ////// vvm_ll4_insertNorthSouth(nodeNorth1, *root, false); ////////// // Determine the SHA-1 on the two nodes ////// vvm_sha1ComputeSha1_Start(context); cb.node = nodeNorth2; vvm_ll4_iterateViaCallback(&cb, _LL4_SOUTH); cb.node = nodeSouth2; vvm_ll4_iterateViaCallback(&cb, _LL4_NORTH); cb.node = nodeWest2; vvm_ll4_iterateViaCallback(&cb, _LL4_EAST); cb.node = nodeEast2; vvm_ll4_iterateViaCallback(&cb, _LL4_WEST); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTest1Ll48NodeSha1As64Bit || lnSha1As32Bit != cgnTest1Ll48NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_SHA1_FAILURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Insert the node to the south ////// vvm_ll4_insertNorthSouth(nodeSouth1, *root, true); ////////// // Determine the SHA-1 on the three nodes ////// vvm_sha1ComputeSha1_Start(context); cb.node = nodeNorth2; vvm_ll4_iterateViaCallback(&cb, _LL4_SOUTH); cb.node = nodeSouth2; vvm_ll4_iterateViaCallback(&cb, _LL4_NORTH); cb.node = nodeWest2; vvm_ll4_iterateViaCallback(&cb, _LL4_EAST); cb.node = nodeEast2; vvm_ll4_iterateViaCallback(&cb, _LL4_WEST); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTest1Ll49NodeSha1As64Bit || lnSha1As32Bit != cgnTest1Ll49NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL4_SHA1_FAILURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good // If we get here, we're good vvm_resourcePrintf(IDS_VVM_TEST_PASS); return(true); }
bool iivvmt_testSll_3(u64 lnHandleLog, SLL** root) { SLLCallback cb; u64 lnSha1As64Bit; u32 lnSha1As32Bit; u8 sha20Bytes[20]; u8 context[92]; SLL* nodePrev; ////////// // Tell them which test we're running ////// vvm_resourcePrintf(IDS_VVM_TEST_SLL_DELETE); ////////// // Prepare for our callbacks ////// cb._func = (u64)&i3vvmt_testSll_1_sha1Callback; cb.node = (*root)->prev; cb.extra1 = (u64)&context[0]; cb.extra2 = (u64)&sha20Bytes[0]; ////////// // Delete the first node ////// vvm_ll_delete((*root)->prev->prev); ////////// // Determine the SHA-1 on that one node ////// vvm_sha1ComputeSha1_Start(context); vvm_ll_iterateViaCallback(&cb); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTestLl8NodeSha1As64Bit || lnSha1As32Bit != cgnTestLl8NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL_SHA1_FAILURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Delete the last node ////// vvm_ll_delete((*root)->next->next); ////////// // Determine the SHA-1 on that one node ////// vvm_sha1ComputeSha1_Start(context); cb.node = (*root)->prev; vvm_ll_iterateViaCallback(&cb); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTestLl9NodeSha1As64Bit || lnSha1As32Bit != cgnTestLl9NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL_SHA1_FAILURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Delete the last node ////// // Get what will become the new root, which is the first item nodePrev = (*root)->prev; // Delete the middle node vvm_ll_delete(*root); // Store the new root *root = nodePrev; ////////// // Determine the SHA-1 on the remaining two nodes going forward ////// vvm_sha1ComputeSha1_Start(context); cb.node = nodePrev; vvm_ll_iterateViaCallback(&cb); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTestLl10NodeSha1As64Bit || lnSha1As32Bit != cgnTestLl10NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL_SHA1_FAILURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Determine the SHA-1 on the remaining two nodes going backward ////// vvm_sha1ComputeSha1_Start(context); cb.node = nodePrev->next; vvm_ll_iterateBackwardViaCallback(&cb); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTestLl11NodeSha1As64Bit || lnSha1As32Bit != cgnTestLl11NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL_SHA1_FAILURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good // If we get here, we're good vvm_resourcePrintf(IDS_VVM_TEST_PASS); return(true); }
////////// // // This test adds the "1" nodes, which make the former "1" nodes become "2" nodes, as they are // 2 hops away from root. // ____ ____ ____ ____ ____ // | p2 | p1 |root| n1 | n2 | // |____|____|____|____|____| // ////// bool iivvmt_testSll_2(u64 lnHandleLog, SLL* root) { SLLCallback cb; u64 lnSha1As64Bit; u32 lnSha1As32Bit; u8 sha20Bytes[20]; u8 context[92]; SLL* nodePrev; SLL* nodeNext; ////////// // Tell them which test we're running ////// vvm_resourcePrintf(IDS_VVM_TEST_SLL_APPEND); ////////// // Prepare for our callbacks ////// cb._func = (u64)&i3vvmt_testSll_1_sha1Callback; cb.node = root->prev; cb.extra1 = (u64)&context[0]; cb.extra2 = (u64)&sha20Bytes[0]; ////////// // Create a node to go before ////// nodePrev = i3vvmt_testSll_1_createSll(cgnLlBufferSize); if (!nodePrev) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL_UNABLE_TO_CREATE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } ////////// // Create a node to go after ////// nodeNext = i3vvmt_testSll_1_createSll(cgnLlBufferSize); if (!nodeNext) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL_UNABLE_TO_CREATE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } ////////// // Insert the node after ////// vvm_ll_insert(nodeNext, root, true); ////////// // Determine the SHA-1 on that one node ////// vvm_sha1ComputeSha1_Start(context); vvm_ll_iterateViaCallback(&cb); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTestLl5NodeSha1As64Bit || lnSha1As32Bit != cgnTestLl5NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL_SHA1_FAILURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Insert the node before ////// vvm_ll_insert(nodePrev, root, false); ////////// // Determine the SHA-1 on that one node ////// vvm_sha1ComputeSha1_Start(context); cb.node = nodePrev->prev; vvm_ll_iterateViaCallback(&cb); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTestLl6NodeSha1As64Bit || lnSha1As32Bit != cgnTestLl6NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL_SHA1_FAILURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good ////////// // Determine the SHA-1 on that one node ////// vvm_sha1ComputeSha1_Start(context); cb.node = nodeNext->next; vvm_ll_iterateBackwardViaCallback(&cb); vvm_sha1ComputeSha1_FinishAsSha1(context, sha20Bytes, false); vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As64Bit = vvm_sha1Compute64BitFromSha1(sha20Bytes); lnSha1As32Bit = vvm_sha1Compute32BitFromSha1(sha20Bytes); if (lnSha1As64Bit != cgnTestLl7NodeSha1As64Bit || lnSha1As32Bit != cgnTestLl7NodeSha1As32Bit) { // Failure vvm_resourcePrintf(IDS_VVM_TEST_SLL_SHA1_FAILURE); vvm_resourcePrintf(IDS_VVM_TEST_FAIL); return(false); } // If we get here, we're good // If we get here, we're good vvm_resourcePrintf(IDS_VVM_TEST_PASS); return(true); }
bool iivvmt_testSha1_1(u64 lnHandleLog) { // Used for test #3 u32 lnI; u8 context[96]; ////////// // Tell them which test we're running ////// vvm_resourcePrintf(IDS_VVM_TEST_SHA1_FIPS_PUB_180_1); ////////// // "abc" // A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D ////// vvm_resourcePrintf(IDS_VVM_1DOTDOTDOT); vvm_sha1ComputeSha1AsHex((s8*)cgc_Test_Sha1_1_1, sizeof(cgc_Test_Sha1_1_1) - 1, cgc_Test_Sha1_1_3, true);; if (vvm_memicmp(_csu8p(cgc_Test_Sha1_1_2), _csu8p(cgc_Test_Sha1_1_3), sizeof(cgc_Test_Sha1_1_2) - 1) != 0) { failure: // Error vvm_resourcePrintf(IDS_VVM_TEST_FAIL); // Indicate we failed return false; } ////////// // "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" // 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1 ////// vvm_resourcePrintf(IDS_VVM_2DOTDOTDOT); vvm_sha1ComputeSha1AsHex((s8*)cgc_Test_Sha1_2_1, sizeof(cgc_Test_Sha1_2_1) - 1, cgc_Test_Sha1_2_3, true);; if (vvm_memicmp(_csu8p(cgc_Test_Sha1_2_2), _csu8p(cgc_Test_Sha1_2_3), sizeof(cgc_Test_Sha1_2_2) - 1) != 0) goto failure; // Failure ////////// // A million repetitions of "a" // 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F ////// vvm_resourcePrintf(IDS_VVM_3DOTDOTDOT); // Initialize vvm_sha1ComputeSha1_Start(context); // Process one million lower-case "a" characters in succession, one at a time for (lnI = 0; lnI < 1000000; lnI++) vvm_sha1ComputeSha1_ProcessThisData(context, (s8*)cgc_Test_Sha1_3_1, sizeof(cgc_Test_Sha1_3_1) - 1); // Finalize and compute the value a hex vvm_sha1ComputeSha1_FinishAsHex(context, cgc_Test_Sha1_3_3, true, true); if (vvm_memicmp(_csu8p(cgc_Test_Sha1_3_2), _csu8p(cgc_Test_Sha1_3_3), sizeof(cgc_Test_Sha1_3_2) - 1) != 0) goto failure; // Failure // If we get here, we're good vvm_resourcePrintf(IDS_VVM_TEST_PASS); return(true); }