PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/usr/src/tools/tet/contrib/ctitools/src/lib/ksh/ctiutils.ksh

https://bitbucket.org/illumos/illumos-stc
Korn Shell | 820 lines | 416 code | 82 blank | 322 comment | 36 complexity | 92f2ff0d301164616d4771b726aa9aac MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception
  1. #
  2. # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
  3. # Use is subject to license terms.
  4. #
  5. # ident "%Z%%M% %I% %E% SMI"
  6. #
  7. ########################################################################
  8. #
  9. # NAME: ctiutils.ksh
  10. #
  11. # SYNOPSIS:
  12. # cti_assert assertion_number assertion_msg
  13. # cti_report arg ...
  14. # cti_pass
  15. # cti_fail [msg ...]
  16. # cti_unresolved [msg ...]
  17. # cti_untested [msg ...]
  18. # cti_unsupported [msg ...]
  19. # cti_notinuse [msg ...]
  20. # cti_pathtrace
  21. # cti_checkpath expected-path-count
  22. # cti_deleteall reason
  23. # cti_reportfile path [title]
  24. # cti_rmf [files...]
  25. # cti_writefile path mode lines...
  26. # cti_appendfile path mode lines...
  27. # cti_execute [-c out|err] [-i input] result cmd [args...]
  28. # cti_runexpect failtext command pattern action [pattern action ...]
  29. # cti_expecttest failtext command pattern action [pattern action ...]
  30. # cti_cancel test_num [msg ...] [test result]
  31. # cti_cancelall [msg ...] [test result]
  32. #
  33. # DESCRIPTION:
  34. # Common korn shell functions for tests.
  35. #
  36. # cti_report() writes an informational line to the journal.
  37. #
  38. # The functions cti_pass(), cti_fail(), cti_unresolved(),
  39. # cti_untested(), cti_unsupported() and cti_notinuse() each
  40. # registers the corresponding result code against the current test,
  41. # and write any arguments to the execution results file, as a
  42. # single line.
  43. #
  44. # The cti_pathtrace() and cti_checkpath() are used in path tracing.
  45. # cti_pathtrace() increments the variable pathok. cti_checkpath()
  46. # checks the path tracing and registers a PASS result if
  47. # appropriate.
  48. #
  49. # cti_deleteall() cancels all tests in the current test case.
  50. #
  51. # cti_reportfile() writes the contents of a file to the journal.
  52. #
  53. # cti_rmf() removes files.
  54. #
  55. # cti_writefile() writes to the contents of a file;
  56. # cti_appendfile() appends to contents of a file.
  57. #
  58. # cti_execute() executes a command.
  59. #
  60. # cti_runexpect() runs the expect utility. cti_expecttest() is
  61. # like cti_runexpect() except that it is written with path tracing
  62. # and is designed to do the complete work of a test purpose.
  63. # cti_runexpect() runs the expect utility. cti_expecttest() is
  64. # like cti_runexpect() except that it is written with path tracing
  65. # and is designed to do the complete work of a test purpose.
  66. #
  67. # cti_cancel() cancels the dedicated test purpose in the current test
  68. # case from execution with the test result that user gives. It will work
  69. # in startup function.
  70. #
  71. # cti_cancelall() cancels all tests in the current test case. It could
  72. # be used in startup function to cancel the execution of test cases
  73. # with the test result that user gives.
  74. #
  75. ########################################################################
  76. #
  77. # cti_lf_checkargs() - check number of arguments passed to a shell function.
  78. #
  79. # Usage: cti_lf_checkargs argc expected-argc operator funcname
  80. #
  81. # operator can be EQ or GE.
  82. #
  83. # Returns 0 if the expected number of arguments were passed, non-zero
  84. # otherwise.
  85. #
  86. function cti_lf_checkargs
  87. {
  88. typeset -i cti_lv_argc=$1
  89. typeset -i cti_lv_expargc=$2
  90. typeset cti_lv_op="$3"
  91. typeset cti_lv_funcname="$4"
  92. case "$cti_lv_op" in
  93. EQ)
  94. if test $cti_lv_argc -ne $cti_lv_expargc
  95. then
  96. cti_unresolved "Test coding error:" \
  97. "$cti_lv_funcname() called with $cti_lv_argc" \
  98. "args, need $cti_lv_expargc"
  99. return 1
  100. fi
  101. ;;
  102. GE)
  103. if test $cti_lv_argc -lt $cti_lv_expargc
  104. then
  105. cti_unresolved "Test coding error:" \
  106. "$cti_lv_funcname() called with $cti_lv_argc" \
  107. "args, need >= $cti_lv_expargc"
  108. return 1
  109. fi
  110. ;;
  111. *)
  112. cti_unresolved "Internal error: cti_lf_checkargs()" \
  113. "called for $funcname() with operator $cti_lv_op"
  114. return 1
  115. ;;
  116. esac
  117. return 0
  118. }
  119. #
  120. # cti_result() - register a result and write informational line to journal.
  121. #
  122. # Usage: cti_result result [msg ...]
  123. #
  124. # If the current test function is not a startup or cleanup, this routine
  125. # registers the specified result code for the current test. The remaining
  126. # arguments, if any, are written to the execution results file as a single
  127. # line.
  128. #
  129. function cti_result
  130. {
  131. test $# -eq 0 && return
  132. test -n "$tet_thistest" && tet_result $1
  133. shift
  134. my_host=`hostname`
  135. my_timestamp=`date | awk '{print $4}'`
  136. test $# -gt 0 && tet_infoline "$my_host $my_timestamp $@"
  137. }
  138. #
  139. # cti_report() - write an informational line to the journal
  140. #
  141. # Usage: cti_report arg ...
  142. #
  143. # Writes the arguments to the execution results file, as a single line.
  144. #
  145. function cti_report
  146. {
  147. my_host=`hostname`
  148. my_timestamp=`date | awk '{print $4}'`
  149. tet_infoline "$my_host $my_timestamp $@"
  150. }
  151. #
  152. # cti_assert() - write an Assert line to the journal
  153. #
  154. # Usage: cti_assert assertion_number assertion_msg
  155. #
  156. # Writes the arguments to the execution results file, as a single line.
  157. #
  158. function cti_assert
  159. {
  160. cti_lf_checkargs $# 2 GE cti_assert || return 1
  161. cti_report "ASSERT $1: $2"
  162. }
  163. #
  164. # cti_pass() - register a PASS result.
  165. #
  166. # Usage: cti_pass [msg ...]
  167. #
  168. function cti_pass
  169. {
  170. cti_result PASS "$@"
  171. }
  172. #
  173. # cti_fail() - register a FAIL result.
  174. #
  175. # Usage: cti_fail [msg ...]
  176. #
  177. # Registers a FAIL result for the current test, and writes any arguments to
  178. # the execution results file, as a single line.
  179. #
  180. function cti_fail
  181. {
  182. cti_result FAIL "$@"
  183. }
  184. #
  185. # cti_unresolved() - register an UNRESOLVED result.
  186. #
  187. # Usage: cti_unresolved [msg ...]
  188. #
  189. # Registers an UNRESOLVED result for the current test, and writes any arguments
  190. # to the execution results file, as a single line.
  191. #
  192. function cti_unresolved
  193. {
  194. cti_result UNRESOLVED "$@"
  195. }
  196. #
  197. # cti_uninitiated() - register an UNINITIATED result.
  198. #
  199. # Usage: cti_uninitiated [msg ...]
  200. #
  201. # Registers an UNINITIATED result for the current test, and writes any arguments
  202. # to the execution results file, as a single line.
  203. #
  204. function cti_uninitiated
  205. {
  206. cti_result UNINITIATED "$@"
  207. }
  208. #
  209. # cti_untested() - register an UNTESTED result.
  210. #
  211. # Usage: cti_untested [msg ...]
  212. #
  213. # Registers an UNTESTED result for the current test, and writes any arguments
  214. # to the execution results file, as a single line.
  215. #
  216. function cti_untested
  217. {
  218. cti_result UNTESTED "$@"
  219. }
  220. #
  221. # cti_unsupported() - register an UNSUPPORTED result.
  222. #
  223. # Usage: cti_unsupported [msg ...]
  224. #
  225. # Registers an UNSUPPORTED result for the current test, and writes any
  226. # arguments to the execution results file, as a single line.
  227. #
  228. function cti_unsupported
  229. {
  230. cti_result UNSUPPORTED "$@"
  231. }
  232. #
  233. # cti_notinuse() - register a NOTINUSE result.
  234. #
  235. # Usage: cti_notinuse [msg ...]
  236. #
  237. # Registers a NOTINUSE result for the current test, and writes any arguments
  238. # to the execution results file, as a single line.
  239. #
  240. function cti_notinuse
  241. {
  242. cti_result NOTINUSE "$@"
  243. }
  244. #
  245. # cti_pathtrace() - increment path counter.
  246. #
  247. # Usage: cti_pathtrace
  248. #
  249. # Increments variable pathok. Like C macro PATH_TRACE.
  250. #
  251. function cti_pathtrace
  252. {
  253. : $((pathok += 1))
  254. }
  255. #
  256. # cti_checkpath() - check path tracing and register a PASS result.
  257. #
  258. # Usage: cti_checkpath expected-path-count
  259. #
  260. # Like C macro PATH_XS_RPT().
  261. #
  262. function cti_checkpath
  263. {
  264. cti_lf_checkargs $# 1 EQ cti_checkpath || return
  265. if test $pathok -eq $1
  266. then
  267. cti_pass
  268. else
  269. cti_unresolved "Path tracing error: path counter $pathok," \
  270. "expecting $1"
  271. fi
  272. }
  273. #
  274. # cti_deleteall() - cancel all tests.
  275. #
  276. # Usage: cti_deleteall reason
  277. #
  278. # Cancels all tests, using tet_delete().
  279. #
  280. function cti_deleteall
  281. {
  282. typeset cti_lv_ic
  283. typeset cti_lv_tp
  284. test $# -eq 0 && return
  285. for cti_lv_ic in $iclist
  286. do
  287. for cti_lv_tp in `eval echo \\$$cti_lv_ic`
  288. do
  289. if test -n "$cti_lv_tp"
  290. then
  291. tet_delete "$cti_lv_tp" "$@"
  292. fi
  293. done
  294. done
  295. }
  296. #
  297. # cti_reportfile() - write the contents of a file to the journal.
  298. #
  299. # Usage: cti_reportfile path [title]
  300. #
  301. # Writes the contents of the file specified by path to the execution results
  302. # file, line by line.
  303. #
  304. function cti_reportfile
  305. {
  306. typeset cti_lv_path=$1
  307. typeset cti_lv_title="${2:-$cti_lv_path}"
  308. typeset cti_lv_line
  309. cti_lf_checkargs $# 1 GE cti_reportfile || return
  310. cti_report "+++ $cti_lv_title +++"
  311. while read cti_lv_line
  312. do
  313. cti_report "$cti_lv_line"
  314. done < $cti_lv_path
  315. cti_report "+++ end +++"
  316. cti_report " "
  317. }
  318. #
  319. # cti_rmf() - remove files.
  320. #
  321. # Usage: cti_rmf [files...]
  322. #
  323. # Calls "rm -f" to remove the files, and verifies that they have been removed.
  324. #
  325. # Returns 0 on success, non-zero if any of the files could not be removed.
  326. #
  327. function cti_rmf
  328. {
  329. typeset cti_lv_file
  330. for cti_lv_file in "$@"
  331. do
  332. rm -f "$cti_lv_file"
  333. if test -f "$cti_lv_file"
  334. then
  335. cti_unresolved "Error removing file \"$cti_lv_file\""
  336. return 1
  337. fi
  338. done
  339. return 0
  340. }
  341. #
  342. # cti_writefile() - write contents of a file.
  343. #
  344. # Usage: cti_writefile path mode lines...
  345. #
  346. # Truncates the file specified by path and then writes the third and
  347. # subsequent arguments to the specified file as separate lines.
  348. #
  349. # Returns 0 on success, non-zero if any of the files could not be removed.
  350. #
  351. function cti_writefile
  352. {
  353. cti_lf_checkargs $# 3 GE cti_writefile || return 1
  354. cti_rmf "$1" || return 1
  355. cti_appendfile "$@"
  356. }
  357. #
  358. # cti_appendfile() - append to contents of a file.
  359. #
  360. # Usage: cti_appendfile path mode lines...
  361. #
  362. # Appends the third and subsequent arguments to the specified file as separate
  363. # lines.
  364. #
  365. # Returns 0 on success, non-zero if any of the files could not be removed.
  366. #
  367. function cti_appendfile
  368. {
  369. typeset cti_lv_path="$1"
  370. typeset cti_lv_mode="$2"
  371. typeset cti_lv_line
  372. cti_lf_checkargs $# 3 GE cti_appendfile || return 1
  373. shift 2
  374. for cti_lv_line in "$@"
  375. do
  376. echo "$cti_lv_line" >> "$cti_lv_path"
  377. if [[ $? -ne 0 ]]
  378. then
  379. cti_unresolved \
  380. "Error writing to file \"$cti_lv_path\""
  381. return 1
  382. fi
  383. done
  384. cti_execute UNRESOLVED chmod "$cti_lv_mode" "$cti_lv_path"
  385. return $?
  386. }
  387. #
  388. # cti_execute() - execute a command
  389. #
  390. # Usage: cti_execute [-c out|err] [-i input] result cmd [args...]
  391. #
  392. # Executes a command. The standard output is redirected to the file cti_stdout
  393. # and the standard error is redirected to the file cti_stderr.
  394. #
  395. # If the command has a non-zero exit status, cti_execute() registers a result
  396. # code of `result'.
  397. #
  398. # Options:
  399. # -c out|err Check standard output/error. If anything is written to
  400. # the specified output channel, a result code of `result'
  401. # is registered and the output written to the journal.
  402. # May have multiple -c options.
  403. # -i input Use -i as an input line to the command.
  404. # May have multiple -i options.
  405. #
  406. # Returns 0 on success, non-zero on failure.
  407. #
  408. function cti_execute
  409. {
  410. typeset cti_lv_opt
  411. typeset -i cti_lv_checkstdout=0
  412. typeset -i cti_lv_checkstderr=0
  413. typeset cti_lv_result
  414. typeset -i cti_lv_status
  415. typeset -i cti_lv_rv=0
  416. # Remove files used for redirecting standard I/O.
  417. cti_rmf cti_stdin cti_stdout cti_stderr || return 1
  418. # Create (empty) files to take standard output and error so there are
  419. # no problems later when we come to run the command.
  420. touch cti_stdout cti_stderr
  421. if [[ $? -ne 0 ]]
  422. then
  423. cti_unresolved "Error creating files cti_stdout and cti_stderr"
  424. return 1
  425. fi
  426. # Parse command line options
  427. while getopts "c:i:l:s:" cti_lv_opt
  428. do
  429. case $cti_lv_opt in
  430. c)
  431. case "$OPTARG" in
  432. out|err)
  433. eval cti_lv_checkstd$OPTARG=1
  434. ;;
  435. *)
  436. cti_unresolved "cti_execute() called with" \
  437. "bad option argument -c $OPTARG"
  438. return 1
  439. ;;
  440. esac
  441. ;;
  442. i)
  443. echo "$OPTARG" >> cti_stdin
  444. if [[ $? -ne 0 ]]
  445. then
  446. cti_unresolved "Error writing to cti_stdin"
  447. return 1
  448. fi
  449. ;;
  450. *)
  451. cti_unresolved "cti_execute() called with illegal" \
  452. "option $cti_lv_opt"
  453. return 1
  454. ;;
  455. esac
  456. done
  457. shift $((OPTIND-1))
  458. # Verify the correct number of arguments were passed.
  459. cti_lf_checkargs $# 2 GE cti_execute || return 1
  460. # First (non-option) argument is the result code to use if the command
  461. # fails.
  462. cti_lv_result="${1:-UNRESOLVED}"
  463. shift
  464. # Execute the command, redirecting standard input if required.
  465. if test -f cti_stdin
  466. then
  467. "$@" < cti_stdin > cti_stdout 2> cti_stderr
  468. else
  469. # XXX "$@" > cti_stdout 2> cti_stderr
  470. > cti_stdout 2> cti_stderr eval "$@"
  471. fi
  472. cti_lv_status=$?
  473. # Check the exit status of the command
  474. if test $cti_lv_status -ne 0
  475. then
  476. if [[ "$cti_lv_result" = "CTI" ]]
  477. then
  478. cti_report "Command \"$*\" failed with status $cti_lv_status"
  479. else
  480. cti_result "$cti_lv_result" \
  481. "Command \"$*\" failed with status $cti_lv_status"
  482. cti_lv_rv=1
  483. fi
  484. fi
  485. if [[ "$cti_lv_result" = "CTI" ]]
  486. then
  487. if test -s cti_stdout
  488. then
  489. cti_reportfile cti_stdout "Standard output from command \"$*\""
  490. fi
  491. if test -s cti_stderr
  492. then
  493. cti_reportfile cti_stderr "Standard error from command \"$*\""
  494. fi
  495. return $cti_lv_status
  496. fi
  497. # If required, check standard error.
  498. if test \( $cti_lv_rv -ne 0 -o $cti_lv_checkstderr -eq 1 \) \
  499. -a -s cti_stderr
  500. then
  501. cti_result "$cti_lv_result" \
  502. "Command \"$*\" produced standard error"
  503. cti_reportfile cti_stderr "Standard error from command \"$*\""
  504. cti_lv_rv=1
  505. fi
  506. # If required, check standard output.
  507. if test \( $cti_lv_rv -ne 0 -o $cti_lv_checkstdout -eq 1 \) \
  508. -a -s cti_stdout
  509. then
  510. cti_result "$cti_lv_result" \
  511. "Command \"$*\" produced standard output"
  512. cti_reportfile cti_stdout "Standard output from command \"$*\""
  513. cti_lv_rv=1
  514. fi
  515. return $cti_lv_rv
  516. }
  517. #
  518. # Exit values for expect scripts.
  519. # N.B. Do not use 0, as expect uses this for e.g. syntax errors.
  520. #
  521. typeset -ri CTI_EXP_RV_TIMEDOUT=1
  522. typeset -ri CTI_EXP_RV_TESTFAIL=2
  523. typeset -ri CTI_EXP_RV_OK=3
  524. #
  525. # cti_runexpect() - run the expect utility.
  526. #
  527. # Usage: cti_runexpect failtext command pattern action [pattern action ...]
  528. #
  529. # Executes the expect utility using the command line specified in the second
  530. # argument. Generates a temporary expect script which is removed at the end of
  531. # the call. The arguments following the second are pattern-action pairs. The
  532. # pattern can be a regular expression or "CALL", which indicates the action is
  533. # simply a function call which is unconditionally executed at that point.
  534. #
  535. # The following expect functions are available:
  536. #
  537. # startcritical Indicates that failures from this point onwards
  538. # constitute a test failure. In that case the
  539. # ``failtext'' argument is used to report the error
  540. # message.
  541. # endcritical Indicates the end of the test failure section begun by
  542. # startcritical.
  543. # finish Exit the expect script here - the test has passed.
  544. #
  545. # Returns 0 on success, non-zero on failure.
  546. #
  547. function cti_runexpect
  548. {
  549. typeset -ri CTI_EXP_TIMEOUT=5
  550. typeset -r cti_lv_expfile="./cti_$tet_thistest-$$.exp"
  551. typeset cti_lv_failtext="$1"
  552. typeset cti_lv_command="$2"
  553. typeset -i cti_lv_rv=0
  554. typeset cti_lv_dopt
  555. # Verify the correct number of arguments were passed.
  556. cti_lf_checkargs $# 4 GE cti_runexpect || return 1
  557. shift 2
  558. # Generate expect script.
  559. {
  560. echo "set STATUS_OK $CTI_EXP_RV_OK"
  561. echo "set STATUS_FAIL $CTI_EXP_RV_TESTFAIL"
  562. echo "set STATUS_TIMEDOUT $CTI_EXP_RV_TIMEDOUT"
  563. echo ''
  564. echo "set timeout $CTI_EXP_TIMEOUT"
  565. echo 'set retval $STATUS_TIMEDOUT'
  566. echo ''
  567. echo 'eval spawn [lrange $argv 0 end]'
  568. echo ''
  569. echo 'proc startcritical {} {'
  570. echo ' global retval'
  571. echo ' global STATUS_FAIL'
  572. echo ' set retval $STATUS_FAIL'
  573. echo '}'
  574. echo ''
  575. echo 'proc endcritical {} {'
  576. echo ' global retval'
  577. echo ' global STATUS_TIMEDOUT'
  578. echo ' set retval $STATUS_TIMEDOUT'
  579. echo '}'
  580. echo ''
  581. echo 'proc finish {} {'
  582. echo ' global STATUS_OK'
  583. echo ' exit $STATUS_OK'
  584. echo '}'
  585. while test $# -gt 1
  586. do
  587. echo ''
  588. if test "$1" = "CALL"
  589. then
  590. echo "$2"
  591. else
  592. echo 'expect {'
  593. echo " -re \"$1\" {"
  594. echo " $2 "
  595. echo ' }'
  596. echo ' timeout {'
  597. echo ' exit $retval'
  598. echo ' }'
  599. echo '}'
  600. fi
  601. shift 2
  602. done
  603. } > $cti_lv_expfile
  604. # Check that there were no errors writing to the script file.
  605. if test $? -ne 0
  606. then
  607. cti_unresolved "Error writing expect script to file" \
  608. "\"$cti_lv_expfile\""
  609. return 1
  610. fi
  611. # If debug is on, turn on expect debug flag.
  612. case "$CTI_SHELL_DEBUG" in
  613. y*|Y*)
  614. cti_lv_dopt='-d'
  615. ;;
  616. esac
  617. # Execute expect using generated script.
  618. expect $cti_lv_dopt -f $cti_lv_expfile $cti_lv_command > cti_expout 2>&1
  619. cti_lv_rv=$?
  620. # If debug is on, save expect script and output, otherwise remove
  621. # script.
  622. case "$CTI_SHELL_DEBUG" in
  623. y*|Y*)
  624. cp cti_expout ${cti_lv_expfile%.exp}.out
  625. cti_report "DEBUG: expect script is $PWD/$cti_lv_expfile," \
  626. "expect output is in $PWD/${cti_lv_expfile%.exp}.out"
  627. ;;
  628. *)
  629. rm -f $cti_lv_expfile
  630. esac
  631. # Deal with return value from expect.
  632. case $cti_lv_rv in
  633. $CTI_EXP_RV_OK)
  634. return 0
  635. ;;
  636. $CTI_EXP_RV_TIMEDOUT)
  637. cti_unresolved "Expect script timed-out during test setup"
  638. ;;
  639. $CTI_EXP_RV_TESTFAIL)
  640. cti_fail "$cti_lv_failtext"
  641. ;;
  642. *)
  643. cti_unresolved "Test coding error or expect bug:" \
  644. "unexpected exit status $cti_lv_rv from expect script"
  645. cti_reportfile cti_expout "Output from expect"
  646. ;;
  647. esac
  648. return 1
  649. }
  650. #
  651. # cti_expecttest() - run the expect utility.
  652. #
  653. # Usage: cti_expecttest failtext command pattern action [pattern action ...]
  654. #
  655. # Common test function for test purposes which use expect. Like cti_runexpect()
  656. # except that this is written with path tracing and is designed to do the
  657. # complete work of a test purpose.
  658. #
  659. function cti_expecttest
  660. {
  661. # Verify the correct number of arguments were passed.
  662. cti_lf_checkargs $# 4 GE cti_expecttest || return
  663. # Use cti_runexpect() to execute expect utililty.
  664. if cti_runexpect "$@"
  665. then
  666. cti_pathtrace
  667. else
  668. return
  669. fi
  670. cti_checkpath 1
  671. }
  672. function cti_execute_cmd
  673. {
  674. cti_execute CTI "$@"
  675. }
  676. #
  677. # "private" functions for internal use by cti_cancel function
  678. # used to replace test purpose functions which will be canceled.
  679. #
  680. function cancel_ic {
  681. cti_result $cticancel_result "$cticancel_msg"
  682. }
  683. #
  684. # cti_cancel() - cancel an individual test purpose.
  685. #
  686. # Usage: cti_cancel tp reason [test result]
  687. #
  688. # Cancels an individual test by replace the tp function with
  689. # cancel_ic function
  690. #
  691. function cti_cancel {
  692. test $# -gt 3 && return
  693. test_num=$1
  694. cticancel_msg="$2"
  695. cticancel_result=${3:-"UNSUPPORTED"}
  696. typeset cti_lv_ic cti_lv_ic_mod
  697. typeset cti_lv_tp
  698. cti_report "Canceling test $test_num: $cticancel_msg"
  699. #
  700. # translate the ic and point the test purpose ic to
  701. # cancel_ic function
  702. #
  703. for cti_lv_ic in $iclist
  704. do
  705. cti_lv_ic_mod=""
  706. for cti_lv_tp in `eval echo \\$$cti_lv_ic`
  707. do
  708. if [ X"$cti_lv_tp" == X"$test_num" ]; then
  709. cti_lv_ic_mod=$cti_lv_ic_mod" cancel_ic"
  710. else
  711. cti_lv_ic_mod=$cti_lv_ic_mod" $cti_lv_tp"
  712. fi
  713. done
  714. eval "$cti_lv_ic=\"$cti_lv_ic_mod\""
  715. done
  716. }
  717. #
  718. # cti_cancelall() - cancel all tests.
  719. #
  720. # Usage: cti_cancelall reason [test result]
  721. #
  722. # Cancels all tests by replace the tests functions with cancel_ic function
  723. #
  724. function cti_cancelall {
  725. typeset cti_lv_ic
  726. typeset cti_lv_tp
  727. cticancel_msg=$1
  728. cticancel_result=${2:-"UNSUPPORTED"}
  729. test $# -eq 0 && return
  730. for cti_lv_ic in $iclist
  731. do
  732. for cti_lv_tp in `eval echo \\$$cti_lv_ic`
  733. do
  734. cti_cancel $cti_lv_tp "$cticancel_msg" \
  735. $cticancel_result
  736. done
  737. done
  738. }