** Copyright (C) 2001-2025 Zabbix SIA
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
func BenchmarkReadAll(b *testing.B) {
for i := 0; i < b.N; i++ {
_, _ = ReadAll("/proc/self/stat")
func Test_byteFromProcFileData(t *testing.T) {
{"+kB", args{testData, "VmPeak"}, 6032 * 1024, true, false},
{"+mB", args{testData, "VmHWM"}, 456 * 1024 * 1024, true, false},
{"+GB", args{testData, "VmRSS"}, 456 * 1024 * 1024 * 1024, true, false},
{"+TB", args{testData, "VmData"}, 376 * 1024 * 1024 * 1024 * 1024, true, false},
{"-malformed_line", args{testData, "b"}, 0, false, false},
{"-incorrect_value", args{testData, "fail"}, 0, false, true},
{"-incorrect_value_type", args{testData, "fail_type"}, 0, false, true},
{"-not_found", args{testData, "FooBar"}, 0, false, false},
{"-no_data", args{nil, ""}, 0, false, false},
for _, tt := range tests {