mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-22 00:22:57 -05:00
test(savedata): update journal and Windows failure cases for exclusive staging
This commit is contained in:
1 parent
32b268fe0f
commit
3eee6be59d
3 files changed
+23
-4
No files matched your search
@@ -89,7 +89,13 @@ int main() {
|
||||
std::filesystem::remove(temporary);
|
||||
|
||||
std::error_code symlinkError;
|
||||
#ifdef _WIN32
|
||||
if (!CreateSymbolicLinkW(temporary.c_str(), unrelated.c_str(), SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE)) {
|
||||
symlinkError = std::error_code(GetLastError(), std::system_category());
|
||||
}
|
||||
#else
|
||||
std::filesystem::create_symlink(unrelated, temporary, symlinkError);
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
if (symlinkError == std::errc::permission_denied ||
|
||||
symlinkError == std::error_code(ERROR_PRIVILEGE_NOT_HELD, std::system_category())) {
|
||||
@@ -100,8 +106,15 @@ int main() {
|
||||
Require(!symlinkError);
|
||||
Require(savedata::replace_file(savePath, replacement.data(), replacement.size()));
|
||||
Require(ReadFile(unrelated) == oldData);
|
||||
#ifdef _WIN32
|
||||
const auto linkAttributes = GetFileAttributesW(temporary.c_str());
|
||||
const auto saveAttributes = GetFileAttributesW(savePath.c_str());
|
||||
Require(linkAttributes != INVALID_FILE_ATTRIBUTES && (linkAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0);
|
||||
Require(saveAttributes != INVALID_FILE_ATTRIBUTES && (saveAttributes & FILE_ATTRIBUTE_REPARSE_POINT) == 0);
|
||||
#else
|
||||
Require(std::filesystem::is_symlink(temporary));
|
||||
Require(!std::filesystem::is_symlink(savePath));
|
||||
#endif
|
||||
Require(ReadFile(savePath) == replacement);
|
||||
std::filesystem::remove(temporary);
|
||||
}
|
||||
|
||||
@@ -91,10 +91,16 @@ int main() {
|
||||
|
||||
Require(std::filesystem::create_directory(temporaryPath));
|
||||
first.fill('q');
|
||||
Require(sceSaveDataSetSaveDataMemory2(&set) == static_cast<int>(0x809F000Bu));
|
||||
Require(Read(memoryPath) == expected);
|
||||
Require(sceSaveDataSetSaveDataMemory2(&set) == 0);
|
||||
std::copy(first.begin(), first.end(), expected.begin() + 8);
|
||||
Require(Read(memoryPath) == expected && Read(aliasPath) == expected);
|
||||
Require(!std::filesystem::exists(journalPath));
|
||||
Require(!std::filesystem::exists(temporaryPath));
|
||||
Require(std::filesystem::is_directory(temporaryPath));
|
||||
Require(std::filesystem::remove(temporaryPath));
|
||||
const auto temporaryPrefix = temporaryPath.filename().string();
|
||||
for (const auto& entry : std::filesystem::directory_iterator(memoryPath.parent_path())) {
|
||||
Require(!entry.path().filename().string().starts_with(temporaryPrefix));
|
||||
}
|
||||
|
||||
Write(journalPath, Journal(16, "jour"));
|
||||
std::array<char, 4> got{};
|
||||
|
||||
@@ -74,7 +74,7 @@ template <typename Operation>
|
||||
static int FailWrite(const std::filesystem::path& path, [[maybe_unused]] std::size_t sizeLimit,
|
||||
Operation&& operation) {
|
||||
#ifdef _WIN32
|
||||
const auto locked = CreateFileW(path.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
const auto locked = CreateFileW(path.c_str(), GENERIC_READ, FILE_SHARE_READ,
|
||||
nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
Require(locked != INVALID_HANDLE_VALUE);
|
||||
const int result = operation();
|
||||
|
||||
Reference in new issue
Block a user