~chaffra/+junk/trilinos

« back to all changes in this revision

Viewing changes to cmake/utils/UnitTestHelpers.cmake

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme, Christophe Prud'homme, Johannes Ring
  • Date: 2009-12-13 12:53:22 UTC
  • mfrom: (5.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20091213125322-in0nrdjc55deqsw9
Tags: 10.0.3.dfsg-1
[Christophe Prud'homme]
* New upstream release

[Johannes Ring]
* debian/patches/libname.patch: Add prefix 'libtrilinos_' to all
  libraries. 
* debian/patches/soname.patch: Add soversion to libraries.
* debian/watch: Update download URL.
* debian/control:
  - Remove python-numeric from Build-Depends (virtual package).
  - Remove automake and autotools from Build-Depends and add cmake to
    reflect switch to CMake.
  - Add python-support to Build-Depends.
* debian/rules: 
  - Cleanup and updates for switch to CMake.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
INCLUDE(ParseVariableArguments)
 
2
INCLUDE(GlobalSet)
 
3
 
 
4
 
 
5
#
 
6
# Perform a single equality check and update overall test statistics
 
7
#
 
8
 
 
9
FUNCTION(UNITTEST_COMPARE_CONST VAR_NAME CONST_VAL)
 
10
 
 
11
  MATH( EXPR NUMRUN ${UNITTEST_OVERALL_NUMRUN}+1 )
 
12
  GLOBAL_SET(UNITTEST_OVERALL_NUMRUN ${NUMRUN})
 
13
 
 
14
  MESSAGE(
 
15
    "\nCheck:\n"
 
16
    "    ${VAR_NAME} =\n"
 
17
    "    [${${VAR_NAME}}]\n"
 
18
    "  EQUALS:\n"
 
19
    "    [${CONST_VAL}]"
 
20
    )
 
21
 
 
22
  IF ("${${VAR_NAME}}" STREQUAL "${CONST_VAL}")
 
23
    MESSAGE("  [PASSED]\n")
 
24
    MATH( EXPR NUMPASSED ${UNITTEST_OVERALL_NUMPASSED}+1 )
 
25
    GLOBAL_SET(UNITTEST_OVERALL_NUMPASSED ${NUMPASSED})
 
26
  ELSE()
 
27
    MESSAGE("  [FAILED]\n")
 
28
    GLOBAL_SET(UNITTEST_OVERALL_PASS FALSE)
 
29
  ENDIF()
 
30
 
 
31
ENDFUNCTION()
 
32
 
 
33
 
 
34
#
 
35
# Perform a series regex of given strings and update overall test statistics
 
36
#
 
37
 
 
38
FUNCTION(UNITTEST_STRING_REGEX INPUT_STRING)
 
39
 
 
40
  PARSE_ARGUMENTS(
 
41
     #prefix
 
42
     PARSE
 
43
     #lists
 
44
     "REGEX_STRINGS"
 
45
     #options
 
46
     ""
 
47
     ${ARGN}
 
48
     )
 
49
 
 
50
  FOREACH(REGEX ${PARSE_REGEX_STRINGS})
 
51
 
 
52
    MATH( EXPR NUMRUN ${UNITTEST_OVERALL_NUMRUN}+1 )
 
53
    GLOBAL_SET(UNITTEST_OVERALL_NUMRUN ${NUMRUN})
 
54
 
 
55
    STRING(REGEX MATCH "${REGEX}" REGEX_MATCH_RESULT "${INPUT_STRING}")
 
56
 
 
57
    IF (REGEX_MATCH_RESULT)
 
58
      MESSAGE("  Searching for REGEX {${REGEX}}:  [PASSED]\n")
 
59
      MATH( EXPR NUMPASSED ${UNITTEST_OVERALL_NUMPASSED}+1 )
 
60
      GLOBAL_SET(UNITTEST_OVERALL_NUMPASSED ${NUMPASSED})
 
61
    ELSE()
 
62
      MESSAGE("  Searching for REGEX {${REGEX}}:  [FAILED]\n")
 
63
      GLOBAL_SET(UNITTEST_OVERALL_PASS FALSE)
 
64
    ENDIF()
 
65
 
 
66
  ENDFOREACH()
 
67
 
 
68
ENDFUNCTION()
 
69
 
 
70
 
 
71
#
 
72
# Perform a series regex of given strings and update overall test statistics
 
73
#
 
74
 
 
75
FUNCTION(UNITTEST_FILE_REGEX  INPUT_FILE)
 
76
  MESSAGE("\nRegexing for strings in the file '${INPUT_FILE}':\n")
 
77
  FILE(READ "${INPUT_FILE}" INPUT_FILE_STRING)
 
78
  UNITTEST_STRING_REGEX("${INPUT_FILE_STRING}" ${ARGN})
 
79
ENDFUNCTION()
 
80
 
 
81
 
 
82
#
 
83
# Print final statstics from all tests and assert final pass/fail
 
84
#
 
85
 
 
86
FUNCTION(UNITTEST_FINAL_RESULT  EXPECTED_NUMPASSED)
 
87
   MESSAGE("\nFinal UnitTests Result: num_run = ${UNITTEST_OVERALL_NUMRUN}\n")
 
88
  IF (UNITTEST_OVERALL_PASS)
 
89
    IF (UNITTEST_OVERALL_NUMPASSED EQUAL ${EXPECTED_NUMPASSED})  
 
90
      MESSAGE("Final UnitTests Result: PASSED (num_passed = ${UNITTEST_OVERALL_NUMPASSED})")
 
91
    ELSE()
 
92
      MESSAGE("\nError: num_passed = ${UNITTEST_OVERALL_NUMPASSED} != num_expected = ${EXPECTED_NUMPASSED}")
 
93
      MESSAGE("\nFinal UnitTests Result: FAILED\n")
 
94
      MESSAGE(SEND_ERROR "FAIL")
 
95
    ENDIF()
 
96
  ELSE()
 
97
    MESSAGE("\nFinal UnitTests Result: FAILED\n")
 
98
  ENDIF()
 
99
ENDFUNCTION()
 
100