Hi!
> +int main(int argc, char *argv[])
> +{
> + int lc;
> + int ret;
> + int lock_sz;
> + char *msg;
> + char line[LINELEN];
> + FILE *fstatus = NULL;
> +
> + msg = parse_opts(argc, argv, NULL, NULL);
> + if (msg != NULL)
> + tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
> +
> + setup();
> +
> + for (lc = 0; TEST_LOOPING(lc); lc++) {
> +
> + tst_count = 0;
> +
> + addr = mmap(NULL, MMAPSIZE, PROT_READ | PROT_WRITE,
> + MAP_FILE | MAP_PRIVATE | MAP_LOCKED | MAP_ANONYMOUS,
> + -1, 0);
> +
> + if (addr == MAP_FAILED) {
> + tst_resm(TFAIL | TERRNO, "mmap of %s failed", TEMPFILE);
> + continue;
> + }
> +
> + if (STD_FUNCTIONAL_TEST) {
> +
> + fstatus = fopen("/proc/self/status", "r");
> + if (fstatus == NULL)
> + tst_brkm(TFAIL | TERRNO, NULL, "Open dev "
> + "status failed");
> +
> + while (fgets(line, LINELEN, fstatus) != NULL)
> + if (strstr(line, "VmLck") != NULL)
> + break;
> +
> + ret = sscanf(line, "%*[^0-9]%d%*[^0-9]", &lock_sz);
> + if (ret != 1)
> + tst_brkm(TFAIL | TERRNO, NULL, "Get lock "
> + "size failed");
> +
> + if (lock_sz == MMAPSIZE / 1024)
> + tst_resm(TPASS, "Functionality of mmap() "
> + "successful");
I know that it's unlikely that process would have some pages locked
prior the mmap above, but getting the number of locked pages before the
mmap after it and using the difference in the comparsion would be more
robust. And the additional work needed for this is minimal, just move
the part of the code that reads VmLck value into a function and call it
before and after the mmap.
--
Cyril Hrubis
[email protected]
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list