@@ -12,49 +12,10 @@ if ($zend_mm_enabled === "0") {
12
12
}
13
13
14
14
if (getenv ("SKIP_SLOW_TESTS " )) die ("skip slow test " );
15
- // check the available memory
16
- if (PHP_OS == 'Linux ' ) {
17
- $ lines = file ('/proc/meminfo ' );
18
- $ infos = array ();
19
- foreach ($ lines as $ line ) {
20
- $ tmp = explode (": " , $ line );
21
- $ index = strtolower ($ tmp [0 ]);
22
- $ value = (int )ltrim ($ tmp [1 ], " " )*1024 ;
23
- $ infos [$ index ] = $ value ;
24
- }
25
- $ freeMemory = $ infos ['memfree ' ]+$ infos ['buffers ' ]+$ infos ['cached ' ];
26
- if ($ freeMemory < 2100 *1024 *1024 ) {
27
- die ('skip Not enough memory. ' );
28
- }
29
- }
30
- elseif (PHP_OS == 'FreeBSD ' ) {
31
- $ lines = explode ("\n" ,`sysctl -a `);
32
- $ infos = array ();
33
- foreach ($ lines as $ line ) {
34
- if (!$ line ){
35
- continue ;
36
- }
37
- $ tmp = explode (": " , $ line );
38
- if (count ($ tmp ) < 2 ) {
39
- continue ;
40
- }
41
- $ index = strtolower ($ tmp [0 ]);
42
- $ value = trim ($ tmp [1 ], " " );
43
- $ infos [$ index ] = $ value ;
44
- }
45
- $ freeMemory = ($ infos ['vm.stats.vm.v_inactive_count ' ]*$ infos ['hw.pagesize ' ])
46
- +($ infos ['vm.stats.vm.v_cache_count ' ]*$ infos ['hw.pagesize ' ])
47
- +($ infos ['vm.stats.vm.v_free_count ' ]*$ infos ['hw.pagesize ' ]);
48
- if ($ freeMemory < 2100 *1024 *1024 ) {
49
- die ('skip Not enough memory. ' );
50
- }
51
- } elseif (PHP_OS == "WINNT " ) {
52
- $ s = trim (shell_exec ("wmic OS get FreeVirtualMemory /Value 2>nul " ));
53
- $ freeMemory = explode ('= ' , $ s )[1 ]*1 ;
54
15
55
- if ( $ freeMemory < 2.1 * 1024 * 1024 ) {
56
- die ( ' skip Not enough memory. ' );
57
- }
16
+ include ( __DIR__ . ' /../../tests/utils.php ' );
17
+ if (! has_enough_memory ( 2.1 * 1024 * 1024 * 1024 )) {
18
+ die ( ' skip Reason: Insufficient RAM (should be 2.1GB) ' );
58
19
}
59
20
?>
60
21
--INI--
0 commit comments