Files
TheRock/compiler/amd-llvm/compiler-rt/test/xray/TestCases/Posix/fdr-mode-inmemory.cpp
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

52 lines
1.9 KiB
C++

// RUN: %clangxx_xray -g -std=c++11 %s -o %t -fxray-modes=xray-fdr
// RUN: rm -rf %t.dir
// RUN: mkdir -p %t.dir
// RUN: cd %t.dir
// RUN: env XRAY_OPTIONS="patch_premain=false xray_logfile_base=fdr-inmemory-test- \
// RUN: verbosity=1" \
// RUN: env XRAY_FDR_OPTIONS="no_file_flush=true func_duration_threshold_us=0" \
// RUN: %run %t 2>&1 | FileCheck %s
// RUN: find %t.dir -name 'fdr-inmemory-test-*' | wc -l | tr -d '\n' > %t.file_count
// RUN: %python -c "import sys; sys.exit(int(sys.argv[1]))" %{readfile:%t.file_count}
// RUN: rm -rf %t.dir
//
// REQUIRES: built-in-llvm-tree
#include "xray/xray_log_interface.h"
#include <cassert>
#include <iostream>
uint64_t var = 0;
uint64_t buffers = 0;
[[clang::xray_always_instrument]] void __attribute__((noinline)) f() { ++var; }
int main(int argc, char *argv[]) {
assert(__xray_log_select_mode("xray-fdr") ==
XRayLogRegisterStatus::XRAY_REGISTRATION_OK);
auto status = __xray_log_init_mode(
"xray-fdr",
"buffer_size=4096:buffer_max=10:func_duration_threshold_us=0");
assert(status == XRayLogInitStatus::XRAY_LOG_INITIALIZED);
__xray_patch();
// Create enough entries.
for (int i = 0; i != 1 << 20; ++i) {
f();
}
// Then we want to verify that we're getting 10 buffers outside of the initial
// header.
auto finalize_status = __xray_log_finalize();
assert(finalize_status == XRayLogInitStatus::XRAY_LOG_FINALIZED);
auto process_status =
__xray_log_process_buffers([](const char *, XRayBuffer) { ++buffers; });
std::cout << "buffers = " << buffers << std::endl;
assert(process_status == XRayLogFlushStatus::XRAY_LOG_FLUSHED);
auto flush_status = __xray_log_flushLog();
assert(flush_status == XRayLogFlushStatus::XRAY_LOG_FLUSHED);
// We expect 11 buffers because 1 header buffer + 10 actual FDR buffers.
// CHECK: Buffers = 11
std::cout << "Buffers = " << buffers << std::endl;
return 0;
}