This is an archive of the discontinued LLVM Phabricator instance.

[libc] simplify test for getrandom
ClosedPublic

Authored by gchatelet on May 24 2023, 6:59 AM.

Details

Summary

getrandom is implemented as a syscall.
We don't want to test linux implementation of the syscall. We just want to verify that it reacts as expected to sensible values.

Runtime before

[ RUN      ] LlvmLibcGetRandomTest.InvalidFlag
[       OK ] LlvmLibcGetRandomTest.InvalidFlag (took 0 ms)
[ RUN      ] LlvmLibcGetRandomTest.InvalidBuffer
[       OK ] LlvmLibcGetRandomTest.InvalidBuffer (took 0 ms)
[ RUN      ] LlvmLibcGetRandomTest.ReturnsSize
[       OK ] LlvmLibcGetRandomTest.ReturnsSize (took 83 ms)
[ RUN      ] LlvmLibcGetRandomTest.PiEstimation
[       OK ] LlvmLibcGetRandomTest.PiEstimation (took 9882 ms)

Runtime after

[ RUN      ] LlvmLibcGetRandomTest.InvalidFlag
[       OK ] LlvmLibcGetRandomTest.InvalidFlag (took 0 ms)
[ RUN      ] LlvmLibcGetRandomTest.InvalidBuffer
[       OK ] LlvmLibcGetRandomTest.InvalidBuffer (took 0 ms)
[ RUN      ] LlvmLibcGetRandomTest.ReturnsSize
[       OK ] LlvmLibcGetRandomTest.ReturnsSize (took 0 ms)
[ RUN      ] LlvmLibcGetRandomTest.CheckValue
[       OK ] LlvmLibcGetRandomTest.CheckValue (took 0 ms)

Diff Detail

Event Timeline

gchatelet created this revision.May 24 2023, 6:59 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMay 24 2023, 6:59 AM
gchatelet requested review of this revision.May 24 2023, 6:59 AM

There's a bit of noise in the patch, sorry about that. The two first tests are just cosmetic changes.

lntue accepted this revision.May 24 2023, 7:09 AM
lntue added inline comments.
libc/test/src/sys/random/linux/getrandom_test.cpp
18–20

I think these are redundant, ErrnoSetterMatcher does reset libc_errno to 0 after matching.

This revision is now accepted and ready to land.May 24 2023, 7:09 AM
gchatelet updated this revision to Diff 525180.May 24 2023, 7:43 AM
gchatelet marked an inline comment as done.
  • Remove redundant reset of libc_errno
libc/test/src/sys/random/linux/getrandom_test.cpp
18–20

Sounds good, removing.

lntue accepted this revision.May 24 2023, 7:54 AM
This revision was automatically updated to reflect the committed changes.