[compiler-rt] r244827 - Move tests that use unistd.h and pthread.h to TestCases/Posix

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 12 15:58:56 PDT 2015


Author: rnk
Date: Wed Aug 12 17:58:56 2015
New Revision: 244827

URL: http://llvm.org/viewvc/llvm-project?rev=244827&view=rev
Log:
Move tests that use unistd.h and pthread.h to TestCases/Posix

Added:
    compiler-rt/trunk/test/asan/TestCases/Posix/closed-fds.cc
      - copied, changed from r244647, compiler-rt/trunk/test/asan/TestCases/closed-fds.cc
    compiler-rt/trunk/test/asan/TestCases/Posix/coverage-caller-callee.cc
      - copied, changed from r244647, compiler-rt/trunk/test/asan/TestCases/coverage-caller-callee.cc
    compiler-rt/trunk/test/asan/TestCases/Posix/coverage-maybe-open-file.cc
      - copied, changed from r244647, compiler-rt/trunk/test/asan/TestCases/coverage-maybe-open-file.cc
    compiler-rt/trunk/test/asan/TestCases/Posix/current_allocated_bytes.cc
      - copied, changed from r244647, compiler-rt/trunk/test/asan/TestCases/current_allocated_bytes.cc
    compiler-rt/trunk/test/asan/TestCases/Posix/deep_thread_stack.cc
      - copied, changed from r244647, compiler-rt/trunk/test/asan/TestCases/deep_thread_stack.cc
    compiler-rt/trunk/test/asan/TestCases/Posix/dlclose-test.cc
      - copied, changed from r244647, compiler-rt/trunk/test/asan/TestCases/dlclose-test.cc
    compiler-rt/trunk/test/asan/TestCases/Posix/free_hook_realloc.cc
      - copied, changed from r244647, compiler-rt/trunk/test/asan/TestCases/free_hook_realloc.cc
    compiler-rt/trunk/test/asan/TestCases/Posix/gc-test.cc
      - copied, changed from r244647, compiler-rt/trunk/test/asan/TestCases/gc-test.cc
    compiler-rt/trunk/test/asan/TestCases/Posix/init-order-pthread-create.cc
      - copied, changed from r244647, compiler-rt/trunk/test/asan/TestCases/init-order-pthread-create.cc
    compiler-rt/trunk/test/asan/TestCases/Posix/stack-overflow.cc
      - copied, changed from r244647, compiler-rt/trunk/test/asan/TestCases/stack-overflow.cc
    compiler-rt/trunk/test/asan/TestCases/Posix/stack-use-after-return.cc
      - copied, changed from r244647, compiler-rt/trunk/test/asan/TestCases/stack-use-after-return.cc
Removed:
    compiler-rt/trunk/test/asan/TestCases/closed-fds.cc
    compiler-rt/trunk/test/asan/TestCases/coverage-caller-callee.cc
    compiler-rt/trunk/test/asan/TestCases/coverage-maybe-open-file.cc
    compiler-rt/trunk/test/asan/TestCases/current_allocated_bytes.cc
    compiler-rt/trunk/test/asan/TestCases/deep_thread_stack.cc
    compiler-rt/trunk/test/asan/TestCases/dlclose-test.cc
    compiler-rt/trunk/test/asan/TestCases/free_hook_realloc.cc
    compiler-rt/trunk/test/asan/TestCases/gc-test.cc
    compiler-rt/trunk/test/asan/TestCases/init-order-pthread-create.cc
    compiler-rt/trunk/test/asan/TestCases/stack-overflow.cc
    compiler-rt/trunk/test/asan/TestCases/stack-use-after-return.cc

