[LTP] [PATCH] lib: add tst_read_meminfo / tst_get_avail_mem

Jan Stancek jstancek@redhat.com
Wed Jul 13 15:12:08 CEST 2016


On 07/13/2016 11:35 AM, Li Wang wrote:
> Jan,
> 
> On Thu, Jun 16, 2016 at 03:08:18AM -0400, Jan Stancek wrote:
>>
>> I'm now considering exposing just a parse function, I'd like to
>> avoid having separate function for each proc file. And possibly
>> more than one since those 2 proc files you mentioned don't have
>> uniform format for all content.
> 
> How is the parse function going?

Latest idea attached.

It's similar to SAFE_FILE_SCANF, but it scanfs each line and first
matching all scanf directives wins and terminates search, otherwise
you get non-zero ret code. For example:

if (SAFE_FILE_LINES_SCANF("/proc/meminfo", "MemFree: %ld", &free))
        tst_brk(TBROK, "Could not parse MemFree");

Regards,
Jan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lib-add-SAFE_FILE_LINES_SCANF.patch
Type: text/x-patch
Size: 5623 bytes
Desc: not available
URL: <http://lists.linux.it/pipermail/ltp/attachments/20160713/54918c2b/attachment.bin>


More information about the ltp mailing list