]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/serf/build/check.py
MFV r339226 (peter): Record merge of serf-1.3.9.
[FreeBSD/FreeBSD.git] / contrib / serf / build / check.py
1 #!/usr/bin/env python
2 #
3 # check.py :  Run all the test cases.
4 #
5 # ===================================================================\r
6 #   Licensed to the Apache Software Foundation (ASF) under one\r
7 #   or more contributor license agreements.  See the NOTICE file\r
8 #   distributed with this work for additional information\r
9 #   regarding copyright ownership.  The ASF licenses this file\r
10 #   to you under the Apache License, Version 2.0 (the\r
11 #   "License"); you may not use this file except in compliance\r
12 #   with the License.  You may obtain a copy of the License at\r
13\r
14 #     http://www.apache.org/licenses/LICENSE-2.0\r
15\r
16 #   Unless required by applicable law or agreed to in writing,\r
17 #   software distributed under the License is distributed on an\r
18 #   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r
19 #   KIND, either express or implied.  See the License for the\r
20 #   specific language governing permissions and limitations\r
21 #   under the License.\r
22 # ===================================================================\r
23 #
24
25 import sys
26 import glob
27 import subprocess
28 import os
29
30
31 if __name__ == '__main__':
32   # get the test directory from the commandline, if set.
33   if len(sys.argv) > 1:
34     testdir = sys.argv[1]
35   else:
36     testdir = 'test'
37
38   if len(sys.argv) > 2:
39     test_builddir = sys.argv[2]
40   else:
41     test_builddir = 'test'
42
43   # define test executable paths
44   if sys.platform == 'win32':
45     SERF_RESPONSE_EXE = 'serf_response.exe'
46     TEST_ALL_EXE = 'test_all.exe'
47   else:
48     SERF_RESPONSE_EXE = 'serf_response'
49     TEST_ALL_EXE = 'test_all'
50   SERF_RESPONSE_EXE = os.path.join(test_builddir, SERF_RESPONSE_EXE)
51   TEST_ALL_EXE = os.path.join(test_builddir, TEST_ALL_EXE)
52
53   # Find test responses and run them one by one
54   for case in glob.glob(testdir + "/testcases/*.response"):
55     print "== Testing %s ==" % (case)
56     try:
57       subprocess.check_call([SERF_RESPONSE_EXE, case])
58     except subprocess.CalledProcessError:
59       print "ERROR: test case %s failed" % (case)
60       sys.exit(1)
61
62   print "== Running the unit tests =="
63   try:
64     subprocess.check_call(TEST_ALL_EXE)
65   except subprocess.CalledProcessError:
66     print "ERROR: test(s) failed in test_all"
67     sys.exit(1)