diff options
Diffstat (limited to 'test/xray/TestCases')
-rw-r--r-- | test/xray/TestCases/Linux/fixedsize-logging.cc | 20 | ||||
-rw-r--r-- | test/xray/TestCases/Linux/optional-inmemory-log.cc | 21 | ||||
-rw-r--r-- | test/xray/TestCases/Linux/patching-unpatching.cc | 48 |
3 files changed, 89 insertions, 0 deletions
diff --git a/test/xray/TestCases/Linux/fixedsize-logging.cc b/test/xray/TestCases/Linux/fixedsize-logging.cc new file mode 100644 index 0000000000000..90e766876c546 --- /dev/null +++ b/test/xray/TestCases/Linux/fixedsize-logging.cc @@ -0,0 +1,20 @@ +// Check to make sure that we have a log file with a fixed-size. + +// RUN: %clangxx_xray -std=c++11 %s -o %t +// RUN: XRAY_OPTIONS="verbosity=1 xray_logfile_base=fixedsize-logging-" %run %t 2>&1 | FileCheck %s +// +// After all that, clean up the output xray log. +// +// RUN: rm fixedsize-logging-* + +#include <cstdio> + +[[clang::xray_always_instrument]] void foo() { + printf("foo() is always instrumented!"); +} + +int main() { + // CHECK: XRay: Log file in 'fixedsize-logging-{{.*}}' + foo(); + // CHECK: foo() is always instrumented! +} diff --git a/test/xray/TestCases/Linux/optional-inmemory-log.cc b/test/xray/TestCases/Linux/optional-inmemory-log.cc new file mode 100644 index 0000000000000..ef2c43f3be776 --- /dev/null +++ b/test/xray/TestCases/Linux/optional-inmemory-log.cc @@ -0,0 +1,21 @@ +// Make sure that we don't get the inmemory logging implementation enabled when +// we turn it off via options. + +// RUN: %clangxx_xray -std=c++11 %s -o %t +// RUN: XRAY_OPTIONS="verbosity=1 xray_naive_log=false xray_logfile_base=optional-inmemory-log.xray-" %run %t 2>&1 | FileCheck %s +// +// Make sure we clean out the logs in case there was a bug. +// +// RUN: rm -f optional-inmemory-log.xray-* + +#include <cstdio> + +[[clang::xray_always_instrument]] void foo() { + printf("foo() is always instrumented!"); +} + +int main() { + // CHECK-NOT: XRay: Log file in 'optional-inmemory-log.xray-{{.*}}' + foo(); + // CHECK: foo() is always instrumented! +} diff --git a/test/xray/TestCases/Linux/patching-unpatching.cc b/test/xray/TestCases/Linux/patching-unpatching.cc new file mode 100644 index 0000000000000..e684e427f068f --- /dev/null +++ b/test/xray/TestCases/Linux/patching-unpatching.cc @@ -0,0 +1,48 @@ +// Check that we can patch and un-patch on demand, and that logging gets invoked +// appropriately. +// +// RUN: %clangxx_xray -fxray-instrument -std=c++11 %s -o %t +// RUN: XRAY_OPTIONS="patch_premain=false" %run %t 2>&1 | FileCheck %s +// REQUIRES: stable-runtime + +#include "xray/xray_interface.h" + +#include <cstdio> + +bool called = false; + +void test_handler(int32_t fid, XRayEntryType type) { + printf("called: %d, type=%d\n", fid, static_cast<int32_t>(type)); + called = true; +} + +[[clang::xray_always_instrument]] void always_instrument() { + printf("always instrumented called\n"); +} + +int main() { + __xray_set_handler(test_handler); + always_instrument(); + // CHECK: always instrumented called + auto status = __xray_patch(); + printf("patching status: %d\n", static_cast<int32_t>(status)); + // CHECK-NEXT: patching status: 1 + always_instrument(); + // CHECK-NEXT: called: {{.*}}, type=0 + // CHECK-NEXT: always instrumented called + // CHECK-NEXT: called: {{.*}}, type=1 + status = __xray_unpatch(); + printf("patching status: %d\n", static_cast<int32_t>(status)); + // CHECK-NEXT: patching status: 1 + always_instrument(); + // CHECK-NEXT: always instrumented called + status = __xray_patch(); + printf("patching status: %d\n", static_cast<int32_t>(status)); + // CHECK-NEXT: patching status: 1 + __xray_remove_handler(); + always_instrument(); + // CHECK-NEXT: always instrumented called + status = __xray_unpatch(); + printf("patching status: %d\n", static_cast<int32_t>(status)); + // CHECK-NEXT: patching status: 1 +} |