2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-31 10:06:39 +00:00

[xCAT Jenkins Email Report] Change all the read' to read -r' in bash script

This commit is contained in:
GONG Jie 2016-06-30 17:40:04 +08:00
parent 329e64700e
commit aae45825c0
7 changed files with 32 additions and 32 deletions

View File

@ -201,7 +201,7 @@ function Email_setSubject()
while :
do
read -n 1
read -r -n 1
[[ -z "${REPLY}" || "${REPLY}" =~ [\x00-\x7f\xc0-\xff] ]] &&
(( ${#w} + ${#c} > limit )) &&
declare -g ${mailSubject}+="$(echo -n "${w}" |
@ -243,7 +243,7 @@ function Email_addAttachment()
# 76 is a magic number, see RFC 2045
while read -n 76
while read -r -n 76
do
inMessage+="${REPLY}"
inMessage+=$'\n'

View File

@ -78,7 +78,7 @@ LatestDailyReport="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Title, Arch, OS, Durati
oIFS="${IFS}"
IFS="|"
color=""
while read n title arch os duration passed failed no_run subtotal pass_rate n
while read -r n title arch os duration passed failed no_run subtotal pass_rate n
do
[ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0"
echo "<tr style=\"background-color: ${color}; vertical-align: baseline;\" title=\"${title}\">"
@ -97,7 +97,7 @@ IFS="${oIFS}"
LatestDailyReportSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(Duration))) AS Duration, SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM LatestDailyReport;")"
oIFS="${IFS}"
IFS="|"
read n duration passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${LatestDailyReportSummary}" | sed -e '1d' -e 's/ *| */|/g')
read -r n duration passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${LatestDailyReportSummary}" | sed -e '1d' -e 's/ *| */|/g')
echo "<tr style=\"background-color: #cccccc; vertical-align: baseline;\">"
echo "<th style=\"border-color: #666666; border-style: solid; border-width: 1px; padding: 2px 3px;\">Total</th>"
echo "<td style=\"border-color: #666666; border-style: solid; border-width: 1px; padding: 2px 3px;\">-</td>"
@ -124,7 +124,7 @@ FailedTestCasesReport="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Title, Arch, OS, \`
oIFS="${IFS}"
IFS="|"
color=""
while read n title arch os failed_test_cases n
while read -r n title arch os failed_test_cases n
do
[ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0"
[ "${color}" = "#e0e0e0" ] && color2="#f0f0f0" || color2="#d0e8ff"
@ -153,7 +153,7 @@ SevenDayLookBack="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Arch, OS, \`Test runs\`,
oIFS="${IFS}"
IFS="|"
color=""
while read n arch os test_runs passed failed no_run subtotal pass_rate n
while read -r n arch os test_runs passed failed no_run subtotal pass_rate n
do
[ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0"
echo "<tr style=\"background-color: ${color}; vertical-align: baseline;\" title=\"${title}\">"
@ -172,7 +172,7 @@ IFS="${oIFS}"
SevenDayLookBackSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SUM(\`Test runs\`), SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM SevenDayLookBack;")"
oIFS="${IFS}"
IFS="|"
read n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${SevenDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g')
read -r n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${SevenDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g')
echo "<tr style=\"background-color: #cccccc; vertical-align: baseline;\">"
echo "<th style=\"border-color: #666666; border-style: solid; border-width: 1px; padding: 2px 3px;\">Total</th>"
echo "<td style=\"border-color: #666666; border-style: solid; border-width: 1px; padding: 2px 3px;\">-</td>"
@ -203,7 +203,7 @@ ThirtyDayLookBack="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Arch, OS, \`Test runs\`
oIFS="${IFS}"
IFS="|"
color=""
while read n arch os test_runs passed failed no_run subtotal pass_rate n
while read -r n arch os test_runs passed failed no_run subtotal pass_rate n
do
[ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0"
echo "<tr style=\"background-color: ${color}; vertical-align: baseline;\" title=\"${title}\">"
@ -222,7 +222,7 @@ IFS="${oIFS}"
ThirtyDayLookBackSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SUM(\`Test runs\`), SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM ThirtyDayLookBack;")"
oIFS="${IFS}"
IFS="|"
read n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${ThirtyDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g')
read -r n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${ThirtyDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g')
echo "<tr style=\"background-color: #cccccc; vertical-align: baseline;\">"
echo "<th style=\"border-color: #666666; border-style: solid; border-width: 1px; padding: 2px 3px;\">Total</th>"
echo "<td style=\"border-color: #666666; border-style: solid; border-width: 1px; padding: 2px 3px;\">-</td>"
@ -253,7 +253,7 @@ NinetyDayLookBack="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Arch, OS, \`Test runs\`
oIFS="${IFS}"
IFS="|"
color=""
while read n arch os test_runs passed failed no_run subtotal pass_rate n
while read -r n arch os test_runs passed failed no_run subtotal pass_rate n
do
[ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0"
echo "<tr style=\"background-color: ${color}; vertical-align: baseline;\" title=\"${title}\">"
@ -272,7 +272,7 @@ IFS="${oIFS}"
NinetyDayLookBackSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SUM(\`Test runs\`), SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM NinetyDayLookBack;")"
oIFS="${IFS}"
IFS="|"
read n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${NinetyDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g')
read -r n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${NinetyDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g')
echo "<tr style=\"background-color: #cccccc; vertical-align: baseline;\">"
echo "<th style=\"border-color: #666666; border-style: solid; border-width: 1px; padding: 2px 3px;\">Total</th>"
echo "<td style=\"border-color: #666666; border-style: solid; border-width: 1px; padding: 2px 3px;\">-</td>"
@ -302,7 +302,7 @@ Top50FailedTestCases="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT @rank := @rank + 1 A
oIFS="${IFS}"
IFS="|"
color=""
while read n rank test_case arch os last_seven_days last_thirty_days last_ninety_days n
while read -r n rank test_case arch os last_seven_days last_thirty_days last_ninety_days n
do
[ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0"
[ "${color}" = "#e0e0e0" ] && color2="#f0f0f0" || color2="#d0e8ff"

View File

@ -338,7 +338,7 @@ SET character_set_client = @saved_cs_client;
/*!50001 SET collation_connection = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `FailedTestCasesTopList` AS select `TestCase`.`TestCaseName` AS `Test case`,`ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,ifnull(`SevenDayFailed`.`Failed`,0) AS `Last seven days`,ifnull(`ThirtyDayFailed`.`Failed`,0) AS `Last thirty days`,`NinetyDayFailed`.`Failed` AS `Last ninety days` from (((((`NinetyDayFailed` left join `SevenDayFailed` on(((`NinetyDayFailed`.`TestCaseId` = `SevenDayFailed`.`TestCaseId`) and (`NinetyDayFailed`.`ArchId` = `SevenDayFailed`.`ArchId`) and (`NinetyDayFailed`.`OSId` = `SevenDayFailed`.`OSId`)))) left join `ThirtyDayFailed` on(((`NinetyDayFailed`.`TestCaseId` = `ThirtyDayFailed`.`TestCaseId`) and (`NinetyDayFailed`.`ArchId` = `ThirtyDayFailed`.`ArchId`) and (`NinetyDayFailed`.`OSId` = `ThirtyDayFailed`.`OSId`)))) left join `TestCase` on((`NinetyDayFailed`.`TestCaseId` = `TestCase`.`TestCaseId`))) left join `ArchDict` on((`NinetyDayFailed`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`NinetyDayFailed`.`OSId` = `OSDict`.`OSId`))) order by ifnull(`SevenDayFailed`.`Failed`,0) desc,ifnull(`ThirtyDayFailed`.`Failed`,0) desc,`NinetyDayFailed`.`Failed` desc,`NinetyDayFailed`.`OSId` desc,`NinetyDayFailed`.`ArchId` desc, `TestCase`.`TestCaseName` */;
/*!50001 VIEW `FailedTestCasesTopList` AS select `TestCase`.`TestCaseName` AS `Test case`,`ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,ifnull(`SevenDayFailed`.`Failed`,0) AS `Last seven days`,ifnull(`ThirtyDayFailed`.`Failed`,0) AS `Last thirty days`,`NinetyDayFailed`.`Failed` AS `Last ninety days` from (((((`NinetyDayFailed` left join `SevenDayFailed` on(((`NinetyDayFailed`.`TestCaseId` = `SevenDayFailed`.`TestCaseId`) and (`NinetyDayFailed`.`ArchId` = `SevenDayFailed`.`ArchId`) and (`NinetyDayFailed`.`OSId` = `SevenDayFailed`.`OSId`)))) left join `ThirtyDayFailed` on(((`NinetyDayFailed`.`TestCaseId` = `ThirtyDayFailed`.`TestCaseId`) and (`NinetyDayFailed`.`ArchId` = `ThirtyDayFailed`.`ArchId`) and (`NinetyDayFailed`.`OSId` = `ThirtyDayFailed`.`OSId`)))) left join `TestCase` on((`NinetyDayFailed`.`TestCaseId` = `TestCase`.`TestCaseId`))) left join `ArchDict` on((`NinetyDayFailed`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`NinetyDayFailed`.`OSId` = `OSDict`.`OSId`))) order by ifnull(`SevenDayFailed`.`Failed`,0) desc,ifnull(`ThirtyDayFailed`.`Failed`,0) desc,`NinetyDayFailed`.`Failed` desc,`OSName`,`ArchName`,`TestCase`.`TestCaseName` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;

View File

@ -4,7 +4,7 @@ function usage()
{
local script="${0##*/}"
while read ; do echo "${REPLY}" ; done <<-EOF
while read -r ; do echo "${REPLY}" ; done <<-EOF
Usage: ${script} [OPTIONS] DIRECTORY
Options:
@ -194,7 +194,7 @@ function xcattestlog2sql()
[ -n "${test_run_name}" ]
warn_if_bad "$?" "test run has no name" || return 1
while read ; do echo "${REPLY}" ; done <<-EOF
while read -r ; do echo "${REPLY}" ; done <<-EOF
--
-- Test run has name '${test_run_name}'
--
@ -204,16 +204,16 @@ function xcattestlog2sql()
[ -f "${logfile}" ]
warn_if_bad "$?" "${logfile}: No such log file" || return 1
while read ; do echo "${REPLY}" ; done <<-EOF
while read -r ; do echo "${REPLY}" ; done <<-EOF
--
-- Analysis file '${logfile}'
--
EOF
while read test_case_name test_case_result duration
while read -r test_case_name test_case_result duration
do
while read ; do echo "${REPLY}" ; done <<-EOF
while read -r ; do echo "${REPLY}" ; done <<-EOF
INSERT INTO TestCase (TestCaseId, TestCaseName)
SELECT * FROM (SELECT NULL, '${test_case_name}') AS tmp
WHERE NOT EXISTS (
@ -259,7 +259,7 @@ function xcattestbundle2sql()
[ -n "${test_run_name}" ]
warn_if_bad "$?" "test run has no name" || return 1
while read ; do echo "${REPLY}" ; done <<-EOF
while read -r ; do echo "${REPLY}" ; done <<-EOF
--
-- Test run has name '${test_run_name}'
--
@ -269,7 +269,7 @@ function xcattestbundle2sql()
[ -f "${logfile}" ]
warn_if_bad "$?" "${logfile}: No such log file" || return 1
while read ; do echo "${REPLY}" ; done <<-EOF
while read -r ; do echo "${REPLY}" ; done <<-EOF
--
-- Analysis file '${logfile}'
--
@ -282,12 +282,12 @@ function xcattestbundle2sql()
EOF
while read test_case_name
while read -r test_case_name
do
# Need chomp ${test_case_name}
test_case_name=$(echo ${test_case_name})
while read ; do echo "${REPLY}" ; done <<-EOF
while read -r ; do echo "${REPLY}" ; done <<-EOF
INSERT INTO TestCase (TestCaseId, TestCaseName)
SELECT * FROM (SELECT NULL, '${test_case_name}') AS tmp
WHERE NOT EXISTS (
@ -330,7 +330,7 @@ function jenkinsprojectlog2sql()
[ -f "${logfile}" ]
warn_if_bad "$?" "${logfile}: No such log file" || return 1
while read ; do echo "${REPLY}" ; done <<-EOF
while read -r ; do echo "${REPLY}" ; done <<-EOF
--
-- Analysis file '${logfile}'
--
@ -363,7 +363,7 @@ function jenkinsprojectlog2sql()
memo="$(tr -d '\r' <"${logfile}" | grep -A 7 'project.*description' | cut -d ' ' -f 4-)"
while read ; do echo "${REPLY}" ; done <<-EOF
while read -r ; do echo "${REPLY}" ; done <<-EOF
INSERT INTO ArchDict (ArchId, ArchName)
SELECT * FROM (SELECT NULL, '${arch}') AS tmp
WHERE NOT EXISTS (
@ -428,7 +428,7 @@ JenkinsMailLog="$(echo "${xCATjkLog_DIR}/mail."*)"
[ -f "${JenkinsMailLog}" ]
exit_if_bad "$?" "${JenkinsMailLog}: no such log file"
while read ; do echo "${REPLY}" ; done <<EOF
while read -r ; do echo "${REPLY}" ; done <<EOF
-- xCATjkLog2SQL - version ${VERSION}
--
-- Run on host ${HOSTNAME}
@ -452,7 +452,7 @@ do
warn_if_bad "$?" "${xCATTestLog}: parse error"
done
while read ; do echo "${REPLY}" ; done <<EOF
while read -r ; do echo "${REPLY}" ; done <<EOF
-- Logs parse completed on $(date "+%Y-%m-%d %H:%M:%S %z")
EOF

View File

@ -22,7 +22,7 @@ then
exit 1
fi
while read ; do echo "${REPLY}" ; done <<EOF
while read -r ; do echo "${REPLY}" ; done <<EOF
-- xCATjkLogs scan last three days
--
-- Run on host ${HOSTNAME}

View File

@ -30,7 +30,7 @@ then
exit 1
fi
while read ; do echo "${REPLY}" ; done <<EOF
while read -r ; do echo "${REPLY}" ; done <<EOF
-- xCATjkLogs redo everything
--
-- Run on host ${HOSTNAME}
@ -38,6 +38,6 @@ while read ; do echo "${REPLY}" ; done <<EOF
EOF
while read ; do echo "${REPLY}" ; done <"${SQLofCreateTables}"
while read -r ; do echo "${REPLY}" ; done <"${SQLofCreateTables}"
"${xCATjkScanLogs}" /xCATjk/log

View File

@ -4,7 +4,7 @@ function usage()
{
local script="${0##*/}"
while read ; do echo "${REPLY}" ; done <<-EOF
while read -r ; do echo "${REPLY}" ; done <<-EOF
Usage: ${script} [OPTIONS] DIRECTORY
Options:
@ -226,7 +226,7 @@ done
[ -d "${xCATjkLog_TopDir}" ]
exit_if_bad "$?" "${xCATjkLog_TopDir}: No such directory"
while read ; do echo "${REPLY}" ; done <<EOF
while read -r ; do echo "${REPLY}" ; done <<EOF
-- xCATjkScanLogs - version ${VERSION}
--
-- Run on host ${HOSTNAME}
@ -240,7 +240,7 @@ find "${xCATjkLog_TopDir}" -name 'log.*-*-*' "${FIND_ARGS[@]}" -print0 |
awk '{ print $2 }' | xargs -r -n 1 dirname |
xargs -r -n 1 "${xCATjkLog2SQL}"
while read ; do echo "${REPLY}" ; done <<EOF
while read -r ; do echo "${REPLY}" ; done <<EOF
--
-- All log directories parse completed on $(date "+%Y-%m-%d %H:%M:%S %z")