Bug 1830271 [Linux] Disable logging for vaapi test by default r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D176638
This commit is contained in:
stransky 2023-04-27 11:39:36 +00:00
parent fa53c65dc3
commit f7b14d8b80
3 changed files with 29 additions and 26 deletions

View File

@ -171,15 +171,13 @@ typedef struct _drmDevice {
# define LIBDRM_FILENAME "libdrm.so.2"
#endif
static int glxtest_out_pipe = 1;
#ifdef MOZ_X11
static int x_error_handler(Display*, XErrorEvent* ev) {
record_value(
"ERROR\nX error, error_code=%d, "
"request_code=%d, minor_code=%d\n",
ev->error_code, ev->request_code, ev->minor_code);
record_flush(glxtest_out_pipe);
record_flush();
_exit(EXIT_FAILURE);
}
#endif
@ -964,7 +962,7 @@ int childgltest(bool aWayland) {
}
#endif
// Finally write buffered data to the pipe.
record_flush(glxtest_out_pipe);
record_flush();
log("GLX_TEST: childgltest finished\n");
return EXIT_SUCCESS;
@ -972,20 +970,6 @@ int childgltest(bool aWayland) {
} // extern "C"
static void close_logging() {
// we want to redirect to /dev/null stdout, stderr, and while we're at it,
// any PR logging file descriptors. To that effect, we redirect all positive
// file descriptors up to what open() returns here. In particular, 1 is stdout
// and 2 is stderr.
int fd = open("/dev/null", O_WRONLY);
for (int i = 1; i < fd; i++) {
if (glxtest_out_pipe != i) {
dup2(fd, i);
}
}
close(fd);
}
static void PrintUsage() {
printf(
"Firefox OpenGL probe utility\n"
@ -1016,7 +1000,7 @@ int main(int argc, char** argv) {
wayland = true;
break;
case 'f':
glxtest_out_pipe = atoi(optarg);
output_pipe = atoi(optarg);
break;
case 'h':
#ifdef MOZ_WAYLAND
@ -1033,7 +1017,7 @@ int main(int argc, char** argv) {
}
if (getenv("MOZ_AVOID_OPENGL_ALTOGETHER")) {
const char* msg = "ERROR\nMOZ_AVOID_OPENGL_ALTOGETHER envvar set";
MOZ_UNUSED(write(glxtest_out_pipe, msg, strlen(msg)));
MOZ_UNUSED(write(output_pipe, msg, strlen(msg)));
exit(EXIT_FAILURE);
}
const char* env = getenv("MOZ_GFX_DEBUG");

View File

@ -30,6 +30,21 @@ static void log(const char* format, ...) {
va_end(args);
}
static int output_pipe = 1;
static void close_logging() {
// we want to redirect to /dev/null stdout, stderr, and while we're at it,
// any PR logging file descriptors. To that effect, we redirect all positive
// file descriptors up to what open() returns here. In particular, 1 is stdout
// and 2 is stderr.
int fd = open("/dev/null", O_WRONLY);
for (int i = 1; i < fd; i++) {
if (output_pipe != i) {
dup2(fd, i);
}
}
close(fd);
}
// C++ standard collides with C standard in that it doesn't allow casting void*
// to function pointer types. So the work-around is to convert first to size_t.
// http://www.trilithium.com/johan/2004/12/problem-with-dlsym/
@ -70,11 +85,11 @@ static void record_warning(const char* str) {
record_value("WARNING\n%s\n", str);
}
static void record_flush(int out_pipe) {
static void record_flush() {
if (!test_buf) {
return;
}
MOZ_UNUSED(write(out_pipe, test_buf, test_length));
MOZ_UNUSED(write(output_pipe, test_buf, test_length));
if (enable_logging) {
MOZ_UNUSED(write(LOG_PIPE, test_buf, test_length));
}

View File

@ -34,7 +34,7 @@
// Print VA-API test results to stdout and logging to stderr
#define OUTPUT_PIPE 1
// bits to use decoding childvaapitest() return values.
// bits to use decoding vaapitest() return values.
constexpr int CODEC_HW_H264 = 1 << 4;
constexpr int CODEC_HW_VP8 = 1 << 5;
constexpr int CODEC_HW_VP9 = 1 << 6;
@ -79,7 +79,7 @@ static void vaapitest(const char* aRenderDevicePath) {
VADisplay display = nullptr;
void* libDrm = nullptr;
log("childvaapitest start, device %s\n", aRenderDevicePath);
log("vaapitest start, device %s\n", aRenderDevicePath);
auto autoRelease = mozilla::MakeScopeExit([&] {
free(profiles);
@ -197,7 +197,7 @@ static void vaapitest(const char* aRenderDevicePath) {
} else {
record_value("VAAPI_SUPPORTED\nFALSE\n");
}
log("childvaapitest finished\n");
log("vaapitest finished\n");
}
} // extern "C"
@ -241,8 +241,12 @@ int main(int argc, char** argv) {
#endif
const char* env = getenv("MOZ_GFX_DEBUG");
enable_logging = env && *env == '1';
output_pipe = OUTPUT_PIPE;
if (!enable_logging) {
close_logging();
}
vaapitest(drmDevice);
record_flush(OUTPUT_PIPE);
record_flush();
return EXIT_SUCCESS;
}
PrintUsage();