Changeset 51838 in vbox for trunk/src/VBox/Runtime/testcase
- Timestamp:
- Jul 3, 2014 11:05:50 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/tstRTDigest-2.cpp
r51821 r51838 102 102 * @param paTests The test table. 103 103 * @param cTests The number of tests in the table. 104 * @param pszDigestName The name of the digest. 104 105 */ 105 static void testGeneric(const char *pszDigestObjId, TESTRTDIGEST const *paTests, size_t cTests )106 static void testGeneric(const char *pszDigestObjId, TESTRTDIGEST const *paTests, size_t cTests, const char *pszDigestName) 106 107 { 108 /* 109 * Execute the tests. 110 */ 111 RTCRDIGEST hDigest; 107 112 for (uint32_t iTest = 0; iTest < cTests; iTest++) 108 113 { … … 110 115 * The whole thing in one go. 111 116 */ 112 RTCRDIGEST hDigest;113 117 RTTESTI_CHECK_RC_RETV(RTCrDigestCreateByObjIdString(&hDigest, pszDigestObjId), VINF_SUCCESS); 114 118 uint32_t const cbHash = RTCrDigestGetHashSize(hDigest); … … 142 146 break; /* No need to test the other permutations if this fails. */ 143 147 } 148 149 RTTESTI_CHECK_RC(RTCrDigestRelease(hDigest), 0); 144 150 } 151 152 /* 153 * Do a quick benchmark. 154 */ 155 RTTESTI_CHECK_RC_RETV(RTCrDigestCreateByObjIdString(&hDigest, pszDigestObjId), VINF_SUCCESS); 156 uint32_t const cChunks = 64; 157 uint32_t cLeft = cChunks; 158 int rc = VINF_SUCCESS; 159 160 uint64_t uStartTS = RTTimeNanoTS(); 161 while (cLeft-- > 0) 162 rc |= RTCrDigestUpdate(hDigest, g_abRandom72KB, sizeof(g_abRandom72KB)); 163 rc |= RTCrDigestFinal(hDigest, NULL, 0); 164 uint64_t cNsElapsed = RTTimeNanoTS() - uStartTS; 165 166 RTTESTI_CHECK(rc == VINF_SUCCESS); 167 168 RTTestIValueF((uint64_t)cChunks * sizeof(g_abRandom72KB) / _1K / (0.000000001 * cNsElapsed), RTTESTUNIT_KILOBYTES_PER_SEC, 169 "%s throughput", pszDigestName); 145 170 } 146 171 … … 341 366 { &g_abRandom72KB[0x20c9], 9991, "bbba194efa81238e5b613e20e937144e", "MD2 8393 bytes @9991" }, 342 367 }; 343 testGeneric("1.2.840.113549.2.2", s_abTests, RT_ELEMENTS(s_abTests) );368 testGeneric("1.2.840.113549.2.2", s_abTests, RT_ELEMENTS(s_abTests), "MD2"); 344 369 } 345 370 … … 540 565 { &g_abRandom72KB[0x20c9], 9991, "6461339c6615d23c704298a313e07cf5", "MD5 8393 bytes @9991" }, 541 566 }; 542 testGeneric("1.2.840.113549.2.5", s_abTests, RT_ELEMENTS(s_abTests) );567 testGeneric("1.2.840.113549.2.5", s_abTests, RT_ELEMENTS(s_abTests), "MD5"); 543 568 } 544 569 … … 719 744 { &g_abRandom72KB[0x20c9], 9991, "62001184bacacce3774566d916055d425a85eba5", "SHA-1 8393 bytes @9991" }, 720 745 }; 721 testGeneric("1.3.14.3.2.26", s_abTests, RT_ELEMENTS(s_abTests) );746 testGeneric("1.3.14.3.2.26", s_abTests, RT_ELEMENTS(s_abTests), "SHA-1"); 722 747 } 723 748 … … 887 912 { &g_abRandom72KB[0x20c9], 9991, "8bd4c6142e36f15385769ebdeb855dcdf542f72d067315472a52ff626946310e", "SHA-256 8393 bytes @9991" }, 888 913 }; 889 testGeneric("2.16.840.1.101.3.4.2.1", s_abTests, RT_ELEMENTS(s_abTests) );914 testGeneric("2.16.840.1.101.3.4.2.1", s_abTests, RT_ELEMENTS(s_abTests), "SHA-256"); 890 915 } 891 916 … … 1055 1080 { &g_abRandom72KB[0x20c9], 9991, "d6ac7c68664df2e34dc6be233b33f8dad196348350b70a4c2c5a78eb54d6e297c819771313d798de7552b7a3cb85370aab25087e189f3be8560d49406ebb6280", "SHA-512 8393 bytes @9991" }, 1056 1081 }; 1057 testGeneric("2.16.840.1.101.3.4.2.3", s_abTests, RT_ELEMENTS(s_abTests) );1082 testGeneric("2.16.840.1.101.3.4.2.3", s_abTests, RT_ELEMENTS(s_abTests), "SHA-512"); 1058 1083 } 1059 1084
Note:
See TracChangeset
for help on using the changeset viewer.