Skip to contentSkip to conversation

oeqa/selftest/buildoptions: Improve ccache test

PATCH New Richard Purdie 1 participant 5 messages Nov 29, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 oeqa/selftest/buildoptions: Improve ccache test

This test occisionally fails as m4 doesn't recompile, meaning the logfile test then doesn't find mention of ccache.

To ensure m4 does recompile, clean m4 before force compiling it.

(Reading the test is confusing due to the test cleanup also involving a clean)

---
 meta/lib/oeqa/selftest/cases/buildoptions.py | 1 +
 1 file changed, 1 insertion(+)
meta/lib/oeqa/selftest/cases/buildoptions.py +1 -0
index 9b87e7fcfcc..c3c90a0b0dc 100644
@@ -38,6 +38,7 @@ class ImageOptionsTests(OESelftestTestCase):
         self.assertTrue(os.path.isfile(p), msg = "No ccache found (%s)" % p)
         self.write_config('INHERIT += "ccache"')
         self.add_command_to_tearDown('bitbake -c clean m4')
+        bitbake("m4 -c clean")
         bitbake("m4 -f -c compile")
         log_compile = os.path.join(get_bb_var("WORKDIR","m4"), "temp/log.do_compile")
         with open(log_compile, "r") as f:
Signature · 1 line
2.19.1
#1 lore raw

PATCH 2/5 oeqa/selftest/runcmd: Increase timeout delta

Expecting 1s accuracy on a 2s timeout on a heavily loaded system has proven to be unreliable. Update this to a 5s timeout with a 3s delta which should be achievable.

---
 meta/lib/oeqa/selftest/cases/runcmd.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/lib/oeqa/selftest/cases/runcmd.py +2 -2
index d76d7063c69..a1615cfd20b 100644
@@ -24,8 +24,8 @@ class RunCmdTests(OESelftestTestCase):
 
     # The delta is intentionally smaller than the timeout, to detect cases where
     # we incorrectly apply the timeout more than once.
-    TIMEOUT = 2
-    DELTA = 1
+    TIMEOUT = 5
+    DELTA = 3
 
     @OETestID(1916)
     def test_result_okay(self):
Signature · 1 line
2.19.1
#2 lore raw

PATCH 3/5 oeqa/selftest/buildoptions: Ensure diskmon tests run consistently

In reply to Richard Purdie

Heartbeat events default to once a second and we need to ensure we have enough time in the task to see them.

Add a nostamp delay task 5s long so we can have a consistently timed task which doesn't need cleanup or have unneeded dependencies. This ensures we should deterministically see the disk moinitor events regardless of the state of the build. This is done in a way which doesn't corrupt build state or need cleanup and is efficient.

---
 meta-selftest/recipes-test/delay/delay.bb    | 12 ++++++++++++
 meta/lib/oeqa/selftest/cases/buildoptions.py |  6 +++---
 2 files changed, 15 insertions(+), 3 deletions(-)
 create mode 100644 meta-selftest/recipes-test/delay/delay.bb
meta-selftest/recipes-test/delay/delay.bb new file +12 -0
new file mode 100644
index 00000000000..f92d3d99e28
@@ -0,0 +1,12 @@
+SUMMARY = "Recipe with a fixed delay task"
+DESCRIPTION = "Contains a delay task to be used to for testing."
+LICENSE = "MIT"
+
+INHIBIT_DEFAULT_DEPS = "1"
+EXCLUDE_FROM_WORLD = "1"
+
+do_delay() {
+	sleep 5
+}
+do_delay[nostamp] = "1"
+addtask delay
\ No newline at end of file
meta/lib/oeqa/selftest/cases/buildoptions.py +3 -3
index c3c90a0b0dc..f234bac0510 100644
@@ -59,15 +59,15 @@ class DiskMonTest(OESelftestTestCase):
     @OETestID(277)
     def test_stoptask_behavior(self):
         self.write_config('BB_DISKMON_DIRS = "STOPTASKS,${TMPDIR},100000G,100K"')
-        res = bitbake("m4", ignore_status = True)
+        res = bitbake("delay -c delay", ignore_status = True)
         self.assertTrue('ERROR: No new tasks can be executed since the disk space monitor action is "STOPTASKS"!' in res.output, msg = "Tasks should have stopped. Disk monitor is set to STOPTASK: %s" % res.output)
         self.assertEqual(res.status, 1, msg = "bitbake reported exit code %s. It should have been 1. Bitbake output: %s" % (str(res.status), res.output))
         self.write_config('BB_DISKMON_DIRS = "ABORT,${TMPDIR},100000G,100K"')
