UnitTests: Add setup error checking

Check return value of calls to File::CreateTempDir() from CoreTiming,
FileSystem, and MMIO test classes to verify the test user directory
exists, and fail the tests otherwise.
This commit is contained in:
Dentomologist
2021-01-22 11:34:45 -08:00
parent caff472dbf
commit 83f912b58a
3 changed files with 32 additions and 0 deletions

View File

@ -25,15 +25,31 @@ class FileSystemTest : public testing::Test
protected:
FileSystemTest() : m_profile_path{File::CreateTempDir()}
{
if (UserDirectoryCreationFailed())
{
return;
}
UICommon::SetUserDirectory(m_profile_path);
m_fs = IOS::HLE::Kernel{}.GetFS();
}
virtual ~FileSystemTest()
{
if (UserDirectoryCreationFailed())
{
return;
}
m_fs.reset();
File::DeleteDirRecursively(m_profile_path);
}
void SetUp()
{
if (UserDirectoryCreationFailed())
{
FAIL();
}
}
bool UserDirectoryCreationFailed() const { return m_profile_path.empty(); }
std::shared_ptr<FileSystem> m_fs;