Exercise bundled apps through isolated production hosts
This commit is contained in:
1 parent
844eba30b8
commit
10de2aae33
5 files changed
+66
-15
No files matched your search
+3
-3
@@ -9,8 +9,8 @@ apps-test: library-reader-test apps $(ZIRAN_BUILD_DIR)/libziran.a $(LIBOQS_A) $(
|
||||
sh tests/apps_zi_test.sh $(ZIRAN_BIN) $(LIBOQS_A)
|
||||
|
||||
.PHONY: apps-platform-test apps-android-probe
|
||||
apps-platform-test: apps $(ZIRAN_BUILD_DIR)/libziran.a
|
||||
sh tests/apps_platform_test.sh $(ZIRAN_BIN) native
|
||||
apps-platform-test: apps $(ZIRAN_BUILD_DIR)/libziran.a $(SQLITE_SRC) $(LIBOQS_A)
|
||||
sh tests/apps_platform_test.sh $(ZIRAN_BIN) native $(LIBOQS_A) $(SQLITE_SRC)
|
||||
|
||||
apps-android-probe: apps
|
||||
sh tests/apps_platform_test.sh $(ZIRAN_BIN) android
|
||||
@@ -38,7 +38,7 @@ app-locations-test: $(ZIRAN_BIN)
|
||||
--toolchain '$(abspath $(ZIRAN_DIR))' --apps '$(abspath build/packages/apps)' \
|
||||
--daochi-client '$(abspath build/packages/daochi-client)'
|
||||
|
||||
node-app-snapshot-test: $(ZIRAN_BIN) $(ZIRAN_BUILD_DIR)/libziran.a $(SQLITE_SRC) $(LIBOQS_A)
|
||||
node-app-snapshot-test: apps $(ZIRAN_BIN) $(ZIRAN_BUILD_DIR)/libziran.a $(SQLITE_SRC) $(LIBOQS_A)
|
||||
python3 tests/node_app_snapshot_test.py --ziran '$(abspath $(ZIRAN_BIN))' \
|
||||
--runtime '$(abspath $(ZIRAN_BUILD_DIR)/libziran.a)'
|
||||
.PHONY: photos-app-test media-store-test media-metadata-test entity-photos-test
|
||||
|
||||
@@ -21,8 +21,9 @@ String ProbeFullRoot(void)
|
||||
return StringView((char *)full_payload, full_payload_size);
|
||||
}
|
||||
|
||||
/* This loader probe has no publisher or persisted settings. Network-package
|
||||
* authentication always fails; bundled identity checks still execute. */
|
||||
/* The narrow Android probe has no storage runtime. Native probes link the
|
||||
* production SQLite/crypto host with the shared isolated test support. */
|
||||
#ifndef APPS_PLATFORM_STORAGE
|
||||
int crypto_ed25519_check(const uint8_t *signature, const uint8_t *public_key,
|
||||
const uint8_t *message, size_t length)
|
||||
{
|
||||
@@ -38,6 +39,7 @@ int32_t storage_get_setting_int(String key)
|
||||
(void)key;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void app_web_storage_flush(void) {}
|
||||
|
||||
@@ -67,6 +69,7 @@ static unsigned char *read_payload(const char *path, size_t *size)
|
||||
return bytes;
|
||||
}
|
||||
|
||||
#ifndef APPS_PLATFORM_STORAGE
|
||||
void *asset_entry_at(size_t index)
|
||||
{
|
||||
(void)index;
|
||||
@@ -77,6 +80,7 @@ size_t asset_entry_total(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
FILE *__wrap_tmpfile(void)
|
||||
{
|
||||
@@ -86,6 +90,14 @@ FILE *__wrap_tmpfile(void)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
setbuf(stdout, NULL);
|
||||
#ifdef APPS_PLATFORM_STORAGE
|
||||
/* Fail closed if invoked outside the isolated test script. */
|
||||
const char *data_root = getenv("APP_DATA_ROOT");
|
||||
if(data_root == NULL || data_root[0] == '\0') {
|
||||
fprintf(stderr, "Native platform probe requires APP_DATA_ROOT\n");
|
||||
return 12;
|
||||
}
|
||||
#endif
|
||||
if(argc != 3) {
|
||||
return 10;
|
||||
}
|
||||
|
||||
@@ -5,20 +5,28 @@ root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
cd "$root"
|
||||
ziran=${1:-build/ziran-toolchain/bin/ziran}
|
||||
target=${2:-native}
|
||||
liboqs=${3:-}
|
||||
sqlite=${4:-}
|
||||
work=$root/build/apps-platform-probe
|
||||
source=$root/build/packages/ziran
|
||||
generated=$work/generated-$target
|
||||
mkdir -p "$generated"
|
||||
set --
|
||||
definitions=
|
||||
if [ "$target" = android ]; then
|
||||
set -- --define ANDROID_BUILD --define __arm__
|
||||
definitions="--define ANDROID_BUILD --define __arm__"
|
||||
else
|
||||
# Native module callbacks now reach the real storage/optional app host.
|
||||
# Reuse the existing isolated host support rather than dummy DB bindings.
|
||||
set -- "$root/tests/delegate_account_host.zi" "$root/tests/sync_test_host.zi" \
|
||||
"$root/tests/background_audio_stub.zi"
|
||||
fi
|
||||
"$ziran" build --target=c --no-main "$@" --root "$root/tests" \
|
||||
"$ziran" build --target=c --no-main $definitions --root "$root/tests" \
|
||||
--module-path "$root/src" --module-path "$root/build/packages/kryon/src/ui" --module-path "$root/build/packages/kryon/src/backend" \
|
||||
$(sh "$root/scripts/package-paths.sh" "$root/build/packages") \
|
||||
--module-path "$root/build/packages/daochi-client" \
|
||||
--module-path "$source/std" -o "$generated" \
|
||||
"$root/tests/apps_platform_probe.zi"
|
||||
"$root/tests/apps_platform_probe.zi" "$@"
|
||||
if [ "$target" = android ]; then
|
||||
sdk=${ANDROID_SDK_ROOT:-/home/wao/Android/Sdk}
|
||||
ndk=$sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/linux-x86_64/bin
|
||||
@@ -36,12 +44,31 @@ else
|
||||
echo "usage: apps_platform_test.sh ZIRAN native|android" >&2
|
||||
exit 2
|
||||
fi
|
||||
set --
|
||||
if [ "$target" = native ]; then
|
||||
: "${liboqs:?native probe requires LIBOQS_A}" "${sqlite:?native probe requires SQLITE_SRC}"
|
||||
set -- -DAPPS_PLATFORM_STORAGE \
|
||||
-I"$root/build/packages/monocypher/src" \
|
||||
"$root/build/packages/monocypher/src/monocypher.c" \
|
||||
"$root/build/packages/monocypher/src/optional/monocypher-ed25519.c" \
|
||||
"$sqlite" \
|
||||
"$liboqs" \
|
||||
-l:libcurl.so.4 -lz -ldl -lpthread
|
||||
fi
|
||||
"$cc" -D_GNU_SOURCE -std=c11 -O2 -ffunction-sections -fdata-sections \
|
||||
-I"$source/include" -I"$source/cmd/zir" -iquote "$generated" \
|
||||
"$root/tests/apps_platform_host.c" "$generated"/*.c \
|
||||
"$runtime/libziran.a" -Wl,--wrap=tmpfile -Wl,--gc-sections -lm -o "$binary"
|
||||
"$runtime/libziran.a" "$@" -Wl,--wrap=tmpfile -Wl,--gc-sections -lm -o "$binary"
|
||||
if [ "$target" = android ]; then
|
||||
sh tests/apps_android_probe.sh
|
||||
else
|
||||
"$binary" "$root/build/inbe.zx" "$root/build/inbe-full.zx"
|
||||
# Storage can be reached by module callbacks. Never inherit an owner profile.
|
||||
mkdir -p "$root/work"
|
||||
profile=$(mktemp -d "$root/work/apps-platform-test.XXXXXX")
|
||||
trap 'rm -rf "$profile"' EXIT HUP INT TERM
|
||||
mkdir -p "$profile/home"
|
||||
env -u INBE_DIARY_IMPORT -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY \
|
||||
-u DBUS_SESSION_BUS_ADDRESS -u SESSION_MANAGER YUE_DESKTOP_RECOVERY=0 \
|
||||
HOME="$profile/home" APP_DATA_ROOT="$profile/data" XDG_DATA_HOME="$profile/xdg" \
|
||||
"$binary" "$root/build/inbe.zx" "$root/build/inbe-full.zx"
|
||||
fi
|
||||
@@ -209,7 +209,8 @@ with contextlib.ExitStack() as stack:
|
||||
return card
|
||||
page = next(node for node in tree if node["kind"] == "scroll" and node["visible"])
|
||||
driver.pointer(page["visible_x"] + page["visible_width"] / 2,
|
||||
page["visible_y"] + page["visible_height"] / 2, wheel=-12)
|
||||
page["visible_y"] + page["visible_height"] / 2,
|
||||
wheel=12 if card["y"] < page["visible_y"] else -12)
|
||||
driver.wait_idle(frames=3)
|
||||
raise AssertionError(f"Could not reach {label} above the navigation")
|
||||
|
||||
@@ -573,12 +574,18 @@ with contextlib.ExitStack() as stack:
|
||||
wait_setting(profile, "launcher_grid_view", 1)
|
||||
pinned, more, tree = cards()
|
||||
assert all(abs(card["height"] - 88) <= 1 for card in pinned + more), cards()
|
||||
handles = driver.find(label="Move app", role="button", visible=True)
|
||||
for card in pinned + more:
|
||||
# Embedded baselines can add rows below the viewport.
|
||||
# Verify every handle with its card scrolled into view.
|
||||
first_label = pinned[0]["label"]
|
||||
for label in [card["label"] for card in pinned + more]:
|
||||
card = reveal_card(label)
|
||||
handles = driver.find(label="Move app", role="button", visible=True)
|
||||
matches = [node for node in handles
|
||||
if abs(node["y"] - card["y"]) < 2
|
||||
and abs(node["x"] + node["width"] - card["x"]) < 2]
|
||||
assert len(matches) == 1, (card, matches)
|
||||
reveal_card(first_label)
|
||||
pinned, more, tree = cards()
|
||||
first_options = next(node for node in tree if node["kind"] == "button"
|
||||
and node["label"] == "App options" and node["visible"]
|
||||
and node["y"] >= pinned[0]["y"]
|
||||
|
||||
@@ -57,6 +57,7 @@ EmbeddedTestMetadata :: (id: string, key: string, api: s32, size: s64, hash: str
|
||||
|
||||
NodeAppEmbeddedCheck :: () -> s32 {
|
||||
slot := cast(s32)(NodeAppSlots - 2)
|
||||
arcade_marked := NodeAppMarked("arcade")
|
||||
embedded_test_bytes = PackageRead(IconsEnvironmentPath("NODE_OPEN_LEAF_BUNDLE"), PackageMaximumBytes)
|
||||
embedded_test_publishers = PackageRead(IconsEnvironmentPath("NODE_EMBEDDED_PUBLISHERS"), 16384)
|
||||
hash := IconsEnvironmentPath("NODE_OPEN_LEAF_SHA256")
|
||||
@@ -75,6 +76,7 @@ NodeAppEmbeddedCheck :: () -> s32 {
|
||||
node_runners[slot].embedded_release = PackageRelease.{}
|
||||
package_cached_releases[NodeAppIndex(slot)] = PackageRelease.{}
|
||||
NodeAppAssign(slot, "")
|
||||
NodeAppSetMark("arcade", arcade_marked)
|
||||
}
|
||||
NodeAppAssign(slot, "fixture")
|
||||
EmbeddedTestMetadata("inbe.fixture", "baseline", 41, embedded_test_bytes.count, hash)
|
||||
@@ -157,9 +159,12 @@ NodeAppEmbeddedCheck :: () -> s32 {
|
||||
embedded_test_arcade = PackageRead(IconsEnvironmentPath("NODE_EMBEDDED_ARCADE"), PackageMaximumBytes)
|
||||
embedded_test_art = PackageRead(IconsEnvironmentPath("NODE_EMBEDDED_ART"), PackageMaximumBytes)
|
||||
embedded_test_controller = PackageRead(IconsEnvironmentPath("NODE_EMBEDDED_CONTROLLER"), PackageMaximumBytes)
|
||||
NodeAppAssign(slot, "arcade")
|
||||
package_cached_releases[NodeAppIndex(slot)] = PackageRelease.{}
|
||||
if !NodeAppOpen(slot) { return 178 }
|
||||
NodeAppAssign(slot, "")
|
||||
arcade_slot := NodeAppInstall("arcade")
|
||||
if arcade_slot < 0 { return 178 }
|
||||
slot = arcade_slot
|
||||
if !NodeAppMarked("arcade") || PackagePending(NodeAppIndex(slot)) { return 178 }
|
||||
deadline = EmbeddedNow() + 10.0
|
||||
while !NodeAppRunning(slot) && EmbeddedNow() < deadline {
|
||||
unused NodeOpenPump(true)
|
||||
|
||||
Reference in new issue
Block a user