Files
Vole/scripts/tests/test_platform_namespaces.py
T
yiguodev f616f19fee Support custom Windows VPN profiles and stable host COM lifetime (#7)
* Support custom VPN profiles and canonical platform namespaces

Add strict profileName selection to Windows VPN lifecycle requests while preserving package ownership and single-session guards.

Use the canonical Android JNI and Apple logging namespace, with updated contracts and regression coverage.

* Keep Windows host MTA alive across bridge calls

Retain one process-lifetime MTA usage reference for cached WinRT factories while balancing each caller-thread initialization. Preserve STA rejection and prevent guards from moving between threads.

Add isolated native DLL regressions for repeated calls, caller MTA release, worker handoff and STA rejection, and run them before UWP artifact upload.

* Use setup-python and native Windows toolchains in CI
2026-10-09 15:20:23 +08:00

35 lines
1.2 KiB
Python

"""Guard platform namespace source contracts, not native loading or device behavior."""
import re
import unittest
from pathlib import Path
CORE_DIR = Path(__file__).resolve().parents[2]
NAMESPACE = "io.github.yuandevteam.vole"
class PlatformNamespaceTests(unittest.TestCase):
def test_android_exports_only_the_canonical_jni_class(self):
source = (CORE_DIR / "src/ffi/android.rs").read_text(encoding="utf-8")
symbols = re.findall(
r'pub (?:unsafe )?extern "system" fn (Java_\w+)\s*\(', source
)
prefix = "Java_" + NAMESPACE.replace(".", "_") + "_NativeVole_"
self.assertCountEqual(
symbols,
[
prefix + "nativeInvoke",
prefix + "nativeRegisterProtectController",
prefix + "nativeUnregisterProtectController",
],
)
def test_apple_logging_uses_the_canonical_identity(self):
source = (CORE_DIR / "src/platform/apple_logging.rs").read_text(
encoding="utf-8"
)
self.assertRegex(
source, rf'(?m)^const SUBSYSTEM: &str = "{re.escape(NAMESPACE)}";$'
)
self.assertRegex(source, r'(?m)^const CATEGORY: &str = "vole";$')