/* Prototype : resource gzopen(string filename, string mode [, int use_include_path]) * Description: Open a .gz-file and return a .gz-file pointer * Source code: ext/zlib/zlib.c * Alias to functions: */ require_once 'gzopen_include_path.inc'; echo "*** Testing gzopen() : variation ***\n"; $thisTestDir = "gzopenVariation5.dir"; mkdir($thisTestDir); chdir($thisTestDir); $newpath = relative_include_path(); set_include_path($newpath); runtest(); $newpath = generate_next_rel_path(); set_include_path($newpath); runtest(); teardown_relative_path(); restore_include_path(); chdir(".."); rmdir($thisTestDir); function runtest() { $tmpfile = 'gzopen_variation5.tmp'; $h = gzopen($tmpfile, "w", true); fwrite($h, "This is the test file"); fclose($h); $h = @gzopen($tmpfile, "r"); if ($h === false) { echo "Not created in working dir\n"; } else { echo "created in working dir\n";
<?php require 'vendor/autoload.php'; use ToolkitTester\TestableConditions; use ToolkitTester\TestableCondition; use ToolkitApi\CW; $conditionsObj = new TestableConditions(); $conditions = $conditionsObj->getConditions(); echo '<style type="text/css"> .success{background-color:green; color:white;} .failure{background-color:red; color:black;}</style>'; foreach ($conditions as $condition) { echo "<b>-------Begin Test-------</b><br>"; echo "Version: " . $condition->getVersion()->getVersion() . "<br>"; echo "Source: " . $condition->getSource()->getSource() . "<br>"; echo "Transport type: " . $condition->getTransportType()->getTransportType() . "<br>"; echo runtest($condition) . "<br>"; echo "<b>-------End Test-------</b><br>"; echo "<br><br>"; } /** * @param TestableCondition $condition * @return mixed */ function runTest(TestableCondition $condition) { // create curl resource $ch = curl_init(); // set url curl_setopt($ch, CURLOPT_URL, "http://10.0.6.2:10088/ToolkitTester/test.php?version=" . $condition->getVersion()->getVersion() . "&source=" . $condition->getSource()->getSource() . "&transportType=" . $condition->getTransportType()->getTransportType()); //return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $output contains the output string
echo "*** Testing fopen() : variation ***\n"; // fopen with interesting windows paths. $includePathDir = getcwd() . '/fopen15.includeDir'; $testDir = 'fopen15.tmpDir'; $absTestDir = getcwd() . '/' . $testDir; $file = "fopen_variation15.tmp"; $unixifiedDir = '/' . substr(str_replace('\\', '/', $absTestDir), 3); $absFile = $absTestDir . '/' . $file; mkdir($testDir); mkdir($includePathDir); set_include_path($includePathDir); $files = array("file://{$testDir}\\{$file}", "file://{$testDir}/{$file}", "file://./{$testDir}/{$file}", "file://.\\{$testDir}\\{$file}", "file://{$absTestDir}/{$file}", "file://{$absTestDir}\\{$file}", "file://{$unixifiedDir}/{$file}"); runtest($files); chdir($testDir); $files = array("file://../{$testDir}/{$file}", "file://..\\{$testDir}\\{$file}", "file://{$absTestDir}/{$file}", "file://{$absTestDir}\\{$file}", "file://{$unixifiedDir}/{$file}"); runtest($files); chdir(".."); rmdir($testDir); rmdir($includePathDir); function runtest($fileURIs) { global $absFile; $iteration = 0; foreach ($fileURIs as $fileURI) { echo "--- READ: {$fileURI} ---\n"; $readData = "read:{$iteration}"; $writeData = "write:{$iteration}"; // create the file and test read $h = fopen($absFile, 'w'); fwrite($h, $readData); fclose($h);
END_PHP )); function runtest( $lang, $source ) { if ($lang == 'php') { return eval($source); } else { $scriptParser = new ISInterpreter(); $parser = new Parser(); $frame = null; //new Frame(); return $scriptParser->evaluate( $source, $parser, $frame ); } } $runs = 10; foreach( $testcases as $testcase ) { foreach( $testcase as $lang => $code ) { $start = microtime( true ); $result = runtest( $lang, $code ); $delta1 = microtime( true ) - $start; for ($i = 1; $i < $runs; $i++) { runtest( $lang, $code ); } $delta = (microtime( true ) - $start) / $runs; printf( "%s: %0.3f ms first, %0.3f ms avg of %d runs\n", $lang, $delta1 * 1000.0, $delta * 1000.0, $runs ); var_dump($result); print "\n"; } }