|
| 1 | +#!/bin/bash |
| 2 | +# Copyright © 2025 Apple Inc. and the Containerization project authors. |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | + |
| 17 | +# Script to scan the VM boot logs from the integration tests for kernel panics. |
| 18 | +# Looks for common kernel panic messages like "attempted to kill init" or "Kernel panic". |
| 19 | + |
| 20 | +GIT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null) |
| 21 | +if [ -z "$GIT_ROOT" ]; then |
| 22 | + echo "Error: Not in a git repository" |
| 23 | + exit 1 |
| 24 | +fi |
| 25 | + |
| 26 | +BOOT_LOGS_DIR="$GIT_ROOT/bin/integration-bootlogs" |
| 27 | + |
| 28 | +if [ ! -d "$BOOT_LOGS_DIR" ]; then |
| 29 | + echo "Error: Boot logs directory not found: $BOOT_LOGS_DIR" |
| 30 | + exit 1 |
| 31 | +fi |
| 32 | + |
| 33 | +echo "Scanning boot logs in: $BOOT_LOGS_DIR" |
| 34 | +echo "========================================" |
| 35 | +echo "" |
| 36 | + |
| 37 | +PANIC_FOUND=0 |
| 38 | + |
| 39 | +for logfile in "$BOOT_LOGS_DIR"/*; do |
| 40 | + if [ -f "$logfile" ]; then |
| 41 | + if grep -qi "attempted to kill init\|Kernel panic\|end Kernel panic\|Attempted to kill the idle task\|Oops:" "$logfile"; then |
| 42 | + echo "🚨 PANIC DETECTED in: $(basename "$logfile")" |
| 43 | + echo "---" |
| 44 | + grep -i -B 5 -A 10 "attempted to kill init\|Kernel panic\|end Kernel panic\|Attempted to kill the idle task\|Oops:" "$logfile" | head -30 |
| 45 | + echo "" |
| 46 | + echo "========================================" |
| 47 | + echo "" |
| 48 | + PANIC_FOUND=1 |
| 49 | + fi |
| 50 | + fi |
| 51 | +done |
| 52 | + |
| 53 | +if [ $PANIC_FOUND -eq 0 ]; then |
| 54 | + echo "✅ No kernel panics detected in boot logs" |
| 55 | +else |
| 56 | + echo "❌ Found kernel panics - Virtual machine(s) crashed during integration tests" |
| 57 | +fi |
| 58 | + |
| 59 | +exit $PANIC_FOUND |
0 commit comments