133 if( ::geteuid() == 0 )
145 TEST_FOOTPRINT_LIBRARY_ADAPTER adapter( manager );
147 const wxString nickname = wxS(
"scratch" );
148 adapter.SeedLoadedLibrary( nickname, tmpLib.
GetPath().string() );
150 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
158 auto savedFile = tmpLib.
GetPath() /
"readonly_fp.kicad_mod";
163 std::filesystem::permissions( savedFile,
164 std::filesystem::perms::owner_write | std::filesystem::perms::group_write
165 | std::filesystem::perms::others_write,
166 std::filesystem::perm_options::remove );
168 BOOST_CHECK_THROW( adapter.SaveFootprint( nickname, fp ),
IO_ERROR );
179 for(
const auto& entry : std::filesystem::directory_iterator(
180 std::filesystem::path( getResistorLibPath().
ToStdString() ) ) )
182 if( entry.is_regular_file() )
183 std::filesystem::copy_file( entry.path(), tmpLib.
GetPath() / entry.path().filename() );
187 TEST_FOOTPRINT_LIBRARY_ADAPTER adapter( manager );
189 const wxString nickname = wxS(
"Resistor_SMD" );
190 adapter.SeedLoadedLibrary( nickname, tmpLib.
GetPath().string() );
193 const wxString stableFp = wxS(
"R_0603_1608Metric" );
195 BOOST_REQUIRE( adapter.FootprintExists( nickname, stableFp ) );
197 constexpr int readerCount = 6;
198 constexpr int iterations = 40;
200 std::atomic<bool> sawMissing{
false };
201 std::atomic<bool> sawNullLoad{
false };
202 std::atomic<int> savedCount{ 0 };
205 std::atomic<int> ready{ 0 };
206 std::atomic<bool> go{
false };
208 auto waitForStart = [&]()
210 ready.fetch_add( 1 );
213 std::this_thread::yield();
216 std::vector<std::thread> workers;
217 workers.reserve( readerCount + 1 );
219 for(
int t = 0; t < readerCount; ++t )
221 workers.emplace_back(
226 for(
int i = 0; i < iterations; ++i )
229 adapter.IsWritable( nickname );
231 if( !adapter.FootprintExists( nickname, stableFp ) )
234 std::unique_ptr<FOOTPRINT> fp{ adapter.LoadFootprint( nickname, stableFp,
false ) };
242 workers.emplace_back(
245 std::unique_ptr<FOOTPRINT> seed{ adapter.LoadFootprint( nickname, stableFp,
false ) };
255 for(
int i = 0; i < iterations; ++i )
258 seed->SetFPID(
LIB_ID( nickname, wxString::Format( wxS(
"scratch_%d" ), i % 4 ) ) );
263 savedCount.fetch_add( 1 );
272 while( ready.load() < readerCount + 1 )
273 std::this_thread::yield();
277 for( std::thread& worker : workers )
280 BOOST_CHECK( !sawMissing.load() );
281 BOOST_CHECK( !sawNullLoad.load() );
284 BOOST_CHECK( savedCount.load() > 0 );
BOOST_CHECK_EQUAL(result, "25.4")