-        res = bitbake("m4", ignore_status = True)
+        res = bitbake("delay -c delay", ignore_status = True)
         self.assertTrue('ERROR: Immediately abort since the disk space monitor action is "ABORT"!' in res.output, "Tasks should have been aborted immediatelly. Disk monitor is set to ABORT: %s" % res.output)
         self.assertEqual(res.status, 1, msg = "bitbake reported exit code %s. It should have been 1. Bitbake output: %s" % (str(res.status), res.output))
         self.write_config('BB_DISKMON_DIRS = "WARN,${TMPDIR},100000G,100K"')
-        res = bitbake("m4")
+        res = bitbake("delay -c delay")
         self.assertTrue('WARNING: The free space' in res.output, msg = "A warning should have been displayed for disk monitor is set to WARN: %s" %res.output)
 
 class SanityOptionsTest(OESelftestTestCase):
Signature · 1 line
2.19.1
#3 lore raw

PATCH 4/5 meta-selftest/error: Cleanup large trailing whitespace

In reply to Richard Purdie
---
 meta-selftest/recipes-test/error/error.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta-selftest/recipes-test/error/error.bb +1 -1
index 3c22e7cbebb..65d00a46d99 100644
@@ -2,7 +2,7 @@ SUMMARY = "Error Test case that fails on do_compile"
 DESCRIPTION = "This generates a compile time error to be used to for testing."
 LICENSE = "MIT"
 
-INHIBIT_DEFAULT_DEPS = "1"                                                                                                                                                                  
+INHIBIT_DEFAULT_DEPS = "1"
 EXCLUDE_FROM_WORLD = "1"
 
 do_compile() {
Signature · 1 line
2.19.1
#4 lore raw

PATCH 5/5 oeqa/selftest/context: Improve log file handling

In reply to Richard Purdie

The existing logfile is simply placed in the current directory. Since the test changes cwd to BUILDDIR, the symlink to the log can be placed in an invalid directory. We also see trackbacks if the symlink is invalid.

Improve things by:

* Placing logs in LOG_DIR (or BUILDDIR if unset).
* Using a full path to the log meaning the log and link are placed in the same directory.
* Using lexists instead of exists so invalid symlinks are handled correctly.

---
 meta/lib/oeqa/selftest/context.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
meta/lib/oeqa/selftest/context.py +8 -3
index dab72688299..c5212903276 100644
@@ -101,10 +101,15 @@ class OESelftestTestContextExecutor(OETestContextExecutor):
 
     def _process_args(self, logger, args):
         args.test_start_time = time.strftime("%Y%m%d%H%M%S")
-        args.output_log = '%s-results-%s.log' % (self.name, args.test_start_time)
         args.test_data_file = None
         args.CASES_PATHS = None
 
+        bbvars = get_bb_vars()
+        logdir = os.environ.get("BUILDDIR")
+        if 'LOG_DIR' in bbvars:
+            logdir = bbvars['LOG_DIR']
+        args.output_log = logdir + '/%s-results-%s.log' % (self.name, args.test_start_time)
+
         super(OESelftestTestContextExecutor, self)._process_args(logger, args)
 
         if args.list_modules:
@@ -114,7 +119,7 @@ class OESelftestTestContextExecutor(OETestContextExecutor):
         elif args.list_tests:
             args.list_tests = 'name'
 
-        self.tc_kwargs['init']['td'] = get_bb_vars()
+        self.tc_kwargs['init']['td'] = bbvars
         self.tc_kwargs['init']['machines'] = self._get_available_machines()
 
         builddir = os.environ.get("BUILDDIR")
@@ -304,7 +309,7 @@ class OESelftestTestContextExecutor(OETestContextExecutor):
 
             output_link = os.path.join(os.path.dirname(args.output_log),
                     "%s-results.log" % self.name)
-            if os.path.exists(output_link):
+            if os.path.lexists(output_link):
                 os.remove(output_link)
             os.symlink(args.output_log, output_link)
 
Signature · 1 line
2.19.1