Page MenuHomePhorge

ArcanistHostMemorySnapshotTestCase.php
No OneTemporary

ArcanistHostMemorySnapshotTestCase.php

<?php
final class ArcanistHostMemorySnapshotTestCase
extends PhutilTestCase {
public function testSnapshotSwapTotalBytes() {
$test_cases = array(
'meminfo_swap_normal.txt' => 4294963200,
'meminfo_swap_zero.txt' => 0,
'meminfo_swap_missing.txt' => false,
'meminfo_swap_invalid.txt' => false,
'meminfo_swap_badunits.txt' => false,
'meminfo_swap_duplicate.txt' => false,
);
$test_dir = dirname(__FILE__).'/data/';
foreach ($test_cases as $test_file => $expect) {
$test_data = Filesystem::readFile($test_dir.$test_file);
$caught = null;
$actual = null;
try {
$snapshot = ArcanistHostMemorySnapshot::newFromRawMeminfo(
$test_file,
$test_data);
$actual = $snapshot->getTotalSwapBytes();
} catch (Exception $ex) {
if ($expect === false) {
$caught = $ex;
} else {
throw $ex;
}
} catch (Throwable $ex) {
throw $ex;
}
if ($expect === false) {
$this->assertTrue(
($caught instanceof Exception),
pht('Expected exception for "%s".', $test_file));
} else {
$this->assertEqual(
$expect,
$actual,
pht('Result for "%s".', $test_file));
}
}
}
}

File Metadata

Mime Type
text/x-php
Expires
Jan 19 2025, 12:05 (4 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1119856
Default Alt Text
ArcanistHostMemorySnapshotTestCase.php (1 KB)

Event Timeline