Changeset View
Changeset View
Standalone View
Standalone View
src/utils/__tests__/PhutilSystemTestCase.php
<?php | <?php | ||||
final class PhutilSystemTestCase extends PhutilTestCase { | final class PhutilSystemTestCase extends PhutilTestCase { | ||||
public function testParseVMStat() { | public function testParseVMStat() { | ||||
$tests = array( | $tests = array( | ||||
'vmstat.yosemite.txt' => array( | 'vmstat.yosemite.txt' => array( | ||||
'total' => 16503578624, | 'total' => 16503578624, | ||||
'free' => 1732366336, | 'free' => 1732366336, | ||||
), | ), | ||||
); | ); | ||||
$dir = dirname(__FILE__).'/memory'; | $dir = __DIR__.'/memory'; | ||||
foreach ($tests as $input => $expect) { | foreach ($tests as $input => $expect) { | ||||
$raw = Filesystem::readFile($dir.'/'.$input); | $raw = Filesystem::readFile($dir.'/'.$input); | ||||
$actual = PhutilSystem::parseVMStat($raw); | $actual = PhutilSystem::parseVMStat($raw); | ||||
$this->assertEqual( | $this->assertEqual( | ||||
$expect, | $expect, | ||||
$actual, | $actual, | ||||
pht('Parse of "%s".', $input)); | pht('Parse of "%s".', $input)); | ||||
} | } | ||||
} | } | ||||
public function testParseMeminfo() { | public function testParseMeminfo() { | ||||
$tests = array( | $tests = array( | ||||
'meminfo.ubuntu14.txt' => array( | 'meminfo.ubuntu14.txt' => array( | ||||
'total' => 7843336192, | 'total' => 7843336192, | ||||
'free' => 3758297088, | 'free' => 3758297088, | ||||
), | ), | ||||
); | ); | ||||
$dir = dirname(__FILE__).'/memory'; | $dir = __DIR__.'/memory'; | ||||
foreach ($tests as $input => $expect) { | foreach ($tests as $input => $expect) { | ||||
$raw = Filesystem::readFile($dir.'/'.$input); | $raw = Filesystem::readFile($dir.'/'.$input); | ||||
$actual = PhutilSystem::parseMemInfo($raw); | $actual = PhutilSystem::parseMemInfo($raw); | ||||
$this->assertEqual( | $this->assertEqual( | ||||
$expect, | $expect, | ||||
$actual, | $actual, | ||||
pht('Parse of "%s".', $input)); | pht('Parse of "%s".', $input)); | ||||
} | } | ||||
} | } | ||||
} | } |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0