1 '''lib.build.mtprocesser's unit tests.'''
2 from pathlib
import Path
4 sys
.path
= [path
for path
in sys
.path
if path
!= '']
6 # we're in yocto/tests/lib/build/
7 sys
.path
.append(str(Path(__file__
).parent
.parent
.parent
.parent
))
8 from pathlib
import Path
9 from os
.path
import exists
10 from unittest
import TestCase
11 from ya2
.build
.mtprocesser
import ProcesserMgr
14 class ProcesserMgrTests(TestCase
):
15 '''ProcesserMgr's unit tests '''
18 '''unit tests' set up'''
20 Path('./tests/%s.txt' % idx
).unlink(missing_ok
=True)
23 '''unit tests' tear down'''
26 def test_threaded(self
):
27 '''test of the threaded case'''
28 pmgr
= ProcesserMgr(2)
29 pmgr
.add('echo 1 > ./tests/1.txt')
30 pmgr
.add('echo 2 > ./tests/2.txt')
32 self
.assertTrue(exists('./tests/1.txt'))
33 self
.assertTrue(exists('./tests/2.txt'))
35 def test_nothreaded(self
):
36 '''test when we don't use threads'''
37 pmgr
= ProcesserMgr(1)
38 pmgr
.add('echo 1 > ./tests/1.txt')
40 self
.assertTrue(exists('./tests/1.txt'))