OLD | NEW |
1 #!/bin/sh | 1 #!/bin/sh |
2 | 2 |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 set -e | 7 set -e |
8 | 8 |
9 # Product ID in crash report | 9 # Product ID in crash report |
10 CHROMEOS_PRODUCT=ChromeOS | 10 CHROMEOS_PRODUCT=ChromeOS |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 # hours. | 61 # hours. |
62 TIMESTAMPS_DIR="/var/lib/crash_sender" | 62 TIMESTAMPS_DIR="/var/lib/crash_sender" |
63 | 63 |
64 # Temp directory for this process. | 64 # Temp directory for this process. |
65 TMP_DIR="" | 65 TMP_DIR="" |
66 | 66 |
67 lecho() { | 67 lecho() { |
68 logger -t "${TAG}" "$@" | 68 logger -t "${TAG}" "$@" |
69 } | 69 } |
70 | 70 |
| 71 # Returns true if mock is enabled. |
| 72 is_mock() { |
| 73 [ -f "${MOCK_CRASH_SENDING}" ] && return 0 |
| 74 return 1 |
| 75 } |
| 76 |
71 cleanup() { | 77 cleanup() { |
72 if [ -n "${TMP_DIR}" ]; then | 78 if [ -n "${TMP_DIR}" ]; then |
73 rm -rf "${TMP_DIR}" | 79 rm -rf "${TMP_DIR}" |
74 fi | 80 fi |
75 if [ ${CLEAN_UP_RUN_FILE} -eq 1 ]; then | 81 if [ ${CLEAN_UP_RUN_FILE} -eq 1 ]; then |
76 rm -f "${RUN_FILE}" | 82 rm -f "${RUN_FILE}" |
77 fi | 83 fi |
| 84 if is_mock; then |
| 85 # For testing purposes, emit a message to log so that we |
| 86 # know when the test has received all the messages from this run. |
| 87 lecho "crash_sender done." |
| 88 fi |
78 } | 89 } |
79 | 90 |
80 check_not_already_running() { | 91 check_not_already_running() { |
81 set -o noclobber | 92 set -o noclobber |
82 if echo $$ 2>/dev/null > "${RUN_FILE}"; then | 93 if echo $$ 2>/dev/null > "${RUN_FILE}"; then |
83 # Able to write RUN_FILE without contention. | 94 # Able to write RUN_FILE without contention. |
84 CLEAN_UP_RUN_FILE=1 | 95 CLEAN_UP_RUN_FILE=1 |
85 set +o noclobber | 96 set +o noclobber |
86 return | 97 return |
87 fi | 98 fi |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 169 } |
159 | 170 |
160 get_key_value() { | 171 get_key_value() { |
161 if ! grep -q "$2=" "$1"; then | 172 if ! grep -q "$2=" "$1"; then |
162 echo "undefined" | 173 echo "undefined" |
163 return | 174 return |
164 fi | 175 fi |
165 grep "$2=" "$1" | cut -d = -f 2- | 176 grep "$2=" "$1" | cut -d = -f 2- |
166 } | 177 } |
167 | 178 |
168 # Returns true if mock is enabled. | |
169 is_mock() { | |
170 [ -f "${MOCK_CRASH_SENDING}" ] && return 0 | |
171 return 1 | |
172 } | |
173 | |
174 # Return the board name. | 179 # Return the board name. |
175 get_board() { | 180 get_board() { |
176 echo $(get_key_value "/etc/lsb-release" "CHROMEOS_RELEASE_BOARD") | 181 echo $(get_key_value "/etc/lsb-release" "CHROMEOS_RELEASE_BOARD") |
177 } | 182 } |
178 | 183 |
179 # Return the hardware class or "unknown". | 184 # Return the hardware class or "unknown". |
180 get_hardware_class() { | 185 get_hardware_class() { |
181 if [ -r "${HWCLASS_PATH}" ]; then | 186 if [ -r "${HWCLASS_PATH}" ]; then |
182 cat "${HWCLASS_PATH}" | 187 cat "${HWCLASS_PATH}" |
183 else | 188 else |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 TMP_DIR="$(mktemp -d /tmp/crash_sender.XXXX)" | 373 TMP_DIR="$(mktemp -d /tmp/crash_sender.XXXX)" |
369 | 374 |
370 # Send system-wide crashes | 375 # Send system-wide crashes |
371 send_crashes "/var/spool/crash" | 376 send_crashes "/var/spool/crash" |
372 | 377 |
373 # Send user-specific crashes | 378 # Send user-specific crashes |
374 send_crashes "/home/chronos/user/crash" | 379 send_crashes "/home/chronos/user/crash" |
375 } | 380 } |
376 | 381 |
377 main | 382 main |
OLD | NEW |