vcs之urg脚本详解--转载

vcs中,可以使用urg命令生成覆盖率报告,其实urg命令本身是一个sh脚本,本文对该脚本进行分析。
vcs版本:2016.06

    ###############################################
    # env check & setting about VCS_HOME
    ###############################################
    #set mode flag linux -> 32, mode64 -> 64; filter "-mode64"
    URG_MODE_FLAG=32
    URG_MODE_STR=""
    if [ `${ECHO} ${URG_ARGS} | ${EGREP} -c '(^| )\-mode64'` = 1 ]; then
        URG_MODE_FLAG=64;
        URG_MODE_STR="-mode64"
    elif [ `${ECHO} ${URG_ARGS} | ${EGREP} -c '(^| )\-full64'` = 1 ]; then
        URG_MODE_FLAG=64;
        URG_MODE_STR="-full64"
    fi

分析:选择32位还是64位程序运行,默认32位。

    # check whether the given vdb directories contain .mode64 file
    isAutoAppendFull64=0;
    if [ "${URG_MODE_STR}"x = "x" ]; then
        isDir=0;
        for arg in ${URG_ARGS_ARRAY}; do
            if [ `${ECHO} $arg | ${EGREP} -c '^-dir$'` = 1 ]; then
                isDir=1;
            elif [ `${ECHO} $arg | ${EGREP} -c '^-'` = 1 ]; then
                isDir=0;
            else
                if [ $isDir = 1 ]; then
                    if [ -f $arg"/.mode64" ]; then
                        # if any vdb directory contains .mode64 file
                        if [ `${VCS_HOME}/bin/vcs -location -full64 | ${EGREP} -c '^Error-\[CF_SIM_KRNL64\]'` = 0 ]; then
                            # if vcs version is 64bit, add -full64 by default
                            URG_MODE_FLAG=64;
                            URG_MODE_STR="-full64"
                            isAutoAppendFull64=1;
                            if [ ` env | ${EGREP} -c '^VCS_RUNNING_REGRESSION'` = 0 ]; then
                                ${ECHO}
                                ${ECHO} "INFO : The directory  '$arg' passed to the URG command line is generated from a 64-bit simulation kernel. Hence, '-full64' is automatically added to the URG command line and URG would generate the reports with Full64 VCS installation."
                                ${ECHO}
                            fi
                        else
                            if [ ` env | ${EGREP} -c '^VCS_RUNNING_REGRESSION'` = 0 ]; then
                                ${ECHO}
                                ${ECHO} "INFO : The directory '$arg' passed to the URG command line is generated from a 64-bit simulation kernel. Hence, it is advised to install Full64 VCS, pass '-full64' to the URG command line and generate the reports. Currently, URG would generate the reports with 32-bit VCS installation."
                                ${ECHO}
                            fi
                        fi
                        break;
                    fi
                fi
            fi
        done
    fi

分析:vcs会读取你的-dir参数,然后判断vdb目录下是否存在.mode64文件。如果存在且你的vcs支持64bit,它会自己给你加上-full64参数,并将标记isAutoAppendFull64置1,如果你的vcs不支持64bit,那么它就会提醒你安装64bit的版本。

    # set correct home(BASE_STRING), reuse vcs script, do not re-check in urg script
    if [ "X$VCS_HOME" != "X" ]; then
        BASE_STRING=`${VCS_HOME}/bin/vcs -location ${URG_MODE_STR}`
    elif [ "X$PIONEER_HOME" != "X" ]; then
        VCS_HOME=${PIONEER_HOME}
        export VCS_HOME
        BASE_STRING=`${PIONEER_HOME}/bin/vcs -location ${URG_MODE_STR}`
    else
        ${ECHO} " Please make sure VCS_HOME is set correctly and continue.. ";
        exit 1;
    fi
    if [ `${ECHO} ${BASE_STRING} | ${EGREP} -c '(^| )Error\-'` = 1 ]; then #VCSMSG_EXCLUDE
        ${ECHO} "$BASE_STRING"
        ${ECHO} " Please make sure VCS_HOME is set correctly and continue.. ";
        exit 1;
    fi

