tyrael                                   Wed, 02 Nov 2011 21:27:03 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=318708

Log:
adding memory check for FreeBSD also, TODO: refactor the free memory check into 
a function in an include file

Changed paths:
    U   php/php-src/branches/PHP_5_3/Zend/tests/bug55509.phpt
    U   php/php-src/branches/PHP_5_4/Zend/tests/bug55509.phpt
    U   php/php-src/trunk/Zend/tests/bug55509.phpt

Modified: php/php-src/branches/PHP_5_3/Zend/tests/bug55509.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/tests/bug55509.phpt       2011-11-02 
21:15:04 UTC (rev 318707)
+++ php/php-src/branches/PHP_5_3/Zend/tests/bug55509.phpt       2011-11-02 
21:27:03 UTC (rev 318708)
@@ -21,6 +21,25 @@
     die('skip Not enough memory.');
   }
 }
+elseif (PHP_OS == 'FreeBSD') {
+  $lines = explode("\n",`sysctl -a`);
+  $infos = array();
+  foreach ($lines as $line) {
+    if(!$line){
+      continue;
+    }
+    $tmp = explode(":", $line);
+    $index = strtolower($tmp[0]);
+    $value = trim($tmp[1], " ");
+    $infos[$index] = $value;
+  }
+  $freeMemory = ($infos['vm.stats.vm.v_inactive_count']*$infos['hw.pagesize'])
+                +($infos['vm.stats.vm.v_cache_count']*$infos['hw.pagesize'])
+                +($infos['vm.stats.vm.v_free_count']*$infos['hw.pagesize']);
+  if ($freeMemory < 2100*1024*1024) {
+    die('skip Not enough memory.');
+  }
+}
 ?>
 --INI--
 memory_limit=2100M

Modified: php/php-src/branches/PHP_5_4/Zend/tests/bug55509.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/Zend/tests/bug55509.phpt       2011-11-02 
21:15:04 UTC (rev 318707)
+++ php/php-src/branches/PHP_5_4/Zend/tests/bug55509.phpt       2011-11-02 
21:27:03 UTC (rev 318708)
@@ -21,6 +21,25 @@
     die('skip Not enough memory.');
   }
 }
+elseif (PHP_OS == 'FreeBSD') {
+  $lines = explode("\n",`sysctl -a`);
+  $infos = array();
+  foreach ($lines as $line) {
+    if(!$line){
+      continue;
+    }
+    $tmp = explode(":", $line);
+    $index = strtolower($tmp[0]);
+    $value = trim($tmp[1], " ");
+    $infos[$index] = $value;
+  }
+  $freeMemory = ($infos['vm.stats.vm.v_inactive_count']*$infos['hw.pagesize'])
+                +($infos['vm.stats.vm.v_cache_count']*$infos['hw.pagesize'])
+                +($infos['vm.stats.vm.v_free_count']*$infos['hw.pagesize']);
+  if ($freeMemory < 2100*1024*1024) {
+    die('skip Not enough memory.');
+  }
+}
 ?>
 --INI--
 memory_limit=2100M

Modified: php/php-src/trunk/Zend/tests/bug55509.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/bug55509.phpt  2011-11-02 21:15:04 UTC (rev 
318707)
+++ php/php-src/trunk/Zend/tests/bug55509.phpt  2011-11-02 21:27:03 UTC (rev 
318708)
@@ -21,6 +21,25 @@
     die('skip Not enough memory.');
   }
 }
+elseif (PHP_OS == 'FreeBSD') {
+  $lines = explode("\n",`sysctl -a`);
+  $infos = array();
+  foreach ($lines as $line) {
+    if(!$line){
+      continue;
+    }
+    $tmp = explode(":", $line);
+    $index = strtolower($tmp[0]);
+    $value = trim($tmp[1], " ");
+    $infos[$index] = $value;
+  }
+  $freeMemory = ($infos['vm.stats.vm.v_inactive_count']*$infos['hw.pagesize'])
+                +($infos['vm.stats.vm.v_cache_count']*$infos['hw.pagesize'])
+                +($infos['vm.stats.vm.v_free_count']*$infos['hw.pagesize']);
+  if ($freeMemory < 2100*1024*1024) {
+    die('skip Not enough memory.');
+  }
+}
 ?>
 --INI--
 memory_limit=2100M

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to