[compiler-rt] r350248 - [Sanitizer] Enable funopen on FreeBSD

David Carlier via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 2 11:07:28 PST 2019


Author: devnexen
Date: Wed Jan  2 11:07:27 2019
New Revision: 350248

URL: http://llvm.org/viewvc/llvm-project?rev=350248&view=rev
Log:
[Sanitizer] Enable funopen on FreeBSD

Reviewers: krytarowski

Reviewed By: krytarowski

Differential Revision: https://reviews.llvm.org/D56209

Added:
    compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/funopen.cc
      - copied, changed from r350247, compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/funopen.cc
Removed:
    compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/funopen.cc
Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h?rev=350248&r1=350247&r2=350248&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h Wed Jan  2 11:07:27 2019
@@ -551,7 +551,7 @@
 #define SANITIZER_INTERCEPT_POPEN SI_POSIX
 #define SANITIZER_INTERCEPT_POPENVE SI_NETBSD
 #define SANITIZER_INTERCEPT_PCLOSE SI_POSIX
-#define SANITIZER_INTERCEPT_FUNOPEN SI_NETBSD
+#define SANITIZER_INTERCEPT_FUNOPEN (SI_NETBSD || SI_FREEBSD)
 #define SANITIZER_INTERCEPT_FUNOPEN2 SI_NETBSD
 
 #endif  // #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H

Removed: compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/funopen.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/funopen.cc?rev=350247&view=auto
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/funopen.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/funopen.cc (removed)
@@ -1,89 +0,0 @@
-// RUN: %clangxx -g %s -o %t && %run %t | FileCheck %s
-
-// CHECK: READ CALLED; len={{[0-9]*}}
-// CHECK-NEXT: READ: test
-// CHECK-NEXT: WRITE CALLED: test
-// CHECK-NEXT: READ CALLED; len={{[0-9]*}}
-// CHECK-NEXT: READ: test
-// CHECK-NEXT: WRITE CALLED: test
-// CHECK-NEXT: CLOSE CALLED
-// CHECK-NEXT: SEEK CALLED; off=100, whence=0
-// CHECK-NEXT: READ CALLED; len={{[0-9]*}}
-// CHECK-NEXT: READ: test
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-int cookie_var;
-
-int f_read(void *cookie, char *buf, int len) {
-  assert(cookie == &cookie_var);
-  assert(len >= 6);
-  printf("READ CALLED; len=%d\n", len);
-  return strlcpy(buf, "test\n", len);
-}
-
-int f_write(void *cookie, const char *buf, int len) {
-  assert(cookie == &cookie_var);
-  char *data = strndup(buf, len);
-  assert(data);
-  printf("WRITE CALLED: %s\n", data);
-  free(data);
-  return len;
-}
-
-off_t f_seek(void *cookie, off_t off, int whence) {
-  assert(cookie == &cookie_var);
-  assert(whence == SEEK_SET);
-  printf("SEEK CALLED; off=%d, whence=%d\n", (int)off, whence);
-  return off;
-}
-
-int f_close(void *cookie) {
-  assert(cookie == &cookie_var);
-  printf("CLOSE CALLED\n");
-  return 0;
-}
-
-int main(void) {
-  FILE *fp;
-  char buf[10];
-
-  // 1. read-only variant
-  fp = fropen(&cookie_var, f_read);
-  assert(fp);
-  // verify that fileno() does not crash or report nonsense
-  assert(fileno(fp) == -1);
-  assert(fgets(buf, sizeof(buf), fp));
-  printf("READ: %s", buf);
-  assert(!fclose(fp));
-
-  // 2. write-only variant
-  fp = fwopen(&cookie_var, f_write);
-  assert(fp);
-  assert(fileno(fp) == -1);
-  assert(fputs("test", fp) >= 0);
-  assert(!fclose(fp));
-
-  // 3. read+write+close
-  fp = funopen(&cookie_var, f_read, f_write, NULL, f_close);
-  assert(fp);
-  assert(fileno(fp) == -1);
-  assert(fgets(buf, sizeof(buf), fp));
-  printf("READ: %s", buf);
-  assert(fputs("test", fp) >= 0);
-  assert(!fclose(fp));
-
-  // 4. read+seek
-  fp = funopen(&cookie_var, f_read, NULL, f_seek, NULL);
-  assert(fp);
-  assert(fileno(fp) == -1);
-  assert(fseek(fp, 100, SEEK_SET) == 0);
-  assert(fgets(buf, sizeof(buf), fp));
-  printf("READ: %s", buf);
-  assert(!fclose(fp));
-
-  return 0;
-}

Copied: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/funopen.cc (from r350247, compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/funopen.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/funopen.cc?p2=compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/funopen.cc&p1=compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/funopen.cc&r1=350247&r2=350248&rev=350248&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/funopen.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/funopen.cc Wed Jan  2 11:07:27 2019
@@ -10,6 +10,8 @@
 // CHECK-NEXT: SEEK CALLED; off=100, whence=0
 // CHECK-NEXT: READ CALLED; len={{[0-9]*}}
 // CHECK-NEXT: READ: test
+//
+// UNSUPPORTED: linux. darwin, solaris
 
 #include <assert.h>
 #include <stdio.h>




More information about the llvm-commits mailing list