2 # vim: ai ts=4 sts=4 et sw=4
4 # Copyright (c) 2007 Intel Corporation
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by the Free
8 # Software Foundation; version 2 of the License
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc., 59
17 # Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 import os
, re
, shutil
, sys
, tempfile
, unittest
20 sys
.path
.insert(0, '/usr/share/pdk/lib')
27 def iteration(process
):
30 # Test our base FileSystem class
31 class TestFileSystem(unittest
.TestCase
):
33 self
.workdir
= tempfile
.mkdtemp()
34 self
.filesystem_dir
= os
.path
.join(self
.workdir
, "filesystem")
35 self
.project_dir
= os
.path
.join(self
.workdir
, "projects")
36 os
.mkdir(self
.project_dir
)
37 self
.var_dir
= os
.path
.join(self
.workdir
, "var")
38 os
.mkdir(self
.var_dir
)
39 self
.platform_name
= 'unittest-platform'
40 self
.platform_root
= os
.path
.join(self
.workdir
, "platforms")
41 testPlatform
.createSamplePlatformDir(self
.platform_root
, self
.platform_name
)
43 if os
.path
.isdir(self
.workdir
):
44 shutil
.rmtree(self
.workdir
)
45 def testInstantiate(self
):
46 # Directory should not yet exist
47 self
.assert_(not os
.path
.isdir(self
.filesystem_dir
), "Wierd, directory exists")
48 filesystem
= Project
.FileSystem(self
.filesystem_dir
, iteration
)
49 def testStrRepr(self
):
50 filesystem
= Project
.FileSystem(self
.filesystem_dir
, iteration
)
51 temp
= filesystem
.__str
__()
52 temp
= filesystem
.__repr
__()
53 def testEmptyValues(self
):
54 self
.assertRaises(ValueError, Project
.FileSystem
, '', '')
55 self
.assertRaises(ValueError, Project
.Target
, '', '', '')
56 def testProjectCreation(self
):
57 sdk
= SDK
.SDK(progress_callback
= iteration
, path
= self
.workdir
, var_dir
= self
.var_dir
)
58 platform
= sdk
.platforms
[self
.platform_name
]
60 if __name__
== '__main__':
61 if len(sys
.argv
) == 2 and sys
.argv
[1] == "-v":
62 suite
= unittest
.TestLoader().loadTestsFromTestCase(TestFileSystem
)
63 unittest
.TextTestRunner(verbosity
=2).run(suite
)