14470957eSSivas SRR#!/bin/bash
24470957eSSivas SRR
3917ba1a2SGunnar Mills# This program will generate test documentation from the robot test cases.
44470957eSSivas SRR
54470957eSSivas SRR# Description of argument(s):
64470957eSSivas SRR# test_dir_path            Test directory where robot test cases are available.
74470957eSSivas SRR# test_case_doc_file_path  The test case document file path to be stored.
84470957eSSivas SRR
94470957eSSivas SRR
104470957eSSivas SRRfunction get_parms {
114470957eSSivas SRR
124470957eSSivas SRR  # Get program parms.
134470957eSSivas SRR
144470957eSSivas SRR  test_dir_path="${1}" ; shift
154470957eSSivas SRR  test_case_doc_file_path="${1}" ; shift
164470957eSSivas SRR
174470957eSSivas SRR  return 0
184470957eSSivas SRR
194470957eSSivas SRR}
204470957eSSivas SRR
214470957eSSivas SRR
224470957eSSivas SRRfunction validate_parms {
234470957eSSivas SRR
244470957eSSivas SRR  # Validate program parameters.
254470957eSSivas SRR
264470957eSSivas SRR  num_parms="${1}" ; shift
274470957eSSivas SRR
284470957eSSivas SRR  (( ${num_parms} == 0 )) && return 0
294470957eSSivas SRR
304470957eSSivas SRR  if [ -z "${test_dir_path}" ] ; then
314470957eSSivas SRR    echo "**ERROR** You must provide test directory as the first positional" \
324470957eSSivas SRR         "parameter." >&2
334470957eSSivas SRR    return 1
344470957eSSivas SRR  fi
354470957eSSivas SRR
364470957eSSivas SRR  if [ -z "${test_case_doc_file_path}" ] ; then
374470957eSSivas SRR    echo "**ERROR** You must provide file path as the second positional" \
384470957eSSivas SRR         "parameter." >&2
394470957eSSivas SRR    return 1
404470957eSSivas SRR  fi
414470957eSSivas SRR
424470957eSSivas SRR  return 0
434470957eSSivas SRR
444470957eSSivas SRR}
454470957eSSivas SRR
464470957eSSivas SRR
474470957eSSivas SRRfunction generate_all_test_document {
484470957eSSivas SRR
494470957eSSivas SRR  # Generate all test case documents
504470957eSSivas SRR
514470957eSSivas SRR  local ret_code=0
524470957eSSivas SRR  python -m robot.testdoc tests testsdirectoryTCdocs.html || ret_code=1
534470957eSSivas SRR  python -m robot.testdoc extended extendeddirectoryTCdocs.html || ret_code=1
544470957eSSivas SRR  python -m robot.testdoc gui guidirectoryTCdocs.html || ret_code=1
554470957eSSivas SRR  python -m robot.testdoc systest systestdirectoryTCdocs.html || ret_code=1
569bd2f839SSivas SRR  python -m robot.testdoc xcat xcatdirectoryTCdocs.html || ret_code=1
579bd2f839SSivas SRR  python -m robot.testdoc mnfg mnfgdirectoryTCdocs.html || ret_code=1
58b35dd6a6SSivas SRR  python -m robot.testdoc tools toolsdirectoryTCdocs.html || ret_code=1
59*dd9bcf42SSivas SRR  python -m robot.testdoc ./openpower/ras rasdirectoryTCdocs.html || ret_code=1
60*dd9bcf42SSivas SRR  python -m robot.testdoc ./openpower/secureboot securebootdirectoryTCdocs.html\
61*dd9bcf42SSivas SRR  || ret_code=1
624df94a20SSivas SRR  python -m robot.testdoc network networkdirectoryTCdocs.html ||\
634df94a20SSivas SRR  ret_code=1
644470957eSSivas SRR
654470957eSSivas SRR  return ${ret_code}
664470957eSSivas SRR}
674470957eSSivas SRR
684470957eSSivas SRR
694470957eSSivas SRRfunction main_function {
704470957eSSivas SRR
714470957eSSivas SRR  get_parms "$@" || return 1
724470957eSSivas SRR
734470957eSSivas SRR  validate_parms $# || return 1
744470957eSSivas SRR
754470957eSSivas SRR  if (( ${num_parms} == 0 )) ; then
764470957eSSivas SRR    generate_all_test_document || return 1
774470957eSSivas SRR    return 0
784470957eSSivas SRR  fi
794470957eSSivas SRR
804470957eSSivas SRR  echo ${test_dir_path} ${test_case_doc_file_path}
814470957eSSivas SRR  python -m robot.testdoc ${test_dir_path} ${test_case_doc_file_path}\
824470957eSSivas SRR    || return 1
834470957eSSivas SRR
844470957eSSivas SRR  return 0
854470957eSSivas SRR
864470957eSSivas SRR}
874470957eSSivas SRR
884470957eSSivas SRR
894470957eSSivas SRR# Main
904470957eSSivas SRR
914470957eSSivas SRR  main_function "${@}"
924470957eSSivas SRR  rc="${?}"
934470957eSSivas SRR  exit "${rc}"
944470957eSSivas SRR
95