Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp7745106imm; Thu, 28 Jun 2018 08:43:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLMYCeuLTdQOiVsAPwknRFjMY5UWNA1RXvIKwOc0j+2GQzkxfWf+2mtkJjovZhllKcVtE3x X-Received: by 2002:a65:5a4f:: with SMTP id z15-v6mr8930142pgs.283.1530200608088; Thu, 28 Jun 2018 08:43:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530200608; cv=none; d=google.com; s=arc-20160816; b=xhxbLWy/2ubu9Uf2GSbj4Jpj1cX9QNvN3oZdinh093J5UOSa2a6WkqdmquBQoRlnlV vPjVZdcAvJ2mVyPht/xRc/MLEvL10YOwCqQ8kIo8ytPh50gikDyysEBOpwDnkvZahAt1 KFiX2r6T3DwSxXLPxczuXa22h6dlMoPGBZIqodg8ScVU4RdgDywIDM2EAzCRdGbTZYil xkrSXZYGtdOr/qYYmKV8PkEeHNYAAAX5atV5VnA1a6VJAlozVJs+L8XCYV1uJV7rXuvW E9pB+v9Q6Ip32grqX2Q8qfb5MWfj298w/WWGSRgEXvh2Cs/6E8lMtrTDLJejOVWJN0oA ifvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=7Wl2nG//W5vPtqzHFyuOM1u3Ipdhazbc1fLWLNE0ags=; b=DHJTi2ji5v5ePL0LR1v7/KvC/R/B+dwddlwU+hqs7cC0lDa0DIeOfjRp66OBYngtL/ dydQ9YYMoyHpuH0CLcJXusDH76OBDZaM6XwwxUqKp4k8aVlMQqV9X734+Y3O489czBUk N333/6w1LZHDQo/Gbb4c3NkKnFq4RMEFu91DBwOGD97hq9ztntUSywy9vH1/iNfzFg7u m1MqfQlqyZq9+TbC99vARUdl/V4NUfTiZ0Cx+jgtVB0ZISk/DKIvqxVbhVWqQK/fxpr+ prpPuMv72755LfHqFWk6Hzt0I5NKTaTpeDDqaKikGOaev/7b98p64QRSRAoStJkpkje6 UDzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=X4Cjnvhq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d7-v6si7180519pfl.122.2018.06.28.08.43.13; Thu, 28 Jun 2018 08:43:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=X4Cjnvhq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753261AbeF1Ly3 (ORCPT + 99 others); Thu, 28 Jun 2018 07:54:29 -0400 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]:10459 "EHLO smtp-fw-33001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752332AbeF1Ly1 (ORCPT ); Thu, 28 Jun 2018 07:54:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1530186867; x=1561722867; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=7Wl2nG//W5vPtqzHFyuOM1u3Ipdhazbc1fLWLNE0ags=; b=X4Cjnvhqtow2dviC+bdFNKqF3Ad0L9LsMUeSoze93zJcVg+0UQOYmR3w y0VZbQESq4f9TCitq362v3d72SKHL+vg0+kqna/cuGXIB1vzHeifft+fV w4Qms479asawiFHnlfeDXpttpmn0Ls8RbScmBMhnhlM9By8gXygGuFDJI M=; X-IronPort-AV: E=Sophos;i="5.51,283,1526342400"; d="scan'208";a="740109428" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1e-97fdccfd.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 28 Jun 2018 11:54:22 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1e-97fdccfd.us-east-1.amazon.com (8.14.7/8.14.7) with ESMTP id w5SBsLYc096518 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Thu, 28 Jun 2018 11:54:21 GMT Received: from EX13D08UEE004.ant.amazon.com (10.43.62.182) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 28 Jun 2018 11:54:20 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX13D08UEE004.ant.amazon.com (10.43.62.182) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 28 Jun 2018 11:54:20 +0000 Received: from uc1a35a69ae4659.ant.amazon.com (10.28.85.80) by mail-relay.amazon.com (10.43.161.249) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 28 Jun 2018 11:54:19 +0000 From: Norbert Manthey To: David Woodhouse , Linus Torvalds CC: Norbert Manthey , Subject: [build-check] scripts: add check_build script Date: Thu, 28 Jun 2018 13:53:09 +0200 Message-ID: <1530186789-28808-2-git-send-email-nmanthey@amazon.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530186789-28808-1-git-send-email-nmanthey@amazon.de> References: <1530186789-28808-1-git-send-email-nmanthey@amazon.de> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This script performs build testing, by building several configurations several times. The script is introduced to improve the consistency of testing changes in the kernel configuration. This version build randconfig 9 times, as well as allyesconfig, allnoconfig and allmodconfig. Depending on the used machine and system setup, the script might take a while to finish. The script logs all the used config files, as well as the output of the build commands to a log directory "build_check_logs", so that this data can be retrieved after running the script. Signed-off-by: Norbert Manthey --- scripts/check_build.sh | 136 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100755 scripts/check_build.sh diff --git a/scripts/check_build.sh b/scripts/check_build.sh new file mode 100755 index 0000000..a100d99 --- /dev/null +++ b/scripts/check_build.sh @@ -0,0 +1,136 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# Check whether kernel changes compile with multiple configurations. +# Configurations that fail for the current commit are tested on an upstream +# commit, and failures are ignored in case the configuration fails on the +# upstream commit as well. +# +# Usage: +# ./scripts/check_build.sh [upstream-commit] +# +# Example: +# ./scripts/check_build.sh origin/master + +# Fail early on error or uninitialized values +set -e -u + +# Write all files to this directory +declare -r LOG_DIR=build_check_logs + +# Gather all configurations we should build, in form of make targets +collect_configurations () +{ + local CONFIGS="randconfig allyesconfig allnoconfig allmodconfig" + local -i I=0 + + while [ "$I" -le 8 ]; do I=$((I+1)); CONFIGS+=" randconfig"; done + + echo "$CONFIGS" +} + +# Build the kernel with the current configuration, return the status, log to $1 +build () +{ + local -r LOG_FILE="$1" + local -i STATUS=0 + + make clean -j $(nproc) &> /dev/null + make -j $(nproc) &>> "$LOG_FILE" || STATUS=$? + + echo "build status: $STATUS" >> "$LOG_FILE" + echo "[$SECONDS] build status: $STATUS" + return "$STATUS" +} + +# Check whether we're executing from a clean repository, and proper location +check_environment() +{ + local -r UPSTREAM_COMMIT="$1" + + if [ ! -x scripts/check_build.sh ]; then + echo "error: please execute script from repository root!" + exit 1 + fi + + if ! git diff-index --quiet HEAD --; then + echo "error: please commit or stash your local changes!" + exit 1 + fi + + if ! git cat-file -e "$UPSTREAM_COMMIT" &> /dev/null; then + echo "error: upstream commit $UPSTREAM_COMMIT does not exist!" + exit 1 + fi +} + +TEST_COMMIT=$(git rev-parse --short HEAD) + +LAST_TAG=$(git describe --abbrev=0) +DEFAULT_UPSTREAM="origin/master" +[ -z "$LAST_TAG" ] || DEFAULT_UPSTREAM="$LAST_TAG" +UPSTREAM_COMMIT="${1:-$DEFAULT_UPSTREAM}" + +# Before starting, check call location and git environment +check_environment "$UPSTREAM_COMMIT" + +# Collect status, as well as failing configuration file names +declare -i OVERALL_STATUS=0 +mkdir -p "$LOG_DIR" +BRANCH_FAILS="" +UPSTREAM_FAILS="" + +# Build multiple configurations +declare -i COUNT=0 +declare -r CONFIGS=$(collect_configurations) +echo "[$SECONDS] Check commit $TEST_COMMIT with upstream reference $UPSTREAM_COMMIT" +for config in $CONFIGS +do + COUNT=$((COUNT+1)) + echo "[$SECONDS] build $config as build nr $COUNT" + LOG_FILE=$LOG_DIR/build-"$COUNT"-"$config".log + + # Prepare configuration, and memorize it + STATUS=0 + make "$config" &> "$LOG_FILE" || STATUS=$? + cp .config $LOG_DIR/config-"$COUNT"-"$config" + + # Try to build with current configuration + build "$LOG_FILE" || STATUS=$? + + # Evaluate build failure + if [ "$STATUS" -ne 0 ] + then + cp .config "$LOG_DIR"/config-failing-branch-"$COUNT"-"$config" + echo "[$SECONDS] check whether current configuration fails upstream as well ..." + echo "[$SECONDS] go back in time to commit $UPSTREAM_COMMIT" + + # Check whether upstream commit builds + git checkout "$UPSTREAM_COMMIT" &>> "$LOG_FILE" + UPSTREAM_STATUS=0 + build "$LOG_FILE" || UPSTREAM_STATUS=$? + git checkout "$TEST_COMMIT" &>> "$LOG_FILE" + + if [ "$UPSTREAM_STATUS" -ne 0 ] + then + echo "[$SECONDS] upstream build fails as well, ignore failure" + cp .config "$LOG_DIR"/config-failing-upstream-"$COUNT"-"$config" + UPSTREAM_FAILS+=" config-$COUNT-$config" + else + echo "[$SECONDS] upstream build succeeds, while branch build fails" + BRANCH_FAILS+=" config-$COUNT-$config" + OVERALL_STATUS=1 + fi + + echo "[$SECONDS] jump back to commit under test, $TEST_COMMIT" + fi +done + +# Print summary, and exit with status of local changes +echo "Finished after $SECONDS seconds" +echo "Found upstream failures: $UPSTREAM_FAILS" +echo "Found branch failures: $BRANCH_FAILS" +echo "Collected configurations and logs can be found in $LOG_DIR" + +# Exit 0, if no build fails, or the upstream commit always fails as well +exit $OVERALL_STATUS -- 2.7.4 Amazon Development Center Germany GmbH Berlin - Dresden - Aachen main office: Krausenstr. 38, 10117 Berlin Geschaeftsfuehrer: Dr. Ralf Herbrich, Christian Schlaeger Ust-ID: DE289237879 Eingetragen am Amtsgericht Charlottenburg HRB 149173 B