/[ascend]/trunk/test/printutil.c
ViewVC logotype

Annotation of /trunk/test/printutil.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2649 - (hide annotations) (download) (as text)
Wed Dec 12 12:39:25 2012 UTC (9 years, 11 months ago) by jpye
File MIME type: text/x-csrc
File size: 2127 byte(s)
Fixing GPL header, removing postal address (rpmlint incorrect-fsf-address)
1 jds 59 /*
2     * Assert implementation override for ASCEND unit tests
3     *
4     * Copyright (C) 2005 Jerry St.Clair
5     *
6     * This file is part of the Ascend Environment.
7     *
8     * The Ascend Environment is free software; you can redistribute it
9     * and/or modify it under the terms of the GNU General Public License as
10     * published by the Free Software Foundation; either version 2 of the
11     * License, or (at your option) any later version.
12     *
13     * The Ascend Environment is distributed in hope that it will be useful,
14     * but WITHOUT ANY WARRANTY; without even the implied warranty of
15     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16     * General Public License for more details.
17     *
18     * You should have received a copy of the GNU General Public License
19 jpye 2649 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 jds 59 */
21    
22     #include <stdio.h>
23     #include <stdlib.h>
24 johnpye 451 #include <stdarg.h>
25 jds 59
26 jpye 2323 #include <ascend/general/platform.h>
27 jpye 2018 #include <ascend/utilities/ascPrint.h>
28     #include <ascend/compiler/redirectFile.h>
29 johnpye 451
30     #define f_vtable_name "asc_test_vtable"
31 jpye 2349
32     /** @NOTE
33     the problem with these functions is that they only do what they appear to do
34     when USE_ASC_PRINTF is defined in ascend/general/platform.h, which currently
35     only occurs on Windows. An alternative way to suppress debug output is via
36     error_reporter_set_callback, but this doesn't prevent ALL output, eg via
37     Asc_FPrintF or CONSOLE_DEBUG. There is also some code possibility of using the
38 jpye 2524 test/redirectStdStreams.h code but not attempting that at this stage
39 jpye 2349 -- JP, Jan 2010
40     */
41 johnpye 451
42 jds 59 static struct Asc_PrintVTable f_vtable = {f_vtable_name, vfprintf, fflush, NULL};
43     static int f_vtable_registered = FALSE;
44    
45 jpye 2349 int test_enable_printing(void){
46 jpye 2524 if(TRUE == f_vtable_registered){
47 johnpye 956 return TRUE;
48 jpye 2524 }else{
49 johnpye 956 f_vtable_registered = TRUE;
50     return (0 == Asc_PrintPushVTable(&f_vtable)) ? TRUE : FALSE ;
51     }
52 jds 59 }
53    
54    
55 jpye 2349 void test_disable_printing(void){
56 johnpye 956 if (TRUE == f_vtable_registered) {
57     f_vtable_registered = FALSE;
58     Asc_PrintRemoveVTable(f_vtable_name);
59     }
60 jds 59 }
61    
62    
63 johnpye 956 int test_printing_enabled(void){
64     return TRUE;
65    
66     return f_vtable_registered;
67 jds 59 }
68    

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22