2014年5月6日 星期二

Linux Test Project (LTP) on Android

Perform LTP on Android

Preface

LTP WiKi said, "The Linux Test Project is a joint project started by SGI, developed and maintained by IBM, Cisco, Fujitsu, SUSE, Red Hat and others, that has a goal to deliver test suites to the open source community that validate the reliability, robustness, and stability of Linux. The LTP testsuite contains a collection of tools for testing the Linux kernel and related features."

The kernel layer of Android is based on Linux. User can connect to Linux Console by Android ADB. Download the LTP from official website, it can run on Linux PC. However, it can not run on ARM platform such as Android because of its original design on X86. Therefore, if you would like to use LTP on Android, the Cross Compiler is required.

Introduction

Configuration Environment
1. Prepare a PC and install Ubuntu64 bit on it. (version 12 is applicable.)
2. Download the Cross Compiler from sourcery.mentor.com. (Newer version is applicable.)
3. Install following program on Ubuntu
  • sudo apt-get install git-core flex bison gperf libesd0-dev libwxgtk2.6-dev zlib1g-dev build-essential libstdc++5 tofrodos
  • sudo apt-get install x-dev
  • sudo apt-get install libx11-dev
  • sudo apt-get install libncurses5-dev
  • sudo apt-get install libreadline-dev
  • sudo apt-get install g++-multilib (For build kernel) 
  • Ubuntu 64bit
  • apt-get install ia32-libs ia32-libs-gtk
  • sudo dpkg-reconfigure dash  Selection 'NO‘
  • ./arm-2012.09-64-arm-none-linux-gnueabi.bin
3. Download LTP source code from sourceforge.net

4. Environment settings for Cross Compiler
  • You need to modify the file path for your own. Note that settings here is for ARM platform.
export PATH=$PATH:/home/carl/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/
export CC=/home/carl/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/arm-none-linux-gnueabi-gcc
export LD=/home/carl/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/arm-none-linux-gnueabi-ld
export AR=/home/carl/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/arm-none-linux-gnueabi-ar
export LIB_DIR=/home/carl/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/lib
export AS=/home/carl/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/arm-none-linux-gnueabi-as
export RANLIB=/home/carl/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/arm-none-linux-gnueabi-ranlib
export STRIP=/home/carl/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/arm-none-linux-gnueabi-strip

Compile and install LTP
1. Configuration
./configure AR=arm-none-linux-gnueabi-ar CC=arm-none-linux-gnueabi-gcc RANLIB=arm-none-linux-gnueabi-ranlib STRIP=arm-none-linux-gnueabi-strip --host=arm-linux --target=arm-linux CFLAGS="-static" LDFLAGS="-static -pthread“
2. Some values of parameter should be changed for ARM platform. Here I illustrate what should be changed by the version in 2012. (The version of 2013 is applicable)
  • Find and edit the file ltp-full-20120104/testcases/kernel/controllers/libcontrollers/libcontrollers.h and add one line for LINE_MAX and define its value as 255.
  • Change the varialbe name of array in random-access.c, random-del-create.c and random-access-del-create.c which files are located at ltp-full-20120104/testcases/kernel/fs/fs-bench/
  • Find and edit the files named ltp-full-20120104/testcases/kernel/sched/sched_stress/sched_driver.c and ltp-full-20120104/testcases/kernel/fs/ftest/libftest.c and add one line for PATH_MAX and define its value as1024.
  • Find and edit the file ltp-full-20120104/testcases/kernel/sched/cfs-scheduler/hackbench.c and add one line for PTHREAD_STACK_MIN and define its value as 1024.
  • make
  • make install prefix=/[Install Folder]
3. After the install, there are some files in your Install Folder and the total file size is about 1GByte. It takes long time to perform compiling work.


Deploy LTP into your Android device

1. Download Busybox and push it to your Android in order to have necessary shell command on Android. adb push busybox /data/local/tmp
2. Push all the installed LTP folder (Install Folder) to Android. I always push the files to /data/local/tmp.
3. Ln all the command from busybox. Following examples only shows you some pieces, you need to ln all the commands that busybox have.
  • busybox ln -f busybox readlink
  • busybox ln -f busybox basename
  • busybox ln -f busybox mktemp
  • busybox ln -f busybox dirname
  • busybox ln -f busybox grep
  • busybox ln -f busybox sed
  • busybox ln -f busybox awk
  • busybox ln -f busybox head
  • busybox ln -f busybox free
  • busybox ln -f busybox uname

4. Setting the LTP variable environment in Adroid. You need to change the path to where your file located in Android.
  • export PATH=/data/local/tmp/busyboxdir:$PATH
  • export PATH=/data/local/tmp/LTP13:$PATH
  • export PATH=/data/local/tmp/LTP13/testcases/bin:$PATH
  • export PATH=/data/local/tmp/LTP13/runtest:$PATH
Run LTP on Android
sh ./runltp -p -l 130326report1ipc.log -o 130326output1ipc.log  -d /data/local/tmp/LTP13/tmp -f ipc


Reference

Internet Q&A

Keyword: LTP, Android, Linux Test Project, Stress Test, Android Reliability, Automation Test. Share to Line

2 則留言:

  1. Hi, How about the tests which fails on android platform and pass on normal linux kernel. I've tried running on android and observed lot of tests are failing due to environment and also the APIs which are exposing by bionic libc. Do you fix them locally? If yes, can i get the patches for the same to try?

    Thanks in advance.

    回覆刪除
  2. I tried to fix some failure on Android platform. Most of failures belong to the path of folder. You're free to change the path of folder in script, then you can get a lot of pass on it.

    回覆刪除