|
KiCad PCB EDA Suite
|
#include <boost/test/unit_test.hpp>#include <atomic>#include <filesystem>#include <optional>#include <thread>#include <vector>#include <common.h>#include <env_paths.h>#include <env_vars.h>#include <jobs/job_export_pcb_stats.h>#include <pgm_base.h>#include <settings/environment.h>#include <title_block.h>#include <wx/filename.h>#include <wx/utils.h>Go to the source code of this file.
Classes | |
| struct | ExpandTextVarsFixture |
| Test fixture for ExpandTextVars tests. More... | |
| struct | OverlappingEnvVarsFixture |
| Regression tests for overlapping-prefix environment variables. More... | |
| struct | EnvVarRecursiveExpansionFixture |
| Regression test for KiCad GitLab issue #24244. More... | |
| struct | VersionedEnvVarFallbackFixture |
| Regression test for KiCad GitLab issue #24460. More... | |
Macros | |
| #define | BOOST_TEST_NO_MAIN |
Functions | |
| BOOST_AUTO_TEST_CASE (SimpleVariable) | |
| BOOST_AUTO_TEST_CASE (MultipleVariables) | |
| BOOST_AUTO_TEST_CASE (EscapedVariable) | |
| BOOST_AUTO_TEST_CASE (EscapedThenRegularVariable) | |
| BOOST_AUTO_TEST_CASE (RegularThenEscapedVariable) | |
| BOOST_AUTO_TEST_CASE (EscapedInsideMathExpression) | |
| BOOST_AUTO_TEST_CASE (EscapedInsideVariableReference) | |
| BOOST_AUTO_TEST_CASE (MultipleEscapedInMathExpression) | |
| BOOST_AUTO_TEST_CASE (EscapedAtInExpression) | |
| BOOST_AUTO_TEST_CASE (ConsecutiveEscaped) | |
| BOOST_AUTO_TEST_CASE (BackslashBeforeVariableIsEscape) | |
| BOOST_AUTO_TEST_CASE (ForwardSlashBeforeVariableExpands) | |
| BOOST_AUTO_TEST_CASE (BackslashSeparatorBeforeVarExpands) | |
| BOOST_AUTO_TEST_CASE (MultipleVarsAfterBackslashSeparators) | |
| BOOST_AUTO_TEST_CASE (ForwardSlashPathUnchanged) | |
| BOOST_AUTO_TEST_CASE (NonVariableBackslashesArePreserved) | |
| BOOST_AUTO_TEST_CASE (BackslashPathSeparatorBeforeTextVar) | |
| BOOST_AUTO_TEST_CASE (BackslashPathSeparatorBeforeMultipleTextVars) | |
| BOOST_AUTO_TEST_CASE (TextVarNotFirstInFilename) | |
| BOOST_AUTO_TEST_CASE (NormalizePicksLongestPrefix) | |
| BOOST_AUTO_TEST_CASE (RoundTripPreservesAbsolutePath) | |
| BOOST_AUTO_TEST_CASE (ParallelResolveTextVarsWithMathExpressions) | |
| Regression test for KiCad GitLab issue #23962. | |
| BOOST_AUTO_TEST_CASE (ExpandsNestedReferences) | |
| BOOST_AUTO_TEST_CASE (UndefinedReferenceLeavesLiteralMarker) | |
| BOOST_AUTO_TEST_CASE (UserVarIsNotTreatedAsVersionedLibraryDir) | |
| BOOST_AUTO_TEST_CASE (LegacyVersionedVarStillResolvesToCurrentDir) | |
| BOOST_AUTO_TEST_CASE (DeprecatedUnversionedAliasStillResolves) | |
| BOOST_AUTO_TEST_CASE (IsVersionedEnvVarPredicate) | |
| #define BOOST_TEST_NO_MAIN |
Definition at line 21 of file test_expand_text_vars.cpp.
| BOOST_AUTO_TEST_CASE | ( | BackslashBeforeVariableIsEscape | ) |
Definition at line 194 of file test_expand_text_vars.cpp.
References ExpandTextVars(), resolver, and result.
| BOOST_AUTO_TEST_CASE | ( | BackslashPathSeparatorBeforeMultipleTextVars | ) |
Definition at line 288 of file test_expand_text_vars.cpp.
References BOOST_CHECK_MESSAGE(), path, JOB::ResolveOutputPath(), result, TITLE_BLOCK::SetComment(), TITLE_BLOCK::SetRevision(), and JOB::SetTitleBlock().
| BOOST_AUTO_TEST_CASE | ( | BackslashPathSeparatorBeforeTextVar | ) |
Definition at line 267 of file test_expand_text_vars.cpp.
References BOOST_AUTO_TEST_CASE(), BOOST_CHECK_MESSAGE(), path, JOB::ResolveOutputPath(), result, TITLE_BLOCK::SetRevision(), and JOB::SetTitleBlock().
| BOOST_AUTO_TEST_CASE | ( | BackslashSeparatorBeforeVarExpands | ) |
Definition at line 219 of file test_expand_text_vars.cpp.
References BOOST_AUTO_TEST_CASE(), BOOST_CHECK_MESSAGE(), ExpandTextVars(), NormalizeFilePathForTextVars(), path, resolver, and result.
| BOOST_AUTO_TEST_CASE | ( | ConsecutiveEscaped | ) |
Definition at line 173 of file test_expand_text_vars.cpp.
References BOOST_CHECK_EQUAL(), ExpandTextVars(), resolver, and result.
| BOOST_AUTO_TEST_CASE | ( | DeprecatedUnversionedAliasStillResolves | ) |
Definition at line 680 of file test_expand_text_vars.cpp.
References BOOST_CHECK_EQUAL(), ExpandEnvVarSubstitutions(), and ENV_VAR::GetVersionedEnvVarName().
| BOOST_AUTO_TEST_CASE | ( | EscapedAtInExpression | ) |
Definition at line 163 of file test_expand_text_vars.cpp.
References ExpandTextVars(), resolver, and result.
| BOOST_AUTO_TEST_CASE | ( | EscapedInsideMathExpression | ) |
Definition at line 110 of file test_expand_text_vars.cpp.
References BOOST_CHECK_MESSAGE(), ExpandTextVars(), resolver, and result.
| BOOST_AUTO_TEST_CASE | ( | EscapedInsideVariableReference | ) |
Definition at line 129 of file test_expand_text_vars.cpp.
References ExpandTextVars(), resolver, and result.
| BOOST_AUTO_TEST_CASE | ( | EscapedThenRegularVariable | ) |
Definition at line 91 of file test_expand_text_vars.cpp.
References ExpandTextVars(), resolver, and result.
| BOOST_AUTO_TEST_CASE | ( | EscapedVariable | ) |
Definition at line 83 of file test_expand_text_vars.cpp.
References ExpandTextVars(), resolver, and result.
| BOOST_AUTO_TEST_CASE | ( | ExpandsNestedReferences | ) |
Definition at line 560 of file test_expand_text_vars.cpp.
References BOOST_AUTO_TEST_CASE(), BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), ExpandEnvVarSubstitutions(), and expected.
| BOOST_AUTO_TEST_CASE | ( | ForwardSlashBeforeVariableExpands | ) |
Definition at line 204 of file test_expand_text_vars.cpp.
References ExpandTextVars(), resolver, and result.
| BOOST_AUTO_TEST_CASE | ( | ForwardSlashPathUnchanged | ) |
Definition at line 241 of file test_expand_text_vars.cpp.
References ExpandTextVars(), NormalizeFilePathForTextVars(), path, resolver, and result.
| BOOST_AUTO_TEST_CASE | ( | IsVersionedEnvVarPredicate | ) |
Definition at line 715 of file test_expand_text_vars.cpp.
References ENV_VAR::IsVersionedEnvVar().
| BOOST_AUTO_TEST_CASE | ( | LegacyVersionedVarStillResolvesToCurrentDir | ) |
Definition at line 669 of file test_expand_text_vars.cpp.
References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), and ExpandEnvVarSubstitutions().
| BOOST_AUTO_TEST_CASE | ( | MultipleEscapedInMathExpression | ) |
Definition at line 141 of file test_expand_text_vars.cpp.
References BOOST_CHECK_EQUAL(), BOOST_CHECK_MESSAGE(), ExpandTextVars(), resolver, and result.
| BOOST_AUTO_TEST_CASE | ( | MultipleVariables | ) |
Definition at line 76 of file test_expand_text_vars.cpp.
References ExpandTextVars(), resolver, and result.
| BOOST_AUTO_TEST_CASE | ( | MultipleVarsAfterBackslashSeparators | ) |
Definition at line 232 of file test_expand_text_vars.cpp.
References ExpandTextVars(), NormalizeFilePathForTextVars(), path, resolver, and result.
| BOOST_AUTO_TEST_CASE | ( | NonVariableBackslashesArePreserved | ) |
Definition at line 252 of file test_expand_text_vars.cpp.
References NormalizeFilePathForTextVars(), and path.
| BOOST_AUTO_TEST_CASE | ( | NormalizePicksLongestPrefix | ) |
Definition at line 388 of file test_expand_text_vars.cpp.
References BOOST_AUTO_TEST_CASE(), BOOST_CHECK_MESSAGE(), and NormalizePath().
| BOOST_AUTO_TEST_CASE | ( | ParallelResolveTextVarsWithMathExpressions | ) |
Regression test for KiCad GitLab issue #23962.
ResolveTextVars and ExpandTextVars used a function-local static EXPRESSION_EVALUATOR shared across all threads. CONNECTION_GRAPH evaluates schematic labels in parallel via a thread pool and label text may contain...} expressions, which caused the shared evaluator's internal ERROR_COLLECTOR vector to be mutated concurrently, leading to heap corruption and a segfault inside std::vector::clear.
This test hammers ResolveTextVars from many threads to make the race observable, primarily under TSan. It also serves as a smoke test that no thread crashes.
Definition at line 443 of file test_expand_text_vars.cpp.
References BOOST_AUTO_TEST_CASE(), BOOST_CHECK_EQUAL(), resolver, ResolveTextVars(), and result.
| BOOST_AUTO_TEST_CASE | ( | RegularThenEscapedVariable | ) |
Definition at line 100 of file test_expand_text_vars.cpp.
References ExpandTextVars(), resolver, and result.
| BOOST_AUTO_TEST_CASE | ( | RoundTripPreservesAbsolutePath | ) |
Definition at line 404 of file test_expand_text_vars.cpp.
References BOOST_CHECK_MESSAGE(), ExpandEnvVarSubstitutions(), and NormalizePath().
| BOOST_AUTO_TEST_CASE | ( | SimpleVariable | ) |
Definition at line 69 of file test_expand_text_vars.cpp.
References BOOST_AUTO_TEST_CASE(), ExpandTextVars(), resolver, and result.
| BOOST_AUTO_TEST_CASE | ( | TextVarNotFirstInFilename | ) |
Definition at line 308 of file test_expand_text_vars.cpp.
References BOOST_CHECK_MESSAGE(), path, JOB::ResolveOutputPath(), result, TITLE_BLOCK::SetRevision(), and JOB::SetTitleBlock().
| BOOST_AUTO_TEST_CASE | ( | UndefinedReferenceLeavesLiteralMarker | ) |
Definition at line 577 of file test_expand_text_vars.cpp.
References BOOST_REQUIRE(), and ExpandEnvVarSubstitutions().
| BOOST_AUTO_TEST_CASE | ( | UserVarIsNotTreatedAsVersionedLibraryDir | ) |
Definition at line 657 of file test_expand_text_vars.cpp.
References BOOST_AUTO_TEST_CASE(), BOOST_CHECK_EQUAL(), and ExpandEnvVarSubstitutions().