Copied: compiler-rt/trunk/test/asan/TestCases/Posix/closed-fds.cc (from r244647, compiler-rt/trunk/test/asan/TestCases/closed-fds.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/closed-fds.cc?p2=compiler-rt/trunk/test/asan/TestCases/Posix/closed-fds.cc&p1=compiler-rt/trunk/test/asan/TestCases/closed-fds.cc&r1=244647&r2=244827&rev=244827&view=diff
==============================================================================
    (empty)

Copied: compiler-rt/trunk/test/asan/TestCases/Posix/coverage-caller-callee.cc (from r244647, compiler-rt/trunk/test/asan/TestCases/coverage-caller-callee.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/coverage-caller-callee.cc?p2=compiler-rt/trunk/test/asan/TestCases/Posix/coverage-caller-callee.cc&p1=compiler-rt/trunk/test/asan/TestCases/coverage-caller-callee.cc&r1=244647&r2=244827&rev=244827&view=diff
==============================================================================
    (empty)

Copied: compiler-rt/trunk/test/asan/TestCases/Posix/coverage-maybe-open-file.cc (from r244647, compiler-rt/trunk/test/asan/TestCases/coverage-maybe-open-file.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/coverage-maybe-open-file.cc?p2=compiler-rt/trunk/test/asan/TestCases/Posix/coverage-maybe-open-file.cc&p1=compiler-rt/trunk/test/asan/TestCases/coverage-maybe-open-file.cc&r1=244647&r2=244827&rev=244827&view=diff
==============================================================================
    (empty)

Copied: compiler-rt/trunk/test/asan/TestCases/Posix/current_allocated_bytes.cc (from r244647, compiler-rt/trunk/test/asan/TestCases/current_allocated_bytes.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/current_allocated_bytes.cc?p2=compiler-rt/trunk/test/asan/TestCases/Posix/current_allocated_bytes.cc&p1=compiler-rt/trunk/test/asan/TestCases/current_allocated_bytes.cc&r1=244647&r2=244827&rev=244827&view=diff
==============================================================================
    (empty)

Copied: compiler-rt/trunk/test/asan/TestCases/Posix/deep_thread_stack.cc (from r244647, compiler-rt/trunk/test/asan/TestCases/deep_thread_stack.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/deep_thread_stack.cc?p2=compiler-rt/trunk/test/asan/TestCases/Posix/deep_thread_stack.cc&p1=compiler-rt/trunk/test/asan/TestCases/deep_thread_stack.cc&r1=244647&r2=244827&rev=244827&view=diff
==============================================================================
    (empty)

Copied: compiler-rt/trunk/test/asan/TestCases/Posix/dlclose-test.cc (from r244647, compiler-rt/trunk/test/asan/TestCases/dlclose-test.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/dlclose-test.cc?p2=compiler-rt/trunk/test/asan/TestCases/Posix/dlclose-test.cc&p1=compiler-rt/trunk/test/asan/TestCases/dlclose-test.cc&r1=244647&r2=244827&rev=244827&view=diff
==============================================================================
    (empty)

Copied: compiler-rt/trunk/test/asan/TestCases/Posix/free_hook_realloc.cc (from r244647, compiler-rt/trunk/test/asan/TestCases/free_hook_realloc.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/free_hook_realloc.cc?p2=compiler-rt/trunk/test/asan/TestCases/Posix/free_hook_realloc.cc&p1=compiler-rt/trunk/test/asan/TestCases/free_hook_realloc.cc&r1=244647&r2=244827&rev=244827&view=diff
==============================================================================
    (empty)

Copied: compiler-rt/trunk/test/asan/TestCases/Posix/gc-test.cc (from r244647, compiler-rt/trunk/test/asan/TestCases/gc-test.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/gc-test.cc?p2=compiler-rt/trunk/test/asan/TestCases/Posix/gc-test.cc&p1=compiler-rt/trunk/test/asan/TestCases/gc-test.cc&r1=244647&r2=244827&rev=244827&view=diff
==============================================================================
    (empty)

Copied: compiler-rt/trunk/test/asan/TestCases/Posix/init-order-pthread-create.cc (from r244647, compiler-rt/trunk/test/asan/TestCases/init-order-pthread-create.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/init-order-pthread-create.cc?p2=compiler-rt/trunk/test/asan/TestCases/Posix/init-order-pthread-create.cc&p1=compiler-rt/trunk/test/asan/TestCases/init-order-pthread-create.cc&r1=244647&r2=244827&rev=244827&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/init-order-pthread-create.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Posix/init-order-pthread-create.cc Wed Aug 12 17:58:56 2015
@@ -1,7 +1,7 @@
 // Check that init-order checking is properly disabled if pthread_create is
 // called.
 
-// RUN: %clangxx_asan %s %p/Helpers/init-order-pthread-create-extra.cc -pthread -o %t
+// RUN: %clangxx_asan %s %p/../Helpers/init-order-pthread-create-extra.cc -pthread -o %t
 // RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:strict_init_order=true %run %t
 
 #include <stdio.h>

Copied: compiler-rt/trunk/test/asan/TestCases/Posix/stack-overflow.cc (from r244647, compiler-rt/trunk/test/asan/TestCases/stack-overflow.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/stack-overflow.cc?p2=compiler-rt/trunk/test/asan/TestCases/Posix/stack-overflow.cc&p1=compiler-rt/trunk/test/asan/TestCases/stack-overflow.cc&r1=244647&r2=244827&rev=244827&view=diff
==============================================================================
    (empty)

Copied: compiler-rt/trunk/test/asan/TestCases/Posix/stack-use-after-return.cc (from r244647, compiler-rt/trunk/test/asan/TestCases/stack-use-after-return.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/stack-use-after-return.cc?p2=compiler-rt/trunk/test/asan/TestCases/Posix/stack-use-after-return.cc&p1=compiler-rt/trunk/test/asan/TestCases/stack-use-after-return.cc&r1=244647&r2=244827&rev=244827&view=diff
==============================================================================
    (empty)

Removed: compiler-rt/trunk/test/asan/TestCases/closed-fds.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/closed-fds.cc?rev=244826&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/closed-fds.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/closed-fds.cc (removed)
@@ -1,33 +0,0 @@
-// Check that when the program closed its std(in|out|err), running the external
-// symbolizer still works.
-
-// RUN: rm -f %t.log.*
-// RUN: %clangxx_asan -O0 %s -o %t 2>&1 && ASAN_OPTIONS=$ASAN_OPTIONS:log_path=%t.log:verbosity=2 not %run %t 2>&1
-// RUN: FileCheck %s --check-prefix=CHECK-FILE < %t.log.*
-
-// FIXME: copy %t.log back from the device and re-enable on Android.
-// UNSUPPORTED: android
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-int main(int argc, char **argv) {
-  int result = fprintf(stderr, "Closing streams.\n");
-  assert(result > 0);
-  close(STDIN_FILENO);
-  close(STDOUT_FILENO);
-  close(STDERR_FILENO);
-  result = fprintf(stderr, "Can you hear me now?\n");
-  assert(result < 0);
-  char *x = (char *)malloc(10 * sizeof(char));
-  free(x);
-  x[argc] = 'X';  // BOOM
-  // CHECK-FILE: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}}
-  // CHECK-FILE:   {{0x.* at pc 0x.* bp 0x.* sp 0x.*}}
-  // CHECK-FILE: {{WRITE of size 1 at 0x.* thread T0}}
-  // CHECK-FILE: {{    #0 0x.* in main .*closed-fds.cc:}}[[@LINE-4]]
-  return 0;
-}

Removed: compiler-rt/trunk/test/asan/TestCases/coverage-caller-callee.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/coverage-caller-callee.cc?rev=244826&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/coverage-caller-callee.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/coverage-caller-callee.cc (removed)
@@ -1,74 +0,0 @@
-// Test caller-callee coverage with large number of threads
-// and various numbers of callers and callees.
-
-// RUN: %clangxx_asan -fsanitize-coverage=edge,indirect-calls %s -o %t
-// RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:coverage=1:verbosity=1 %run %t 10 1 2>&1 | FileCheck %s --check-prefix=CHECK-10-1
-// RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:coverage=1:verbosity=1 %run %t 9  2 2>&1 | FileCheck %s --check-prefix=CHECK-9-2
-// RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:coverage=1:verbosity=1 %run %t 7  3 2>&1 | FileCheck %s --check-prefix=CHECK-7-3
-// RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:coverage=1:verbosity=1 %run %t 17 1 2>&1 | FileCheck %s --check-prefix=CHECK-17-1
-// RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:coverage=1:verbosity=1 %run %t 15 2 2>&1 | FileCheck %s --check-prefix=CHECK-15-2
-// RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:coverage=1:verbosity=1 %run %t 18 3 2>&1 | FileCheck %s --check-prefix=CHECK-18-3
-// RUN: rm -f caller-callee*.sancov
-//
-// REQUIRES: asan-64-bits
-//
-// CHECK-10-1: CovDump: 10 caller-callee pairs written
-// CHECK-9-2: CovDump: 18 caller-callee pairs written
-// CHECK-7-3: CovDump: 21 caller-callee pairs written
-// CHECK-17-1: CovDump: 14 caller-callee pairs written
-// CHECK-15-2: CovDump: 28 caller-callee pairs written
-// CHECK-18-3: CovDump: 42 caller-callee pairs written
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <pthread.h>
-int P = 0;
-struct Foo {virtual void f() {if (P) printf("Foo::f()\n");}};
-struct Foo1 : Foo {virtual void f() {if (P) printf("%d\n", __LINE__);}};
-struct Foo2 : Foo {virtual void f() {if (P) printf("%d\n", __LINE__);}};
-struct Foo3 : Foo {virtual void f() {if (P) printf("%d\n", __LINE__);}};
-struct Foo4 : Foo {virtual void f() {if (P) printf("%d\n", __LINE__);}};
-struct Foo5 : Foo {virtual void f() {if (P) printf("%d\n", __LINE__);}};
-struct Foo6 : Foo {virtual void f() {if (P) printf("%d\n", __LINE__);}};
-struct Foo7 : Foo {virtual void f() {if (P) printf("%d\n", __LINE__);}};
-struct Foo8 : Foo {virtual void f() {if (P) printf("%d\n", __LINE__);}};
-struct Foo9 : Foo {virtual void f() {if (P) printf("%d\n", __LINE__);}};
-struct Foo10 : Foo {virtual void f() {if (P) printf("%d\n", __LINE__);}};
-struct Foo11 : Foo {virtual void f() {if (P) printf("%d\n", __LINE__);}};
-struct Foo12 : Foo {virtual void f() {if (P) printf("%d\n", __LINE__);}};
-struct Foo13 : Foo {virtual void f() {if (P) printf("%d\n", __LINE__);}};
-struct Foo14 : Foo {virtual void f() {if (P) printf("%d\n", __LINE__);}};
-struct Foo15 : Foo {virtual void f() {if (P) printf("%d\n", __LINE__);}};
-struct Foo16 : Foo {virtual void f() {if (P) printf("%d\n", __LINE__);}};
-struct Foo17 : Foo {virtual void f() {if (P) printf("%d\n", __LINE__);}};
-struct Foo18 : Foo {virtual void f() {if (P) printf("%d\n", __LINE__);}};
-struct Foo19 : Foo {virtual void f() {if (P) printf("%d\n", __LINE__);}};
-
-Foo *foo[20] = {
-    new Foo,   new Foo1,  new Foo2,  new Foo3,  new Foo4,  new Foo5,  new Foo6,
-    new Foo7,  new Foo8,  new Foo9,  new Foo10, new Foo11, new Foo12, new Foo13,
-    new Foo14, new Foo15, new Foo16, new Foo17, new Foo18, new Foo19,
-};
-
-int n_functions = 10;
-int n_callers = 2;
-
-void *Thread(void *arg) {
-  if (n_callers >= 1) for (int i = 0; i < 2000; i++) foo[i % n_functions]->f();
-  if (n_callers >= 2) for (int i = 0; i < 2000; i++) foo[i % n_functions]->f();
-  if (n_callers >= 3) for (int i = 0; i < 2000; i++) foo[i % n_functions]->f();
-  return arg;
-}
-
-int main(int argc, char **argv) {
-  if (argc >= 2)
-    n_functions = atoi(argv[1]);
-  if (argc >= 3)
-    n_callers = atoi(argv[2]);
-  const int kNumThreads = 16;
-  pthread_t t[kNumThreads];
-  for (int i = 0; i < kNumThreads; i++)
-    pthread_create(&t[i], 0, Thread, 0);
-  for (int i = 0; i < kNumThreads; i++)
-    pthread_join(t[i], 0);
-}

Removed: compiler-rt/trunk/test/asan/TestCases/coverage-maybe-open-file.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/coverage-maybe-open-file.cc?rev=244826&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/coverage-maybe-open-file.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/coverage-maybe-open-file.cc (removed)
@@ -1,32 +0,0 @@
-// FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316
-// XFAIL: android
-//
-// RUN: %clangxx_asan -fsanitize-coverage=func %s -o %t
-// RUN: rm -rf %T/coverage-maybe-open-file
-// RUN: mkdir -p %T/coverage-maybe-open-file && cd %T/coverage-maybe-open-file
-// RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:coverage=1 %run %t | FileCheck %s --check-prefix=CHECK-success
-// RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:coverage=0 %run %t | FileCheck %s --check-prefix=CHECK-fail
-// RUN: [ "$(cat test.sancov.packed)" == "test" ]
-// RUN: cd .. && rm -rf %T/coverage-maybe-open-file
-
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <sanitizer/coverage_interface.h>
-
-// FIXME: the code below might not work on Windows.
-int main(int argc, char **argv) {
-  int fd = __sanitizer_maybe_open_cov_file("test");
-  if (fd > 0) {
-    printf("SUCCESS\n");
-    const char s[] = "test\n";
-    write(fd, s, strlen(s));
-    close(fd);
-  } else {
-    printf("FAIL\n");
-  }
-}
-
-// CHECK-success: SUCCESS
-// CHECK-fail: FAIL

Removed: compiler-rt/trunk/test/asan/TestCases/current_allocated_bytes.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/current_allocated_bytes.cc?rev=244826&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/current_allocated_bytes.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/current_allocated_bytes.cc (removed)
@@ -1,44 +0,0 @@
-// RUN: %clangxx_asan -O0 %s -pthread -o %t && %run %t
-// RUN: %clangxx_asan -O2 %s -pthread -o %t && %run %t
-// REQUIRES: stable-runtime
-
-#include <assert.h>
-#include <pthread.h>
-#include <sanitizer/allocator_interface.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-const size_t kLargeAlloc = 1UL << 20;
-
-void* allocate(void *arg) {
-  volatile void *ptr = malloc(kLargeAlloc);
-  free((void*)ptr);
-  return 0;
-}
-
-void* check_stats(void *arg) {
-  assert(__sanitizer_get_current_allocated_bytes() > 0);
-  return 0;
-}
-
-int main() {
-  size_t used_mem = __sanitizer_get_current_allocated_bytes();
-  printf("Before: %zu\n", used_mem);
-  const int kNumIterations = 1000;
-  for (int iter = 0; iter < kNumIterations; iter++) {
-    pthread_t thr[4];
-    for (int j = 0; j < 4; j++) {
-      assert(0 ==
-             pthread_create(&thr[j], 0, (j < 2) ? allocate : check_stats, 0));
-    }
-    for (int j = 0; j < 4; j++)
-      assert(0 == pthread_join(thr[j], 0));
-    used_mem = __sanitizer_get_current_allocated_bytes();
-    if (used_mem > kLargeAlloc) {
-      printf("After iteration %d: %zu\n", iter, used_mem);
-      return 1;
-    }
-  }
-  printf("Success after %d iterations\n", kNumIterations);
-  return 0;
-}

Removed: compiler-rt/trunk/test/asan/TestCases/deep_thread_stack.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/deep_thread_stack.cc?rev=244826&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/deep_thread_stack.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/deep_thread_stack.cc (removed)
@@ -1,58 +0,0 @@
-// RUN: %clangxx_asan -O0 %s -pthread -o %t && not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O1 %s -pthread -o %t && not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O2 %s -pthread -o %t && not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O3 %s -pthread -o %t && not %run %t 2>&1 | FileCheck %s
-// REQUIRES: stable-runtime
-
-#include <pthread.h>
-
-int *x;
-
-void *AllocThread(void *arg) {
-  x = new int;
-  *x = 42;
-  return NULL;
-}
-
-void *FreeThread(void *arg) {
-  delete x;
-  return NULL;
-}
-
-void *AccessThread(void *arg) {
-  *x = 43;  // BOOM
-  return NULL;
-}
-
-typedef void* (*callback_type)(void* arg);
-
-void *RunnerThread(void *function) {
-  pthread_t thread;
-  pthread_create(&thread, NULL, (callback_type)function, NULL);
-  pthread_join(thread, NULL);
-  return NULL;
-}
-
-void RunThread(callback_type function) {
-  pthread_t runner;
-  pthread_create(&runner, NULL, RunnerThread, (void*)function);
-  pthread_join(runner, NULL);
-}
-
-int main(int argc, char *argv[]) {
-  RunThread(AllocThread);
-  RunThread(FreeThread);
-  RunThread(AccessThread);
-  return (x != 0);
-}
-
-// CHECK: AddressSanitizer: heap-use-after-free
-// CHECK: WRITE of size 4 at 0x{{.*}} thread T[[ACCESS_THREAD:[0-9]+]]
-// CHECK: freed by thread T[[FREE_THREAD:[0-9]+]] here:
-// CHECK: previously allocated by thread T[[ALLOC_THREAD:[0-9]+]] here:
-// CHECK: Thread T[[ACCESS_THREAD]] created by T[[ACCESS_RUNNER:[0-9]+]] here:
-// CHECK: Thread T[[ACCESS_RUNNER]] created by T0 here:
-// CHECK: Thread T[[FREE_THREAD]] created by T[[FREE_RUNNER:[0-9]+]] here:
-// CHECK: Thread T[[FREE_RUNNER]] created by T0 here:
-// CHECK: Thread T[[ALLOC_THREAD]] created by T[[ALLOC_RUNNER:[0-9]+]] here:
-// CHECK: Thread T[[ALLOC_RUNNER]] created by T0 here:

Removed: compiler-rt/trunk/test/asan/TestCases/dlclose-test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/dlclose-test.cc?rev=244826&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/dlclose-test.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/dlclose-test.cc (removed)
@@ -1,106 +0,0 @@
-// Regression test for
-// http://code.google.com/p/address-sanitizer/issues/detail?id=19
-// Bug description:
-// 1. application dlopens foo.so
-// 2. asan registers all globals from foo.so
-// 3. application dlcloses foo.so
-// 4. application mmaps some memory to the location where foo.so was before
-// 5. application starts using this mmaped memory, but asan still thinks there
-// are globals.
-// 6. BOOM
-
-// This sublte test assumes that after a foo.so is dlclose-d
-// we can mmap the region of memory that has been occupied by the library.
-// It works on i368/x86_64 Linux, but not necessary anywhere else.
-// REQUIRES: x86_64-supported-target,i386-supported-target
-
-// RUN: %clangxx_asan -O0 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
-// RUN: %clangxx_asan -O0 %s %libdl -o %t && %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O1 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
-// RUN: %clangxx_asan -O1 %s %libdl -o %t && %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O2 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
-// RUN: %clangxx_asan -O2 %s %libdl -o %t && %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O3 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
-// RUN: %clangxx_asan -O3 %s %libdl -o %t && %run %t 2>&1 | FileCheck %s
-
-#if !defined(SHARED_LIB)
-#include <assert.h>
-#include <dlfcn.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <unistd.h>
-
-#include <string>
-
-#if defined(__FreeBSD__)
-// The MAP_NORESERVE define has been removed in FreeBSD 11.x, and even before
-// that, it was never implemented. So just define it to zero.
-#undef MAP_NORESERVE
-#define MAP_NORESERVE 0
-#endif
-
-using std::string;
-
-typedef int *(fun_t)();
-
-int main(int argc, char *argv[]) {
-  string path = string(argv[0]) + "-so.so";
-  size_t PageSize = sysconf(_SC_PAGESIZE);
-  printf("opening %s ... \n", path.c_str());
-  void *lib = dlopen(path.c_str(), RTLD_NOW);
-  if (!lib) {
-    printf("error in dlopen(): %s\n", dlerror());
-    return 1;
-  }
-  fun_t *get = (fun_t*)dlsym(lib, "get_address_of_static_var");
-  if (!get) {
-    printf("failed dlsym\n");
-    return 1;
-  }
-  int *addr = get();
-  assert(((size_t)addr % 32) == 0);  // should be 32-byte aligned.
-  printf("addr: %p\n", addr);
-  addr[0] = 1;  // make sure we can write there.
-
-  // Now dlclose the shared library.
-  printf("attempting to dlclose\n");
-  if (dlclose(lib)) {
-    printf("failed to dlclose\n");
-    return 1;
-  }
-  // Now, the page where 'addr' is unmapped. Map it.
-  size_t page_beg = ((size_t)addr) & ~(PageSize - 1);
-  void *res = mmap((void*)(page_beg), PageSize,
-                   PROT_READ | PROT_WRITE,
-                   MAP_PRIVATE | MAP_ANON | MAP_FIXED | MAP_NORESERVE, -1, 0);
-  if (res == (char*)-1L) {
-    printf("failed to mmap\n");
-    return 1;
-  }
-  addr[1] = 2;  // BOOM (if the bug is not fixed).
-  printf("PASS\n");
-  // CHECK: PASS
-  return 0;
-}
-#else  // SHARED_LIB
-#include <stdio.h>
-
-static int pad1;
-static int static_var;
-static int pad2;
-
-extern "C"
-int *get_address_of_static_var() {
-  return &static_var;
-}
-
-__attribute__((constructor))
-void at_dlopen() {
-  printf("%s: I am being dlopened\n", __FILE__);
-}
-__attribute__((destructor))
-void at_dlclose() {
-  printf("%s: I am being dlclosed\n", __FILE__);
-}
-#endif  // SHARED_LIB

Removed: compiler-rt/trunk/test/asan/TestCases/free_hook_realloc.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/free_hook_realloc.cc?rev=244826&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/free_hook_realloc.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/free_hook_realloc.cc (removed)
@@ -1,34 +0,0 @@
-// Check that free hook doesn't conflict with Realloc.
-// RUN: %clangxx_asan -O2 %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <sanitizer/allocator_interface.h>
-
-static void *glob_ptr;
-
-extern "C" {
-void __sanitizer_free_hook(const volatile void *ptr) {
-  if (ptr == glob_ptr) {
-    *(int*)ptr = 0;
-    write(1, "FreeHook\n", sizeof("FreeHook\n"));
-  }
-}
-}
-
-int main() {
-  int *x = (int*)malloc(100);
-  x[0] = 42;
-  glob_ptr = x;
-  int *y = (int*)realloc(x, 200);
-  // Verify that free hook was called and didn't spoil the memory.
-  if (y[0] != 42) {
-    _exit(1);
-  }
-  write(1, "Passed\n", sizeof("Passed\n"));
-  free(y);
-  // CHECK: FreeHook
-  // CHECK: Passed
-  return 0;
-}

Removed: compiler-rt/trunk/test/asan/TestCases/gc-test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/gc-test.cc?rev=244826&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/gc-test.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/gc-test.cc (removed)
@@ -1,54 +0,0 @@
-// RUN: %clangxx_asan %s -pthread -o %t
-// RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:detect_stack_use_after_return=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1
-// RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:detect_stack_use_after_return=0 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK0
-// RUN: %clangxx_asan -O3 %s -pthread -o %t
-// RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:detect_stack_use_after_return=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1
-// RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:detect_stack_use_after_return=0 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK0
-// REQUIRES: stable-runtime
-
-#include <assert.h>
-#include <stdio.h>
-#include <pthread.h>
-#include <sanitizer/asan_interface.h>
-
-static const int kNumThreads = 2;
-static const int kLeftRedzoneSize = sizeof(void *) * 4;
-
-void *Thread(void *unused)  {
-  void *fake_stack = __asan_get_current_fake_stack();
-  char var[15];
-  if (fake_stack) {
-    fprintf(stderr, "fake stack found: %p; var: %p\n", fake_stack, var);
-    // CHECK1: fake stack found
-    // CHECK1: fake stack found
-    void *beg, *end;
-    void *real_stack =
-        __asan_addr_is_in_fake_stack(fake_stack, &var[0], &beg, &end);
-    assert(real_stack);
-    assert((char*)beg <= (char*)&var[0]);
-    assert((char*)end > (char*)&var[0]);
-    for (int i = -kLeftRedzoneSize; i < 15; i++) {
-      void *beg1, *end1;
-      char *ptr = &var[0] + i;
-      void *real_stack1 =
-          __asan_addr_is_in_fake_stack(fake_stack, ptr, &beg1, &end1);
-      assert(real_stack == real_stack1);
-      assert(beg == beg1);
-      assert(end == end1);
-    }
-  } else {
-    fprintf(stderr, "no fake stack\n");
-    // CHECK0: no fake stack
-    // CHECK0: no fake stack
-  }
-  return NULL;
-}
-
-int main(int argc, char **argv) {
-  pthread_t t[kNumThreads];
-  for (int i = 0; i < kNumThreads; i++)
-    pthread_create(&t[i], 0, Thread, 0);
-  for (int i = 0; i < kNumThreads; i++)
-    pthread_join(t[i], 0);
-  return 0;
-}

Removed: compiler-rt/trunk/test/asan/TestCases/init-order-pthread-create.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/init-order-pthread-create.cc?rev=244826&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/init-order-pthread-create.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/init-order-pthread-create.cc (removed)
@@ -1,43 +0,0 @@
-// Check that init-order checking is properly disabled if pthread_create is
-// called.
-
-// RUN: %clangxx_asan %s %p/Helpers/init-order-pthread-create-extra.cc -pthread -o %t
-// RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:strict_init_order=true %run %t
-
-#include <stdio.h>
-#include <pthread.h>
-#include <unistd.h>
-
-void *bar(void *input, bool sleep_before_init) {
-  if (sleep_before_init)
-    usleep(500000);
-  return input;
-}
-
-void *glob = bar((void*)0x1234, false);
-extern void *glob2;
-
-void *poll(void *arg) {
-  void **glob = (void**)arg;
-  while (true) {
-    usleep(100000);
-    printf("glob is now: %p\n", *glob);
-  }
-}
-
-struct GlobalPollerStarter {
-  GlobalPollerStarter() {
-    pthread_t p;
-    pthread_attr_t attr;
-    pthread_attr_init(&attr);
-    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-    pthread_create(&p, 0, poll, &glob);
-    pthread_attr_destroy(&attr);
-    printf("glob poller is started");
-  }
-} global_poller;
-
-int main() {
-  printf("%p %p\n", glob, glob2);
-  return 0;
-}

Removed: compiler-rt/trunk/test/asan/TestCases/stack-overflow.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/stack-overflow.cc?rev=244826&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/stack-overflow.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/stack-overflow.cc (removed)
@@ -1,114 +0,0 @@
-// Test ASan detection of stack-overflow condition.
-
-// RUN: %clangxx_asan -O0 %s -DSMALL_FRAME -pthread -o %t && env ASAN_OPTIONS=$ASAN_OPTIONS:use_sigaltstack=1 not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O3 %s -DSMALL_FRAME -pthread -o %t && env ASAN_OPTIONS=$ASAN_OPTIONS:use_sigaltstack=1 not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O0 %s -DSAVE_ALL_THE_REGISTERS -pthread -o %t && env ASAN_OPTIONS=$ASAN_OPTIONS:use_sigaltstack=1 not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O3 %s -DSAVE_ALL_THE_REGISTERS -pthread -o %t && env ASAN_OPTIONS=$ASAN_OPTIONS:use_sigaltstack=1 not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O0 %s -pthread -o %t && env ASAN_OPTIONS=$ASAN_OPTIONS:use_sigaltstack=1 not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O3 %s -pthread -o %t && env ASAN_OPTIONS=$ASAN_OPTIONS:use_sigaltstack=1 not %run %t 2>&1 | FileCheck %s
-
-// RUN: %clangxx_asan -O0 %s -DTHREAD -DSMALL_FRAME -pthread -o %t && env ASAN_OPTIONS=$ASAN_OPTIONS:use_sigaltstack=1 not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O3 %s -DTHREAD -DSMALL_FRAME -pthread -o %t && env ASAN_OPTIONS=$ASAN_OPTIONS:use_sigaltstack=1 not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O0 %s -DTHREAD -DSAVE_ALL_THE_REGISTERS -pthread -o %t && env ASAN_OPTIONS=$ASAN_OPTIONS:use_sigaltstack=1 not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O3 %s -DTHREAD -DSAVE_ALL_THE_REGISTERS -pthread -o %t && env ASAN_OPTIONS=$ASAN_OPTIONS:use_sigaltstack=1 not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O0 %s -DTHREAD -pthread -o %t && env ASAN_OPTIONS=$ASAN_OPTIONS:use_sigaltstack=1 not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O3 %s -DTHREAD -pthread -o %t && env ASAN_OPTIONS=$ASAN_OPTIONS:use_sigaltstack=1 not %run %t 2>&1 | FileCheck %s
-// RUN: not %run %t 2>&1 | FileCheck %s
-// REQUIRES: stable-runtime
-
-#include <assert.h>
-#include <stdlib.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sanitizer/asan_interface.h>
-
-const int BS = 1024;
-volatile char x;
-volatile int y = 1;
-volatile int z0, z1, z2, z3, z4, z5, z6, z7, z8, z9, z10, z11, z12, z13;
-
-void recursive_func(char *p) {
-#if defined(SMALL_FRAME)
-  char *buf = 0;
-#elif defined(SAVE_ALL_THE_REGISTERS)
-  char *buf = 0;
-  int t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13;
-  t0 = z0;
-  t1 = z1;
-  t2 = z2;
-  t3 = z3;
-  t4 = z4;
-  t5 = z5;
-  t6 = z6;
-  t7 = z7;
-  t8 = z8;
-  t9 = z9;
-  t10 = z10;
-  t11 = z11;
-  t12 = z12;
-  t13 = z13;
-
-  z0 = t0;
-  z1 = t1;
-  z2 = t2;
-  z3 = t3;
-  z4 = t4;
-  z5 = t5;
-  z6 = t6;
-  z7 = t7;
-  z8 = t8;
-  z9 = t9;
-  z10 = t10;
-  z11 = t11;
-  z12 = t12;
-  z13 = t13;
-#else
-  char buf[BS];
-  // Check that the stack grows in the righ direction, unless we use fake stack.
-  if (p && !__asan_get_current_fake_stack())
-    assert(p - buf >= BS);
-  buf[rand() % BS] = 1;
-  buf[rand() % BS] = 2;
-  x = buf[rand() % BS];
-#endif
-  if (y)
-    recursive_func(buf);
-  x = 1; // prevent tail call optimization
-  // CHECK: {{stack-overflow on address 0x.* \(pc 0x.* bp 0x.* sp 0x.* T.*\)}}
-  // If stack overflow happens during function prologue, stack trace may be
-  // corrupted. Unwind tables are not always 100% exact there.
-  // For this reason, we don't do any further checks.
-}
-
-void *ThreadFn(void* unused) {
-  recursive_func(0);
-  return 0;
-}
-
-void LimitStackAndReexec(int argc, char **argv) {
-  struct rlimit rlim;
-  int res = getrlimit(RLIMIT_STACK, &rlim);
-  assert(res == 0);
-  if (rlim.rlim_cur == RLIM_INFINITY) {
-    rlim.rlim_cur = 256 * 1024;
-    res = setrlimit(RLIMIT_STACK, &rlim);
-    assert(res == 0);
-
-    execv(argv[0], argv);
-    assert(0 && "unreachable");
-  }
-}
-
-int main(int argc, char **argv) {
-  LimitStackAndReexec(argc, argv);
-#ifdef THREAD
-  pthread_t t;
-  pthread_create(&t, 0, ThreadFn, 0);
-  pthread_join(t, 0);
-#else
-  recursive_func(0);
-#endif
-  return 0;
-}

Removed: compiler-rt/trunk/test/asan/TestCases/stack-use-after-return.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/stack-use-after-return.cc?rev=244826&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/stack-use-after-return.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/stack-use-after-return.cc (removed)
@@ -1,80 +0,0 @@
-// RUN: export ASAN_OPTIONS=$ASAN_OPTIONS:detect_stack_use_after_return=1
-// RUN: %clangxx_asan  -O0 %s -pthread -o %t && not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan  -O1 %s -pthread -o %t && not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan  -O2 %s -pthread -o %t && not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan  -O3 %s -pthread -o %t && not %run %t 2>&1 | FileCheck %s
-// RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:detect_stack_use_after_return=0 %run %t
-// Regression test for a CHECK failure with small stack size and large frame.
-// RUN: %clangxx_asan  -O3 %s -pthread -o %t -DkSize=10000 -DUseThread -DkStackSize=65536 && not %run %t 2>&1 | FileCheck --check-prefix=THREAD %s
-//
-// Test that we can find UAR in a thread other than main:
-// RUN: %clangxx_asan  -DUseThread -O2 %s -pthread -o %t && not %run %t 2>&1 | FileCheck --check-prefix=THREAD %s
-//
-// Test the max_uar_stack_size_log/min_uar_stack_size_log flag.
-//
-// RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:max_uar_stack_size_log=20:verbosity=1 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-20 %s
-// RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:min_uar_stack_size_log=24:max_uar_stack_size_log=24:verbosity=1 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-24 %s
-
-#include <stdio.h>
-#include <pthread.h>
-
-#ifndef kSize
-# define kSize 1
-#endif
-
-#ifndef UseThread
-# define UseThread 0
-#endif
-
-#ifndef kStackSize
-# define kStackSize 0
-#endif
-
-__attribute__((noinline))
-char *Ident(char *x) {
-  fprintf(stderr, "1: %p\n", x);
-  return x;
-}
-
-__attribute__((noinline))
-char *Func1() {
-  char local[kSize];
-  return Ident(local);
-}
-
-__attribute__((noinline))
-void Func2(char *x) {
-  fprintf(stderr, "2: %p\n", x);
-  *x = 1;
-  // CHECK: WRITE of size 1 {{.*}} thread T0
-  // CHECK:     #0{{.*}}Func2{{.*}}stack-use-after-return.cc:[[@LINE-2]]
-  // CHECK: is located in stack of thread T0 at offset
-  // CHECK: 'local' <== Memory access at offset {{16|32}} is inside this variable
-  // THREAD: WRITE of size 1 {{.*}} thread T{{[1-9]}}
-  // THREAD:     #0{{.*}}Func2{{.*}}stack-use-after-return.cc:[[@LINE-6]]
-  // THREAD: is located in stack of thread T{{[1-9]}} at offset
-  // THREAD: 'local' <== Memory access at offset {{16|32}} is inside this variable
-  // CHECK-20: T0: FakeStack created:{{.*}} stack_size_log: 20
-  // CHECK-24: T0: FakeStack created:{{.*}} stack_size_log: 24
-}
-
-void *Thread(void *unused)  {
-  Func2(Func1());
-  return NULL;
-}
-
-int main(int argc, char **argv) {
-#if UseThread
-  pthread_attr_t attr;
-  pthread_attr_init(&attr);
-  if (kStackSize > 0)
-    pthread_attr_setstacksize(&attr, kStackSize);
-  pthread_t t;
-  pthread_create(&t, &attr, Thread, 0);
-  pthread_attr_destroy(&attr);
-  pthread_join(t, 0);
-#else
-  Func2(Func1());
-#endif
-  return 0;
-}




More information about the llvm-commits mailing list