KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_expand_text_vars.cpp File Reference
#include <boost/test/unit_test.hpp>
#include <atomic>
#include <filesystem>
#include <thread>
#include <vector>
#include <common.h>
#include <env_paths.h>
#include <pgm_base.h>
#include <settings/environment.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...
 

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 (NormalizePicksLongestPrefix)
 
 BOOST_AUTO_TEST_CASE (RoundTripPreservesAbsolutePath)
 
 BOOST_AUTO_TEST_CASE (ParallelResolveTextVarsWithMathExpressions)
 Regression test for KiCad GitLab issue #23962.
 

Macro Definition Documentation

◆ BOOST_TEST_NO_MAIN

#define BOOST_TEST_NO_MAIN

Definition at line 21 of file test_expand_text_vars.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/13]

BOOST_AUTO_TEST_CASE ( ConsecutiveEscaped )

Definition at line 169 of file test_expand_text_vars.cpp.

References BOOST_CHECK_EQUAL(), ExpandTextVars(), resolver, and result.

◆ BOOST_AUTO_TEST_CASE() [2/13]

BOOST_AUTO_TEST_CASE ( EscapedAtInExpression )

Definition at line 159 of file test_expand_text_vars.cpp.

References ExpandTextVars(), resolver, and result.

◆ BOOST_AUTO_TEST_CASE() [3/13]

BOOST_AUTO_TEST_CASE ( EscapedInsideMathExpression )

Definition at line 106 of file test_expand_text_vars.cpp.

References BOOST_CHECK_MESSAGE(), ExpandTextVars(), resolver, and result.

◆ BOOST_AUTO_TEST_CASE() [4/13]

BOOST_AUTO_TEST_CASE ( EscapedInsideVariableReference )

Definition at line 125 of file test_expand_text_vars.cpp.

References ExpandTextVars(), resolver, and result.

◆ BOOST_AUTO_TEST_CASE() [5/13]

BOOST_AUTO_TEST_CASE ( EscapedThenRegularVariable )

Definition at line 87 of file test_expand_text_vars.cpp.

References ExpandTextVars(), resolver, and result.

◆ BOOST_AUTO_TEST_CASE() [6/13]

BOOST_AUTO_TEST_CASE ( EscapedVariable )

Definition at line 79 of file test_expand_text_vars.cpp.

References ExpandTextVars(), resolver, and result.

◆ BOOST_AUTO_TEST_CASE() [7/13]

BOOST_AUTO_TEST_CASE ( MultipleEscapedInMathExpression )

◆ BOOST_AUTO_TEST_CASE() [8/13]

BOOST_AUTO_TEST_CASE ( MultipleVariables )

Definition at line 72 of file test_expand_text_vars.cpp.

References ExpandTextVars(), resolver, and result.

◆ BOOST_AUTO_TEST_CASE() [9/13]

BOOST_AUTO_TEST_CASE ( NormalizePicksLongestPrefix )

◆ BOOST_AUTO_TEST_CASE() [10/13]

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 305 of file test_expand_text_vars.cpp.

References BOOST_AUTO_TEST_CASE(), BOOST_CHECK_EQUAL(), resolver, ResolveTextVars(), and result.

◆ BOOST_AUTO_TEST_CASE() [11/13]

BOOST_AUTO_TEST_CASE ( RegularThenEscapedVariable )

Definition at line 96 of file test_expand_text_vars.cpp.

References ExpandTextVars(), resolver, and result.

◆ BOOST_AUTO_TEST_CASE() [12/13]

BOOST_AUTO_TEST_CASE ( RoundTripPreservesAbsolutePath )

◆ BOOST_AUTO_TEST_CASE() [13/13]

BOOST_AUTO_TEST_CASE ( SimpleVariable )

Definition at line 65 of file test_expand_text_vars.cpp.

References BOOST_AUTO_TEST_CASE(), ExpandTextVars(), resolver, and result.