Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Used constants in memory stress tests for easier configuration #1022

Merged
merged 4 commits into from
Aug 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion test/functional/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
60 changes: 59 additions & 1 deletion test/functional/pdo_sqlsrv/PDO81_MemoryCheck.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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)
{
Expand Down
8 changes: 6 additions & 2 deletions test/functional/sqlsrv/TC81_MemoryCheck.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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();
}
Expand Down