#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "common/mathutil.h"
#include "common/system_utils.h"
#include "util/test_utils.h"
#include <fstream>
#include <sstream>
#include <vector>
#if defined(ANGLE_PLATFORM_POSIX)
# include <signal.h>
#endif
usingnamespaceangle;
namespace
{
TEST(SystemUtils, ExecutablePath)
{ … }
TEST(SystemUtils, ExecutableDir)
{ … }
TEST(SystemUtils, Environment)
{ … }
TEST(SystemUtils, CpuTimeSmallOp)
{ … }
TEST(SystemUtils, CpuTimeSleepy)
{ … }
TEST(SystemUtils, CpuTimeHeavyOp)
{ … }
#if defined(ANGLE_PLATFORM_POSIX)
TEST(SystemUtils, ConcatenatePathSimple)
{ … }
TEST(SystemUtils, ConcatenatePath1Empty)
{ … }
TEST(SystemUtils, ConcatenatePath2Empty)
{ … }
TEST(SystemUtils, ConcatenatePath2FullPath)
{ … }
TEST(SystemUtils, ConcatenatePathRedundantSeparators)
{ … }
TEST(SystemUtils, IsFullPath)
{ … }
#elif defined(ANGLE_PLATFORM_WINDOWS)
TEST(SystemUtils, ConcatenatePathSimple)
{
std::string path1 = "C:\\this\\is\\path1";
std::string path2 = "this\\is\\path2";
std::string expected = "C:\\this\\is\\path1\\this\\is\\path2";
EXPECT_EQ(ConcatenatePath(path1, path2), expected);
}
TEST(SystemUtils, ConcatenatePath1Empty)
{
std::string path1 = "";
std::string path2 = "this\\is\\path2";
std::string expected = "this\\is\\path2";
EXPECT_EQ(ConcatenatePath(path1, path2), expected);
}
TEST(SystemUtils, ConcatenatePath2Empty)
{
std::string path1 = "C:\\this\\is\\path1";
std::string path2 = "";
std::string expected = "C:\\this\\is\\path1";
EXPECT_EQ(ConcatenatePath(path1, path2), expected);
}
TEST(SystemUtils, ConcatenatePath2FullPath)
{
std::string path1 = "C:\\this\\is\\path1";
std::string path2 = "C:\\this\\is\\path2";
std::string expected = "C:\\this\\is\\path2";
EXPECT_EQ(ConcatenatePath(path1, path2), expected);
}
TEST(SystemUtils, ConcatenatePathRedundantSeparators)
{
std::string path1 = "C:\\this\\is\\path1\\";
std::string path2 = "this\\is\\path2";
std::string expected = "C:\\this\\is\\path1\\this\\is\\path2";
EXPECT_EQ(ConcatenatePath(path1, path2), expected);
}
TEST(SystemUtils, ConcatenatePathRedundantSeparators2)
{
std::string path1 = "C:\\this\\is\\path1\\";
std::string path2 = "\\this\\is\\path2";
std::string expected = "C:\\this\\is\\path1\\this\\is\\path2";
EXPECT_EQ(ConcatenatePath(path1, path2), expected);
}
TEST(SystemUtils, ConcatenatePathRedundantSeparators3)
{
std::string path1 = "C:\\this\\is\\path1";
std::string path2 = "\\this\\is\\path2";
std::string expected = "C:\\this\\is\\path1\\this\\is\\path2";
EXPECT_EQ(ConcatenatePath(path1, path2), expected);
}
TEST(SystemUtils, IsFullPath)
{
std::string path1 = "C:\\this\\is\\path1\\";
std::string path2 = "this\\is\\path2";
EXPECT_TRUE(IsFullPath(path1));
EXPECT_FALSE(IsFullPath(path2));
}
#endif
#if defined(ANGLE_PLATFORM_ANDROID)
#define MAYBE_CreateAndDeleteTemporaryFile …
#define MAYBE_CreateAndDeleteFileInTempDir …
#else
#define MAYBE_CreateAndDeleteTemporaryFile …
#define MAYBE_CreateAndDeleteFileInTempDir …
#endif
TEST(SystemUtils, MAYBE_CreateAndDeleteTemporaryFile)
{ … }
TEST(SystemUtils, MAYBE_CreateAndDeleteFileInTempDir)
{ … }
TEST(SystemUtils, PageSize)
{ … }
#if defined(ANGLE_PLATFORM_FUCHSIA)
#define MAYBE_PageFaultHandlerInit …
#define MAYBE_PageFaultHandlerProtect …
#define MAYBE_PageFaultHandlerDefaultHandler …
#elif ANGLE_PLATFORM_MACOS || ANGLE_PLATFORM_IOS_FAMILY_SIMULATOR
#define MAYBE_PageFaultHandlerInit …
#define MAYBE_PageFaultHandlerProtect …
#define MAYBE_PageFaultHandlerDefaultHandler …
#else
#define MAYBE_PageFaultHandlerInit …
#define MAYBE_PageFaultHandlerProtect …
#define MAYBE_PageFaultHandlerDefaultHandler …
#endif
TEST(SystemUtils, MAYBE_PageFaultHandlerInit)
{ … }
TEST(SystemUtils, MAYBE_PageFaultHandlerProtect)
{ … }
TEST(SystemUtils, StripFilenameFromPathUsage)
{ … }
#if defined(ANGLE_PLATFORM_POSIX)
std::mutex gCustomHandlerMutex;
bool gCustomHandlerCalled = …;
void CustomSegfaultHandlerFunction(int sig, siginfo_t *info, void *unused)
{ … }
TEST(SystemUtils, MAYBE_PageFaultHandlerDefaultHandler)
{ … }
#else
TEST(SystemUtils, MAYBE_PageFaultHandlerDefaultHandler) {}
#endif
TEST(SystemUtils, GetCurrentThreadId)
{ … }
}