-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[compiler-rt] [libFuzzer] Fix merge-posix.test file size test #168137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Andrew Haberlandt (ndrewh) ChangesThis test uses This test appears to be passing on accident since the "control file" happens to be > 1KB, but this is not always the case depending upon the length of the path where the test is run from. This modifies the test to ensure that one of the input file is actually >1KB. Full diff: https://github.com/llvm/llvm-project/pull/168137.diff 1 Files Affected:
diff --git a/compiler-rt/test/fuzzer/merge-posix.test b/compiler-rt/test/fuzzer/merge-posix.test
index 2721668fb9706..edd91324e5a92 100644
--- a/compiler-rt/test/fuzzer/merge-posix.test
+++ b/compiler-rt/test/fuzzer/merge-posix.test
@@ -14,7 +14,7 @@ RUN: echo ....U. > %tmp/T2/2
RUN: echo ...Z.. > %tmp/T2/3
RUN: echo ...Z.. > %tmp/T2/4
RUN: echo ....E. > %tmp/T2/5
-RUN: echo .....R > %tmp/T2/6
+RUN: (echo .....R; for i in {1..1024}; do echo -n X; done) > %tmp/T2/6
# Check that we can report an error if file size exceeded
RUN: (ulimit -f 1; not %run %t-FullCoverageSetTest -merge=1 %tmp/T1 %tmp/T2 2>&1 | FileCheck %s --check-prefix=SIGXFSZ)
|
| RUN: echo ...Z.. > %tmp/T2/4 | ||
| RUN: echo ....E. > %tmp/T2/5 | ||
| RUN: echo .....R > %tmp/T2/6 | ||
| RUN: (echo .....R; for i in {1..1024}; do echo -n X; done) > %tmp/T2/6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw, before I made this change I did look and found other tests doing similar shell scripting
| // RUN: for I in {1..3}; do \ |
I'm definitely not sure that this is the best / most portable way to write out a 1024B file 😄. We could just call into python3 (other tests do that), or use dd (but i didn't see any other tests doing that).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is another option:
RUN: %python -c "f = open('%tmp/T2/6', 'wb'); f.write(b'.....R'.ljust(1025, b'X')); f.close()"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Internal shell supports redirects, so this would do I believe:
RUN: %python -c "print('X' * 1024, end='')" > %tmp/T2/6
DanBlackwell
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update looks good, thanks!
Yes, it will. |
This test uses
ulimit -f 1to test what libFuzzer does when trying to create a file > 1KB. However, the none of the input files used by this test are actually >= 1KB, so there's no reason to expect this test to pass.This test appears to be passing on accident since the "control file" happens to be > 1KB, but this is not always the case depending upon the length of the path where the test is run from.
This modifies the test to ensure that one of the input file is actually >1KB.