KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_history_autosave.cpp File Reference
#include <qa_utils/wx_utils/unit_test_utils.h>
#include <board.h>
#include <local_history.h>
#include <pgm_base.h>
#include <project.h>
#include <settings/common_settings.h>
#include <settings/settings_manager.h>
#include <git2.h>
#include <vector>
#include <wx/dir.h>
#include <wx/ffile.h>
#include <wx/filefn.h>
#include <wx/filename.h>
#include <wx/stdpaths.h>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (SaveToHistoryWithNullProjectDoesNotCrash)
 Regression test for https://gitlab.com/kicad/code/kicad/-/issues/23737.
 
 BOOST_AUTO_TEST_CASE (SaveToHistoryUnsavedBoardProducesNothing)
 SaveToHistory with a real project but no board filename should not produce any file data (the board is unsaved).
 
 BOOST_AUTO_TEST_CASE (RestoreCommitPreservesZipBackupsDirectory)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/3]

◆ BOOST_AUTO_TEST_CASE() [2/3]

BOOST_AUTO_TEST_CASE ( SaveToHistoryUnsavedBoardProducesNothing )

SaveToHistory with a real project but no board filename should not produce any file data (the board is unsaved).

It must also not crash.

Definition at line 117 of file test_history_autosave.cpp.

References BOOST_REQUIRE(), BOARD::ClearProject(), BOARD::GetFileName(), PROJECT::GetProjectPath(), SETTINGS_MANAGER::LoadProject(), SETTINGS_MANAGER::Prj(), BOARD::SaveToHistory(), BOARD::SetProject(), and SETTINGS_MANAGER::UnloadProject().

◆ BOOST_AUTO_TEST_CASE() [3/3]

BOOST_AUTO_TEST_CASE ( SaveToHistoryWithNullProjectDoesNotCrash )

Regression test for https://gitlab.com/kicad/code/kicad/-/issues/23737.

After importing a non-KiCad board, BOARD::SaveToHistory could be invoked from the autosave timer while the board's project pointer was transiently null (between unloading the previous project and linking the new one). The function then dereferenced GetProject() and crashed with EXCEPTION_ACCESS_VIOLATION_READ. SaveToHistory must tolerate a null project and bail out cleanly without crashing.

Definition at line 101 of file test_history_autosave.cpp.

References BOOST_AUTO_TEST_CASE(), BOOST_REQUIRE(), BOARD::GetProject(), and BOARD::SaveToHistory().