[PATCH] Add user-defined callback on write() calls to labeled data.
Sam Kerner
skerner at chromium.org
Mon Apr 14 11:59:54 PDT 2014
================
Comment at: test/dfsan/write_callback.c:1
@@ +1,2 @@
+// RUN: %clang_dfsan -m64 %s -o %t && %t %T/file1.txt
+// RUN: %clang_dfsan -mllvm -dfsan-args-abi -m64 %s -o %t && %t %T/file2.txt
----------------
Sam Kerner wrote:
> Peter Collingbourne wrote:
> > Maybe we could check that these files have the contents we expect?
> It would be reasonable to assume that calls to write() do not fail in
> tests. But write() may only write some of the bytes it is passed.
> For example:
>
> char buf[] = "123456789";
> int bytes_written = write(fd, buf, 10);
>
> If (for whatever reason) only 5 bytes are written, write may return 5.
> I doubt it would do so on a local file system, but I don't want to
> assume something that is not in the spec.
>
> I considered adding retries to writes:
>
> char buf[] = "123456789";
>
> char* cur = buf;
> int bytes_left = strlen(buf);
> while ( bytes_left > 0 ) {
> int result = write(fd, cur, bytes_left);
>
> if (result < 0) ERROR HANDLER
>
> bytes_left -= result;
> }
>
> ... but now the number of callbacks tests must expect changes based on
> how many times write() ends up being called.
>
>
Please ignore the above comment. I wrote it before realizing that its premise is flawed, and wrote the rest in a way that does check that the file is written.
http://reviews.llvm.org/D3268
More information about the llvm-commits
mailing list