Skip to content

Commit 2508d50

Browse files
committed
Extend skip section
The test requires some untrivial amount of RAM. Added a simple check for the system free RAM to avoid false positive fails.
1 parent ce0ab99 commit 2508d50

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

ext/gmp/tests/gmp_setbit_long.phpt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@ gmp_setbit() with large index
44
<?php if (!extension_loaded("gmp")) print "skip"; ?>
55
<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?>
66
<?php if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); ?>
7+
<?php
8+
/* This test requires about 8G RAM which likely not to be present on an arbitrary CI. */
9+
if (!file_exists("/proc/meminfo")) {
10+
die("skip cannot determine free memory amount.");
11+
}
12+
$s = file_get_contents("/proc/meminfo");
13+
$free = 0;
14+
if (preg_match(",MemFree:\s+(\d+)\s+kB,", $s, $m)) {
15+
/* Got amount in kb. */
16+
$free = $m[1]/1024/1024;
17+
}
18+
if ($free < 8) {
19+
die("skip not enough free RAM.");
20+
}
21+
?>
722
--FILE--
823
<?php
924

@@ -23,4 +38,4 @@ FFFFFFFFF
2338
3FFFFFFFFF
2439

2540
Warning: gmp_setbit(): Index must be less than %d * %d in %s/gmp_setbit_long.php on line %d
26-
Done
41+
Done

0 commit comments

Comments
 (0)