Module EDTestCaseParallelExecute
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 __authors__ = ["Jérôme Kieffer", "Olof Svensson"]
30 __contact__ = "Jerome.Kieffer@esrf.eu"
31 __license__ = "LGPLv3+"
32 __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
33
34 """This is the parallel Execute testing program """
35
36 import os, tempfile, types
37
38 from EDVerbose import EDVerbose
39 from EDTestCase import EDTestCase
40 from EDAssert import EDAssert
41 from EDParallelExecute import EDParallelExecute
42 from EDUtilsParallel import EDUtilsParallel
43
45 """Just a fake function that returns an empty XML string"""
46 return "<xml></xml>"
47
49 """
50 Unit & execution test for the EDParallelExecute class
51 """
52
54 EDTestCase.__init__(self, "EDTestCaseParallelExecute")
55 self.__edpluginPE = EDParallelExecute("EDPluginTestPluginFactory", fakeXML)
56
57
59 """
60 test the execution of self.movetoTempDir
61 """
62 initcwd = os.getcwd()
63 self.__edpluginPE.moveToTempDir()
64 EDAssert.equal(os.path.abspath(os.path.dirname(os.getcwd())), os.path.abspath(tempfile.gettempdir()), "Test Move to Temporary Directory...")
65 os.chdir(initcwd)
66
67
69 """
70 test the execution of detectNumberOfCPUs
71 """
72 iNbCPU = EDUtilsParallel.detectNumberOfCPUs()
73 EDVerbose.unitTest("Detection of the number of Cores: %s" % iNbCPU)
74 EDAssert.equal(types.IntType, type(iNbCPU), "Number of CPU is an integer")
75 iNbCPU = EDUtilsParallel.detectNumberOfCPUs(1)
76 EDAssert.equal(1, iNbCPU, "Limit number of CPU")
77 iNbCPU = EDUtilsParallel.detectNumberOfCPUs(100, True)
78 EDAssert.equal(100, iNbCPU, "Force number of CPU")
79
84
85
86
87 if __name__ == '__main__':
88
89 edTestCaseEDUtilsTable = EDTestCaseParallelExecute("EDTestCaseParallelExecute")
90 edTestCaseEDUtilsTable.execute()
91