Page MenuHomeFreeBSD

Add tests for bad arguments passed to mmap().
ClosedPublic

Authored by jhb on Aug 1 2015, 5:45 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 3 2025, 9:56 AM
Unknown Object (File)
Jan 17 2025, 8:23 PM
Unknown Object (File)
Jan 4 2025, 11:18 AM
Unknown Object (File)
Jan 3 2025, 10:25 AM
Unknown Object (File)
Dec 3 2024, 6:23 PM
Unknown Object (File)
Nov 13 2024, 11:21 AM
Unknown Object (File)
Nov 11 2024, 12:55 PM
Unknown Object (File)
Oct 26 2024, 9:11 AM
Subscribers

Details

Summary

I had a standalone program that performed these tests back when I changed
mmap() to be stricter about checking for invalid arguments a while back.
This just incorporates them into the standard mmap test.

Test Plan

Run the test.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb retitled this revision from to Add tests for bad arguments passed to mmap()..
jhb updated this object.
jhb edited the test plan for this revision. (Show Details)
jhb added reviewers: kib, alc.

What about mmap(..., fd = open("dev/zero"), ...)?

Is MAP_SHARED allowed in this case?

tests/sys/vm/mmap_test.c
110 ↗(On Diff #7573)

No unmap ? If not needed, why freeing str ?

In D3269#66135, @alc wrote:

What about mmap(..., fd = open("dev/zero"), ...)?

Is MAP_SHARED allowed in this case?

Currently MAP_SHARED is accepted with that, though it is actually a private mapping due to /dev/zero's special nature.

tests/sys/vm/mmap_test.c
110 ↗(On Diff #7573)

Humm, I could actually drop the va_args thing entirely since all the tests don't pass any args.

John, I probably should have asked this question first. What are you looking for from kib@ and me, i.e., just to verify that the proposed tests are correct, or suggest additional tests, or ... ?

In D3269#66515, @alc wrote:

John, I probably should have asked this question first. What are you looking for from kib@ and me, i.e., just to verify that the proposed tests are correct, or suggest additional tests, or ... ?

Partly it's an FYI, but primarily verifying that this set of tests looks correct. I'm certainly open to suggestions for more test cases as well.

Sean Bruno has run into a regression with my fo_mmap() change where mmap of /dev/zero is failing under qemu. I have a follow-on change to add some simple /dev/zero tests as well. Unfortunately those work fine normally so I haven't been able to track down what Sean is running into, but adding a test for whatever that bug turns out to be was my motivation for converting the existing mmap_test.c to ATF. Subsequent to converting it, I noticed I had a standalone test program that contained these tests lying around from before and thought I would add it as well.

jhb edited edge metadata.
  • Drop va_list since it was unused. Unmap successful mappings to cleanup.
kib edited edge metadata.
This revision is now accepted and ready to land.Aug 6 2015, 2:01 PM
This revision was automatically updated to reflect the committed changes.

LGTM

head/tests/sys/vm/mmap_test.c
95–107

There are a couple other macros that could be used here, like ATF_CHECK_ERRNO, but I admit that it overloads ATF_CHECK_EQ as well for little/no benefit :/.