文件操作 - xmltest
返回文件管理
返回主菜单
删除本文件
文件: /usr/bin/xmltest
编辑文件内容
#!/bin/sh # ============================================================================ # xmltest # # (C) Copyright IBM Corp. 2005 # # THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE # ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE # CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT. # # You can obtain a current copy of the Eclipse Public License from # http://www.opensource.org/licenses/eclipse-1.0.php # # Author: Dr. Gareth S. Bestor, <bestorga@us.ibm.com> # Contributors: Adrian Schuur, <schuur@de.ibm.com> # Description: # Simple test program to send CIM-XML test request files to a CIMOM and # compare the returned results to an expected response file. # If test file is specified then run only that test. If test directory is # specified then run all tests in the directory in sorted order. If no test # file or directory specified then run all tests in the current directory. # ============================================================================ _RC=0 # Check for wbemcat utility if ! which wbemcat > /dev/null; then echo "Cannot find wbemcat. Please check your PATH" exit 1 fi # ---------------------------------------------------------------------------- function _runxmltest { typeset _TESTXML=$1 _TEST=${_TESTXML%.xml} _TESTDIR=$( dirname $_TEST) _TESTOK=$_TEST.OK _TESTRESULT=$_TEST.result echo -n "Running test $_TESTXML ... " # Make sure we will be able to write the result file if [[ ! -w $_TESTDIR ]]; then echo "FAILED"; echo -e "\tCannot write to $_TESTDIR" continue fi # Remove any old test result file rm -f $_TESTRESULT # Send the test CIM-XML to the CIMOM and save the response, # stripping off the http header wbemcat $_TESTXML | awk '/<\?xml.*/{xml=1} {if (xml) print}' > $_TESTRESULT if [[ $? -ne 0 ]]; then echo "FAILED"; echo -e "\twbemcat failed to send CIM-XML request" _RC=1 continue fi # If we dont yet have the expected result file, then save this response # as the (new) expected result if [[ ! -f $_TESTOK ]]; then echo "OK"; echo -e "\tSaving response as $_TESTOK" mv $_TESTRESULT $_TESTOK # Compare the response XML against the expected XML for differences elif ! diff --brief $_TESTOK $_TESTRESULT > /dev/null; then echo "FAILED"; echo -e "\tCheck $_TESTRESULT for errors" _RC=1; continue # We got the expected response XML else echo "Passed" rm -f $_TESTRESULT fi } # ---------------------------------------------------------------------------- if [[ -f $1 ]]; then _runxmltest $1 else if [[ -d $1 ]]; then _DIR=$1 else _DIR=./ fi # Look for all *.xml test files and run them in sorted order, # hence tests should be numbered find $_DIR -name "*.xml" | sort | while read _TESTXML; do _runxmltest $_TESTXML # Wait for the dust to settle before trying the next test... sleep 1 done fi exit $_RC
修改文件时间
将文件时间修改为当前时间的前一年
删除文件