Used constants in memory stress tests for easier configuration (#1022)

This commit is contained in:
Jenny Tam 2019-08-20 12:38:09 -07:00 committed by GitHub
parent aa03782638
commit eb8ecbf6f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 68 additions and 4 deletions

View file

@ -76,11 +76,13 @@ def gen_XML(logfile, number, logfilename):
# Generating the xml report.
if logfilename is True:
file = open(filename + '.xml', 'w')
report = filename
else:
file = open('nativeresult' + str(number) + '.xml', 'w')
report = 'Native Tests'
file.write('<?xml version="1.0" encoding="UTF-8" ?>' + os.linesep)
file.write('<testsuite tests="' + str(num - 1) + '" failures="' + str(failnum) + '" name="Native Tests" >' + os.linesep)
file.write('<testsuite tests="' + str(num - 1) + '" failures="' + str(failnum) + '" name="' + report + '" >' + os.linesep)
index = 1
for test in tests_list:

View file

@ -11,6 +11,10 @@ PHPT_EXEC=true
<?php
include 'MsCommon.inc';
const _NUM_PASSES = 20;
const _NUM_ROWS1 = 10;
const _NUM_ROWS2 = 15;
function MemCheck($noPasses, $noRows1, $noRows2, $startStep, $endStep, $leakThreshold)
{
include 'MsSetup.inc';
@ -135,6 +139,18 @@ function ExecTest($noPasses, $noRows, $startStep, $endStep, $tableName, $conn, $
Trace("$i. Fetch\t - ");
break;
case 4: // fetchAll
Trace("$i. FetchAll\t - ");
break;
case 5: // fetch object
trace("$i. Fetch Object\t - ");
break;
case 6: // fetch column
trace("$i. Fetch Column\t - ");
break;
default:
break;
}
@ -198,6 +214,48 @@ function RunTest($noPasses, $noRows, $tableName, $conn, $prepared, $mode)
}
break;
case 4: // fetchAll
$stmt = ExecuteQueryEx($conn, $tsql, ($prepared ? false : true));
$fldCount = $stmt->columnCount();
$result = $stmt->fetchAll();
$rowCount = count($result);
unset($result);
$stmt->closeCursor();
unset($stmt);
if ($rowCount != $noRows) {
die("$rowCount rows retrieved instead of $noRows\n");
}
break;
case 5: // fetchObject
$stmt = ExecuteQueryEx($conn, $tsql, ($prepared ? false : true));
$fldCount = $stmt->columnCount();
while ($obj = $stmt->fetchObject()) {
unset($obj);
$rowCount++;
}
$stmt->closeCursor();
unset($stmt);
if ($rowCount != $noRows) {
die("$rowCount rows retrieved instead of $noRows\n");
}
break;
case 6: // fetchColumn
$stmt = ExecuteQueryEx($conn, $tsql, ($prepared ? false : true));
$fldCount = $stmt->columnCount();
// Check for "false" to terminate because fetchColumn may return NULL
while (($result = $stmt->fetchColumn()) !== false) {
unset($result);
$rowCount++;
}
$stmt->closeCursor();
unset($stmt);
if ($rowCount != $noRows) {
die("$rowCount rows retrieved instead of $noRows\n");
}
break;
default:
break;
@ -228,7 +286,7 @@ function Repro()
{
try
{
MemCheck(20, 10, 15, 1, 3, 0);
MemCheck(_NUM_PASSES, _NUM_ROWS1, _NUM_ROWS2, 1, 6, 0);
}
catch (Exception $e)
{

View file

@ -7,11 +7,15 @@ emalloc (which only allocate memory in the memory space allocated for the PHP pr
PHPT_EXEC=true
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
<?php require('skipif_azure.inc'); ?>
<?php require('skipif_azure_dw.inc'); ?>
--FILE--
<?php
require_once('MsCommon.inc');
const _NUM_PASSES = 20;
const _NUM_ROWS1 = 10;
const _NUM_ROWS2 = 15;
function memCheck($noPasses, $noRows1, $noRows2, $startStep, $endStep)
{
$testName = "Memory Leakage Check";
@ -337,7 +341,7 @@ function runTest($noPasses, $noRows, $tableName, $conn, $prepared, $release, $mo
}
try {
memCheck(20, 10, 15, 1, 7);
memCheck(_NUM_PASSES, _NUM_ROWS1, _NUM_ROWS2, 1, 7);
} catch (Exception $e) {
echo $e->getMessage();
}