1 /* 2 * Check: a unit test framework for C 3 * Copyright (C) 2001,2002 Arien Malec 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library; if not, write to the 17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 * Boston, MA 02111-1307, USA. 19 */ 20 21 #ifndef CHECK_IMPL_H 22 #define CHECK_IMPL_H 23 24 25 /* This header should be included by any module that needs 26 to know the implementation details of the check structures 27 Include stdio.h & list.h before this header 28 */ 29 30 typedef struct TF { 31 TFun fn; 32 int loop_start; 33 int loop_end; 34 const char *name; 35 int signal; 36 unsigned char allowed_exit_value; 37 } TF; 38 39 struct Suite { 40 const char *name; 41 List *tclst; /* List of test cases */ 42 }; 43 44 typedef struct Fixture 45 { 46 int ischecked; 47 SFun fun; 48 } Fixture; 49 50 struct TCase { 51 const char *name; 52 int timeout; 53 List *tflst; /* list of test functions */ 54 List *unch_sflst; 55 List *unch_tflst; 56 List *ch_sflst; 57 List *ch_tflst; 58 }; 59 60 typedef struct TestStats { 61 int n_checked; 62 int n_failed; 63 int n_errors; 64 } TestStats; 65 66 struct TestResult { 67 enum test_result rtype; /* Type of result */ 68 enum ck_result_ctx ctx; /* When the result occurred */ 69 char *file; /* File where the test occured */ 70 int line; /* Line number where the test occurred */ 71 int iter; /* The iteration value for looping tests */ 72 const char *tcname; /* Test case that generated the result */ 73 const char *tname; /* Test that generated the result */ 74 char *msg; /* Failure message */ 75 }; 76 77 TestResult *tr_create(void); 78 void tr_reset(TestResult *tr); 79 80 enum cl_event { 81 CLINITLOG_SR, 82 CLENDLOG_SR, 83 CLSTART_SR, 84 CLSTART_S, 85 CLEND_SR, 86 CLEND_S, 87 CLSTART_T, /* A test case is about to run */ 88 CLEND_T 89 }; 90 91 typedef void (*LFun) (SRunner *, FILE*, enum print_output, 92 void *, enum cl_event); 93 94 typedef struct Log { 95 FILE *lfile; 96 LFun lfun; 97 int close; 98 enum print_output mode; 99 } Log; 100 101 struct SRunner { 102 List *slst; /* List of Suite objects */ 103 TestStats *stats; /* Run statistics */ 104 List *resultlst; /* List of unit test results */ 105 const char *log_fname; /* name of log file */ 106 const char *xml_fname; /* name of xml output file */ 107 List *loglst; /* list of Log objects */ 108 enum fork_status fstat; /* controls if suites are forked or not 109 NOTE: Don't use this value directly, 110 instead use srunner_fork_status */ 111 }; 112 113 114 void set_fork_status(enum fork_status fstat); 115 enum fork_status cur_fork_status (void); 116 117 #endif /* CHECK_IMPL_H */ 118