blob: 0e61ce18a15e781704bf51d82ba5ceb3303f753d [file] [log] [blame]
#!/bin/bash
#
# Copyright 2021 The Cobalt Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Unset the previous test's name and runner function.
unset TEST_NAME
unset TEST_FILE
unset -f run_test
TEST_NAME="CrashpadRuns"
TEST_FILE="test.html"
function run_test() {
clear_storage
LOG="${TEST_NAME}.0.log"
start_cobalt "file:///tests/${TEST_FILE}?channel=tcrash" "${LOG}" LOADER
watch_cobalt "${LOG}" "update from tcrash channel was installed"
if [[ $? -ne 0 ]]; then
log "error" " Failed to download and install the tcrash package"
return 1
fi
log "info" " Stopping with 'kill -9 ${LOADER}'"
kill -9 "${LOADER}" 1> /dev/null
sleep 1
LOG="${TEST_NAME}.1.log"
start_cobalt "file:///tests/${TEST_FILE}?channel=tcrash" "${LOG}" LOADER
watch_cobalt "${LOG}" "Caught signal: SIG[A-Z]{4}"
if [[ $? -ne 0 ]]; then
log "error" " Binary did not crash"
return 1
fi
local num_recently_completed_crash_files=$(eval "run_command \"find ${CACHE_DIR}/crashpad_database/completed/ -mmin -3 | ${WC} -l\"")
# The actual numeric value in the variable may be surrounded by newlines and spaces.
if [[ $(echo "$num_recently_completed_crash_files" | tr -d '\n' | tr -d '[:space:]') != "0" ]]; then
# Some recently completed crash files were found in the local crash database.
return 0
else
log "error" " Failed upload crash to crash database"
return 1
fi
}