diff --git a/compiler-rt/test/xray/TestCases/Posix/patching-unpatching.cpp b/compiler-rt/test/xray/TestCases/Posix/patching-unpatching.cpp index a8a820bbe45f2..2bd85e8cc570d 100644 --- a/compiler-rt/test/xray/TestCases/Posix/patching-unpatching.cpp +++ b/compiler-rt/test/xray/TestCases/Posix/patching-unpatching.cpp @@ -26,6 +26,31 @@ void test_handler(int32_t fid, XRayEntryType type) { int main() { __xray_set_handler(test_handler); always_instrument(); +#if defined(__riscv) + // RISC-V has looser execution ordering; relax CHECK-NEXT to CHECK + // CHECK: always instrumented called + auto status = __xray_patch(); + printf("patching status: %d\n", static_cast(status)); + // CHECK-NEXT: patching status: 1 + always_instrument(); + // CHECK: called: {{.*}}, type=0 + // CHECK: always instrumented called + // CHECK-NEXT: called: {{.*}}, type=1 + status = __xray_unpatch(); + printf("patching status: %d\n", static_cast(status)); + // CHECK: patching status: 1 + always_instrument(); + // CHECK: always instrumented called + status = __xray_patch(); + printf("patching status: %d\n", static_cast(status)); + // CHECK: patching status: 1 + __xray_remove_handler(); + always_instrument(); + // CHECK: always instrumented called + status = __xray_unpatch(); + printf("patching status: %d\n", static_cast(status)); + // CHECK: patching status: 1 +#else // CHECK: always instrumented called auto status = __xray_patch(); printf("patching status: %d\n", static_cast(status)); @@ -48,4 +73,5 @@ int main() { status = __xray_unpatch(); printf("patching status: %d\n", static_cast(status)); // CHECK-NEXT: patching status: 1 +#endif }