summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/oescripts.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/selftest/oescripts.py')
-rw-r--r--meta/lib/oeqa/selftest/oescripts.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/oescripts.py b/meta/lib/oeqa/selftest/oescripts.py
new file mode 100644
index 0000000000..31cd50809c
--- /dev/null
+++ b/meta/lib/oeqa/selftest/oescripts.py
@@ -0,0 +1,54 @@
1import datetime
2import unittest
3import os
4import re
5import shutil
6
7import oeqa.utils.ftools as ftools
8from oeqa.selftest.base import oeSelfTest
9from oeqa.selftest.buildhistory import BuildhistoryBase
10from oeqa.utils.commands import Command, runCmd, bitbake, get_bb_var, get_test_layer
11from oeqa.utils.decorators import testcase
12
13class TestScripts(oeSelfTest):
14
15 @testcase(300)
16 def test_cleanup_workdir(self):
17 path = os.path.dirname(get_bb_var('WORKDIR', 'gzip'))
18 old_version_recipe = os.path.join(get_bb_var('COREBASE'), 'meta/recipes-extended/gzip/gzip_1.3.12.bb')
19 old_version = '1.3.12'
20 bitbake("-ccleansstate gzip")
21 bitbake("-ccleansstate -b %s" % old_version_recipe)
22 if os.path.exists(get_bb_var('WORKDIR', "-b %s" % old_version_recipe)):
23 shutil.rmtree(get_bb_var('WORKDIR', "-b %s" % old_version_recipe))
24 if os.path.exists(get_bb_var('WORKDIR', 'gzip')):
25 shutil.rmtree(get_bb_var('WORKDIR', 'gzip'))
26
27 if os.path.exists(path):
28 initial_contents = os.listdir(path)
29 else:
30 initial_contents = []
31
32 bitbake('gzip')
33 intermediary_contents = os.listdir(path)
34 bitbake("-b %s" % old_version_recipe)
35 runCmd('cleanup-workdir')
36 remaining_contents = os.listdir(path)
37
38 expected_contents = [x for x in intermediary_contents if x not in initial_contents]
39 remaining_not_expected = [x for x in remaining_contents if x not in expected_contents]
40 self.assertFalse(remaining_not_expected, msg="Not all necessary content has been deleted from %s: %s" % (path, ', '.join(map(str, remaining_not_expected))))
41 expected_not_remaining = [x for x in expected_contents if x not in remaining_contents]
42 self.assertFalse(expected_not_remaining, msg="The script removed extra contents from %s: %s" % (path, ', '.join(map(str, expected_not_remaining))))
43
44class BuildhistoryDiffTests(BuildhistoryBase):
45
46 @testcase(295)
47 def test_buildhistory_diff(self):
48 self.add_command_to_tearDown('cleanup-workdir')
49 target = 'xcursor-transparent-theme'
50 self.run_buildhistory_operation(target, target_config="PR = \"r1\"", change_bh_location=True)
51 self.run_buildhistory_operation(target, target_config="PR = \"r0\"", change_bh_location=False, expect_error=True)
52 result = runCmd("buildhistory-diff -p %s" % get_bb_var('BUILDHISTORY_DIR'))
53 expected_output = 'PR changed from "r1" to "r0"'
54 self.assertTrue(expected_output in result.output, msg="Did not find expected output: %s" % result.output)