syscalls/madvise11: new test for madvise(MADV_DONTNEED)
Hi,
Quoted 21 lines
Hi!
Quoted 6 lines
(quoted diff) +6
-0+static void run(void) +{ + char cmd[BUF_SIZE]; + char line[BUF_SIZE]; + char vm_area_addr[128]; +Review
Quoted 10 lines
(quoted diff) +10
-0+ TEST(madvise(addr, MAP_SIZE, MADV_DONTNEED)); + if (TST_RET == -1) { + tst_brk(TBROK | TTERRNO, "madvise(%p, %d, 0x%x)", + addr, MAP_SIZE, MADV_DONTNEED); + } + + sprintf(vm_area_addr, "%p", addr); + sprintf(cmd, + "cat /proc/%d/smaps | grep %s -A 4 | grep Rss: | grep '0 kB'", + getpid(), &(vm_area_addr[2]));This is way too ugly and may break easily too.
Quoted 3 lines
If we are going to parse the file we should do it properly in C instead. Why can't we just read the file line by line until we find the right address at the start of the line and once we do look for the Rss?
I have do it with C at first, but it seems not intuitive. I will change back on next version of the patch.
Regards,
Gongyi
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp