[Fuego] [PATCH 2/2] tests: add Functional.kernel_build test

Daniel Sangorrin daniel.sangorrin at toshiba.co.jp
Tue Apr 18 08:41:48 UTC 2017


Easy to automatize kernel builds for different architectures.
There are a few TODOs for corner cases but it works.

Next I want to add a deploy option so that we can put the
resulting kernel on a tftp folder or give it to lava.

Signed-off-by: Daniel Sangorrin <daniel.sangorrin at toshiba.co.jp>
---
 .../Functional.kernel_build.spec                   | 18 +++++
 .../tests/Functional.kernel_build/kernel_build.sh  | 80 ++++++++++++++++++++++
 2 files changed, 98 insertions(+)
 create mode 100644 engine/tests/Functional.kernel_build/Functional.kernel_build.spec
 create mode 100755 engine/tests/Functional.kernel_build/kernel_build.sh

diff --git a/engine/tests/Functional.kernel_build/Functional.kernel_build.spec b/engine/tests/Functional.kernel_build/Functional.kernel_build.spec
new file mode 100644
index 0000000..39914a8
--- /dev/null
+++ b/engine/tests/Functional.kernel_build/Functional.kernel_build.spec
@@ -0,0 +1,18 @@
+{
+    "testName": "Functional.kernel_build",
+    "specs":
+    [
+        {
+            "name": "cip-x86",
+            "repo": "https://github.com/cip-project/linux-cip.git"
+        },
+        {
+            "name": "cip-arm64",
+            "repo": "https://github.com/cip-project/linux-cip.git",
+            "platform": "aarch64",
+            "arch": "arm64",
+            "params": "-j8 Image dtbs modules",
+            "regex_p": "^  OBJCOPY arch/arm64/boot/Image"
+        }
+    ]
+}
diff --git a/engine/tests/Functional.kernel_build/kernel_build.sh b/engine/tests/Functional.kernel_build/kernel_build.sh
new file mode 100755
index 0000000..285d5ba
--- /dev/null
+++ b/engine/tests/Functional.kernel_build/kernel_build.sh
@@ -0,0 +1,80 @@
+function test_pre_check {
+    echo "Doing a pre_check"
+    # FIXTHIS: if making uImage, check for mkimage
+}
+
+function test_build {
+    FOLDER="$(basename "$FUNCTIONAL_KERNEL_BUILD_REPO" .git)"
+
+    # Clone if no tarball was defined
+    if [ -z ${tarball+x} ]; then
+        assert_define FUNCTIONAL_KERNEL_BUILD_REPO
+
+        # Set branch or tag (default: "master" branch)
+        if [ -z ${FUNCTIONAL_KERNEL_BUILD_TAG+x} ]; then
+            if [ -z ${FUNCTIONAL_KERNEL_BUILD_BRANCH+x} ]; then
+                FUNCTIONAL_KERNEL_BUILD_BRANCH="master"
+            fi
+        else
+            FUNCTIONAL_KERNEL_BUILD_BRANCH=$FUNCTIONAL_KERNEL_BUILD_TAG
+        fi
+
+        # FIXTHIS: the folder gets removed with the rebuild flag set to true
+        if [ ! -d "$FOLDER" ]; then
+            echo "Cloning $FUNCTIONAL_KERNEL_BUILD_REPO:$FUNCTIONAL_KERNEL_BUILD_BRANCH"
+            git clone --depth 1 "$FUNCTIONAL_KERNEL_BUILD_REPO" \
+                      --branch $FUNCTIONAL_KERNEL_BUILD_BRANCH
+            cd "$FOLDER"
+        else
+            cd "$FOLDER"
+            if [ -z ${FUNCTIONAL_KERNEL_BUILD_TAG+x} ]; then
+                make mrproper
+                git pull
+            fi
+        fi
+    fi
+
+    # Configuration
+    if [ -z ${FUNCTIONAL_KERNEL_BUILD_ARCH+x} ]; then
+        FUNCTIONAL_KERNEL_BUILD_ARCH="x86_64"
+    fi
+
+    if [ -z ${FUNCTIONAL_KERNEL_BUILD_CONFIG+x} ]; then
+        FUNCTIONAL_KERNEL_BUILD_CONFIG="defconfig"
+    fi
+    echo "Configuring kernel with $FUNCTIONAL_KERNEL_BUILD_CONFIG"
+    make ARCH=$FUNCTIONAL_KERNEL_BUILD_ARCH $FUNCTIONAL_KERNEL_BUILD_CONFIG
+
+    # Building
+    echo "Building Kernel"
+    if [ -z ${FUNCTIONAL_KERNEL_BUILD_PARAMS+x} ]; then
+        $FUNCTIONAL_KERNEL_BUILD_PARAMS="-j4 bzImage modules"
+    fi
+
+    if [ ! -z ${FUNCTIONAL_KERNEL_BUILD_PLATFORM+x} ]; then
+          OLD_PLATFORM=$PLATFORM
+          PLATFORM=$FUNCTIONAL_KERNEL_BUILD_PLATFORM
+          source $FUEGO_RO/toolchains/tools.sh
+          PLATFORM=$OLD_PLATFORM
+    fi
+
+    make ARCH=$FUNCTIONAL_KERNEL_BUILD_ARCH $FUNCTIONAL_KERNEL_BUILD_PARAMS > build.log 2>&1 || true
+
+    report "cat build.log"
+}
+
+function test_deploy {
+    echo "Deploying kernel"
+    # FIXTHIS: copy to tftp folder for lava etc..
+}
+
+function test_processing {
+    echo "Processing kernel build log"
+    if [ -z ${FUNCTIONAL_KERNEL_BUILD_REGEX_P+x} ]; then
+        log_compare "$TESTDIR" "1" "^Kernel: arch/.* is ready" "p"
+    else
+        log_compare "$TESTDIR" "1" "$FUNCTIONAL_KERNEL_BUILD_REGEX_P" "p"
+    fi
+}
+
+. $FUEGO_CORE/engine/scripts/functional.sh
-- 
2.7.4




More information about the Fuego mailing list