分析:没啥好说的,重新设置vcs命令路径(可以将32bit的vcs改成64bit的)。

    # use vcs error message report
    if [ -f ${BASE_STRING}/bin/vcsMsgReport ]; then #VCSMSG_EXCLUDE
        ERR_MSG_REPORT=${BASE_STRING}/bin/vcsMsgReport; #VCSMSG_EXCLUDE
    else
        ${ECHO} " ERROR : Cannot find 'vcsMsgReport' script in $BASE_STRING/bin " ; #VCSMSG_EXCLUDE
        ${ECHO} " Please make sure VCS_HOME is set correctly and continue.. ";
        exit 1;
    fi

分析:该脚本会调用vcsMsgReport脚本,所以要确认下vcsMsgReport是否存在。

    # no longer support 64_32 mode
    if [ "$URG_MODE_FLAG"x = "64_32x" ]; then
        $ERR_MSG_REPORT "URG-S-MNS"
        exit 1;
    fi

分析:不再支持64_32x模式,这TM是个什么模式。

  ###############################################
    # env check & setting about URG
    ###############################################
    # check for bin directory
    binpath="${BASE_STRING}/${BIN}";
    if [ ! -d ${BASE_STRING}/${BIN} ]; then
        $ERR_MSG_REPORT "URG-S-DE" "$binpath"
        exit 1
    fi
     
    # check for urg1
    CMD="${binpath}";
    if [ ! -f ${BASE_STRING}/${BIN}/urg1 ]; then
        $ERR_MSG_REPORT "URG-NF" "urg1" "VCS installation"
        exit 1;
    elif [ ! -x ${BASE_STRING}/${BIN}/urg1 ]; then
        $ERR_MSG_REPORT "URG-PERM" "urg1" "$CMD"
    fi

分析:检查bin目录和urg1(实际使用到的urg)是否存在。

  PrintID() 
    {
    	m=`uname -n`;
    	if [ "$URG_ARCH" = "AIX" ]; then
    		o=`uname -s -v`.$URG_RNAME;
    	else
    		o=`uname -s -r`;
    	fi
    	echo "machine name = $m "
    	echo "machine os = $o "
    	exec ${binpath}/urg1 -ID
    	
    	exit 0;
    }

分析:打印主机的信息。

 Run() 
    {
        # if it contains -parallel , swtich to hierarchicalMerge 
        if [ `${ECHO} ${URG_ARGS} | ${EGREP} -c -i '(^| )\-parallel($| )'` = 1  ]; then
            PARALLEL_MODE=1;
        else
            if [ `${ECHO} ${URG_ARGS} | ${EGREP} -c -i '(^| )\-readucis($| )'` = 1  ]; then
                $ERR_MSG_REPORT URG-CVOP -readucis
            else
                exec $URG_DIAGTOOL $CMD/urg1 $URG_ARGS
            fi
        fi 
    }

分析:如果urg参数含有-parallel(并行merge覆盖率)时,将标志PARALLEL_MODE置位。如果出现-readucis参数,报错。猜测这是urg早期的一个参数,现在不再支持。如果不进行并行merge,那么直接调用urg1命令,urg1的参数和urg是一样的,但是urg1不是脚本,而是一个可执行文件。

   EXEC()
    {
        #Invoking actual executable .. with all the options supplied.
     
        #set LD_LIBRARY_PATH
        if [ -x ${BASE_STRING}/lib ]; then
    #        ${ECHO} "$BASE_STRING/lib"
    	case $URG_ARCH in
    	        HP-UX)
        		SHLIB_PATH=$BASE_STRING/lib:$SHLIB_PATH
    	    	export SHLIB_PATH
        		;;
    	        AIX)
        		LIBPATH=$BASE_STRING/lib:$LIBPATH
    	    	export LIBPATH
        		;;
    	        *)
        		LD_LIBRARY_PATH=$BASE_STRING/lib:$LD_LIBRARY_PATH
    	    	export LD_LIBRARY_PATH
        		;;
        	esac
        fi
     
        #Run urg -id, then exit    
        if [ `${ECHO} ${URG_ARGS} | ${EGREP} -c -i '(^| )\-id'` = 1 ]; then
            URG_ARGS=`echo ${URG_ARGS} | sed -e 's/\-[Ii][Dd]//g'`;
            PrintID;
            exit 1;
        fi
     
        #Run normal case
        Run
    }

