Skip to content

Commit 4e31d3c

Browse files
committed
[MERGE #5325 @dilijev] Fix rl timeout override
Merge pull request #5325 from dilijev:fix-rl-timeout
2 parents fed9437 + cbbea35 commit 4e31d3c

File tree

1 file changed

+92
-73
lines changed

1 file changed

+92
-73
lines changed

bin/rl/rl.cpp

Lines changed: 92 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -3514,102 +3514,121 @@ FindTest(
35143514
}
35153515

35163516
BOOL
3517-
IsTimeoutStringValid(const char *strTimeout) {
3518-
char *end;
3519-
_set_errno(0);
3517+
IsTimeoutStringValid(const char *strTimeout)
3518+
{
3519+
char *end;
3520+
_set_errno(0);
35203521

3521-
uint32 secTimeout = strtoul(strTimeout, &end, 10);
3522+
uint32 secTimeout = strtoul(strTimeout, &end, 10);
35223523

3523-
if (errno != 0 || *end != 0) {
3524-
return FALSE;
3525-
}
3524+
if (errno != 0 || *end != 0)
3525+
{
3526+
return FALSE;
3527+
}
35263528

3527-
// Check to see if the value is too large and would cause overflow
3529+
// Check to see if the value is too large and would cause overflow
35283530

3529-
// Do the multiplication using 64-bit unsigned math.
3530-
unsigned __int64 millisecTimeout = 1000ui64 * static_cast<unsigned __int64>(secTimeout);
3531+
// Do the multiplication using 64-bit unsigned math.
3532+
unsigned __int64 millisecTimeout = 1000ui64 * static_cast<unsigned __int64>(secTimeout);
35313533

3532-
// Does the result fit in 32-bits?
3533-
if (millisecTimeout >= (1ui64 << 32)) {
3534-
return FALSE;
3535-
}
3534+
// Does the result fit in 32-bits?
3535+
if (millisecTimeout >= (1ui64 << 32))
3536+
{
3537+
return FALSE;
3538+
}
35363539

3537-
return TRUE;
3540+
return TRUE;
3541+
}
3542+
3543+
uint32 GetTimeoutValue(const char *strTimeout)
3544+
{
3545+
if (strTimeout == nullptr)
3546+
{
3547+
return 0;
3548+
}
3549+
3550+
char *end = nullptr;
3551+
_set_errno(0);
3552+
uint32 secTimeout = strtoul(strTimeout, &end, 10);
3553+
return secTimeout;
35383554
}
35393555

35403556
BOOL
35413557
GetTestInfoFromNode
35423558
(
3543-
const char * fileName,
3544-
Xml::Node * node,
3545-
TestInfo * testInfo
3559+
const char * fileName,
3560+
Xml::Node * node,
3561+
TestInfo * testInfo
35463562
)
35473563
{
3548-
if (node == NULL)
3549-
{
3550-
return TRUE;
3551-
}
3552-
3553-
for (int i = 0; i < _TIK_COUNT; i++)
3554-
{
3555-
Xml::Node * childNode = node->GetChild(TestInfoKindName[i]);
3556-
if (childNode != NULL)
3557-
{
3558-
testInfo->hasData[i] = TRUE;
3559-
if (i == TIK_ENV)
3560-
{
3561-
ASSERT(childNode->ChildList != NULL);
3562-
testInfo->data[i] = (char*)childNode;
3563-
}
3564-
else
3565-
{
3566-
if (childNode->ChildList != NULL)
3567-
{
3568-
CFG_ERROR_EX(fileName, node->LineNumber,
3569-
"Expected data, not child list\n", NULL);
3570-
childNode->Dump();
3571-
return FALSE;
3572-
}
3564+
if (node == nullptr)
3565+
{
3566+
return TRUE;
3567+
}
35733568

3574-
if (childNode->Data != NULL && childNode->Data[0] != '\0')
3569+
for (int i = 0; i < _TIK_COUNT; i++)
3570+
{
3571+
Xml::Node * childNode = node->GetChild(TestInfoKindName[i]);
3572+
if (childNode != nullptr)
3573+
{
3574+
testInfo->hasData[i] = TRUE;
3575+
if (i == TIK_ENV)
35753576
{
3576-
char * data = childNode->Data;
3577-
if (i == TIK_SOURCE_PATH && IsRelativePath(childNode->Data))
3578-
{
3579-
// Make sure sourcepath is not relative, if relative make it full path
3580-
data = MakeFullPath(fileName, data);
3581-
ASSERT(data != NULL);
3582-
}
3583-
testInfo->data[i] = data;
3577+
ASSERT(childNode->ChildList != nullptr);
3578+
testInfo->data[i] = (char*)childNode;
35843579
}
35853580
else
35863581
{
3587-
testInfo->data[i] = NULL;
3582+
if (childNode->ChildList != nullptr)
3583+
{
3584+
CFG_ERROR_EX(fileName, node->LineNumber,
3585+
"Expected data, not child list\n", nullptr);
3586+
childNode->Dump();
3587+
return FALSE;
3588+
}
3589+
3590+
if (childNode->Data != nullptr && childNode->Data[0] != '\0')
3591+
{
3592+
char * data = childNode->Data;
3593+
if (i == TIK_SOURCE_PATH && IsRelativePath(childNode->Data))
3594+
{
3595+
// Make sure sourcepath is not relative, if relative make it full path
3596+
data = MakeFullPath(fileName, data);
3597+
ASSERT(data != nullptr);
3598+
}
3599+
testInfo->data[i] = data;
3600+
}
3601+
else
3602+
{
3603+
testInfo->data[i] = nullptr;
3604+
}
3605+
3606+
if (i == TIK_TIMEOUT)
3607+
{
3608+
// Validate the timeout string now to fail early so we don't run any tests when there is an error.
3609+
if (!IsTimeoutStringValid(testInfo->data[i])) {
3610+
CFG_ERROR_EX(fileName, node->LineNumber,
3611+
"Invalid timeout specified. Cannot parse or too large.\n", nullptr);
3612+
childNode->Dump();
3613+
return FALSE;
3614+
}
3615+
}
35883616
}
3617+
}
35893618

3590-
if (i == TIK_TIMEOUT)
3619+
if (i == TIK_TIMEOUT && TestTimeout != nullptr)
3620+
{
3621+
// Overriding the timeout value with the command line value (if the command line value is larger)
3622+
uint32 xmlTimeoutValue = GetTimeoutValue(testInfo->data[i]);
3623+
uint32 testTimeoutValue = GetTimeoutValue(TestTimeout);
3624+
if (xmlTimeoutValue < testTimeoutValue)
35913625
{
3592-
// Validate the timeout string now to fail early so we don't run any tests when there is an error.
3593-
if (!IsTimeoutStringValid(testInfo->data[i])) {
3594-
CFG_ERROR_EX(fileName, node->LineNumber,
3595-
"Invalid timeout specified. Cannot parse or too large.\n", NULL);
3596-
childNode->Dump();
3597-
return FALSE;
3598-
}
3626+
testInfo->data[i] = TestTimeout;
35993627
}
3600-
}
3601-
}
3602-
if (i == TIK_TIMEOUT && TestTimeout != NULL)
3603-
{
3604-
// Overriding the timeout value with the command line value (if the command line value is larger)
3605-
if (testInfo->data[i] < TestTimeout)
3606-
{
3607-
testInfo->data[i] = TestTimeout;
3608-
}
3609-
}
3610-
}
3628+
}
3629+
}
36113630

3612-
return TRUE;
3631+
return TRUE;
36133632
}
36143633

36153634
BOOL

0 commit comments

Comments
 (0)