blob: 94cf6f3d35454ebc0137a58fa06691329dc77966 [file] [log] [blame]
# Copyright 2020 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Serivce to persist crash test state files across reboots.
# This should only be installed on test images.
description "Set up crash test flag files"
author "chromium-os-dev@chromium.org"
# Start after startup, when /var/ is mounted.
# This will be before crash_reporter starts because `stopping` is a hook,
# meaning that "the emitter waits for it to complete before carrying on", per
# http://upstart.ubuntu.com/cookbook/#hooks.
# crash_reporter has `start on starting boot-services`, so it will start just
# before boot_services. boot_services, in turn, `starts on stopped startup`.
start on stopping startup
task
oom score -100 # This is extremely unlikely to run out of memory
script
(
copy_and_decrement_or_remove() {
source="$1"
cp -v "${source}" /run/crash_reporter/
if [ "$(cat "${source}")" -le 1 ]; then
rm -v "${source}"
else
echo "$(($(cat "${source}") - 1))" > ${source}
fi
}
set -x
echo "$(date --iso-8601=ns): Running persist-crash-test"
if [ -f /var/spool/crash/crash-test-in-progress ]; then
copy_and_decrement_or_remove /var/spool/crash/crash-test-in-progress
fi
if [ -f /var/spool/crash/mock-consent ]; then
copy_and_decrement_or_remove /var/spool/crash/mock-consent
fi
echo "$(date --iso-8601=ns): Finished persist-crash-test"
) >> /run/crash-reporter-early-init.log 2>&1
end script