分析:设置LD_LIBRARY_PATH。如果命令中含有-id,执行PrintID子程序。

EXEC

分析:主程序

  if [ $PARALLEL_MODE = 1 ]; then
    #
    # Note we get hierarchicalMerge from the same directory as the urg script,
    # NOT from the '$CMD' directory
    #
        hierMergeDir=`dirname ${0}`
        hierMergeCMD="$hierMergeDir/hierarchicalMerge"
     
        if [ -x $hierMergeCMD ]; then
              perlVersion=`perl -v | sed -n '/[p|P]erl\ 4/'p | wc -l`
              if [ $perlVersion = 1 ]; then
    	  	$ERR_MSG_REPORT "URG-S-PVE"
    		exit 1;
              else
                  if [ $isAutoAppendFull64 = 1 ]; then
                      exec $hierMergeCMD "$@" "-full64"
                  else
                      exec $hierMergeCMD "$@"
                  fi
              fi
        else
              if [ -f $hierMergeCMD ]; then
    	  	$ERR_MSG_REPORT "URG-PERM" "hierarchicalMerge" "$hierMergeCMD"
              else
    	  	$ERR_MSG_REPORT "URG-NF" "hierarchicalMerge" "$hierMergeCMD"
              fi
     
    	  exit 1;
        fi
     
    fi 

分析:按照这种写法风格,很明显-parallel参数在vcs早期的版本是不支持的,是后来才加上去的。主要还是调用hierarchicalMerge脚本来进行覆盖率并行merge。而且,还要求perl的版本不能是perl 4。并行merge的脚本参数和urg参数是一致的。

 # Normal exit
    exit 0;

分析:正常退出。

  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
vcs错误v-16-1-10600表示在使用该版本控制系统时遇到了一个问题。具体错误信息可能因情况而异,错误代码v-16-1-10600只是标识问题的一种方式。这个错误代码通常与VCS的配置或运行环境有关。 要解决这个问题,可以尝试以下几种方法: 1. 检查VCS的配置:首先确保VCS的配置正确,包括仓库路径、用户名和密码等。检查VCS的配置文件,确保没有错误或缺漏。 2. 检查网络连接:确保电脑或服务器的网络连接正常,可以尝试通过Ping命令测试网络连接是否畅通。如果网络连接有问题,可能会导致VCS无法正常工作。 3. 检查文件权限:如果VCS操作的文件或目录没有足够的权限,可能会出现VCS错误。确保VCS所需的文件和目录具有正确的读写权限。 4. 升级或重新安装VCS:如果以上方法无效,可以尝试升级或重新安装VCS。有时候旧版本的VCS可能会有错误或兼容性问题,升级到最新版本或重新安装可以解决一些问题。 5. 咨询技术支持:如果以上方法仍无法解决问题,可以联系VCS的技术支持团队,向他们求助。他们可能会提供更具体的解决方案或帮助您诊断问题。 综上所述,vcs错误v-16-1-10600通常与VCS的配置或运行环境有关,通过检查配置、网络连接、文件权限,升级或重新安装VCS等方法,可以尝试解决这个问题。如遇到更严重的情况,建议咨询技术支持团队以获得更专业的解决方案。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值