Merge pull request #5639 from leoetlino/unit-test-profile

UnitTests: Use a temporary profile directory
This commit is contained in:
shuffle2 2017-06-18 12:57:57 -07:00 committed by GitHub
commit 72d5dd754a
2 changed files with 12 additions and 3 deletions

View File

@ -6,7 +6,9 @@
#include <array> #include <array>
#include <bitset> #include <bitset>
#include <string>
#include "Common/FileUtil.h"
#include "Core/Config/Config.h" #include "Core/Config/Config.h"
#include "Core/ConfigManager.h" #include "Core/ConfigManager.h"
#include "Core/Core.h" #include "Core/Core.h"
@ -35,10 +37,10 @@ void CallbackTemplate(u64 userdata, s64 lateness)
class ScopeInit final class ScopeInit final
{ {
public: public:
ScopeInit() ScopeInit() : m_profile_path(File::CreateTempDir())
{ {
Core::DeclareAsCPUThread(); Core::DeclareAsCPUThread();
UICommon::SetUserDirectory(""); UICommon::SetUserDirectory(m_profile_path);
Config::Init(); Config::Init();
SConfig::Init(); SConfig::Init();
PowerPC::Init(PowerPC::CORE_INTERPRETER); PowerPC::Init(PowerPC::CORE_INTERPRETER);
@ -51,7 +53,10 @@ public:
SConfig::Shutdown(); SConfig::Shutdown();
Config::Shutdown(); Config::Shutdown();
Core::UndeclareAsCPUThread(); Core::UndeclareAsCPUThread();
File::DeleteDirRecursively(m_profile_path);
} }
private:
std::string m_profile_path;
}; };
static void AdvanceAndCheck(u32 idx, int downcount, int expected_lateness = 0, static void AdvanceAndCheck(u32 idx, int downcount, int expected_lateness = 0,

View File

@ -3,9 +3,11 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <string>
#include <unordered_set> #include <unordered_set>
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Core/Config/Config.h" #include "Core/Config/Config.h"
#include "Core/HW/MMIO.h" #include "Core/HW/MMIO.h"
#include "UICommon/UICommon.h" #include "UICommon/UICommon.h"
@ -31,7 +33,8 @@ TEST(UniqueID, UniqueEnough)
TEST(IsMMIOAddress, SpecialAddresses) TEST(IsMMIOAddress, SpecialAddresses)
{ {
UICommon::SetUserDirectory(""); const std::string profile_path = File::CreateTempDir();
UICommon::SetUserDirectory(profile_path);
Config::Init(); Config::Init();
SConfig::Init(); SConfig::Init();
SConfig::GetInstance().bWii = true; SConfig::GetInstance().bWii = true;
@ -56,6 +59,7 @@ TEST(IsMMIOAddress, SpecialAddresses)
SConfig::Shutdown(); SConfig::Shutdown();
Config::Shutdown(); Config::Shutdown();
File::DeleteDirRecursively(profile_path);
} }
class MappingTest : public testing::Test class MappingTest : public testing::Test