source: proiecte/HadoopJUnit/hadoop-0.20.1/contrib/hod/testing/testUtil.py @ 173

Last change on this file since 173 was 120, checked in by (none), 14 years ago

Added the mail files for the Hadoop JUNit Project

  • Property svn:executable set to *
File size: 1.8 KB
Line 
1#Licensed to the Apache Software Foundation (ASF) under one
2#or more contributor license agreements.  See the NOTICE file
3#distributed with this work for additional information
4#regarding copyright ownership.  The ASF licenses this file
5#to you under the Apache License, Version 2.0 (the
6#"License"); you may not use this file except in compliance
7#with the License.  You may obtain a copy of the License at
8
9#     http://www.apache.org/licenses/LICENSE-2.0
10
11#Unless required by applicable law or agreed to in writing, software
12#distributed under the License is distributed on an "AS IS" BASIS,
13#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14#See the License for the specific language governing permissions and
15#limitations under the License.
16import unittest, os, sys, re, threading, time
17
18myDirectory = os.path.realpath(sys.argv[0])
19rootDirectory   = re.sub("/testing/.*", "", myDirectory)
20
21sys.path.append(rootDirectory)
22
23from testing.lib import BaseTestSuite
24from hodlib.Common.util import *
25from hodlib.Common.threads import simpleCommand
26
27excludes = []
28
29class test_Util(unittest.TestCase):
30
31  def testProcessStatus(self):
32    sc = simpleCommand('testsleep', 'sleep 60')
33    sc.start()
34    pid = sc.getPid()
35    while pid is None:
36      pid = sc.getPid()
37    self.assertTrue(isProcessRunning(pid))
38    sc.kill()
39    sc.wait()
40    sc.join()
41    self.assertFalse(isProcessRunning(pid))
42   
43
44class UtilTestSuite(BaseTestSuite):
45  def __init__(self):
46    # suite setup
47    BaseTestSuite.__init__(self, __name__, excludes)
48    pass
49 
50  def cleanUp(self):
51    # suite tearDown
52    pass
53
54def RunUtilTests():
55  # modulename_suite
56  suite = UtilTestSuite()
57  testResult = suite.runTests()
58  suite.cleanUp()
59  return testResult
60
61if __name__ == "__main__":
62  RunUtilTests()
Note: See TracBrowser for help on using the repository browser.