2018-12-11 15:48:50 +01:00
|
|
|
<?php
|
|
|
|
|
2019-12-18 16:45:20 +01:00
|
|
|
$rc = 0;
|
|
|
|
$numTestedExtensions = 0;
|
2019-12-27 14:56:03 +01:00
|
|
|
$nameMap = [
|
2019-12-18 16:45:20 +01:00
|
|
|
'opcache' => 'Zend OPcache',
|
2020-05-24 18:40:31 +02:00
|
|
|
'apcu_bc' => 'apc',
|
2019-12-27 14:56:03 +01:00
|
|
|
];
|
2019-12-27 10:17:59 +01:00
|
|
|
$testsDir = __DIR__ . '/tests';
|
|
|
|
function runTest($testFile)
|
|
|
|
{
|
|
|
|
return include $testFile;
|
|
|
|
}
|
|
|
|
|
2019-12-18 16:45:20 +01:00
|
|
|
for ($index = 1, $count = isset($argv) ? count($argv) : 0; $index < $count; $index++) {
|
|
|
|
$numTestedExtensions++;
|
|
|
|
$rcThis = 1;
|
|
|
|
$extension = $argv[$index];
|
|
|
|
if ($extension === '') {
|
|
|
|
fprintf(STDERR, "Missing extension handle.\n");
|
2019-09-27 17:29:02 +02:00
|
|
|
} else {
|
2019-12-18 16:45:20 +01:00
|
|
|
$extensionLowerCase = strtolower($extension);
|
|
|
|
if (isset($nameMap[$extensionLowerCase])) {
|
|
|
|
$extension = $nameMap[$extensionLowerCase];
|
|
|
|
}
|
|
|
|
if (!extension_loaded($extension)) {
|
|
|
|
fprintf(STDERR, sprintf("Extension not loaded: %s\n", $extension));
|
|
|
|
} else {
|
2019-12-27 14:56:03 +01:00
|
|
|
$testFile = "{$testsDir}/{$extension}.php";
|
2019-12-27 10:17:59 +01:00
|
|
|
if (is_file($testFile)) {
|
|
|
|
try {
|
|
|
|
if (runTest($testFile) === true) {
|
|
|
|
fprintf(STDOUT, sprintf("Extension tested successfully: %s\n", $extension));
|
2019-12-27 14:56:03 +01:00
|
|
|
$rcThis = 0;
|
2019-12-27 10:17:59 +01:00
|
|
|
} else {
|
|
|
|
fprintf(STDERR, sprintf("Extension test failed: %s\n", $extension));
|
|
|
|
}
|
|
|
|
} catch (Exception $x) {
|
|
|
|
fprintf(STDERR, sprintf("Extension test failed: %s (%s)\n", $extension, $x->getMessage()));
|
|
|
|
} catch (Throwable $x) {
|
|
|
|
fprintf(STDERR, sprintf("Extension test failed: %s (%s)\n", $extension, $x->getMessage()));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
fprintf(STDOUT, sprintf("Extension correctly loaded: %s\n", $extension));
|
|
|
|
$rcThis = 0;
|
|
|
|
}
|
2019-12-18 16:45:20 +01:00
|
|
|
}
|
2019-09-27 17:29:02 +02:00
|
|
|
}
|
2019-12-18 16:45:20 +01:00
|
|
|
if ($rcThis !== 0) {
|
|
|
|
$rc = $rcThis;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($numTestedExtensions === 0) {
|
|
|
|
fprintf(STDERR, "No extension handles specified.\n");
|
|
|
|
$rc = 1;
|
2018-12-11 15:48:50 +01:00
|
|
|
}
|
|
|
|
|
2019-09-27 17:29:02 +02:00
|
|
|
exit($rc);
|