public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Uladzimir Bely <ubely@ilbers.de>
To: isar-users@googlegroups.com
Subject: [PATCH v3 3/3] ci: Add test for ccache
Date: Fri, 29 Oct 2021 15:57:00 +0200	[thread overview]
Message-ID: <20211029135700.27885-4-ubely@ilbers.de> (raw)
In-Reply-To: <20211029135700.27885-1-ubely@ilbers.de>

The test runs bitbake target twice. First run with ccache enabled
makes CCACHE_DIR be populated and the second run reuses it to
speedup build process.

Signed-off-by: Uladzimir Bely <ubely@ilbers.de>
---
 testsuite/build_test/build_test.py | 11 ++++++++++
 testsuite/build_test/cibase.py     | 33 ++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/testsuite/build_test/build_test.py b/testsuite/build_test/build_test.py
index d39c10c0..05db4b78 100644
--- a/testsuite/build_test/build_test.py
+++ b/testsuite/build_test/build_test.py
@@ -206,3 +206,14 @@ class ContainerSdkTest(CIBaseTest):
         targets = ['mc:container-amd64-stretch:isar-image-base']
 
         self.perform_container_test(targets, 'do_populate_sdk')
+
+class CcacheTest(CIBaseTest):
+
+    """
+    Test rebuild speed improve with ccache
+
+    :avocado: tags=ccache,full
+    """
+    def test_ccache_rebuild(self):
+        targets = ['mc:de0-nano-soc-buster:isar-image-base']
+        self.perform_ccache_test(targets)
diff --git a/testsuite/build_test/cibase.py b/testsuite/build_test/cibase.py
index 78d7bdb7..0b053aa5 100644
--- a/testsuite/build_test/cibase.py
+++ b/testsuite/build_test/cibase.py
@@ -3,6 +3,7 @@
 import os
 import re
 import tempfile
+import time
 
 from cibuilder import CIBuilder
 from avocado.utils import process
@@ -114,3 +115,35 @@ class CIBaseTest(CIBuilder):
 
         self.bitbake(build_dir, targets, bitbake_cmd, bb_args)
 
+
+    def perform_ccache_test(self, targets):
+        build_dir, bb_args = self.prep('Isar ccache build', targets, 0, 0)
+
+        self.deletetmp(build_dir)
+        process.run('rm -rf ' + build_dir + '/ccache', sudo=True)
+
+        with open(build_dir + '/conf/ci_build.conf', 'a') as file:
+            file.write('USE_CCACHE = "1"\n')
+            file.write('CCACHE_TOP_DIR = "${TOPDIR}/ccache"')
+
+        self.log.info('Starting build and filling ccache dir...')
+        start = time.time()
+        self.bitbake(build_dir, targets, None, bb_args)
+        first_time = time.time() - start
+        self.log.info('Non-cached build: ' + str(round(first_time)) + 's')
+
+        self.deletetmp(build_dir)
+
+        self.log.info('Starting build and using ccache dir...')
+        start = time.time()
+        self.bitbake(build_dir, targets, None, bb_args)
+        second_time = time.time() - start
+        self.log.info('Cached build: ' + str(round(second_time)) + 's')
+
+        speedup_k = 1.1
+        if first_time / second_time < speedup_k:
+            self.fail('No speedup after rebuild with ccache')
+
+        # Cleanup
+        self.deletetmp(build_dir)
+        process.run('rm -rf ' + build_dir + '/ccache', sudo=True)
-- 
2.20.1


  parent reply	other threads:[~2021-10-29 13:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-29 13:56 [PATCH v3 0/3] Support of ccache Uladzimir Bely
2021-10-29 13:56 ` [PATCH v3 1/3] meta: Support for ccache for custom packages Uladzimir Bely
2021-10-29 13:56 ` [PATCH v3 2/3] doc: Add section about ccache usage Uladzimir Bely
2021-10-29 13:57 ` Uladzimir Bely [this message]
2021-10-29 14:04   ` [PATCH v3 3/3] ci: Add test for ccache Uladzimir Bely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211029135700.27885-4-ubely@ilbers.de \
    --to=ubely@ilbers.de \
    --cc=isar-users@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox