• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Regression.h

Go to the documentation of this file.
00001 /** @file
00002 
00003   A brief file description
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
00022  */
00023 
00024 #ifndef _Regression_h
00025 #define _Regression_h
00026 
00027 #include "libts.h"
00028 #include "Regex.h"
00029 
00030 //   Each module should provide one or more regression tests
00031 //
00032 //   An example:
00033 //
00034 //   REGRESSION_TEST(Addition)(RegressionTest *t, int atype, int *pstatus) {
00035 //     if (atype < REGRESSION_TEST_NIGHTLY) { // to expensive to do more than nightly
00036 //       *pstatus = REGRESSION_TEST_NOT_RUN;
00037 //       return;
00038 //     }
00039 //     if (1 + 1 != 2) {
00040 //       rprintf(t, "drat, 1+1 isn't 2??");
00041 //       *pstatus = REGRESSION_TEST_FAILED;
00042 //     } else
00043 //       *pstatus = REGRESSION_TEST_PASSED;
00044 //   }
00045 
00046 
00047 // status values
00048 #define REGRESSION_TEST_PASSED         1
00049 #define REGRESSION_TEST_INPROGRESS     0 // initial value
00050 #define REGRESSION_TEST_FAILED         -1
00051 #define REGRESSION_TEST_NOT_RUN        -2
00052 
00053 // regression types
00054 #define REGRESSION_TEST_NONE           0
00055 #define REGRESSION_TEST_QUICK          1
00056 #define REGRESSION_TEST_NIGHTLY        2
00057 #define REGRESSION_TEST_EXTENDED       3
00058  // use only for testing TS error handling!
00059 #define REGRESSION_TEST_FATAL          4
00060 
00061 // regression options
00062 #define REGRESSION_OPT_EXCLUSIVE       (1 << 0)
00063 
00064 struct RegressionTest;
00065 
00066 typedef void TestFunction(RegressionTest * t, int type, int *status);
00067 
00068 struct RegressionTest
00069 {
00070   const char *name;
00071   TestFunction *function;
00072   RegressionTest *next;
00073   int status;
00074   int printed;
00075   int opt;
00076 
00077   RegressionTest(const char *name_arg, TestFunction * function_arg, int aopt);
00078 
00079   static int final_status;
00080   static int ran_tests;
00081   static DFA dfa;
00082   static RegressionTest *current;
00083   static int run(char *name = NULL);
00084   static int run_some();
00085   static int check_status();
00086 };
00087 
00088 #define REGRESSION_TEST(_f) \
00089 void RegressionTest_##_f(RegressionTest * t, int atype, int *pstatus); \
00090 RegressionTest regressionTest_##_f(#_f,&RegressionTest_##_f, 0);\
00091 void RegressionTest_##_f
00092 
00093 #define EXCLUSIVE_REGRESSION_TEST(_f) \
00094 void RegressionTest_##_f(RegressionTest * t, int atype, int *pstatus); \
00095 RegressionTest regressionTest_##_f(#_f,&RegressionTest_##_f, REGRESSION_OPT_EXCLUSIVE);\
00096 void RegressionTest_##_f
00097 
00098 int rprintf(RegressionTest * t, const char *format, ...);
00099 int rperf(RegressionTest *t, const char *tag, double val);
00100 char *regression_status_string(int status);
00101 
00102 extern int regression_level;
00103 
00104 #define SignalError(_buf, _already)                                     \
00105 {                                                                       \
00106   if(_already == false) pmgmt->signalManager(MGMT_SIGNAL_CONFIG_ERROR, _buf); \
00107   _already = true;                                                      \
00108   Warning("%s", _buf);                                                  \
00109 }                                                                       \
00110 
00111 #endif /* _Regression_h */

Generated by  doxygen 1.7.1