Compilation of LTP (Linux Test Project) for Android

Linux Test Project (GitHub home page is here) (Hereinafter referred to as LTP) A collection of tools containing the Linux kernel and kernel-related features. The purpose of this tool is to improve the quality of Linux kernel by introducing test automation into Linux kernel testing. It is well known that Android is also a Linux Kernel. If there is a need for kernel testing for Android, you can consider using LTP. Here is a record of compilation.

Prepare Android NDK cross compilation package

Because we need to use the NDK for cross-compilation on Linux, we must configure the NDK before continuing the subsequent compilation. The NDK version I use is r10e (Reference download address). Note that the method of cross-compiling on Linux is universal, and many other compilation scenarios are similar methods (for example, compiling on Linux supports Android versions of ffmpeg and x264)

After downloading the NDK, unzip it to any location (I unzip it to /home/xuyu/android-ndk-r10e)
cd to android-ndk-r10e/build/tools
Execute the following command to make an independent cross-compiled package:

./make-standalone-toolchain.sh --platform=android-19 --ndk-dir=/home/xuyu/android-ndk-r10e

note–platformwith–ndk-dirNeed to be replaced according to the actual situation.

The following is the output of the command execution. After success, you will see that the cross compilation toolkit has been packaged. Of course, you can also use when executing make-standalone-toolchain.sh–install-path=To specify the output path.

Copying prebuilt binaries...
Copying sysroot headers and libraries...
Copying c++ runtime headers and libraries...
Creating package file: /tmp/ndk-xuyu/arm-linux-androideabi-4.9.tar.bz2
Cleaning up...
Done.

Unzip arm-linux-androideabi-4.9.tar.bz2 (using bzip2 -d and tar -xf in turn) to get the folder arm-linux-androideabi-4.9. Put the folder in any path, for example, I put it in /home/xuyu/, and changed the folder name to ndk-toolchains. The toolchain directory looks like this:

Environment variable

In order to facilitate the compilation, we first add the NDK to the environment variables, there are many ways, such as vim ~/.bashrc, add the following environment variables at the end:

export PATH=/home/xuyu/ndk-toolchains/bin:$PATH
export SYSROOT=/home/xuyu/ndk-toolchains/sysroot
export CC="/home/xuyu/ndk-toolchains/bin/arm-linux-androideabi-gcc --sysroot=$SYSROOT"
export ANDROID=1

Explain one of themANDROID=1: In the LTP INSTALL document, there is a description for Android users, excerpted as follows:

Specify ANDROID=1 when calling make. Many tests which would otherwise work are currently not built because they share a directory with an incompatible test.

The shell scripts expect /bin/sh to exist, so create a symlink.

It means that there are some tests that are not applicable to Android. Adding this option will filter out these tests (in fact, I found that there still seem to be some tests that are not blocked)

Prepare source code

git clone https://github.com/linux-test-project/ltp.git

The INSTALL file in the source code directory has a detailed list of compilation dependency tools, which can be installed one by one. The compilation steps are very simple, and the description in INSTALL is very detailed, I will outline it:

cd to the ltp source code directory, execute first

make autotools

The second step is to configure. This step is the key, I only set a few simple compilation parameters, as follows:

./configure AR=arm-linux-androideabi-ar RANLIB=arm-linux-androideabi-ranlib --host=arm-linux-androideabi --target=arm-linux-androideabi CFLAGS="-static" LDFLAGS="-static"

The third step is to execute:

make all

Note: Errors are likely to occur during the make process, because the author seems to have not considered the compatibility of Android when writing. For example, when I wrote this article, it happened when compiling /testcases/kernel/syscalls/fanotify/fanotify07.c Error:

I did not study how to make this file compile and pass, but chose to delete it directly...
To say something off topic, when looking through LTP’s Pull Request, I stumbled upon153In this Pull Request, a Contributor of the project: Steven Jackson also removed some uncompiled and inapplicable files and options.

The fourth step is to execute:

make "DESTDIR=$HOME/ltp_output" SKIP_IDCHECK=1 install

Wait patiently for the long-awaited LTP output to the specified path ($HOME/ltp_output).

Command execution is complete:

The result we want:

OK, at this point, LTP for Android is compiled. As for the use of LTP itself, it is not what this article describes.

Intelligent Recommendation

[Ltp] [eas] test cases resolved

contents eas_one_small_task eas_one_big_task eas_small_to_big eas_big_to_small eas_small_big_toggle eas_two_big_three_small sched_cfs_prio sched_dl_runtime sched_latency_dl sched_latency_rt sched_prio...

Detailed explanation of ijkplayer project compilation script and Android project test (eclipse compilation)

The official tutorial of the ijkplayer library has given a clear compilation process and compilation script https://github.com/Bilibili/ijkplayer But because I downloaded the zip package of the entire...

Linux performance testing tools LTP

Linux Test Project Linux Test Project is sponsored by SGI, OSDL, and Bull joint project of IBM, Cisco, Fujitsu, SUSE, Red Hat, Oracle and other development and maintenance. The project's objective is ...

Android project compilation process

The continuous integration of Android project builds requires a set of automated compilation and packaging processes, such as building a daily build system, automatically generating release files, and...

Android project construction and compilation

One, build gradle The location of the project path built by gradle: C:\Users\Administrator\.gradle\wrapper\dists\gradle-6.1.1-all\cfmwm155h49vnt3hynmlrsdst Two, compile and package After the build is ...

More Recommendation

HanLP vs LTP word segmentation function test

The article is taken from github, this test uses HanLP 1.6.0, LTP 3.4.0 Test idea The two lexicons were trained using the same corpus, and the same test data tested the performance of the two lexicons...

Ltp test suite - pthread_rwlock_unlock_3-1 analysis record

I recently did a ltp test on the linux-4.14 kernel. The pthread_rwlock_unlock_3-1 use case test did not pass, and then I did the test on various other Linux systems. Test failed: reader did not get th...

Ltp test suite - pthread_rwlock_rdlock_2-1 analysis record

The test pthread_rwlock_rdlock_2-1.c use case failed. The log is as follows: [83#yuchen@ubuntu ltp]# gcc 2-1.c -o 21 -pthread [84#yuchen@ubuntu ltp]# ./21 main: has priority: 3 main: attempt read lock...

Shell script example (2)-ltp test

Test sched_latency_dl 100 times  ...

LTP Chapter 4 Development_exit() Test Set

LTP series link: Chapter 1 Introduction to LTP and Internal Mechanism Chapter 2 Develop Shell Test Set Chapter 3 Development System Call Test Set Chapter 4 Development _exit() test set Chapter 5 Devel...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top