toBe('812344') ->and(ss_linux_memory_parse(SS_LINUX_MEMORY_FIXTURE, 'SwapFree'))->toBe('2097148'); }); test('parse does not run Active together with Active(anon) and Active(file)', function () { expect(ss_linux_memory_parse(SS_LINUX_MEMORY_FIXTURE, 'Active'))->toBe('7012340') ->and(ss_linux_memory_parse(SS_LINUX_MEMORY_FIXTURE, 'Active(anon)'))->toBe('5123400'); }); test('parse returns U for a key that is absent or has no kB value', function () { expect(ss_linux_memory_parse(SS_LINUX_MEMORY_FIXTURE, 'Shmem'))->toBe('U') ->and(ss_linux_memory_parse(SS_LINUX_MEMORY_FIXTURE, 'HugePages_Total'))->toBe('U') ->and(ss_linux_memory_parse(SS_LINUX_MEMORY_FIXTURE, 'Mem'))->toBe('U'); }); test('rejected keys return U with a failing exit status', function (string $key) { expect(ss_linux_memory_collect($key))->toBe(['U', 1]) ->and(ss_linux_memory($key))->toBe('U'); })->with(['', 'Mem Free', 'MemFree;id', '-x', '../MemFree', 'MemFree::']); test('a valid key reads /proc/meminfo where it exists', function () { [$value, $status] = ss_linux_memory_collect('MemTotal:'); if (is_readable('/proc/meminfo')) { expect($status)->toBe(0)->and($value)->toMatch('/^\d+$/'); } else { expect([$value, $status])->toBe(['U', 1]); } });