KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_sch_io_kicad_sexpr_leak_cache.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
21#include "eeschema_test_utils.h"
22
23#include <lib_symbol.h>
24#include <sch_io/sch_io.h>
25#include <sch_io/sch_io_mgr.h>
26
27#include <wx/filename.h>
28
29
30BOOST_AUTO_TEST_SUITE( SchIoKicadSexprLeakCache )
31
32
33// Threads such as an HTTP library refresher may still read the cache after the exit hook runs
34BOOST_AUTO_TEST_CASE( CacheSurvivesLeakCacheAtExit )
35{
36 wxFileName libPath( KI_TEST::GetEeschemaTestDataDir() );
37 libPath.AppendDir( "variants" );
38 libPath.SetFullName( "pic_programmer.kicad_sym" );
39
40 IO_RELEASER<SCH_IO> pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
41
42 LIB_SYMBOL* before = pi->LoadSymbol( libPath.GetFullPath(), wxS( "74LS125" ) );
43 BOOST_REQUIRE( before );
44
45 pi->LeakCacheAtExit();
46
47 BOOST_CHECK_EQUAL( pi->LoadSymbol( libPath.GetFullPath(), wxS( "74LS125" ) ), before );
48}
49
50
Define a library symbol object.
Definition lib_symbol.h:114
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
Definition io_mgr.h:33
std::string GetEeschemaTestDataDir()
Get the configured location of Eeschema test data.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_CHECK_EQUAL(std::any_cast< std::string >(rows[0].at("val")), "12345678901234567.89")
BOOST_REQUIRE(res.columns()==1)
BOOST_AUTO_TEST_SUITE_END()