• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    TCL/EXPECT自動化測試腳本實例二 --- 主程序

    發布: 2009-6-24 10:17 | 作者: 不詳 | 來源: 領測軟件測試網采編 | 查看: 270次 | 進入軟件測試論壇討論

    領測軟件測試網 這里介紹了測試主程序,主程序采用一種靈活的機制,方便增加新的測試項目,也可以執行一系列命令,或者執行指定的腳本程序。

        現在介紹一下測試主程序: test.exp。
        為了方便加入新的測試項目,主程序采用了一種靈活的機制,它根據需要通過source命令調用相應的子測試程序。這樣一來,每個測試點都可以單獨放到一個文件中,然后被主程序引用。
    先看一下代碼:

    #! /usr/bin/expect --

    # $Id$
    # Usage:
    #    ./test [-uuser] [-ppassward] [-iip_address]  test_001 ...
    # or ./test [-uuser] [-ppassward] [-iip_address] [-ccommand_file] cmd
    # or ./test [-uuser] [-ppassward] [-iip_address] [-sscript_file] script

    source global.exp
    source commonLib.exp

    # initialize variables
    set cmdFile ""
    set tList $argv
    set execScript ""

    # process options
    set endOptIndex -1
    foreach arg $argv {
        if {![string match "-\[a-zA-Z]*" $arg]} {
            break
        }

        # inc end option index
        incr endOptIndex

        # get option flag and option value
        set optFlg [string range $arg 1 1]
        set optVal [string range $arg 2 end]
        dbgLog "$optFlg $optVal"
        if {$optVal == ""} {
            dbgLog "option value is null: -$optFlg"
            return -1
        }

        switch $optFlg {
            "u" {
                set g_user $optVal
                dbgLog "user: $g_user"
            }
            "p" {
                set g_passwd $optVal
                dbgLog "password: $g_passwd"
            }
            "i" {
                set g_devip $optVal
                dbgLog "devip: $g_devip"
            }
            "c" {
                set cmdFile $optVal
                dbgLog "cmdFile: $cmdFile"
            }
            "s" {
                set execScript $optVal
                dbgLog "execScript: $execScript"
            }
            default {
                puts "unknown option: -$optFlg"
                return -1
            }
        } ;# end switch
    } ;# end foreach

    # remove options from list
    if {$endOptIndex != -1} {
        set tList [lreplace $argv 0 $endOptIndex]
    }

    dbgLog "tList is: $tList"

    # create log dir
    if { ![file exist "log"] || ![file isdirectory "log"] } {
        puts "please create directory \"log\""
        return -1
    }

    # read current time
    set clicks [clock clicks]
    set tstr [clock format $clicks -format "%y%m%d%I%M%S"]

    延伸閱讀

    文章來源于領測軟件測試網 http://www.kjueaiud.com/

    TAG: EXPECT TCL 實例 自動化 主程序

    21/212>

    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備2023014753號-2
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>