4dd0f462a5
run_self_tests() now takes the same effective AppConfig any other command
gets and stashes it into a new g_test_app_config global (tests/support/
fixtures.h) before Catch2 runs anything. test_rootless_run.cpp's own
run_in_fixture() reads a copy of it instead of a hardcoded default
AppConfig{}, so -c actually reaches that test's container creation.
Verified: a config with every unshare-*/with-* key set to false, used via
-c <file> -t -- "[integration][net]~[root]", flips all 3 of that file's
container-creating tests to failing -- including the nohup-straggler
regression test, since with neither a pid namespace nor a cgroup nothing
reaps the backgrounded process -- while [unit] and non-networking
[integration] tests are completely unaffected, as expected.
45 lines
2.2 KiB
C++
45 lines
2.2 KiB
C++
// Copyright (C) 2026 Viorel Munteanu
|
|
//
|
|
// This program is free software; you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License along
|
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "config_file.h"
|
|
|
|
// Implements -t/--test, this project's own built-in Catch2-driven test
|
|
// suite (distinct from the Meson-driven fixture smoke test under tests/,
|
|
// which stays a separate, always-on mount/unmount/cleanup check).
|
|
// `args` is `ParsedArgs::test_args` (cli_args.h) -- everything on the
|
|
// command line after `-t`, forwarded to Catch2's own Session::run()
|
|
// unmodified (tag expressions, --list-tests, --reporter, etc.); a bare
|
|
// `-t` (empty `args`) runs every registered TEST_CASE. `config` is the
|
|
// same effective (`-c/--config-file`-resolved) AppConfig any other command
|
|
// gets, given to test code so a test that creates a real container can
|
|
// reflect the same global settings a real `-r/--run` would (see
|
|
// `tests/support/fixtures.h`'s `g_test_app_config`, which this stashes it
|
|
// into) -- letting e.g. `-c <all-unshare-off.yaml> -t -- "[integration][net]"`
|
|
// exercise what happens with pid/cgroup isolation actually disabled,
|
|
// instead of every test always creating containers under hardcoded
|
|
// defaults regardless of `-c`. Only compiled to
|
|
// actually run Catch2 when this build has ENABLE_TESTS set (config.h,
|
|
// from Meson's `enable_tests` option, default on) -- otherwise prints a
|
|
// clear "not compiled into this build" message and returns nonzero,
|
|
// since a -Denable_tests=false build has no TEST_CASEs (or Catch2 itself)
|
|
// linked in at all.
|
|
int run_self_tests(const std::vector<std::string>& args, const AppConfig& config);
|