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
95 lines
2.1 KiB
C++
95 lines
2.1 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#pragma once
|
|
#ifdef __linux__
|
|
#include <errno.h>
|
|
#include <error.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <fstream>
|
|
#include <iostream>
|
|
#include <string>
|
|
|
|
struct CaptureStream {
|
|
int saved_fd;
|
|
int orig_fd;
|
|
int temp_fd;
|
|
|
|
char tempname[13] = "mytestXXXXXX";
|
|
|
|
explicit CaptureStream(FILE* original) {
|
|
orig_fd = fileno(original);
|
|
saved_fd = dup(orig_fd);
|
|
|
|
if ((temp_fd = mkstemp(tempname)) == -1) {
|
|
error(0, errno, "Error");
|
|
assert(false);
|
|
}
|
|
|
|
fflush(nullptr);
|
|
if (dup2(temp_fd, orig_fd) == -1) {
|
|
error(0, errno, "Error");
|
|
assert(false);
|
|
}
|
|
if (close(temp_fd) != 0) {
|
|
error(0, errno, "Error");
|
|
assert(false);
|
|
}
|
|
}
|
|
|
|
void restoreStream() {
|
|
if (saved_fd == -1) return;
|
|
fflush(nullptr);
|
|
if (dup2(saved_fd, orig_fd) == -1) {
|
|
error(0, errno, "Error");
|
|
assert(false);
|
|
}
|
|
if (close(saved_fd) != 0) {
|
|
error(0, errno, "Error");
|
|
assert(false);
|
|
}
|
|
saved_fd = -1;
|
|
}
|
|
|
|
const char* getTempFilename() { return (const char*)tempname; }
|
|
|
|
std::ifstream getCapturedData() {
|
|
restoreStream();
|
|
std::ifstream temp(tempname);
|
|
return temp;
|
|
}
|
|
|
|
~CaptureStream() {
|
|
restoreStream();
|
|
if (remove(tempname) != 0) {
|
|
error(0, errno, "Error");
|
|
assert(false);
|
|
}
|
|
}
|
|
std::string gulp(std::ifstream& input) {
|
|
std::string retval;
|
|
input.seekg(0, std::ios_base::end);
|
|
retval.resize(input.tellg());
|
|
input.seekg(0, std::ios_base::beg);
|
|
input.read(&retval[0], retval.size());
|
|
input.close();
|
|
return retval;
|
|
}
|
|
};
|
|
extern const char* msg_short;
|
|
extern const char* msg_long1;
|
|
extern const char* msg_long2;
|
|
|
|
__device__ const char* msg_short_dev = "Carpe diem.";
|
|
__device__ const char* msg_long1_dev =
|
|
"Lorem ipsum dolor sit amet, consectetur nullam. In mollis imperdiet nibh nec ullamcorper."; // NOLINT
|
|
__device__ const char* msg_long2_dev =
|
|
"Curabitur nec metus sit amet augue vehicula ultrices ut id leo. Lorem ipsum dolor sit amet, "
|
|
"consectetur adipiscing elit amet."; // NOLINT
|
|
#endif
|