Establish native Linux ARM64 Android CI and verification gates (#94)
This commit is contained in:
1 parent
1abd75282e
commit
66b1d4a4c4
29 files changed
+1882
-56
No files matched your search
+26
@@ -0,0 +1,26 @@
|
||||
package de.rfc1437.ironstorage.bridge
|
||||
|
||||
import android.os.Bundle
|
||||
import android.os.SystemClock
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import de.rfc1437.ironstorage.bridge.generated.MobileShellState
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class NativeLoadPerformanceTest {
|
||||
@Test
|
||||
fun reportsNativeLoadAndFirstRustFixtureWithoutSecretData() {
|
||||
val instrumentation = InstrumentationRegistry.getInstrumentation()
|
||||
val runtime = NativeRuntime(instrumentation.targetContext)
|
||||
val started = SystemClock.elapsedRealtimeNanos()
|
||||
val shell = runtime.fixture(MobileShellState.EMPTY)
|
||||
val elapsed = SystemClock.elapsedRealtimeNanos() - started
|
||||
assertTrue(elapsed > 0)
|
||||
assertEquals(5, shell.pages.size)
|
||||
instrumentation.sendStatus(
|
||||
0,
|
||||
Bundle().apply { putLong("ironstorage_native_load_ns", elapsed) }
|
||||
)
|
||||
}
|
||||
}
|
||||
+8
-2
@@ -14,6 +14,7 @@ import de.rfc1437.ironstorage.bridge.generated.MobileTab
|
||||
import de.rfc1437.ironstorage.bridge.generated.UniffiRustCallStatus
|
||||
import de.rfc1437.ironstorage.bridge.generated.uniffiTraitInterfaceCall
|
||||
import java.io.File
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipOutputStream
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
@@ -102,12 +103,17 @@ class NativeRuntimeTest {
|
||||
@Test
|
||||
fun missingLibraryAndUnsupportedAbiFailBeforeEnteringRust() {
|
||||
val abiFailure = assertThrows(NativeBridgeException::class.java) {
|
||||
NativeRuntime.supportedAbi(listOf("unsupported-fixture-abi"))
|
||||
NativeRuntime.supportedAbi(listOf("x86_64", "unsupported-fixture-abi"))
|
||||
}
|
||||
assertEquals(NativeFailureKind.UnsupportedAbi, abiFailure.kind)
|
||||
assertEquals("arm64-v8a", NativeRuntime.supportedAbi(listOf("x86_64", "arm64-v8a")))
|
||||
val packageFile = File.createTempFile("native-empty-package", ".apk", context.cacheDir)
|
||||
try {
|
||||
ZipOutputStream(packageFile.outputStream()).close()
|
||||
ZipOutputStream(packageFile.outputStream()).use { archive ->
|
||||
// API 26 rejects a ZIP with no entries; keep this valid package free of native code.
|
||||
archive.putNextEntry(ZipEntry("non-native-fixture"))
|
||||
archive.closeEntry()
|
||||
}
|
||||
val info = ApplicationInfo(context.applicationInfo).apply {
|
||||
sourceDir = packageFile.absolutePath
|
||||
splitSourceDirs = null
|
||||
|
||||
@@ -85,7 +85,7 @@ class NativeRuntime(context: Context) {
|
||||
private const val LIBRARY_FILE = "libironstorage_android.so"
|
||||
|
||||
internal fun supportedAbi(deviceAbis: List<String>): String =
|
||||
deviceAbis.firstOrNull { it in setOf("arm64-v8a", "armeabi-v7a", "x86_64") }
|
||||
deviceAbis.firstOrNull { it in setOf("arm64-v8a", "armeabi-v7a") }
|
||||
?: throw NativeBridgeException(NativeFailureKind.UnsupportedAbi)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user