LTP套件使用方法详解

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提示去检查命令文件及相应的脚本文件,一些脚本文件可能需要特定的参数才能正确执行。
  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值