[PATCH] Implement a bunch of custom glibc wrappers & corresponding tests.
Peter Collingbourne
peter at pcc.me.uk
Wed Nov 20 21:01:21 PST 2013
================
Comment at: lib/dfsan/done_abilist.txt:159
@@ -136,1 +158,3 @@
+fun:sigaction=custom
+fun:gettimeofday=custom
----------------
Do any of these belong here? I don't think any of them take a callback.
================
Comment at: lib/dfsan/dfsan_custom.cc:432
@@ +431,3 @@
+ if (ret) {
+ internal_memcpy(shadow_for(dest), shadow_for(src), strlen(src) + 1);
+ }
----------------
Length needs to be multiplied by sizeof(dfsan_label).
================
Comment at: lib/dfsan/lit_tests/check_tests.sh:3
@@ +2,3 @@
+
+tests=$(dirname "$0")/custom.c
+abilist=$(dirname "$tests")/../done_abilist.txt
----------------
testdir=$(dirname "$0") ?
Then base the other variables on it.
================
Comment at: lib/dfsan/lit_tests/check_tests.sh:11
@@ +10,3 @@
+ <(grep "fun:.*=custom" "$abilist" | grep -v "dfsan_get_label" \
+ | sed "s/^fun:\(.*\)=custom.*/__dfsw_\1/")
+
----------------
How about sorting the two outputs and piping them into diff?
================
Comment at: lib/dfsan/lit_tests/check_tests.sh:1
@@ +1,2 @@
+# RUN: bash %s
+
----------------
I think this should be part of check_lint.sh rather than a test.
================
Comment at: lib/dfsan/lit_tests/check_tests.sh:21
@@ +20,3 @@
+ <(grep "^\\s*test_.*();" "$tests" | sed "s/.*\(test_.*\)();/\1/") \
+ <(grep __dfsw_ "$wrappers" | sed "s/.*__dfsw_\([^(]*\).*/test_\1()/")
+
----------------
Ditto.
================
Comment at: lib/dfsan/lit_tests/custom.c:29
@@ -17,6 +28,3 @@
-void *ptcb(void *p) {
- assert(p == (void *)1);
- assert(dfsan_get_label((uintptr_t)p) == 0);
- return (void *)2;
-}
+dfsan_label I_LABEL = 0;
+dfsan_label J_LABEL = 0;
----------------
Lowercase, please.
================
Comment at: lib/dfsan/lit_tests/custom.c:35
@@ -31,5 +34,3 @@
-int main(void) {
- int i = 1;
- dfsan_label i_label = dfsan_create_label("i", 0);
- dfsan_set_label(i_label, &i, sizeof(i));
+#define ASSERT_ZERO_LABELS(ptr, size) assert(0 == dfsan_read_label(ptr, size))
+
----------------
How about calling it ASSERT_READ_ZERO_LABEL? That name makes it clear that the test is reading from memory.
================
Comment at: lib/dfsan/lit_tests/custom.c:39
@@ +38,3 @@
+
+#define ASSERT_LABELS(ptr, size, label) \
+ assert(label == dfsan_read_label(ptr, size))
----------------
ASSERT_READ_LABEL.
http://llvm-reviews.chandlerc.com/D2234
More information about the llvm-commits
mailing list