Skip to content

run-tests: use the EXTENSIONS section for skipping #6787

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

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 2 additions & 4 deletions ext/sodium/tests/bug78114.phpt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
--TEST--
Bug #78114 (segfault when calling sodium_* functions from eval)
--SKIPIF--
<?php
if (!extension_loaded('sodium')) die('skip sodium extension not available');
?>
--EXTENSIONS--
sodium
--FILE--
<?php
try {
Expand Down
3 changes: 2 additions & 1 deletion ext/sodium/tests/bug78516.phpt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
--TEST--
Bug #78516 (password_hash(): Memory cost is not in allowed range)
--EXTENSIONS--
sodium
--SKIPIF--
<?php
if (!extension_loaded('sodium')) die('skip sodium extension not available');
if (!defined('PASSWORD_ARGON2ID')) die('skip PASSWORD_ARGON2ID not available');
?>
--FILE--
Expand Down
3 changes: 2 additions & 1 deletion ext/sodium/tests/crypto_aead.phpt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
--TEST--
Check for libsodium AEAD
--EXTENSIONS--
sodium
--SKIPIF--
<?php
if (!extension_loaded("sodium")) print "skip extension not loaded";
if (!defined('SODIUM_CRYPTO_AEAD_AES256GCM_NPUBBYTES')) print "skip libsodium without AESGCM";
?>
--FILE--
Expand Down
4 changes: 2 additions & 2 deletions ext/sodium/tests/crypto_auth.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Check for libsodium auth
--SKIPIF--
<?php if (!extension_loaded("sodium")) print "skip"; ?>
--EXTENSIONS--
sodium
--FILE--
<?php
$msg = random_bytes(1000);
Expand Down
4 changes: 2 additions & 2 deletions ext/sodium/tests/crypto_box.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Check for libsodium box
--SKIPIF--
<?php if (!extension_loaded("sodium")) print "skip"; ?>
--EXTENSIONS--
sodium
--FILE--
<?php
$keypair = sodium_crypto_box_keypair();
Expand Down
4 changes: 2 additions & 2 deletions ext/sodium/tests/crypto_generichash.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Check for libsodium generichash
--SKIPIF--
<?php if (!extension_loaded("sodium")) print "skip"; ?>
--EXTENSIONS--
sodium
--FILE--
<?php
$q = sodium_crypto_generichash('msg');
Expand Down
4 changes: 2 additions & 2 deletions ext/sodium/tests/crypto_hex.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Check for libsodium bin2hex
--SKIPIF--
<?php if (!extension_loaded("sodium")) print "skip"; ?>
--EXTENSIONS--
sodium
--FILE--
<?php
$bin = random_bytes(random_int(1, 1000));
Expand Down
4 changes: 2 additions & 2 deletions ext/sodium/tests/crypto_kdf.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Check for libsodium KDF
--SKIPIF--
<?php if (!extension_loaded("sodium")) print "skip"; ?>
--EXTENSIONS--
sodium
--FILE--
<?php
$key = sodium_crypto_kdf_keygen();
Expand Down
4 changes: 2 additions & 2 deletions ext/sodium/tests/crypto_kx.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Check for libsodium-based key exchange
--SKIPIF--
<?php if (!extension_loaded("sodium")) print "skip"; ?>
--EXTENSIONS--
sodium
--FILE--
<?php
$client_seed = sodium_hex2bin('0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef');
Expand Down
4 changes: 2 additions & 2 deletions ext/sodium/tests/crypto_scalarmult.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Check for libsodium scalarmult
--SKIPIF--
<?php if (!extension_loaded("sodium")) print "skip"; ?>
--EXTENSIONS--
sodium
--FILE--
<?php
$n = sodium_hex2bin("5dab087e624a8a4b79e17f8b83800ee66f3bb1292618b6fd1c2f8b27ff88e0eb");
Expand Down
4 changes: 2 additions & 2 deletions ext/sodium/tests/crypto_secretbox.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Check for libsodium secretbox
--SKIPIF--
<?php if (!extension_loaded("sodium")) print "skip"; ?>
--EXTENSIONS--
sodium
--FILE--
<?php
$nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
Expand Down
3 changes: 2 additions & 1 deletion ext/sodium/tests/crypto_secretstream.phpt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
--TEST--
Check for libsodium secretstream
--EXTENSIONS--
sodium
--SKIPIF--
<?php
if (!extension_loaded("sodium")) print "skip extension not loaded";
if (!defined('SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_ABYTES')) print "skip libsodium without secretbytes";
?>
--FILE--
Expand Down
4 changes: 2 additions & 2 deletions ext/sodium/tests/crypto_shorthash.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Check for libsodium shorthash
--SKIPIF--
<?php if (!extension_loaded("sodium")) print "skip"; ?>
--EXTENSIONS--
sodium
--FILE--
<?php
$m1 = 'message';
Expand Down
4 changes: 2 additions & 2 deletions ext/sodium/tests/crypto_sign.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Check for libsodium ed25519 signatures
--SKIPIF--
<?php if (!extension_loaded("sodium")) print "skip"; ?>
--EXTENSIONS--
sodium
--FILE--
<?php
$keypair = sodium_crypto_sign_keypair();
Expand Down
4 changes: 2 additions & 2 deletions ext/sodium/tests/crypto_stream.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Check for libsodium stream
--SKIPIF--
<?php if (!extension_loaded("sodium")) print "skip"; ?>
--EXTENSIONS--
sodium
--FILE--
<?php
$nonce = random_bytes(SODIUM_CRYPTO_STREAM_NONCEBYTES);
Expand Down
4 changes: 2 additions & 2 deletions ext/sodium/tests/exception_trace_without_args.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
SodiumException backtraces do not contain function arguments
--SKIPIF--
<?php if (!extension_loaded("sodium")) print "skip"; ?>
--EXTENSIONS--
sodium
--FILE--
<?php

Expand Down
4 changes: 2 additions & 2 deletions ext/sodium/tests/inc_add.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
increment and add edge cases
--SKIPIF--
<?php if (!extension_loaded("sodium")) print "skip"; ?>
--EXTENSIONS--
sodium
--FILE--
<?php

Expand Down
4 changes: 2 additions & 2 deletions ext/sodium/tests/installed.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Check for sodium presence
--SKIPIF--
<?php if (!extension_loaded("sodium")) print "skip"; ?>
--EXTENSIONS--
sodium
--FILE--
<?php
echo "sodium extension is available";
Expand Down
4 changes: 3 additions & 1 deletion ext/sodium/tests/pwhash_argon2i.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
--TEST--
Check for libsodium argon2i
--EXTENSIONS--
sodium
--SKIPIF--
<?php if (!extension_loaded("sodium")) print "skip";
<?php
if (!defined('SODIUM_CRYPTO_PWHASH_SALTBYTES')) print "skip libsodium without argon2i"; ?>
--FILE--
<?php
Expand Down
4 changes: 3 additions & 1 deletion ext/sodium/tests/pwhash_scrypt.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
--TEST--
Check for libsodium scrypt
--EXTENSIONS--
sodium
--SKIPIF--
<?php if (!extension_loaded("sodium")) print "skip";
<?php
if (!defined('SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_SALTBYTES')) print "skip libsodium without scrypt"; ?>
--FILE--
<?php
Expand Down
4 changes: 2 additions & 2 deletions ext/sodium/tests/sodium_error_001.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
TypeErrors will not contain param values in backtrace
--SKIPIF--
<?php if (!extension_loaded("sodium")) die("skip ext/sodium required"); ?>
--EXTENSIONS--
sodium
--FILE--
<?php
declare(strict_types=1);
Expand Down
4 changes: 2 additions & 2 deletions ext/sodium/tests/utils.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Check for libsodium utils
--SKIPIF--
<?php if (!extension_loaded("sodium")) print "skip"; ?>
--EXTENSIONS--
sodium
--FILE--
<?php
$a = 'test';
Expand Down
4 changes: 2 additions & 2 deletions ext/sodium/tests/version.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Check for libsodium version
--SKIPIF--
<?php if (!extension_loaded("sodium")) print "skip"; ?>
--EXTENSIONS--
sodium
--FILE--
<?php
echo strlen(SODIUM_LIBRARY_VERSION) >= 5;
Expand Down
15 changes: 13 additions & 2 deletions run-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -2057,15 +2057,26 @@ function run_test(string $php, $file, array $env): string
$extensions = preg_split("/[\n\r]+/", trim($test->getSection('EXTENSIONS')));
[$ext_dir, $loaded] = $skipCache->getExtensions("$php $pass_options $extra_options $ext_params $no_file_cache");
$ext_prefix = IS_WINDOWS ? "php_" : "";
$missing = [];
foreach ($extensions as $req_ext) {
if (!in_array($req_ext, $loaded)) {
if ($req_ext == 'opcache') {
$ini_settings['zend_extension'][] = $ext_dir . DIRECTORY_SEPARATOR . $ext_prefix . $req_ext . '.' . PHP_SHLIB_SUFFIX;
$ext_file = $ext_dir . DIRECTORY_SEPARATOR . $ext_prefix . $req_ext . '.' . PHP_SHLIB_SUFFIX;
$ini_settings['zend_extension'][] = $ext_file;
} else {
$ini_settings['extension'][] = $ext_dir . DIRECTORY_SEPARATOR . $ext_prefix . $req_ext . '.' . PHP_SHLIB_SUFFIX;
$ext_file = $ext_dir . DIRECTORY_SEPARATOR . $ext_prefix . $req_ext . '.' . PHP_SHLIB_SUFFIX;
$ini_settings['extension'][] = $ext_file;
}
if (!is_readable($ext_file)) {
$missing[] = $req_ext;
}
}
}
if ($missing) {
$message = 'Required extension' . (count($missing) > 1 ? 's' : '')
. ' missing: ' . implode(', ', $missing);
return skip_test($tested, $tested_file, $shortname, $message);
}
}

