Skip to content

Commit

Permalink
Skip tests using memory limit when zend mm not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
dixyes committed Nov 29, 2024
1 parent 57b5b1d commit 87b4651
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 4 deletions.
7 changes: 7 additions & 0 deletions ext/tests/swow_coroutine/edge_case_of_kill_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ swow_coroutine: edge case of kill
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.php';

if (memory_get_usage() == 0) {
// zend mm not enabled, skip test
exit("SKIP: zend mm not enabled");
}
?>
--INI--
memory_limit=32M
--FILE--
<?php
require __DIR__ . '/../include/bootstrap.php';
Expand Down
7 changes: 7 additions & 0 deletions ext/tests/swow_coroutine/edge_case_of_kill_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ swow_coroutine: edge case of kill
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.php';

if (memory_get_usage() == 0) {
// zend mm not enabled, skip test
exit("SKIP: zend mm not enabled");
}
?>
--INI--
memory_limit=32M
--FILE--
<?php
require __DIR__ . '/../include/bootstrap.php';
Expand Down
11 changes: 10 additions & 1 deletion ext/tests/swow_coroutine/in_shutdown/bailout_in_main.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ swow_coroutine: bailout in main
--SKIPIF--
<?php
require __DIR__ . '/../../include/skipif.php';

if (memory_get_usage() == 0) {
// zend mm not enabled, skip test
exit("SKIP: zend mm not enabled");
}
?>
--INI--
memory_limit=32M
--FILE--
<?php
require __DIR__ . '/../../include/bootstrap.php';
Expand All @@ -22,8 +29,10 @@ for ($c = 0; $c < TEST_MAX_CONCURRENCY; $c++) {
});
}

echo str_repeat('X', 128 * 1024 * 1024);
$str128M = str_repeat('X', 128 * 1024 * 1024);
var_dump(md5($str128M));

echo "Never here\n";
?>
--EXPECTF--
%AFatal error: [Fatal error in main] Allowed memory size of %d bytes exhausted%A (tried to allocate %d bytes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ swow_coroutine: bailout in shutdown functions
--SKIPIF--
<?php
require __DIR__ . '/../../include/skipif.php';

if (memory_get_usage() == 0) {
// zend mm not enabled, skip test
exit("SKIP: zend mm not enabled");
}
?>
--INI--
memory_limit=32M
--FILE--
<?php
require __DIR__ . '/../../include/bootstrap.php';
Expand All @@ -15,7 +22,10 @@ use function Swow\Sync\waitAll;
register_shutdown_function(static function (): void {
Assert::same(Coroutine::count(), TEST_MAX_CONCURRENCY + 2);
echo sprintf("\nCoroutine count: %d\n", Coroutine::count());
echo str_repeat('X', 128 * 1024 * 1024 + 1);
$str128M = str_repeat('X', 128 * 1024 * 1024 + 1);
var_dump(md5($str128M));

echo "Never here\n";
});

for ($c = 0; $c < TEST_MAX_CONCURRENCY; $c++) {
Expand All @@ -26,7 +36,10 @@ for ($c = 0; $c < TEST_MAX_CONCURRENCY; $c++) {
}

Coroutine::run(static function (): void {
echo str_repeat('X', 128 * 1024 * 1024);
$str128M = str_repeat('X', 128 * 1024 * 1024);
var_dump(md5($str128M));

echo "Never here\n";
});

waitAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ swow_coroutine: bailout in main
--SKIPIF--
<?php
require __DIR__ . '/../../include/skipif.php';

if (memory_get_usage() == 0) {
// zend mm not enabled, skip test
exit("SKIP: zend mm not enabled");
}
?>
--INI--
memory_limit=32M
--FILE--
<?php
require __DIR__ . '/../../include/bootstrap.php';
Expand All @@ -25,7 +32,10 @@ for ($c = 0; $c < TEST_MAX_CONCURRENCY; $c++) {
}

Coroutine::run(static function (): void {
echo str_repeat('X', 128 * 1024 * 1024);
$str128M = str_repeat('X', 128 * 1024 * 1024);
var_dump(md5($str128M));

echo "Never here\n";
});

waitAll();
Expand Down

0 comments on commit 87b4651

Please sign in to comment.