summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/tests/utils.py')
-rw-r--r--bitbake/lib/bb/tests/utils.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/utils.py b/bitbake/lib/bb/tests/utils.py
index 7c50b1d786..677b3872ba 100644
--- a/bitbake/lib/bb/tests/utils.py
+++ b/bitbake/lib/bb/tests/utils.py
@@ -21,6 +21,7 @@
21 21
22import unittest 22import unittest
23import bb 23import bb
24import os
24 25
25class VerCmpString(unittest.TestCase): 26class VerCmpString(unittest.TestCase):
26 27
@@ -51,3 +52,52 @@ class VerCmpString(unittest.TestCase):
51 result = bb.utils.explode_dep_versions2("foo ( =1.10 )") 52 result = bb.utils.explode_dep_versions2("foo ( =1.10 )")
52 self.assertEqual(result, correctresult) 53 self.assertEqual(result, correctresult)
53 54
55 def test_vercmp_string_op(self):
56 compareops = [('1', '1', '=', True),
57 ('1', '1', '==', True),
58 ('1', '1', '!=', False),
59 ('1', '1', '>', False),
60 ('1', '1', '<', False),
61 ('1', '1', '>=', True),
62 ('1', '1', '<=', True),
63 ('1', '0', '=', False),
64 ('1', '0', '==', False),
65 ('1', '0', '!=', True),
66 ('1', '0', '>', True),
67 ('1', '0', '<', False),
68 ('1', '0', '>>', True),
69 ('1', '0', '<<', False),
70 ('1', '0', '>=', True),
71 ('1', '0', '<=', False),
72 ('0', '1', '=', False),
73 ('0', '1', '==', False),
74 ('0', '1', '!=', True),
75 ('0', '1', '>', False),
76 ('0', '1', '<', True),
77 ('0', '1', '>>', False),
78 ('0', '1', '<<', True),
79 ('0', '1', '>=', False),
80 ('0', '1', '<=', True)]
81
82 for arg1, arg2, op, correctresult in compareops:
83 result = bb.utils.vercmp_string_op(arg1, arg2, op)
84 self.assertEqual(result, correctresult, 'vercmp_string_op("%s", "%s", "%s") != %s' % (arg1, arg2, op, correctresult))
85
86 # Check that clearly invalid operator raises an exception
87 self.assertRaises(bb.utils.VersionStringException, bb.utils.vercmp_string_op, '0', '0', '$')
88
89
90class Path(unittest.TestCase):
91 def test_unsafe_delete_path(self):
92 checkitems = [('/', True),
93 ('//', True),
94 ('///', True),
95 (os.getcwd().count(os.sep) * ('..' + os.sep), True),
96 (os.environ.get('HOME', '/home/test'), True),
97 ('/home/someone', True),
98 ('/home/other/', True),
99 ('/home/other/subdir', False),
100 ('', False)]
101 for arg1, correctresult in checkitems:
102 result = bb.utils._check_unsafe_delete_path(arg1)
103 self.assertEqual(result, correctresult, '_check_unsafe_delete_path("%s") != %s' % (arg1, correctresult))