void stat_counter_index_object_t::test<10>() { LLSimpleStatMMM<U64> m1; typedef LLSimpleStatMMM<U64>::Value lcl_int; lcl_int zero(0); // Freshly-constructed ensure("Constructed MMM<U64> has 0 count", (0 == m1.getCount())); ensure("Constructed MMM<U64> has 0 min", (zero == m1.getMin())); ensure("Constructed MMM<U64> has 0 max", (zero == m1.getMax())); ensure("Constructed MMM<U64> has 0 mean no div-by-zero", (zero == m1.getMean())); // Single insert m1.record(1); ensure("Single insert MMM<U64> has 1 count", (1 == m1.getCount())); ensure("Single insert MMM<U64> has 1 min", (1 == m1.getMin())); ensure("Single insert MMM<U64> has 1 max", (1 == m1.getMax())); ensure("Single insert MMM<U64> has 1 mean", (1 == m1.getMean())); // Second insert m1.record(3); ensure("2nd insert MMM<U64> has 2 count", (2 == m1.getCount())); ensure("2nd insert MMM<U64> has 1 min", (1 == m1.getMin())); ensure("2nd insert MMM<U64> has 3 max", (3 == m1.getMax())); ensure("2nd insert MMM<U64> has 2 mean", (2 == m1.getMean())); // Third insert m1.record(5); ensure("3rd insert MMM<U64> has 3 count", (3 == m1.getCount())); ensure("3rd insert MMM<U64> has 1 min", (1 == m1.getMin())); ensure("3rd insert MMM<U64> has 5 max", (5 == m1.getMax())); ensure("3rd insert MMM<U64> has 3 mean", (3 == m1.getMean())); // Fourth insert m1.record(U64L(1000000000000)); ensure("4th insert MMM<U64> has 4 count", (4 == m1.getCount())); ensure("4th insert MMM<U64> has 1 min", (1 == m1.getMin())); ensure("4th insert MMM<U64> has 1000000000000ULL max", (U64L(1000000000000) == m1.getMax())); ensure("4th insert MMM<U64> has 250000000002ULL mean", (U64L( 250000000002) == m1.getMean())); // Reset m1.reset(); ensure("Reset MMM<U64> has 0 count", (0 == m1.getCount())); ensure("Reset MMM<U64> has 0 min", (zero == m1.getMin())); ensure("Reset MMM<U64> has 0 max", (zero == m1.getMax())); ensure("Reset MMM<U64> has 0 mean no div-by-zero", (zero == m1.getMean())); }
void llsdutil_object::test<1>() { LLSD sd; U64 valueIn , valueOut; valueIn = U64L(0xFEDCBA9876543210); sd = ll_sd_from_U64(valueIn); valueOut = ll_U64_from_sd(sd); ensure_equals("U64 valueIn->sd->valueOut", valueIn, valueOut); }
void namevalue_object_t::test<11>() { //skip_fail("incomplete support for U64."); LLNameValue nValue("SecondLife", "44444444444", "U64", "RW", "SIM"); ensure("getU64 failed",*nValue.getU64() == U64L(44444444444)); // there is no LLNameValue::setU64() }
void namevalue_object_t::test<11>() { skip_fail("incomplete support for U64."); LLNameValue nValue("SecondLife", "44444444444", "U64", "CB", "SIM", NameValueCallbackFunction, (void**) this); ensure("getU64 failed",*nValue.getU64() == U64L(44444444444)); ensure("U64 nonzero failed", nValue.nonzero() == TRUE); // there is no LLNameValue::setU64() }
void namevalue_object_t::test<3>() { LLNameValue nValue("SecondLife", "232324343", "ASSET", "READ_WRITE"); ensure("mName not set correctly", (0 == strcmp(nValue.mName,"SecondLife"))); ensure("getTypeEnum failed", nValue.getTypeEnum() == NVT_ASSET); ensure("getClassEnum failed", nValue.getClassEnum() == NVC_READ_WRITE); ensure("getSendtoEnum failed", nValue.getSendtoEnum() == NVS_SIM); ensure("getString failed", (0==strcmp(nValue.getAsset(),"232324343"))); LLNameValue nValue1("SecondLife", "232324343", "STRING", "READ_WRITE"); ensure("1. mName not set correctly", (0 == strcmp(nValue1.mName,"SecondLife"))); ensure("1. getTypeEnum failed", nValue1.getTypeEnum() == NVT_STRING); ensure("1. getClassEnum failed", nValue1.getClassEnum() == NVC_READ_WRITE); ensure("1. getSendtoEnum failed", nValue1.getSendtoEnum() == NVS_SIM); ensure("1. getString failed", (0==strcmp(nValue1.getString(),"232324343"))); LLNameValue nValue2("SecondLife", "23.5", "F32", "R"); ensure("2. getTypeEnum failed", nValue2.getTypeEnum() == NVT_F32); ensure("2. getClassEnum failed", nValue2.getClassEnum() == NVC_READ_ONLY); ensure("2. getSendtoEnum failed", nValue2.getSendtoEnum() == NVS_SIM); ensure("2. getF32 failed", *nValue2.getF32() == 23.5f); LLNameValue nValue3("SecondLife", "-43456787", "S32", "READ_ONLY"); ensure("3. getTypeEnum failed", nValue3.getTypeEnum() == NVT_S32); ensure("3. getClassEnum failed", nValue3.getClassEnum() == NVC_READ_ONLY); ensure("3. getSendtoEnum failed", nValue3.getSendtoEnum() == NVS_SIM); ensure("3. getS32 failed", *nValue3.getS32() == -43456787); LLNameValue nValue4("SecondLife", "<1.0, 2.0, 3.0>", "VEC3", "RW"); LLVector3 llvec4(1.0, 2.0, 3.0); ensure("4. getTypeEnum failed", nValue4.getTypeEnum() == NVT_VEC3); ensure("4. getClassEnum failed", nValue4.getClassEnum() == NVC_READ_WRITE); ensure("4. getSendtoEnum failed", nValue4.getSendtoEnum() == NVS_SIM); ensure("4. getVec3 failed", *nValue4.getVec3() == llvec4); LLNameValue nValue5("SecondLife", "-1.0, 2.4, 3", "VEC3", "RW"); LLVector3 llvec5(-1.0f, 2.4f, 3); ensure("5. getTypeEnum failed", nValue5.getTypeEnum() == NVT_VEC3); ensure("5. getClassEnum failed", nValue5.getClassEnum() == NVC_READ_WRITE); ensure("5. getSendtoEnum failed", nValue5.getSendtoEnum() == NVS_SIM); ensure("5. getVec3 failed", *nValue5.getVec3() == llvec5); LLNameValue nValue6("SecondLife", "89764323", "U32", "RW"); ensure("6. getTypeEnum failed", nValue6.getTypeEnum() == NVT_U32); ensure("6. getClassEnum failed", nValue6.getClassEnum() == NVC_READ_WRITE); ensure("6. getSendtoEnum failed", nValue6.getSendtoEnum() == NVS_SIM); ensure("6. getU32 failed", *nValue6.getU32() == 89764323); LLNameValue nValue7("SecondLife", "89764323323232", "U64", "RW"); U64 u64_7 = U64L(89764323323232); ensure("7. getTypeEnum failed", nValue7.getTypeEnum() == NVT_U64); ensure("7. getClassEnum failed", nValue7.getClassEnum() == NVC_READ_WRITE); ensure("7. getSendtoEnum failed", nValue7.getSendtoEnum() == NVS_SIM); ensure("7. getU32 failed", *nValue7.getU64() == u64_7); }
void llsdutil_object::test<5>() { LLSD sd; LLVector3d vec1((F64)(U64L(0xFEDCBA9876543210) << 2), -1., 0); sd = ll_sd_from_vector3d(vec1); LLVector3d vec2 = ll_vector3d_from_sd(sd); ensure_equals("vector3d -> sd -> vector3d: 1", vec1, vec2); LLVector3d vec3(sd); ensure_equals("vector3d -> sd -> vector3d : 2", vec1, vec3); }
void HttpPolicy::retryOp(HttpOpRequest * op) { static const HttpTime retry_deltas[] = { 250000, // 1st retry in 0.25 S, etc... 500000, 1000000, 2000000, 5000000 // ... to every 5.0 S. }; static const int delta_max(int(LL_ARRAY_SIZE(retry_deltas)) - 1); static const HttpStatus error_503(503); const HttpTime now(totalTime()); const int policy_class(op->mReqPolicy); HttpTime delta(retry_deltas[llclamp(op->mPolicyRetries, 0, delta_max)]); bool external_delta(false); if (op->mReplyRetryAfter > 0 && op->mReplyRetryAfter < 30) { delta = op->mReplyRetryAfter * U64L(1000000); external_delta = true; } op->mPolicyRetryAt = now + delta; ++op->mPolicyRetries; if (error_503 == op->mStatus) { ++op->mPolicy503Retries; } LL_DEBUGS(LOG_CORE) << "HTTP request " << static_cast<HttpHandle>(op) << " retry " << op->mPolicyRetries << " scheduled in " << (delta / HttpTime(1000)) << " mS (" << (external_delta ? "external" : "internal") << "). Status: " << op->mStatus.toTerseString() << LL_ENDL; if (op->mTracing > HTTP_TRACE_OFF) { LL_INFOS(LOG_CORE) << "TRACE, ToRetryQueue, Handle: " << static_cast<HttpHandle>(op) << ", Delta: " << (delta / HttpTime(1000)) << ", Retries: " << op->mPolicyRetries << LL_ENDL; } mClasses[policy_class]->mRetryQueue.push(op); }
void stat_counter_index_object_t::test<11>() { LLSimpleStatMMM<U64> m1; typedef LLSimpleStatMMM<U64>::Value lcl_int; lcl_int zero(0); // Insert overflowing values const lcl_int bignum(U64L(0xffffffffffffffff) / 2); m1.record(bignum); m1.record(bignum); m1.record(bignum); m1.record(bignum); m1.record(bignum); m1.record(bignum); m1.record(bignum); m1.record(zero); ensure("Overflowed MMM<U64> has 8 count", (8 == m1.getCount())); ensure("Overflowed MMM<U64> has 0 min", (zero == m1.getMin())); ensure("Overflowed MMM<U64> has huge max", (bignum == m1.getMax())); ensure("Overflowed MMM<U64> has fetchable mean", (zero == m1.getMean() || true)); }
void namevalue_object_t::test<2>() { LLNameValue nValue(" SecondLife ASSET RW S 232324343"); ensure("mName not set correctly", (0 == strcmp(nValue.mName,"SecondLife"))); ensure("getTypeEnum failed", nValue.getTypeEnum() == NVT_ASSET); ensure("getClassEnum failed", nValue.getClassEnum() == NVC_READ_WRITE); ensure("getSendtoEnum failed", nValue.getSendtoEnum() == NVS_SIM); ensure("getString failed", (0==strcmp(nValue.getAsset(),"232324343"))); ensure("sendToData or sendToViewer failed", !nValue.sendToData() && !nValue.sendToViewer()); LLNameValue nValue1("\n\r SecondLife_1 STRING READ_WRITE SIM 232324343"); ensure("1. mName not set correctly", (0 == strcmp(nValue1.mName,"SecondLife_1"))); ensure("1. getTypeEnum failed", nValue1.getTypeEnum() == NVT_STRING); ensure("1. getClassEnum failed", nValue1.getClassEnum() == NVC_READ_WRITE); ensure("1. getSendtoEnum failed", nValue1.getSendtoEnum() == NVS_SIM); ensure("1. getString failed", (0==strcmp(nValue1.getString(),"232324343"))); ensure("1. sendToData or sendToViewer failed", !nValue1.sendToData() && !nValue1.sendToViewer()); LLNameValue nValue2("SecondLife", "23.5", "F32", "R", "DS"); ensure("2. getTypeEnum failed", nValue2.getTypeEnum() == NVT_F32); ensure("2. getClassEnum failed", nValue2.getClassEnum() == NVC_READ_ONLY); ensure("2. getSendtoEnum failed", nValue2.getSendtoEnum() == NVS_DATA_SIM); ensure("2. getF32 failed", *nValue2.getF32() == 23.5f); ensure("2. sendToData or sendToViewer failed", nValue2.sendToData() && !nValue2.sendToViewer()); LLNameValue nValue3("SecondLife", "-43456787", "S32", "READ_ONLY", "SIM_SPACE"); ensure("3. getTypeEnum failed", nValue3.getTypeEnum() == NVT_S32); ensure("3. getClassEnum failed", nValue3.getClassEnum() == NVC_READ_ONLY); ensure("3. getSendtoEnum failed", nValue3.getSendtoEnum() == NVS_DATA_SIM); ensure("3. getS32 failed", *nValue3.getS32() == -43456787); ensure("sendToData or sendToViewer failed", nValue3.sendToData() && !nValue3.sendToViewer()); LLNameValue nValue4("SecondLife", "<1.0, 2.0, 3.0>", "VEC3", "RW", "SV"); LLVector3 llvec4(1.0, 2.0, 3.0); ensure("4. getTypeEnum failed", nValue4.getTypeEnum() == NVT_VEC3); ensure("4. getClassEnum failed", nValue4.getClassEnum() == NVC_READ_WRITE); ensure("4. getSendtoEnum failed", nValue4.getSendtoEnum() == NVS_SIM_VIEWER); ensure("4. getVec3 failed", *nValue4.getVec3() == llvec4); ensure("4. sendToData or sendToViewer failed", !nValue4.sendToData() && nValue4.sendToViewer()); LLNameValue nValue5("SecondLife", "-1.0, 2.4, 3", "VEC3", "RW", "SIM_VIEWER"); LLVector3 llvec5(-1.0f, 2.4f, 3); ensure("5. getTypeEnum failed", nValue5.getTypeEnum() == NVT_VEC3); ensure("5. getClassEnum failed", nValue5.getClassEnum() == NVC_READ_WRITE); ensure("5. getSendtoEnum failed", nValue5.getSendtoEnum() == NVS_SIM_VIEWER); ensure("5. getVec3 failed", *nValue5.getVec3() == llvec5); ensure("5. sendToData or sendToViewer failed", !nValue5.sendToData() && nValue5.sendToViewer()); LLNameValue nValue6("SecondLife", "89764323", "U32", "RW", "DSV"); ensure("6. getTypeEnum failed", nValue6.getTypeEnum() == NVT_U32); ensure("6. getClassEnum failed", nValue6.getClassEnum() == NVC_READ_WRITE); ensure("6. getSendtoEnum failed", nValue6.getSendtoEnum() == NVS_DATA_SIM_VIEWER); ensure("6. getU32 failed", *nValue6.getU32() == 89764323); ensure("6. sendToData or sendToViewer failed", nValue6.sendToData() && nValue6.sendToViewer()); LLNameValue nValue7("SecondLife", "89764323323232", "U64", "RW", "SIM_SPACE_VIEWER"); U64 u64_7 = U64L(89764323323232); ensure("7. getTypeEnum failed", nValue7.getTypeEnum() == NVT_U64); ensure("7. getClassEnum failed", nValue7.getClassEnum() == NVC_READ_WRITE); ensure("7. getSendtoEnum failed", nValue7.getSendtoEnum() == NVS_DATA_SIM_VIEWER); ensure("7. getU32 failed", *nValue7.getU64() == u64_7); ensure("7. sendToData or sendToViewer failed", nValue7.sendToData() && nValue7.sendToViewer()); }
/** * @brief generate a random U32 from [0, val) */ U32 janky_fast_random_seeded_bytes(U32 seed, U32 val) { seed = U64L(1664525) * (U64)(seed) + U64L(1013904223); return (U32)(seed) % val; }
/** * @brief generate a random U32 from [0, val) */ U32 janky_fast_random_byes_range(U32 val) { sJankyRandomSeed = U64L(1664525) * sJankyRandomSeed + U64L(1013904223); return (U32)(sJankyRandomSeed) % val; }
/** * @brief generate a random U32. */ U32 janky_fast_random_bytes() { sJankyRandomSeed = U64L(1664525) * sJankyRandomSeed + U64L(1013904223); return (U32)sJankyRandomSeed; }