From patchwork Thu Apr 30 14:09:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Bourhis-Cloarec X-Patchwork-Id: 1280447 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=smile.fr Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=smile-fr.20150623.gappssmtp.com header.i=@smile-fr.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=B1szP2Gu; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Cch24lGgz9sXK for ; Fri, 1 May 2020 00:09:22 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 5009087EDB; Thu, 30 Apr 2020 14:09:20 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NXRqEtJoJpdr; Thu, 30 Apr 2020 14:09:19 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 7C338876F6; Thu, 30 Apr 2020 14:09:19 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 7327B1BF869 for ; Thu, 30 Apr 2020 14:09:13 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 6DB91876F6 for ; Thu, 30 Apr 2020 14:09:13 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id p7E8j5IKzmsC for ; Thu, 30 Apr 2020 14:09:11 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by whitealder.osuosl.org (Postfix) with ESMTPS id 3B88187697 for ; Thu, 30 Apr 2020 14:09:11 +0000 (UTC) Received: by mail-wm1-f67.google.com with SMTP id r26so2066916wmh.0 for ; Thu, 30 Apr 2020 07:09:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile-fr.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=eT7yGP99ZAhZlHP66UD3E78Ojg1fgiZtTka9Mpq/73w=; b=B1szP2Guc4ulPHPlOjwr1gJ4wTX3swFY1vXfDJ8mR8M/07bOzEGzsmL36U7I3Q3PBm lBN6Of4R0oZ7EyqAJycMgyQbtYGYTmwb17Yxw0z7jY3D6rauZP4WIZK/k2O3zoITn+Be qPjbDZXbLp0u4vw/uRvXe3D3FUd6sTGymY/Rud//JZAFkVyumRTPWx6qtz54z6hnY71I nNBvaMqKk2BlnCKUix5x/LmboMQBzi5d/d9JfNvp33KHXfYe/1YNp0wgdZYyIyYUaBbK Miy60tGxli98qAK78XESg1gox8fzSTNBASSdFIONwG9tXsNjD5sEqU++Q54RkfCW06fu yBow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=eT7yGP99ZAhZlHP66UD3E78Ojg1fgiZtTka9Mpq/73w=; b=gJCliApKtWVmdlAVkw0ATua99kpPAec/r46Rhb6lP11bI+YSb+E26wOiYxhahJFc0i 30VKXrPM4mvyq6W5i9/jnJ5QSZiukxQf2C4GgWoHZr7OGuW7Zjd1h8CPoSQSr3RPVycC 7ZWz0Ku9ZOCFTVM9R8zhx2Q6vBrmKmeRXvE7FRvZ4o2hnY56zI9NwKY31IxCv/alnEeS Zz1lSEyRKdq+QsM+vqpkHwhZtYC2ylDL63WmhdrkdcwepoIpv0MoqJFeK5anJzOcf8dl 4xfBOzsflMSwH7z+MEz59+mEk6wWLwaIM+jDNNLKEQqBb2yq+vyzaDwlycDqnUZsR95b 3c9g== X-Gm-Message-State: AGi0Puau+Z6zC0QGLr7NxD8zwo1twIRLMItiUBqvd+ERLIPlY6s9hnm+ 4Khb2oJzyY3FlhCAciZjrrmWF8t7g6M= X-Google-Smtp-Source: APiQypKOJEyT/g3J4Id6OjU3dREk/I9rzGooM3cIlossxyZQdHT7vRjTJJhwpHkGY/lmD0vZUDyFbw== X-Received: by 2002:a7b:cb0c:: with SMTP id u12mr3417311wmj.137.1588255749160; Thu, 30 Apr 2020 07:09:09 -0700 (PDT) Received: from P-NAN-EREVAN-mikbou ([2a01:e0a:47d:2970:3b38:5d74:1a8f:f4b3]) by smtp.gmail.com with ESMTPSA id a24sm12084317wmb.24.2020.04.30.07.09.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 07:09:08 -0700 (PDT) Date: Thu, 30 Apr 2020 16:09:06 +0200 From: Mikael Bourhis-Cloarec To: buildroot@buildroot.org Message-ID: <20200430140906.GA10544@P-NAN-EREVAN-mikbou> MIME-Version: 1.0 Content-Disposition: inline Subject: [Buildroot] [PATCH v2 1/1] support/testing: add package/test_mender.py X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: angelo.compagnucci@gmail.com, aduskett@gmail.com Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Create a test to check Mender client at runtime. The aim of this test is: - to check the correct execution of simple Mender commands, in a minimal environment; - to validate there is no missing dependencies for runtime. This test is not a board integration test for Mender, including well-configured bootloader, partitioning, ... Check: - the daemon is started; - the current 'artifact name' (name of the image or update) of the active partition is read, without error. For that, we need to fake (see the 'overlay' directory): - some bootloader environment variables; - the name of an update. Signed-off-by: Mikael Bourhis-Cloarec --- Changes v1 -> v2: - Update the test by removing unnecessary 'build' option (Thomas P.) - Remove a useless test case (Thomas P.) Signed-off-by: Mikael Bourhis-Cloarec --- .gitlab-ci.yml | 1 + support/testing/tests/package/test_mender.py | 32 +++++++++++++++++++ .../rootfs-overlay/etc/mender/artifact_info | 1 + .../rootfs-overlay/usr/bin/fw_printenv | 6 ++++ 4 files changed, 40 insertions(+) create mode 100644 support/testing/tests/package/test_mender.py create mode 100644 support/testing/tests/package/test_mender/rootfs-overlay/etc/mender/artifact_info create mode 100755 support/testing/tests/package/test_mender/rootfs-overlay/usr/bin/fw_printenv diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fa8e077a07..029a8d00aa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -520,6 +520,7 @@ tests.package.test_rust.TestRustBin: { extends: .runtime_test } tests.package.test_syslog_ng.TestSyslogNg: { extends: .runtime_test } tests.package.test_tmux.TestTmux: { extends: .runtime_test } tests.package.test_turbolua.TestLuajitTurbolua: { extends: .runtime_test } +tests.package.test_mender.TestMender: { extends: .runtime_test } tests.toolchain.test_external.TestExternalToolchainBuildrootMusl: { extends: .runtime_test } tests.toolchain.test_external.TestExternalToolchainBuildrootuClibc: { extends: .runtime_test } tests.toolchain.test_external.TestExternalToolchainCCache: { extends: .runtime_test } diff --git a/support/testing/tests/package/test_mender.py b/support/testing/tests/package/test_mender.py new file mode 100644 index 0000000000..8b5200b609 --- /dev/null +++ b/support/testing/tests/package/test_mender.py @@ -0,0 +1,32 @@ +import os + +import infra.basetest + + +class TestMender(infra.basetest.BRTest): + config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \ + """ + BR2_PACKAGE_MENDER=y + BR2_TARGET_ROOTFS_CPIO=y + BR2_ROOTFS_OVERLAY="{}" + """.format( + # overlay to add a fake 'fw_printenv', used by Mender + infra.filepath("tests/package/test_mender/rootfs-overlay")) + + def test_run(self): + cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio") + self.emulator.boot(arch="armv5", + kernel="builtin", + options=["-initrd", cpio_file]) + self.emulator.login() + + # Check if the Daemon is running + self.assertRunOk("ls /var/run/mender.pid") + self.assertRunOk("ps aux | egrep [m]ender") + + # Check if a simple Mender command is correctly executed + self.assertRunOk("mender -log-level debug -show-artifact") + self.assertRunOk("mender -log-level debug -show-artifact | grep 'RUNTIME_TEST_ARTIFACT_NAME'") + cmd = "mender -show-artifact 2>&1 | grep -i 'err'" # Check if no 'error' among the traces + _, exit_code = self.emulator.run(cmd) + self.assertEqual(exit_code, 1) diff --git a/support/testing/tests/package/test_mender/rootfs-overlay/etc/mender/artifact_info b/support/testing/tests/package/test_mender/rootfs-overlay/etc/mender/artifact_info new file mode 100644 index 0000000000..4d54b8f89c --- /dev/null +++ b/support/testing/tests/package/test_mender/rootfs-overlay/etc/mender/artifact_info @@ -0,0 +1 @@ +artifact_name=RUNTIME_TEST_ARTIFACT_NAME diff --git a/support/testing/tests/package/test_mender/rootfs-overlay/usr/bin/fw_printenv b/support/testing/tests/package/test_mender/rootfs-overlay/usr/bin/fw_printenv new file mode 100755 index 0000000000..c002a0f2b8 --- /dev/null +++ b/support/testing/tests/package/test_mender/rootfs-overlay/usr/bin/fw_printenv @@ -0,0 +1,6 @@ +#!/bin/sh + +# Fake 'fw_printenv' because UBoot is not installed: print some plausible 'key-value' +echo "bootcount=0" +echo "mender_boot_part=rootfs" +echo "upgrade_available=0"