// additional ini overwrites
Expand Down
10 changes: 0 additions & 10 deletions tests/run-test/bug75042-2.phpt

This file was deleted.

13 changes: 0 additions & 13 deletions tests/run-test/bug75042-3.phpt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
--TEST--
phpt EXTENSIONS directive with shared module
phpt EXTENSIONS directive - shared module
--EXTENSIONS--
openssl
--SKIPIF--
<?php
$php = getenv('TEST_PHP_EXECUTABLE');
Expand All @@ -8,8 +10,7 @@ if (false !== stripos(`$php -n -m`, 'openssl')) {
}
$ext_module = ini_get('extension_dir') . DIRECTORY_SEPARATOR . (substr(PHP_OS, 0, 3) === "WIN" ? "php_openssl." : "openssl.") . PHP_SHLIB_SUFFIX;
if( !file_exists($ext_module) ) die('skip openssl shared extension not found');
--EXTENSIONS--
openssl

--FILE--
<?php
var_dump(extension_loaded('openssl'));
Expand Down
9 changes: 9 additions & 0 deletions tests/run-test/extensions-static.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--TEST--
phpt EXTENSIONS directive - static extension is present
--EXTENSIONS--
standard
--FILE--
<?php
var_dump(extension_loaded('standard'));
--EXPECT--
bool(true)