Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Test suite does not fully respect ${TMPDIR} #793

@Arfrever

Description

@Arfrever

Portage, package manager in Gentoo, sets TMPDIR environmental variable to per-package-version temporary directory.
E.g. TMPDIR="/var/tmp/portage/dev-cpp/glog-0.5.0/temp"

When test suite of Glog is run, it creates e.g. the following files in ${TMPDIR}:

logging_custom_prefix_unittest.ERROR -> logging_custom_prefix_unittest.localhost.portage.log.ERROR.20220218-105043.71
logging_custom_prefix_unittest.INFO -> logging_custom_prefix_unittest.localhost.portage.log.INFO.20220218-105043.71
logging_custom_prefix_unittest.WARNING -> logging_custom_prefix_unittest.localhost.portage.log.WARNING.20220218-105043.71
logging_custom_prefix_unittest.localhost.portage.log.ERROR.20220218-105043.71
logging_custom_prefix_unittest.localhost.portage.log.INFO.20220218-105043.71
logging_custom_prefix_unittest.localhost.portage.log.WARNING.20220218-105043.71
logging_unittest.ERROR -> logging_unittest.localhost.portage.log.ERROR.20220218-105044.76
logging_unittest.INFO -> logging_unittest.localhost.portage.log.INFO.20220218-105044.76
logging_unittest.WARNING -> logging_unittest.localhost.portage.log.WARNING.20220218-105044.76
logging_unittest.localhost.portage.log.ERROR.20220218-105044.76
logging_unittest.localhost.portage.log.INFO.20220218-105044.76
logging_unittest.localhost.portage.log.WARNING.20220218-105044.76
mock-log_unittest.ERROR -> mock-log_unittest.localhost.portage.log.ERROR.20220218-105046.84
mock-log_unittest.INFO -> mock-log_unittest.localhost.portage.log.INFO.20220218-105046.84
mock-log_unittest.WARNING -> mock-log_unittest.localhost.portage.log.WARNING.20220218-105046.84
mock-log_unittest.localhost.portage.log.ERROR.20220218-105046.84
mock-log_unittest.localhost.portage.log.INFO.20220218-105046.84
mock-log_unittest.localhost.portage.log.WARNING.20220218-105046.84

However test suite also leaves some files in /tmp without respecting ${TMPDIR}, e.g.:

captured.err
logging_custom_prefix_unittest.INFO -> logging_test_basename_two_processes_writing
logging_unittest.INFO -> logging_test_basename_two_processes_writing
symlinkbase.INFO -> logging_test_extension20220218-105045.76specialextension
truncatefile
truncatefile.link -> /tmp/truncatefile
truncatefilecustom
truncatefilecustom.link -> /tmp/truncatefilecustom

Current usage of ${TMPDIR} is e.g. here:

glog/src/logging.cc

Lines 2271 to 2282 in b38ed9d

// Directories, in order of preference. If we find a dir that
// exists, we stop adding other less-preferred dirs
const char * candidates[] = {
// Non-null only during unittest/regtest
getenv("TEST_TMPDIR"),
// Explicitly-supplied temp dirs
getenv("TMPDIR"), getenv("TMP"),
// If all else fails
"/tmp",
};

Hardcoded usage of /tmp is here:

glog/src/googletest.h

Lines 78 to 80 in b38ed9d

static inline string GetTempDir() {
#ifndef GLOG_OS_WINDOWS
return "/tmp";

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions