mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-17 11:24:27 +01:00
Add a storage test screen, to test content URIs on a device
The unit tests have no Java VM on Android, so the content URI storage code could only be tested by hand. RunStorageTests() exercises file creation, overwrite, listing, rename, moves, copies, deletes, odd names and free space in a scratch folder, and times the calls the emulator makes most. The new StorageTestScreen (--start-screen=storagetest) runs them in a picked folder and remembers it. Tools/android_storage_test.py starts it over adb and collects the results from logcat, and Tools/android_run.py builds, installs and starts the app with any options. The screen raises the System log channel to INFO during a run, so the results get through. The Storage unit test runs the same tests on a native folder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
22bc3f9db4
commit
aa4053c2b0
23 files changed
+803
-3
No files matched your search
@@ -12,7 +12,7 @@ for it:
|
||||
| Doc | When you need it |
|
||||
|---|---|
|
||||
| [docs/building.md](docs/building.md) | Build commands for every target (VS/MSBuild, CMake, UWP, legacy Android NDK, libretro), unit tests, pspautotests |
|
||||
| [docs/android-device-testing.md](docs/android-device-testing.md) | Running a build on a real Android device or a Quest over adb: installing the build you think you are, forcing activity recreates, measuring retained activities, VR, running the C++ unit tests on a device (`Tools/android_unittest.py`) |
|
||||
| [docs/android-device-testing.md](docs/android-device-testing.md) | Running a build on a real Android device or a Quest over adb: installing the build you think you are, forcing activity recreates, measuring retained activities, VR, running the C++ unit tests on a device (`Tools/android_unittest.py`), starting the app with options (`Tools/android_run.py`), and the storage tests that exercise content URIs in the app (`Tools/android_storage_test.py`) |
|
||||
| [docs/debugging.md](docs/debugging.md) | Driving the WebSocket debugger and PPSSPPHeadless from a script, measuring a commercial game with headless, comparing binaries' speed (`Tools/headless_bench.py`), finding a game's hot JIT blocks (`--jit-profile`), breakpoint reliability per CPU backend, debugging a game that works on hardware, finding and hashing a game function (like its own `memcpy`) for `ReplaceTables` when hardware backends miss CPU writes to VRAM |
|
||||
| [docs/DebuggerThreading.md](docs/DebuggerThreading.md) | `Core_RunOnCPUThread` / `g_frameMutex` / shutdown-lock rules - required reading before touching debugger code |
|
||||
| [docs/HLEModules.md](docs/HLEModules.md) | Adding an HLE module or function, and the seven build files a new source file goes in |
|
||||
|
||||
@@ -688,7 +688,9 @@ add_library(Core STATIC
|
||||
Util/AudioFormat.cpp
|
||||
Util/AudioFormat.h
|
||||
Util/MemStick.cpp
|
||||
Util/StorageTest.cpp
|
||||
Util/MemStick.h
|
||||
Util/StorageTest.h
|
||||
Util/GameDB.cpp
|
||||
Util/GameDB.h
|
||||
Util/PathUtil.cpp
|
||||
|
||||
+1
-1
@@ -216,7 +216,7 @@ const char *g_ExceptionActionValues[] = {
|
||||
static const CommandLineParam g_autoParams[] = {
|
||||
{POFF(fullscreen), CmdParamType::Bool, "fullscreen", '\0', "Force full screen mode", CmdLineMode::Application},
|
||||
{POFF(fullscreen), CmdParamType::BoolInverse, "windowed", '\0', "Force windowed mode", CmdLineMode::Application},
|
||||
{POFF(startScreen), CmdParamType::String, "start-screen", '\0', "Start on a specific screen (e.g. 'gamesettings', 'touchscreentest', 'firmware')", CmdLineMode::Application},
|
||||
{POFF(startScreen), CmdParamType::String, "start-screen", '\0', "Start on a specific screen (e.g. 'gamesettings', 'touchscreentest', 'firmware', 'storagetest')", CmdLineMode::Application},
|
||||
{POFF(escapeExit), CmdParamType::Bool, "escape-exit", '\0', "Escape key exits the application", CmdLineMode::Application},
|
||||
{POFF(gameWindow), CmdParamType::Bool, "game-window", '\0', "Show the game in a second window, for testing multiple outputs (Vulkan, or Metal on Mac)", CmdLineMode::Application},
|
||||
{POFF(pauseMenuExit), CmdParamType::Bool, "pause-menu-exit", '\0', "Exit the application when the game ends, instead of returning to the menu", CmdLineMode::Application},
|
||||
|
||||
@@ -744,6 +744,7 @@
|
||||
<ClCompile Include="Util\GameDB.cpp" />
|
||||
<ClCompile Include="Util\GameManager.cpp" />
|
||||
<ClCompile Include="Util\MemStick.cpp" />
|
||||
<ClCompile Include="Util\StorageTest.cpp" />
|
||||
<ClCompile Include="Util\PathUtil.cpp" />
|
||||
<ClCompile Include="Util\PortManager.cpp" />
|
||||
<ClCompile Include="Util\PPGeDraw.cpp" />
|
||||
@@ -1078,6 +1079,7 @@
|
||||
<ClInclude Include="Util\GameDB.h" />
|
||||
<ClInclude Include="Util\GameManager.h" />
|
||||
<ClInclude Include="Util\MemStick.h" />
|
||||
<ClInclude Include="Util\StorageTest.h" />
|
||||
<ClInclude Include="Util\PathUtil.h" />
|
||||
<ClInclude Include="Util\PortManager.h" />
|
||||
<ClInclude Include="Util\PPGeDraw.h" />
|
||||
|
||||
@@ -1318,6 +1318,9 @@
|
||||
<ClCompile Include="Util\MemStick.cpp">
|
||||
<Filter>Util</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Util\StorageTest.cpp">
|
||||
<Filter>Util</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="HW\Atrac3Standalone.cpp">
|
||||
<Filter>HW</Filter>
|
||||
</ClCompile>
|
||||
@@ -2295,6 +2298,9 @@
|
||||
<ClInclude Include="Util\MemStick.h">
|
||||
<Filter>Util</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Util\StorageTest.h">
|
||||
<Filter>Util</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="HW\Atrac3Standalone.h">
|
||||
<Filter>HW</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@@ -0,0 +1,230 @@
|
||||
// Copyright (c) 2012- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/Data/Text/Parsers.h"
|
||||
#include "Common/File/DirListing.h"
|
||||
#include "Common/File/DiskFree.h"
|
||||
#include "Common/File/FileUtil.h"
|
||||
#include "Common/Log.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Common/TimeUtil.h"
|
||||
#include "Core/Util/StorageTest.h"
|
||||
|
||||
// A test returns an empty string if it passed, and what went wrong if it didn't.
|
||||
#define CHECK(cond) do { if (!(cond)) { return StringFromFormat("line %d: %s", __LINE__, #cond); } } while (false)
|
||||
|
||||
static std::string ReadAll(const Path &path) {
|
||||
std::string str;
|
||||
if (!File::ReadBinaryFileToString(path, &str)) {
|
||||
return "<unreadable>";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
static bool Write(const Path &path, std::string_view str) {
|
||||
return File::WriteStringToFile(false, str, path);
|
||||
}
|
||||
|
||||
static bool HasEntry(const std::vector<File::FileInfo> &files, std::string_view name, bool isDirectory) {
|
||||
return std::any_of(files.begin(), files.end(), [&](const File::FileInfo &f) {
|
||||
return f.name == name && f.isDirectory == isDirectory;
|
||||
});
|
||||
}
|
||||
|
||||
int RunStorageTests(const Path &root, const std::function<void(const StorageTestResult &)> &report) {
|
||||
const Path scratch = root / "ppsspp_storage_test";
|
||||
// On content URIs DeleteDir takes everything in the folder along, on native paths it only removes empty
|
||||
// ones. The memory stick move depends on knowing which.
|
||||
const bool contentURI = root.Type() == PathType::CONTENT_URI;
|
||||
int failures = 0;
|
||||
std::string note;
|
||||
|
||||
auto run = [&](const char *name, const std::function<std::string()> &test) {
|
||||
note.clear();
|
||||
std::string error = test();
|
||||
StorageTestResult result{ name, error.empty(), error.empty() ? note : error };
|
||||
if (!result.passed) {
|
||||
failures++;
|
||||
}
|
||||
INFO_LOG(Log::System, "StorageTest: %s %s%s%s", result.passed ? "PASS" : "FAIL", name, result.detail.empty() ? "" : ": ", result.detail.c_str());
|
||||
report(result);
|
||||
};
|
||||
|
||||
run("CreateDir", [&]() -> std::string {
|
||||
if (File::Exists(scratch)) {
|
||||
// Left over from a run that didn't finish.
|
||||
CHECK(File::DeleteDirRecursively(scratch));
|
||||
}
|
||||
CHECK(!File::Exists(scratch));
|
||||
CHECK(File::CreateDir(scratch));
|
||||
CHECK(File::Exists(scratch));
|
||||
CHECK(File::IsDirectory(scratch));
|
||||
return "";
|
||||
});
|
||||
if (failures) {
|
||||
// Nowhere to run the rest.
|
||||
return failures;
|
||||
}
|
||||
|
||||
run("WriteRead", [&]() -> std::string {
|
||||
const Path file = scratch / "a.txt";
|
||||
CHECK(Write(file, "hello"));
|
||||
CHECK(File::Exists(file));
|
||||
CHECK(!File::IsDirectory(file));
|
||||
CHECK(ReadAll(file) == "hello");
|
||||
File::FileInfo info;
|
||||
CHECK(File::GetFileInfo(file, &info));
|
||||
CHECK(info.exists && !info.isDirectory && info.size == 5);
|
||||
return "";
|
||||
});
|
||||
|
||||
run("Overwrite", [&]() -> std::string {
|
||||
// Writing a shorter file over a longer one has to truncate it.
|
||||
const Path file = scratch / "b.txt";
|
||||
CHECK(Write(file, "a longer string"));
|
||||
CHECK(Write(file, "short"));
|
||||
CHECK(ReadAll(file) == "short");
|
||||
return "";
|
||||
});
|
||||
|
||||
run("ListDir", [&]() -> std::string {
|
||||
CHECK(File::CreateDir(scratch / "sub"));
|
||||
std::vector<File::FileInfo> files;
|
||||
CHECK(File::GetFilesInDir(scratch, &files));
|
||||
CHECK(files.size() == 3);
|
||||
CHECK(HasEntry(files, "a.txt", false));
|
||||
CHECK(HasEntry(files, "b.txt", false));
|
||||
CHECK(HasEntry(files, "sub", true));
|
||||
return "";
|
||||
});
|
||||
|
||||
run("CreateFullPath", [&]() -> std::string {
|
||||
CHECK(File::CreateFullPath(scratch / "x/y/z"));
|
||||
CHECK(File::IsDirectory(scratch / "x/y/z"));
|
||||
// Already there is fine.
|
||||
CHECK(File::CreateFullPath(scratch / "x/y"));
|
||||
return "";
|
||||
});
|
||||
|
||||
run("Rename", [&]() -> std::string {
|
||||
CHECK(File::Rename(scratch / "a.txt", scratch / "renamed.txt"));
|
||||
CHECK(!File::Exists(scratch / "a.txt"));
|
||||
CHECK(ReadAll(scratch / "renamed.txt") == "hello");
|
||||
return "";
|
||||
});
|
||||
|
||||
run("MoveIfFast", [&]() -> std::string {
|
||||
CHECK(File::MoveIfFast(scratch / "renamed.txt", scratch / "sub/renamed.txt"));
|
||||
CHECK(!File::Exists(scratch / "renamed.txt"));
|
||||
CHECK(ReadAll(scratch / "sub/renamed.txt") == "hello");
|
||||
// Folders too, which is what the memory stick move does.
|
||||
CHECK(File::MoveIfFast(scratch / "x", scratch / "sub/x"));
|
||||
CHECK(File::IsDirectory(scratch / "sub/x/y/z"));
|
||||
return "";
|
||||
});
|
||||
|
||||
run("Copy", [&]() -> std::string {
|
||||
CHECK(File::Copy(scratch / "b.txt", scratch / "sub/b.txt"));
|
||||
CHECK(ReadAll(scratch / "sub/b.txt") == "short");
|
||||
CHECK(ReadAll(scratch / "b.txt") == "short");
|
||||
return "";
|
||||
});
|
||||
|
||||
run("Delete", [&]() -> std::string {
|
||||
CHECK(File::Delete(scratch / "b.txt"));
|
||||
CHECK(!File::Exists(scratch / "b.txt"));
|
||||
return "";
|
||||
});
|
||||
|
||||
run("DeleteDir", [&]() -> std::string {
|
||||
const Path dir = scratch / "full";
|
||||
CHECK(File::CreateDir(dir));
|
||||
CHECK(Write(dir / "f.txt", "f"));
|
||||
const bool deleted = File::DeleteDir(dir);
|
||||
if (contentURI) {
|
||||
CHECK(deleted && !File::Exists(dir));
|
||||
note = "takes the contents along";
|
||||
} else {
|
||||
CHECK(!deleted && File::Exists(dir / "f.txt"));
|
||||
note = "only empty folders";
|
||||
}
|
||||
CHECK(File::DeleteDirRecursively(dir) || !File::Exists(dir));
|
||||
CHECK(!File::Exists(dir));
|
||||
return "";
|
||||
});
|
||||
|
||||
run("Names", [&]() -> std::string {
|
||||
// Characters that need escaping in a content URI, and outside ASCII.
|
||||
const char *name = "100% #1 & \xC3\xA4.txt";
|
||||
CHECK(Write(scratch / name, "odd"));
|
||||
CHECK(ReadAll(scratch / name) == "odd");
|
||||
std::vector<File::FileInfo> files;
|
||||
CHECK(File::GetFilesInDir(scratch, &files));
|
||||
CHECK(HasEntry(files, name, false));
|
||||
return "";
|
||||
});
|
||||
|
||||
run("FreeSpace", [&]() -> std::string {
|
||||
int64_t space = 0;
|
||||
CHECK(free_disk_space(root, space));
|
||||
CHECK(space > 0);
|
||||
note = NiceSizeFormat(space);
|
||||
return "";
|
||||
});
|
||||
|
||||
// Not a pass/fail test: the cost of the calls the emulator makes most, for comparing implementations.
|
||||
// On content URIs each is a call into Java and a binder transaction to the provider.
|
||||
run("Timing", [&]() -> std::string {
|
||||
const Path dir = scratch / "timing";
|
||||
CHECK(File::CreateDir(dir));
|
||||
const int count = 20;
|
||||
std::string report;
|
||||
auto time = [&](const char *what, int n, const std::function<bool(int)> &op) -> bool {
|
||||
const Instant start = Instant::Now();
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (!op(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
report += StringFromFormat("%s%s %.2f", report.empty() ? "" : ", ", what, start.ElapsedMs() / n);
|
||||
return true;
|
||||
};
|
||||
auto name = [&](int i) { return dir / StringFromFormat("file%02d.bin", i); };
|
||||
CHECK(time("create+write", count, [&](int i) { return Write(name(i), "0123456789"); }));
|
||||
CHECK(time("overwrite", count, [&](int i) { return Write(name(i), "9876543210"); }));
|
||||
CHECK(time("read", count, [&](int i) { return ReadAll(name(i)) == "9876543210"; }));
|
||||
CHECK(time("exists", count, [&](int i) { return File::Exists(name(i)); }));
|
||||
CHECK(time("missing", count, [&](int i) { return !File::Exists(dir / StringFromFormat("none%02d", i)); }));
|
||||
CHECK(time("info", count, [&](int i) { File::FileInfo info; return File::GetFileInfo(name(i), &info) && info.size == 10; }));
|
||||
CHECK(time("list", 5, [&](int) { std::vector<File::FileInfo> files; return File::GetFilesInDir(dir, &files) && files.size() == count; }));
|
||||
CHECK(time("delete", count, [&](int i) { return File::Delete(name(i)); }));
|
||||
note = "ms per call: " + report;
|
||||
return "";
|
||||
});
|
||||
|
||||
run("Cleanup", [&]() -> std::string {
|
||||
CHECK(File::DeleteDirRecursively(scratch));
|
||||
CHECK(!File::Exists(scratch));
|
||||
return "";
|
||||
});
|
||||
|
||||
INFO_LOG(Log::System, "StorageTest: DONE, %d failed", failures);
|
||||
return failures;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2012- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include "Common/File/Path.h"
|
||||
|
||||
struct StorageTestResult {
|
||||
std::string name;
|
||||
bool passed;
|
||||
// What failed, or for a pass, anything worth knowing (like which way DeleteDir went).
|
||||
std::string detail;
|
||||
};
|
||||
|
||||
// Exercises the file functions in a scratch folder inside root, deleted again
|
||||
// afterwards. root can be a native path, or on Android a picked folder (a content URI), which is the case
|
||||
// the unit tests can't reach: they have no Java VM. report is called after each test, on the calling thread.
|
||||
// Returns the number of failures.
|
||||
int RunStorageTests(const Path &root, const std::function<void(const StorageTestResult &)> &report);
|
||||
@@ -0,0 +1,102 @@
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2012- PPSSPP Project.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License 2.0 for more details.
|
||||
|
||||
# A copy of the GPL 2.0 should have been included with the program.
|
||||
# If not, see http://www.gnu.org/licenses/
|
||||
|
||||
# Official git repository and contact information can be found at
|
||||
# https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
"""Starts PPSSPP on an Android device, with command line options, optionally building and installing it first.
|
||||
|
||||
python Tools/android_run.py --build --start-screen=memsticksetup # build, install, open the memory stick setup
|
||||
python Tools/android_run.py --log --start-screen=firmware # follow the app's log until Ctrl+C
|
||||
python Tools/android_run.py -- --some-option=x # anything after -- goes to the app as is
|
||||
|
||||
The app only reads its options at startup, so it's force-stopped first. --start-screen names are listed in
|
||||
NativeInit() in UI/NativeApp.cpp.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
PACKAGE = "org.ppsspp.ppsspp"
|
||||
APK = os.path.join(ROOT, "android", "build", "outputs", "apk", "normal", "debug", "android-normal-debug.apk")
|
||||
|
||||
|
||||
def adb(args, device, **kwargs):
|
||||
return subprocess.run(["adb"] + (["-s", device] if device else []) + args, **kwargs)
|
||||
|
||||
|
||||
def build_and_install(device):
|
||||
gradlew = os.path.join(ROOT, "gradlew.bat" if os.name == "nt" else "gradlew")
|
||||
if subprocess.run([gradlew, ":android:assembleNormalDebug"], cwd=ROOT).returncode != 0:
|
||||
print("Build failed")
|
||||
return False
|
||||
# -d: a branch can have a lower versionCode (the commit count) than what's installed. See
|
||||
# docs/android-device-testing.md, and don't trust an install without checking what's there afterwards.
|
||||
result = adb(["install", "-r", "-d", "-t", APK], device, capture_output=True, text=True)
|
||||
print(result.stdout.strip(), result.stderr.strip())
|
||||
if result.returncode != 0 or "Success" not in result.stdout:
|
||||
print("Install failed")
|
||||
return False
|
||||
info = adb(["shell", "dumpsys package %s | grep versionName" % PACKAGE], device, capture_output=True, text=True).stdout
|
||||
print("Installed: " + info.strip())
|
||||
return True
|
||||
|
||||
|
||||
def start(device, app_args):
|
||||
"""Force-stops the app and starts it with app_args (a list of options)."""
|
||||
adb(["shell", "am force-stop " + PACKAGE], device)
|
||||
command = "am start -n %s/.PpssppActivity" % PACKAGE
|
||||
if app_args:
|
||||
# The shell on the device parses this once more, so quote the whole thing.
|
||||
joined = " ".join(app_args).replace("'", "'\\''")
|
||||
command += " --es %s.Args '%s'" % (PACKAGE, joined)
|
||||
return adb(["shell", command], device, capture_output=True, text=True)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
parser.add_argument("--build", action="store_true", help="build and install the normal debug APK first")
|
||||
parser.add_argument("-s", "--device", help="adb device serial, if there's more than one")
|
||||
parser.add_argument("--log", action="store_true", help="follow the app's log (the PPSSPP tag) until Ctrl+C")
|
||||
parser.add_argument("--start-screen", help="the screen to start on, like memsticksetup, firmware or storagetest")
|
||||
parser.add_argument("app_args", nargs="*", help="more options for the app, after --")
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.build and not build_and_install(args.device):
|
||||
return 1
|
||||
|
||||
app_args = list(args.app_args)
|
||||
if args.start_screen:
|
||||
app_args.insert(0, "--start-screen=" + args.start_screen)
|
||||
if args.log:
|
||||
adb(["logcat", "-c"], args.device)
|
||||
result = start(args.device, app_args)
|
||||
if result.returncode != 0 or "Error" in result.stdout:
|
||||
print(result.stdout, result.stderr)
|
||||
return 1
|
||||
print("Started %s %s" % (PACKAGE, " ".join(app_args)))
|
||||
if args.log:
|
||||
try:
|
||||
adb(["logcat", "-v", "brief", "PPSSPP:V", "*:S"], args.device)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,101 @@
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2012- PPSSPP Project.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License 2.0 for more details.
|
||||
|
||||
# A copy of the GPL 2.0 should have been included with the program.
|
||||
# If not, see http://www.gnu.org/licenses/
|
||||
|
||||
# Official git repository and contact information can be found at
|
||||
# https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
"""Runs the storage tests (UI/StorageTestScreen.cpp) in the app on an Android device.
|
||||
|
||||
The unit tests can't reach the content URI storage code, since they have no Java VM, so these run in the
|
||||
app itself, in a folder picked with the system folder picker. The first time, create a new empty folder
|
||||
in the picker on the device and choose it. The app remembers it (in its private data), so later runs
|
||||
need no hands.
|
||||
|
||||
python Tools/android_storage_test.py --build # build and install the normal debug APK first
|
||||
python Tools/android_storage_test.py # run with what's installed
|
||||
|
||||
Exits non-zero if a test failed, or no results came within --timeout seconds.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
|
||||
# The build, install and start steps are shared with android_run.py, next to this.
|
||||
from android_run import PACKAGE, adb, build_and_install, start
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
parser.add_argument("--build", action="store_true", help="build and install the normal debug APK first")
|
||||
parser.add_argument("-s", "--device", help="adb device serial, if there's more than one")
|
||||
parser.add_argument("--timeout", type=int, default=300, help="seconds to wait for the results, including picking a folder (default 300)")
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.build and not build_and_install(args.device):
|
||||
return 1
|
||||
|
||||
adb(["logcat", "-c"], args.device)
|
||||
logcat = subprocess.Popen(["adb"] + (["-s", args.device] if args.device else []) + ["logcat", "-v", "brief", "PPSSPP:V", "*:S"],
|
||||
stdout=subprocess.PIPE, text=True, errors="replace")
|
||||
# A fresh start, so the start screen applies (it's only read at startup).
|
||||
if start(args.device, ["--start-screen=storagetest"]).returncode != 0:
|
||||
print("Couldn't start " + PACKAGE)
|
||||
logcat.kill()
|
||||
return 1
|
||||
|
||||
# Read on a thread, so the timeout works even when logcat is quiet.
|
||||
lines = []
|
||||
done = threading.Event()
|
||||
|
||||
def reader():
|
||||
for line in logcat.stdout:
|
||||
lines.append(line.rstrip())
|
||||
if "StorageTest: DONE" in line:
|
||||
done.set()
|
||||
return
|
||||
|
||||
threading.Thread(target=reader, daemon=True).start()
|
||||
deadline = time.time() + args.timeout
|
||||
shown = 0
|
||||
asked = False
|
||||
while not done.is_set() and time.time() < deadline:
|
||||
time.sleep(0.2)
|
||||
while shown < len(lines):
|
||||
line = lines[shown]
|
||||
shown += 1
|
||||
if "StorageTest:" in line:
|
||||
print(line[line.index("StorageTest:"):])
|
||||
if not asked and time.time() > deadline - args.timeout + 5 and not any("StorageTest:" in l for l in lines):
|
||||
print("No results yet. If this is the first run, tap Choose folder on the device, create a new empty folder in the picker, and choose it.")
|
||||
asked = True
|
||||
logcat.kill()
|
||||
for line in lines[shown:]:
|
||||
if "StorageTest:" in line:
|
||||
print(line[line.index("StorageTest:"):])
|
||||
|
||||
summary = [l for l in lines if "StorageTest: DONE" in l]
|
||||
if not summary:
|
||||
print("Timed out after %d seconds" % args.timeout)
|
||||
return 1
|
||||
failed = int(re.search(r"DONE, (\d+) failed", summary[-1]).group(1))
|
||||
return 1 if failed else 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -133,7 +133,9 @@ list(APPEND UISource
|
||||
JitCompareScreen.h
|
||||
JitCompareScreen.cpp
|
||||
MemStickScreen.h
|
||||
StorageTestScreen.h
|
||||
MemStickScreen.cpp
|
||||
StorageTestScreen.cpp
|
||||
ProfilerDraw.h
|
||||
ProfilerDraw.cpp
|
||||
CustomButtonMappingScreen.h
|
||||
|
||||
@@ -147,6 +147,7 @@
|
||||
#include "UI/GPUDriverTestScreen.h"
|
||||
#include "UI/MiscScreens.h"
|
||||
#include "UI/MemStickScreen.h"
|
||||
#include "UI/StorageTestScreen.h"
|
||||
#include "UI/OnScreenDisplay.h"
|
||||
#include "UI/SettingsPage.h"
|
||||
#include "UI/RemoteISOScreen.h"
|
||||
@@ -910,6 +911,9 @@ void NativeInit(int argc, const char *argv[], const CommandLineOptions &cmdLineO
|
||||
} else if (equals(cmdLineOptions.startScreen.value(), "memsticksetup")) {
|
||||
g_screenManager->switchScreen(new MainScreen());
|
||||
g_screenManager->push(new MemStickScreen(true));
|
||||
} else if (equals(cmdLineOptions.startScreen.value(), "storagetest")) {
|
||||
g_screenManager->switchScreen(new MainScreen());
|
||||
g_screenManager->push(new StorageTestScreen());
|
||||
} else if (equals(cmdLineOptions.startScreen.value(), "credits")) {
|
||||
g_screenManager->switchScreen(new MainScreen());
|
||||
g_screenManager->push(new CreditsScreen());
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
// Copyright (c) 2012- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include "Common/File/FileUtil.h"
|
||||
#include "Common/Log.h"
|
||||
#include "Common/Log/LogManager.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Common/System/Request.h"
|
||||
#include "Common/Thread/ThreadUtil.h"
|
||||
#include "Common/UI/Notice.h"
|
||||
#include "Common/UI/ViewGroup.h"
|
||||
#include "Core/Config.h"
|
||||
#include "UI/StorageTestScreen.h"
|
||||
|
||||
// A developer tool, so the strings aren't translated.
|
||||
|
||||
static Path RememberedFolderFile() {
|
||||
return g_Config.internalDataDirectory / "storage_test_dir.txt";
|
||||
}
|
||||
|
||||
StorageTestScreen::StorageTestScreen()
|
||||
: UITwoPaneBaseDialogScreen(Path(), TwoPaneFlags::SettingsToTheRight | TwoPaneFlags::ContentsCanScroll) {
|
||||
std::string remembered;
|
||||
if (!g_Config.internalDataDirectory.empty() && File::ReadTextFileToString(RememberedFolderFile(), &remembered)) {
|
||||
folder_ = Path(StripSpaces(remembered));
|
||||
// Started from a script, most likely, so get going (in update(), once the screen is up).
|
||||
autoStart_ = File::IsDirectory(folder_);
|
||||
if (!autoStart_) {
|
||||
WARN_LOG(Log::System, "StorageTest: Remembered folder '%s' is gone, choose another", folder_.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StorageTestScreen::~StorageTestScreen() {
|
||||
// The tests have no way to stop halfway, but they take seconds.
|
||||
if (thread_.joinable()) {
|
||||
thread_.join();
|
||||
}
|
||||
RestoreLogLevel();
|
||||
}
|
||||
|
||||
void StorageTestScreen::RaiseLogLevel() {
|
||||
if (logRaised_) {
|
||||
return;
|
||||
}
|
||||
LogChannel *channel = g_logManager.GetLogChannel(Log::System);
|
||||
savedLogLevel_ = channel->level;
|
||||
savedLogEnabled_ = channel->enabled;
|
||||
channel->enabled = true;
|
||||
if (channel->level < LogLevel::LINFO) {
|
||||
channel->level = LogLevel::LINFO;
|
||||
}
|
||||
logRaised_ = true;
|
||||
}
|
||||
|
||||
void StorageTestScreen::RestoreLogLevel() {
|
||||
if (!logRaised_) {
|
||||
return;
|
||||
}
|
||||
LogChannel *channel = g_logManager.GetLogChannel(Log::System);
|
||||
channel->level = savedLogLevel_;
|
||||
channel->enabled = savedLogEnabled_;
|
||||
logRaised_ = false;
|
||||
}
|
||||
|
||||
void StorageTestScreen::CreateSettingsViews(UI::ViewGroup *parent) {
|
||||
using namespace UI;
|
||||
if (running_) {
|
||||
parent->Add(new TextView("Running...", ALIGN_LEFT, false));
|
||||
return;
|
||||
}
|
||||
parent->Add(new Choice("Choose folder", ImageID("I_FOLDER_OPEN")))->OnClick.Add([this](EventParams &) {
|
||||
ChooseFolder();
|
||||
});
|
||||
if (!folder_.empty()) {
|
||||
parent->Add(new Choice("Run tests"))->OnClick.Add([this](EventParams &) {
|
||||
StartTests();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void StorageTestScreen::CreateContentViews(UI::ViewGroup *parent) {
|
||||
using namespace UI;
|
||||
LinearLayout *list = parent->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)));
|
||||
if (folder_.empty()) {
|
||||
list->Add(new TextView("Create a new, empty folder for the tests in the folder picker, and choose it. The tests work in a folder of their own inside it and delete it again, but a folder of its own keeps them away from your data. It's remembered for later runs.", ALIGN_LEFT | FLAG_WRAP_TEXT, false));
|
||||
return;
|
||||
}
|
||||
list->Add(new TextView("Folder: " + folder_.ToVisualString(), ALIGN_LEFT | FLAG_WRAP_TEXT, false));
|
||||
const int failures = failures_;
|
||||
if (failures >= 0) {
|
||||
if (failures == 0) {
|
||||
list->Add(new NoticeView(NoticeLevel::SUCCESS, "All passed", ""));
|
||||
} else {
|
||||
list->Add(new NoticeView(NoticeLevel::ERROR, StringFromFormat("%d failed", failures), ""));
|
||||
}
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> guard(resultsLock_);
|
||||
for (const StorageTestResult &result : results_) {
|
||||
list->Add(new NoticeView(result.passed ? NoticeLevel::SUCCESS : NoticeLevel::ERROR, result.name, result.detail));
|
||||
}
|
||||
shownResults_ = results_.size();
|
||||
}
|
||||
|
||||
void StorageTestScreen::update() {
|
||||
UITwoPaneBaseDialogScreen::update();
|
||||
if (autoStart_) {
|
||||
autoStart_ = false;
|
||||
StartTests();
|
||||
}
|
||||
|
||||
bool changed;
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(resultsLock_);
|
||||
changed = results_.size() != shownResults_;
|
||||
}
|
||||
if (!running_ && thread_.joinable()) {
|
||||
thread_.join();
|
||||
RestoreLogLevel();
|
||||
changed = true;
|
||||
}
|
||||
if (changed) {
|
||||
RecreateViews();
|
||||
}
|
||||
}
|
||||
|
||||
void StorageTestScreen::ChooseFolder() {
|
||||
System_BrowseForFolder(GetRequesterToken(), "Choose a folder to test in", folder_, [this](std::string_view value, int) {
|
||||
const Path folder(value);
|
||||
if (folder.empty()) {
|
||||
return;
|
||||
}
|
||||
folder_ = folder;
|
||||
if (!g_Config.internalDataDirectory.empty()) {
|
||||
File::WriteStringToFile(true, folder_.ToString(), RememberedFolderFile());
|
||||
}
|
||||
StartTests();
|
||||
});
|
||||
}
|
||||
|
||||
void StorageTestScreen::StartTests() {
|
||||
if (running_ || folder_.empty()) {
|
||||
return;
|
||||
}
|
||||
if (thread_.joinable()) {
|
||||
thread_.join();
|
||||
}
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(resultsLock_);
|
||||
results_.clear();
|
||||
}
|
||||
shownResults_ = 0;
|
||||
failures_ = -1;
|
||||
running_ = true;
|
||||
RaiseLogLevel();
|
||||
RecreateViews();
|
||||
thread_ = std::thread([this]() {
|
||||
SetCurrentThreadName("StorageTest");
|
||||
// Content URIs go through Java.
|
||||
AndroidJNIThreadContext jniContext;
|
||||
const int failures = RunStorageTests(folder_, [this](const StorageTestResult &result) {
|
||||
std::lock_guard<std::mutex> guard(resultsLock_);
|
||||
results_.push_back(result);
|
||||
});
|
||||
failures_ = failures;
|
||||
running_ = false;
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
// Copyright (c) 2012- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/File/Path.h"
|
||||
#include "Common/Log.h"
|
||||
#include "Core/Util/StorageTest.h"
|
||||
#include "UI/SimpleDialogScreen.h"
|
||||
|
||||
// Runs RunStorageTests() in a folder the user picks, which on Android is a content URI: the storage code
|
||||
// the unit tests can't reach. Opened with --start-screen=storagetest (see Tools/android_storage_test.py).
|
||||
// The folder is remembered, so later runs start by themselves.
|
||||
class StorageTestScreen : public UITwoPaneBaseDialogScreen {
|
||||
public:
|
||||
StorageTestScreen();
|
||||
~StorageTestScreen();
|
||||
|
||||
const char *tag() const override { return "StorageTest"; }
|
||||
|
||||
protected:
|
||||
void CreateSettingsViews(UI::ViewGroup *parent) override;
|
||||
void CreateContentViews(UI::ViewGroup *parent) override;
|
||||
std::string_view GetTitle() const override { return "Storage tests"; }
|
||||
void update() override;
|
||||
|
||||
private:
|
||||
void ChooseFolder();
|
||||
void StartTests();
|
||||
// The results are logged at INFO for Tools/android_storage_test.py, so they have to get through
|
||||
// whatever level the user has. Restored when the run ends, since Config::Save() stores the levels.
|
||||
void RaiseLogLevel();
|
||||
void RestoreLogLevel();
|
||||
|
||||
Path folder_;
|
||||
bool autoStart_ = false;
|
||||
|
||||
std::thread thread_;
|
||||
std::atomic<bool> running_{ false };
|
||||
std::mutex resultsLock_;
|
||||
std::vector<StorageTestResult> results_;
|
||||
size_t shownResults_ = 0;
|
||||
std::atomic<int> failures_{ -1 }; // -1 until a run has finished.
|
||||
|
||||
bool logRaised_ = false;
|
||||
LogLevel savedLogLevel_ = LogLevel::LINFO;
|
||||
bool savedLogEnabled_ = true;
|
||||
};
|
||||
@@ -64,6 +64,7 @@
|
||||
<ClCompile Include="LoadStateConfirmScreen.cpp" />
|
||||
<ClCompile Include="MainScreen.cpp" />
|
||||
<ClCompile Include="MemStickScreen.cpp" />
|
||||
<ClCompile Include="StorageTestScreen.cpp" />
|
||||
<ClCompile Include="MiscScreens.cpp" />
|
||||
<ClCompile Include="MiscViews.cpp" />
|
||||
<ClCompile Include="NativeApp.cpp" />
|
||||
@@ -141,6 +142,7 @@
|
||||
<ClInclude Include="LoadStateConfirmScreen.h" />
|
||||
<ClInclude Include="MainScreen.h" />
|
||||
<ClInclude Include="MemStickScreen.h" />
|
||||
<ClInclude Include="StorageTestScreen.h" />
|
||||
<ClInclude Include="MiscScreens.h" />
|
||||
<ClInclude Include="MiscViews.h" />
|
||||
<ClInclude Include="OnScreenDisplay.h" />
|
||||
|
||||
@@ -91,6 +91,9 @@
|
||||
<ClCompile Include="MemStickScreen.cpp">
|
||||
<Filter>Screens</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="StorageTestScreen.cpp">
|
||||
<Filter>Screens</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Theme.cpp" />
|
||||
<ClCompile Include="GamepadEmu.cpp">
|
||||
<Filter>Views</Filter>
|
||||
@@ -291,6 +294,9 @@
|
||||
<ClInclude Include="MemStickScreen.h">
|
||||
<Filter>Screens</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="StorageTestScreen.h">
|
||||
<Filter>Screens</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Theme.h" />
|
||||
<ClInclude Include="GamepadEmu.h">
|
||||
<Filter>Views</Filter>
|
||||
|
||||
@@ -335,6 +335,7 @@
|
||||
<ClInclude Include="..\..\Core\Util\AtracTrack.h" />
|
||||
<ClInclude Include="..\..\Core\Util\GameDB.h" />
|
||||
<ClInclude Include="..\..\Core\Util\MemStick.h" />
|
||||
<ClInclude Include="..\..\Core\Util\StorageTest.h" />
|
||||
<ClInclude Include="..\..\Core\Util\PathUtil.h" />
|
||||
<ClInclude Include="..\..\Core\Util\PortManager.h" />
|
||||
<ClInclude Include="..\..\Core\Util\RecentFiles.h" />
|
||||
@@ -662,6 +663,7 @@
|
||||
<ClCompile Include="..\..\Core\Util\AtracTrack.cpp" />
|
||||
<ClCompile Include="..\..\Core\Util\GameDB.cpp" />
|
||||
<ClCompile Include="..\..\Core\Util\MemStick.cpp" />
|
||||
<ClCompile Include="..\..\Core\Util\StorageTest.cpp" />
|
||||
<ClCompile Include="..\..\Core\Util\PathUtil.cpp" />
|
||||
<ClCompile Include="..\..\Core\Util\PortManager.cpp" />
|
||||
<ClCompile Include="..\..\Core\Util\RecentFiles.cpp" />
|
||||
|
||||
@@ -264,6 +264,7 @@
|
||||
<ClCompile Include="..\..\Core\Util\AtracTrack.cpp" />
|
||||
<ClCompile Include="..\..\Core\Util\GameDB.cpp" />
|
||||
<ClCompile Include="..\..\Core\Util\MemStick.cpp" />
|
||||
<ClCompile Include="..\..\Core\Util\StorageTest.cpp" />
|
||||
<ClCompile Include="..\..\Core\Util\PortManager.cpp" />
|
||||
<ClCompile Include="..\..\Core\Util\RecentFiles.cpp" />
|
||||
<ClCompile Include="..\..\Core\WebServer.cpp" />
|
||||
@@ -667,6 +668,7 @@
|
||||
<ClInclude Include="..\..\Core\Util\AtracTrack.h" />
|
||||
<ClInclude Include="..\..\Core\Util\GameDB.h" />
|
||||
<ClInclude Include="..\..\Core\Util\MemStick.h" />
|
||||
<ClInclude Include="..\..\Core\Util\StorageTest.h" />
|
||||
<ClInclude Include="..\..\Core\Util\PortManager.h" />
|
||||
<ClInclude Include="..\..\Core\Util\RecentFiles.h" />
|
||||
<ClInclude Include="..\..\Core\WebServer.h" />
|
||||
|
||||
@@ -134,6 +134,7 @@
|
||||
<ClInclude Include="..\..\UI\Theme.h" />
|
||||
<ClInclude Include="..\..\UI\MainScreen.h" />
|
||||
<ClInclude Include="..\..\UI\MemStickScreen.h" />
|
||||
<ClInclude Include="..\..\UI\StorageTestScreen.h" />
|
||||
<ClInclude Include="..\..\UI\MiscScreens.h" />
|
||||
<ClInclude Include="..\..\UI\IAPScreen.h" />
|
||||
<ClInclude Include="..\..\UI\OnScreenDisplay.h" />
|
||||
@@ -210,6 +211,7 @@
|
||||
<ClCompile Include="..\..\UI\Theme.cpp" />
|
||||
<ClCompile Include="..\..\UI\MainScreen.cpp" />
|
||||
<ClCompile Include="..\..\UI\MemStickScreen.cpp" />
|
||||
<ClCompile Include="..\..\UI\StorageTestScreen.cpp" />
|
||||
<ClCompile Include="..\..\UI\MiscScreens.cpp" />
|
||||
<ClCompile Include="..\..\UI\IAPScreen.cpp" />
|
||||
<ClCompile Include="..\..\UI\NativeApp.cpp" />
|
||||
|
||||
@@ -107,6 +107,9 @@
|
||||
<ClCompile Include="..\..\UI\MemStickScreen.cpp">
|
||||
<Filter>Screens</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\UI\StorageTestScreen.cpp">
|
||||
<Filter>Screens</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\UI\MiscScreens.cpp">
|
||||
<Filter>Screens</Filter>
|
||||
</ClCompile>
|
||||
@@ -297,6 +300,9 @@
|
||||
<ClInclude Include="..\..\UI\MemStickScreen.h">
|
||||
<Filter>Screens</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\UI\StorageTestScreen.h">
|
||||
<Filter>Screens</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\UI\MiscScreens.h">
|
||||
<Filter>Screens</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@@ -892,6 +892,7 @@ EXEC_AND_LIB_FILES := \
|
||||
$(SRC)/Core/Util/AtracTrack.cpp \
|
||||
$(SRC)/Core/Util/AudioFormat.cpp \
|
||||
$(SRC)/Core/Util/MemStick.cpp \
|
||||
$(SRC)/Core/Util/StorageTest.cpp \
|
||||
$(SRC)/Core/Util/PathUtil.cpp \
|
||||
$(SRC)/Core/Util/PortManager.cpp \
|
||||
$(SRC)/Core/Util/GameDB.cpp \
|
||||
@@ -1098,6 +1099,7 @@ LOCAL_SRC_FILES := \
|
||||
$(SRC)/UI/AdhocServerScreen.cpp \
|
||||
$(SRC)/UI/SimpleDialogScreen.cpp \
|
||||
$(SRC)/UI/MemStickScreen.cpp \
|
||||
$(SRC)/UI/StorageTestScreen.cpp \
|
||||
$(SRC)/UI/IAPScreen.cpp \
|
||||
$(SRC)/UI/MiscScreens.cpp \
|
||||
$(SRC)/UI/MiscViews.cpp \
|
||||
|
||||
@@ -82,6 +82,14 @@ away within seconds, which reads as "logging stopped" rather than "logging was l
|
||||
|
||||
adb logcat -c && adb logcat -s PPSSPP:V PpssppActivity:V # in the background, then start the app
|
||||
|
||||
## Starting the app with options
|
||||
|
||||
python Tools/android_run.py --build --start-screen=memsticksetup # build, install, open the memory stick setup
|
||||
python Tools/android_run.py --log --start-screen=firmware # and follow the app's log
|
||||
|
||||
It force-stops the app first, since options are only read at startup, and passes them in the
|
||||
`org.ppsspp.ppsspp.Args` intent extra. The `--start-screen` names are in `NativeInit()` in `UI/NativeApp.cpp`.
|
||||
|
||||
## Running the C++ unit tests on a device
|
||||
|
||||
CI builds the Android unit test executable but doesn't run it. To run it on a connected device:
|
||||
@@ -97,10 +105,27 @@ failures. Worth doing before a release, and after changing `Common/File` or anyt
|
||||
Two things to know when reading its results:
|
||||
|
||||
- The executable has no Java VM, so content URIs fail like missing files there. They're only exercised
|
||||
for real inside the app.
|
||||
for real inside the app, by the storage tests below.
|
||||
- From Git Bash, set `MSYS_NO_PATHCONV=1` before any `adb push`/`adb shell` of your own, or
|
||||
`/data/local/tmp` gets rewritten into a Windows path and the push silently lands somewhere else.
|
||||
|
||||
## Running the storage tests in the app
|
||||
|
||||
`Core/Util/StorageTest.cpp` exercises the file functions (create, overwrite, list, rename, move, copy,
|
||||
delete, odd names, free space) in a scratch folder, and times the calls the emulator makes most. The
|
||||
`Storage` unit test runs them on a native folder; to run them on a picked folder, through the content
|
||||
URI code:
|
||||
|
||||
python Tools/android_storage_test.py --build # build and install the normal debug APK, then run
|
||||
python Tools/android_storage_test.py # with what's installed
|
||||
|
||||
That starts the app with `--start-screen=storagetest`. The first time, tap Choose folder on the device,
|
||||
create a new empty folder in the picker, and choose it. It's remembered (in `storage_test_dir.txt` in
|
||||
the app's internal data), so later runs need no hands and take seconds. Results go to logcat as
|
||||
`StorageTest: PASS/FAIL ...` lines, ending with `StorageTest: DONE, N failed`. Run them in a folder on
|
||||
an SD card too, if the device has one. Keep the screen on (Stay awake in the developer options) while
|
||||
timing: a locked phone throttles the app, and the times double.
|
||||
|
||||
## VR (Quest)
|
||||
|
||||
- The VR flavor is a separate package: `./gradlew :android:assembleVrDebug`, installing as
|
||||
|
||||
@@ -937,6 +937,7 @@ SOURCES_CXX += \
|
||||
$(COREDIR)/Util/AtracTrack.cpp \
|
||||
$(COREDIR)/Util/BlockAllocator.cpp \
|
||||
$(COREDIR)/Util/MemStick.cpp \
|
||||
$(COREDIR)/Util/StorageTest.cpp \
|
||||
$(COREDIR)/Util/PPGeDraw.cpp \
|
||||
$(COREDIR)/Util/KL4E.cpp \
|
||||
$(COREDIR)/Util/PSARUnpack.cpp \
|
||||
|
||||
@@ -127,6 +127,7 @@
|
||||
#include "Core/ControlMapper.h"
|
||||
#include "Core/HLE/sceCtrl.h"
|
||||
#include "Core/HLE/sceUsbMic.h"
|
||||
#include "Core/Util/StorageTest.h"
|
||||
#include "Core/Util/PathUtil.h"
|
||||
#include "Core/Util/PSARUnpack.h"
|
||||
#include "Core/MIPS/MIPSVFPUUtils.h"
|
||||
@@ -2938,6 +2939,21 @@ static bool TestAndroidContentURI() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// The tests the storage test screen runs on a picked folder, here on a native one.
|
||||
static bool TestStorage() {
|
||||
const Path root = UnitTestTempPath("unittest_storage");
|
||||
File::DeleteDirRecursively(root);
|
||||
EXPECT_TRUE(File::CreateFullPath(root));
|
||||
const int failures = RunStorageTests(root, [](const StorageTestResult &result) {
|
||||
if (!result.passed) {
|
||||
printf("%s: %s\n", result.name.c_str(), result.detail.c_str());
|
||||
}
|
||||
});
|
||||
File::DeleteDirRecursively(root);
|
||||
EXPECT_EQ_INT(failures, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
class UnitTestWordWrapper : public WordWrapper {
|
||||
public:
|
||||
UnitTestWordWrapper(std::string_view str, float maxW, int flags)
|
||||
@@ -4324,6 +4340,7 @@ TestItem availableTests[] = {
|
||||
TEST_ITEM(Path),
|
||||
TEST_ITEM(OverlayHole),
|
||||
TEST_ITEM(AndroidContentURI),
|
||||
TEST_ITEM(Storage),
|
||||
TEST_ITEM(ThreadManager),
|
||||
TEST_ITEM(WrapText),
|
||||
TEST_ITEM(TinySet),
|
||||
|
||||
Reference in new issue
Block a user