LTP套件使用方法詳解

   初次接觸LTP (Linux Test Project) 被LTP的各種man文件、LTP官網文檔還有網上找的七七八八的文章搞得一頭霧水,怎麼都測試不成功,不知道是我英文太爛沒理解對還是它寫的不清楚。經過反覆摸索終於成功了,現詳述如下,還望各位看客不要嫌我寫得羅嗦,希望對初次安裝使用LTP測試套的人有所幫助。



      一、下載LTP測試套


      可以從http://sourceforge.net/projects/ltp/files/LTP Source/下載最新的LTP壓縮包,如ltp-full-20110228.bz2


    下載後建議存放到/home目錄下,不要放在/root目錄下,因爲一些測試需要非root用戶來完成。


    解壓、編譯、安裝:


    1、tar jvxf ltp-full-20110228.bz2


    2、cd ltp-full-20110228.bz2


    3、./configure (此步可能不成功,則先執行make autotools,然後再./configure)


    4、make


    5、make install


    注意:ltp 的默認安裝路徑是/opt/ltp,所以接下來的執行測試步驟都需要在/opt/ltp目錄下完成(這個一定要特別注意,我當時就誤到這了,在/home目錄下折騰半天總是測試報錯


FATAL: LTP not installed correctly


INFO:  Follow directions in INSTALL!


原來不是安裝錯誤,是進錯文件夾了)



    二、執行測試


    當前有三個腳本可用於執行LTP測試套件,分別是runltp、networktests.sh以及diskio.sh。最常用的就是runltp腳本,它可用於執行LTP中絕大部分的測試(default set of tests,但是不包括networktests及diskio測試。


    執行./runltp的一些選項參數如下(借用官網):


    


    -a EMAIL_TO     EMAIL all your Reports to this E-mail Address


    -c NUM_PROCS    Run LTP under additional background CPU load


                    [NUM_PROCS = no. of processes creating the CPU Load by spinning over sqrt()


                                 (Defaults to 1 when value)]


    -C FAILCMDFILE  Command file with all failed test cases.


    -d TMPDIR       Directory where temporary files will be created.


    -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG


                    Run LTP under additional background Load on Secondary Storage (Seperate by comma)


                    [NUM_PROCS   = no. of processes creating Storage Load by spinning over write()]


                    [NUM_FILES   = Write() to these many files (Defaults to 1 when value 0 or undefined)]


                    [NUM_BYTES   = write these many bytes (defaults to 1GB, when value 0 or undefined)]


                    [CLEAN_FLAG  = unlink file to which random data written, when value 1]


    -e              Prints the date of the current LTP release


    -f CMDFILES     Execute user defined list of testcases (separate with ',')


    -g HTMLFILE     Create an additional HTML output format


    -h              Help. Prints all available options.


    -i NUM_PROCS    Run LTP under additional background Load on IO Bus


                    [NUM_PROCS   = no. of processes creating IO Bus Load by spinning over sync()]


    -l LOGFILE      Log results of test in a logfile.


    -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG


                    Run LTP under additional background Load on Main memory (Seperate by comma)


                    [NUM_PROCS   = no. of processes creating main Memory Load by spinning over malloc()]


                    [CHUNKS      = malloc these many chunks (default is 1 when value 0 or undefined)]


                    [BYTES       = malloc CHUNKS of BYTES bytes (default is 256MB when value 0 or undefined) ]


                    [HANGUP_FLAG = hang in a sleep loop after memory allocated, when value 1]


    -N              Run all the networking tests.


    -n              Run LTP with network traffic in background.


    -o OUTPUTFILE   Redirect test output to a file.


    -p              Human readable format logfiles.


    -q              Print less verbose output to screen.


    -r LTPROOT      Fully qualified path where testsuite is installed.


    -s PATTERN      Only run test cases which match PATTERN.


    -t DURATION     Execute the testsuite for given duration. Examples:


                      -t 60s = 60 seconds


                      -t 45m = 45 minutes


                      -t 24h = 24 hours


                      -t 2d  = 2 days


    -T REPETITION   Execute the testsuite for REPETITION no. of times


    -v              Print more verbose output to screen.                   


    -w CMDFILEADDR  Uses wget to get the user's list of testcases.


    -x INSTANCES    Run multiple instances of this testsuite.



    執行LTP測試的方式主要有兩種,一種是執行全部default set of tests, 另一種是執行user defined set of tests。   


1、執行default set of tests


   cd /opt/ltp (你所安裝的ltp的存放目錄,默認是/opt/ltp)


   ./runltp -p -l result.log


2、執行user defined set of tests


   如果你只是想執行LTP中的一部分test cases,你可以按照如下步驟操作:


   cd /opt/ltp/runtest


   vim your_command_file (創建命令文件,當然也可以使用runtest目錄中現有的命令文件)


   命令文件由兩部分組成,一是test case標籤“tag",另一個是你希望執行的具體的"test case"腳本名以及一些參數。比如:


   #Tag          Test case


   #---------------------------------------


   mtest01        mtest01 -p 10


   cgroup_fj      run_cgroup_test_fj.sh


   controllers    test_controllers.sh


   cpuctl_stress  run_cpuctl_stress_test.sh 9


   編輯結束後保存你的命令文件,執行


   cd .. (退出runtest目錄,回到/opt/ltp目錄)


   ./runltp -p -l result.02.log -f your_command_file



  大功告成,此時測試如果還會報錯,那就可能是你的命令文件中參數設置不正確,可根據error提示去檢查命令文件及相應的腳本文件,一些腳本文件可能需要特定的參數才能正確執行。


     









 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章