android - 如何为 Android 交叉编译 LTP

标签 android linux testing cross-compiling

是否有人为 android 交叉编译和使用 LTP,我尝试使用 arm-eabi 工具链、arm-linux-none-gnueabi 工具链交叉编译 LTP,但我无法在 android 设备中执行测试用例。

最佳答案

首先创建独立工具链(使用 make-standalone-toolchain.sh 脚本)并将其安装到 /opt/android-standalone-toolchain.api-${API}

构建本身:

API=24
export TOOLCHAIN_ROOT=/opt/android-standalone-toolchain.api-${API}
export SYSROOT=$TOOLCHAIN_ROOT/sysroot
export CROSS_COMPILE=$TOOLCHAIN_ROOT/bin/arm-linux-androideabi-
export HOST=arm-linux-androideabi

# Non-exhaustive lists of compiler + binutils
# Depending on what you compile, you might need more binutils than that
export CPP=${CROSS_COMPILE}cpp
export AR=${CROSS_COMPILE}ar
export AS=${CROSS_COMPILE}as
export NM=${CROSS_COMPILE}nm
export CC=${CROSS_COMPILE}gcc
export CXX=${CROSS_COMPILE}g++
export LD=${CROSS_COMPILE}ld
export RANLIB=${CROSS_COMPILE}ranlib

export CFLAGS="${CFLAGS} --sysroot=${SYSROOT} -I${SYSROOT}/usr/include \
    -I${ANDROID_PREFIX}/include"
export CPPFLAGS="${CFLAGS}"
export LDFLAGS="${LDFLAGS} -L${SYSROOT}/usr/lib -L${ANDROID_PREFIX}/lib"

make autotools
./configure --host=${HOST} --with-sysroot=${SYSROOT}
make -j$(getconf _NPROCESSORS_ONLN) ANDROID=1
make install
adb push /opt/ltp /data/local/tmp

CREDITS:使用变量 ANDROID=1 记录在 INSTALL 中LTP 源代码中的文件,设置其他变量的灵感来自 android_configure.sh .

但目前构建失败,因为需要禁用许多测试(仿生不支持许多必需的功能,请参阅 list of tests needed to be disabled 由 google 人员制作)。

目前,上游正在努力修复为 Android 构建 LTP。来自谷歌的人 added LTP into AOSP ,但他们正在将代码贡献回 LTP 上游(请参阅 LTP 邮件列表中的信息 people from google planning to contributetheir instructions about building)。

一些与安卓相关的修复(来自谷歌和其他人):fix the executable shell path , fix temp dir , fix stack_clash test .

目前,在 AOSP 中使用 google 的存储库可能更容易(在 AOSP 树中构建树内或使用独立工具链在树外构建),但 LTP 上游迟早应该从 google 的存储库中获取针对 android 的所有修复。

关于android - 如何为 Android 交叉编译 LTP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12207144/

相关文章:

java - 安卓内存不足

android - 如何实现 getSupportParentActivityIntent() 以在 android 中为向上按钮动态设置 Activity

linux - 如何让 DNS 可供公众访问

c - 如何在GDB中调试fork-exec进程的入口点?

linux - GNU 汇编中的符号

php - 检查 mock 的方法是否在没有传递任何参数的情况下被调用(在 phpunit 中)

java - Android Textview onTouchEvent

email - 如何在功能测试中测试电子邮件发送?

mysql - 模拟mysql查询

android - 以编程方式将选项卡添加到选项卡主机