diff options
| author | Sebastian Valle <subv2112@gmail.com> | 2016-11-27 18:56:56 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-11-27 18:56:56 -0500 |
| commit | 4ba5acdaff19f5334b86e86c324763d4e9b969b0 (patch) | |
| tree | 408343a46858bcde292744d89fc6b3dadd9a54b0 /src/tests | |
| parent | 77b7cec8afcaf9c267c8dbae49e123d980a32e73 (diff) | |
| parent | 282195b450721a5b8ad0cea8e66606b2661fe888 (diff) | |
Merge pull request #2132 from wwylele/fix-fs-err
Correct FS error codes & add path boundary checks
Diffstat (limited to 'src/tests')
| -rw-r--r-- | src/tests/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/tests/core/file_sys/path_parser.cpp | 38 | ||||
| -rw-r--r-- | src/tests/glad.cpp | 14 |
3 files changed, 54 insertions, 0 deletions
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 457c55571..89237e477 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -1,5 +1,7 @@ set(SRCS + glad.cpp tests.cpp + core/file_sys/path_parser.cpp ) set(HEADERS diff --git a/src/tests/core/file_sys/path_parser.cpp b/src/tests/core/file_sys/path_parser.cpp new file mode 100644 index 000000000..2b543e438 --- /dev/null +++ b/src/tests/core/file_sys/path_parser.cpp @@ -0,0 +1,38 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include <catch.hpp> +#include "common/file_util.h" +#include "core/file_sys/path_parser.h" + +namespace FileSys { + +TEST_CASE("PathParser", "[core][file_sys]") { + REQUIRE(!PathParser(Path(std::vector<u8>{})).IsValid()); + REQUIRE(!PathParser(Path("a")).IsValid()); + REQUIRE(!PathParser(Path("/|")).IsValid()); + REQUIRE(PathParser(Path("/a")).IsValid()); + REQUIRE(!PathParser(Path("/a/b/../../c/../../d")).IsValid()); + REQUIRE(PathParser(Path("/a/b/../c/../../d")).IsValid()); + REQUIRE(PathParser(Path("/")).IsRootDirectory()); + REQUIRE(!PathParser(Path("/a")).IsRootDirectory()); + REQUIRE(PathParser(Path("/a/..")).IsRootDirectory()); +} + +TEST_CASE("PathParser - Host file system", "[core][file_sys]") { + std::string test_dir = "./test"; + FileUtil::CreateDir(test_dir); + FileUtil::CreateDir(test_dir + "/z"); + FileUtil::CreateEmptyFile(test_dir + "/a"); + + REQUIRE(PathParser(Path("/a")).GetHostStatus(test_dir) == PathParser::FileFound); + REQUIRE(PathParser(Path("/b")).GetHostStatus(test_dir) == PathParser::NotFound); + REQUIRE(PathParser(Path("/z")).GetHostStatus(test_dir) == PathParser::DirectoryFound); + REQUIRE(PathParser(Path("/a/c")).GetHostStatus(test_dir) == PathParser::FileInPath); + REQUIRE(PathParser(Path("/b/c")).GetHostStatus(test_dir) == PathParser::PathNotFound); + + FileUtil::DeleteDirRecursively(test_dir); +} + +} // namespace FileSys diff --git a/src/tests/glad.cpp b/src/tests/glad.cpp new file mode 100644 index 000000000..b0b016440 --- /dev/null +++ b/src/tests/glad.cpp @@ -0,0 +1,14 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include <catch.hpp> +#include <glad/glad.h> + +// This is not an actual test, but a work-around for issue #2183. +// If tests uses functions in core but doesn't explicitly use functions in glad, the linker of macOS +// will error about undefined references from video_core to glad. So we explicitly use a glad +// function here to shut up the linker. +TEST_CASE("glad fake test", "[dummy]") { + REQUIRE(&gladLoadGL != nullptr); +} |
