Blame build/check.py

Packit 3adb1e
#!/usr/bin/env python
Packit 3adb1e
#
Packit 3adb1e
# check.py :  Run all the test cases.
Packit 3adb1e
#
Packit 3adb1e
# ===================================================================
Packit 3adb1e
#   Licensed to the Apache Software Foundation (ASF) under one
Packit 3adb1e
#   or more contributor license agreements.  See the NOTICE file
Packit 3adb1e
#   distributed with this work for additional information
Packit 3adb1e
#   regarding copyright ownership.  The ASF licenses this file
Packit 3adb1e
#   to you under the Apache License, Version 2.0 (the
Packit 3adb1e
#   "License"); you may not use this file except in compliance
Packit 3adb1e
#   with the License.  You may obtain a copy of the License at
Packit 3adb1e
# 
Packit 3adb1e
#     http://www.apache.org/licenses/LICENSE-2.0
Packit 3adb1e
# 
Packit 3adb1e
#   Unless required by applicable law or agreed to in writing,
Packit 3adb1e
#   software distributed under the License is distributed on an
Packit 3adb1e
#   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Packit 3adb1e
#   KIND, either express or implied.  See the License for the
Packit 3adb1e
#   specific language governing permissions and limitations
Packit 3adb1e
#   under the License.
Packit 3adb1e
# ===================================================================
Packit 3adb1e
#
Packit 3adb1e
Packit 3adb1e
import sys
Packit 3adb1e
import glob
Packit 3adb1e
import subprocess
Packit 3adb1e
import os
Packit 3adb1e
Packit 3adb1e
Packit 3adb1e
if __name__ == '__main__':
Packit 3adb1e
  # get the test directory from the commandline, if set.
Packit 3adb1e
  if len(sys.argv) > 1:
Packit 3adb1e
    testdir = sys.argv[1]
Packit 3adb1e
  else:
Packit 3adb1e
    testdir = 'test'
Packit 3adb1e
Packit 3adb1e
  if len(sys.argv) > 2:
Packit 3adb1e
    test_builddir = sys.argv[2]
Packit 3adb1e
  else:
Packit 3adb1e
    test_builddir = 'test'
Packit 3adb1e
Packit 3adb1e
  # define test executable paths
Packit 3adb1e
  if sys.platform == 'win32':
Packit 3adb1e
    SERF_RESPONSE_EXE = 'serf_response.exe'
Packit 3adb1e
    TEST_ALL_EXE = 'test_all.exe'
Packit 3adb1e
  else:
Packit 3adb1e
    SERF_RESPONSE_EXE = 'serf_response'
Packit 3adb1e
    TEST_ALL_EXE = 'test_all'
Packit 3adb1e
  SERF_RESPONSE_EXE = os.path.join(test_builddir, SERF_RESPONSE_EXE)
Packit 3adb1e
  TEST_ALL_EXE = os.path.join(test_builddir, TEST_ALL_EXE)
Packit 3adb1e
Packit 3adb1e
  # Find test responses and run them one by one
Packit 3adb1e
  for case in glob.glob(testdir + "/testcases/*.response"):
Packit 3adb1e
    print "== Testing %s ==" % (case)
Packit 3adb1e
    try:
Packit 3adb1e
      subprocess.check_call([SERF_RESPONSE_EXE, case])
Packit 3adb1e
    except subprocess.CalledProcessError:
Packit 3adb1e
      print "ERROR: test case %s failed" % (case)
Packit 3adb1e
      sys.exit(1)
Packit 3adb1e
Packit 3adb1e
  print "== Running the unit tests =="
Packit 3adb1e
  try:
Packit 3adb1e
    subprocess.check_call(TEST_ALL_EXE)
Packit 3adb1e
  except subprocess.CalledProcessError:
Packit 3adb1e
    print "ERROR: test(s) failed in test_all"
Packit 3adb1e
    sys.exit(1)