Run checked JVM string tests with the Android verification tasks

This commit is contained in:
evgeny committed 2026-10-29 13:35:41 +01:00
1 parent e325a665d0
commit 798e154cc3
3 files changed
+16 -6

No files matched your search

+7 -1
View File
@@ -81,10 +81,16 @@ val testJniLog by tasks.registering(Exec::class) {
workingDir(rootProject.projectDir)
commandLine("python3", rootProject.file("tests/jni_log/run.py"), "--java-home", System.getProperty("java.home"))
}
val testJniUtf8 by tasks.registering(Exec::class) {
onlyIf("Checked JNI JVM test requires Linux") { System.getProperty("os.name").startsWith("Linux") }
workingDir(rootProject.projectDir)
commandLine("python3", rootProject.file("tests/jni_utf8/run.py"), "--java-home", System.getProperty("java.home"))
}
// Зависимость только между задачами: host-модели не входят в classpath приложения/APK.
tasks.withType<org.gradle.api.tasks.testing.Test>().configureEach {
dependsOn(":router-tests:test", ":capture-tests:test", ":language-tests:test", ":call-service-tests:test", ":video-tests:test", testJniLog)
dependsOn(":router-tests:test", ":capture-tests:test", ":language-tests:test", ":call-service-tests:test", ":video-tests:test",
testJniLog, testJniUtf8)
val messageLinkCases = rootProject.file("../chatgui/tests/message_links_cases.tsv")
inputs.file(messageLinkCases)
systemProperty("utun.messageLinkCases", messageLinkCases.absolutePath)
+7 -3
View File
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
"""Linux: проверить обычный UTF-8 настоящего Android bridge в JVM с -Xcheck:jni."""
import argparse
import os
from pathlib import Path
import shlex
@@ -9,12 +10,15 @@ import tempfile
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--java-home", type=Path)
args = parser.parse_args()
directory = Path(__file__).resolve().parent
root = directory.parents[3]
javac = shutil.which("javac")
if not javac:
raise SystemExit("JDK with javac/libjvm required")
java_home = Path(javac).resolve().parents[1]
java_home = args.java_home or (Path(javac).resolve().parents[1] if javac else None)
if java_home is None or not (java_home / "include/jni.h").is_file():
parser.error("JDK with JNI headers/libjvm required; pass --java-home")
server = java_home / "lib/server"
includes = [directory.parent / "jni_log", java_home / "include", java_home / "include/linux",
root / "src", root / "src/transport_layer", root / "src/routing_layer",
@@ -2,8 +2,8 @@
#include "../../jni_bridge/android_jni_bridge.c"
static int fail_allocation;
void* u_malloc(size_t size) { return fail_allocation ? NULL : malloc(size); }
void u_free(void* pointer) { free(pointer); }
void* u_malloc_impl(uint32_t size, const char* location) { (void)location; return fail_allocation ? NULL : malloc(size); }
void u_free_impl(void* pointer, const char* location) { (void)location; free(pointer); }
int __android_log_print(int priority, const char* tag, const char* format, ...) {
(void)priority; (void)tag;
va_list args; va_start(args, format); vfprintf(stderr, format, args); va_end(args); fputc('\n', stderr); return 0;