Skip to contentSkip to conversation

Fix setUp and tearDown for runtime tests

PATCH New [email protected] 1 participant 3 messages Oct 15, 2015

lore
Share & tools
lore
#0 lore raw

cover Fix setUp and tearDown for runtime tests

From: Mariano Lopez <[email protected]>

Some runtime tests will overwrite the setUp and tearDown methods and this will cause the parent's method to not run at all. These changes will fix the setUp and tearDown methods for the child classes.

The following changes since commit d302c98822efe2cb78a63b620aed1b94b4ed4a68:

bitbake: toaster: Fix missing tooltips from layers on project configuration page (2015-10-13 15:35:49 +0300)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib mariano/bug8465
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=mariano/bug8465

Mariano Lopez (2):
oetest: Add tearDownLocal class
oeqa/runtime: Fix setUp and tearDown methods

 meta/lib/oeqa/oetest.py               | 6 ++++++
 meta/lib/oeqa/runtime/_ptest.py       | 2 +-
 meta/lib/oeqa/runtime/date.py         | 4 ++--
 meta/lib/oeqa/runtime/kernelmodule.py | 4 ++--
 meta/lib/oeqa/runtime/scanelf.py      | 2 +-
 5 files changed, 12 insertions(+), 6 deletions(-)
Signature · 1 line
1.8.4.5
#1 lore raw

PATCH 1/2 oetest: Add tearDownLocal class

From: Mariano Lopez <[email protected]>

In the current state there are some runtime test that don't run the tearDown method fromm oeRuntimeTest class because the tearDown class is overwritten in the child class.

This change adds tearDownLocal method in oeRuntimeTest class that will run after tearDown. This method can be overwritten in the child classes to implement specific test functionality.

[YOCTO #8465]

---
 meta/lib/oeqa/oetest.py | 6 ++++++
 1 file changed, 6 insertions(+)
meta/lib/oeqa/oetest.py +6 -0
index e3bbc46..6f9edec 100644
@@ -196,6 +196,12 @@ class oeRuntimeTest(oeTest):
             print ("%s dump data stored in %s" % (self._testMethodName,
                      self.tc.host_dumper.dump_dir))
 
+        self.tearDownLocal()
+
+    # Method to be run after tearDown and implemented by child classes
+    def tearDownLocal(self):
+        pass
+
     #TODO: use package_manager.py to install packages on any type of image
     def install_packages(self, packagelist):
         for package in packagelist:
Signature · 1 line
1.8.4.5
#2 lore raw

PATCH 2/2 oeqa/runtime: Fix setUp and tearDown methods

In reply to [email protected]

From: Mariano Lopez <[email protected]>

Currently some of the runtime test overwrites the setUp and tearDown methods provided by oeRuntimeTest, this will avoid some checks required when running the test suit.

This patch changes the setUp and tearDown methods for their local counterparts, so when these tests are called, it will run the parent setUp and tearDown and also the local ones.

[YOCTO #8465]

---
 meta/lib/oeqa/runtime/_ptest.py       | 2 +-
 meta/lib/oeqa/runtime/date.py         | 4 ++--
 meta/lib/oeqa/runtime/kernelmodule.py | 4 ++--
 meta/lib/oeqa/runtime/scanelf.py      | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)
meta/lib/oeqa/runtime/_ptest.py +1 -1
index 81c9c43..0621028 100644
@@ -98,7 +98,7 @@ class PtestRunnerTest(oeRuntimeTest):
 
         return complementary_pkgs.split()
 
-    def setUp(self):
+    def setUpLocal(self):
         self.ptest_log = os.path.join(oeRuntimeTest.tc.d.getVar("TEST_LOG_DIR",True), "ptest-%s.log" % oeRuntimeTest.tc.d.getVar('DATETIME', True))
 
     @skipUnlessPassed('test_ssh')
meta/lib/oeqa/runtime/date.py +2 -2
index 3a8fe84..447987e 100644
@@ -4,11 +4,11 @@ import re
 
 class DateTest(oeRuntimeTest):
 
-    def setUp(self):
+    def setUpLocal(self):
         if oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager", True) == "systemd":
             self.target.run('systemctl stop systemd-timesyncd')
 
-    def tearDown(self):
+    def tearDownLocal(self):
         if oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager", True) == "systemd":
             self.target.run('systemctl start systemd-timesyncd')
 
meta/lib/oeqa/runtime/kernelmodule.py +2 -2
index 2e81720..38ca184 100644
@@ -10,7 +10,7 @@ def setUpModule():
 
 class KernelModuleTest(oeRuntimeTest):
 
-    def setUp(self):
+    def setUpLocal(self):
         self.target.copy_to(os.path.join(oeRuntimeTest.tc.filesdir, "hellomod.c"), "/tmp/hellomod.c")
         self.target.copy_to(os.path.join(oeRuntimeTest.tc.filesdir, "hellomod_makefile"), "/tmp/Makefile")
 
@@ -30,5 +30,5 @@ class KernelModuleTest(oeRuntimeTest):
             (status, output) = self.target.run(cmd, 900)
             self.assertEqual(status, 0, msg="\n".join([cmd, output]))
 
-    def tearDown(self):
+    def tearDownLocal(self):
         self.target.run('rm -f /tmp/Makefile /tmp/hellomod.c')
meta/lib/oeqa/runtime/scanelf.py +1 -1
index 43a024a..67e02ff 100644
@@ -8,7 +8,7 @@ def setUpModule():
 
 class ScanelfTest(oeRuntimeTest):
 
-    def setUp(self):
+    def setUpLocal(self):
         self.scancmd = 'scanelf --quiet --recursive --mount --ldpath --path'
 
     @testcase(966)
Signature · 1 line
1.8.4.5