Skip to content

Commit

Permalink
bug: handle case where variable is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
timmy-wright committed Nov 14, 2024
1 parent a3120c3 commit 197e016
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions parts/linux/cloud-init/artifacts/cse_benchmark_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ capture_benchmark() {
process_benchmarks() {
set +x

if [ ! -f ${PERFORMANCE_DATA_FILE} ]; then
echo '{}' > ${PERFORMANCE_DATA_FILE}
if [ -z "${PERFORMANCE_DATA_FILE}" ] ; then
return
fi

if [ ! -f "${PERFORMANCE_DATA_FILE}" ]; then
echo '{}' > "${PERFORMANCE_DATA_FILE}"
fi

check_array_size benchmarks || { echo "Benchmarks array is empty"; return; }
Expand All @@ -60,6 +64,6 @@ process_benchmarks() {
'$script_object | .[$script_name] += $section_object')
done

jq ". += $script_object" ${PERFORMANCE_DATA_FILE} > temp-perf-file.json && mv temp-perf-file.json ${PERFORMANCE_DATA_FILE}
chmod 755 ${PERFORMANCE_DATA_FILE}
jq ". += $script_object" "${PERFORMANCE_DATA_FILE}" > temp-perf-file.json && mv temp-perf-file.json "${PERFORMANCE_DATA_FILE}"
chmod 755 "${PERFORMANCE_DATA_FILE}"
}

0 comments on commit 197e016

Please sign in to comment.