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

Contents of /trunk/test/printutil.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2649 - (show annotations) (download) (as text)
Wed Dec 12 12:39:25 2012 UTC (5 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 /*
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 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <stdarg.h>
25
26 #include <ascend/general/platform.h>
27 #include <ascend/utilities/ascPrint.h>
28 #include <ascend/compiler/redirectFile.h>
29
30 #define f_vtable_name "asc_test_vtable"
31
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 test/redirectStdStreams.h code but not attempting that at this stage
39 -- JP, Jan 2010
40 */
41
42 static struct Asc_PrintVTable f_vtable = {f_vtable_name, vfprintf, fflush, NULL};
43 static int f_vtable_registered = FALSE;
44
45 int test_enable_printing(void){
46 if(TRUE == f_vtable_registered){
47 return TRUE;
48 }else{
49 f_vtable_registered = TRUE;
50 return (0 == Asc_PrintPushVTable(&f_vtable)) ? TRUE : FALSE ;
51 }
52 }
53
54
55 void test_disable_printing(void){
56 if (TRUE == f_vtable_registered) {
57 f_vtable_registered = FALSE;
58 Asc_PrintRemoveVTable(f_vtable_name);
59 }
60 }
61
62
63 int test_printing_enabled(void){
64 return TRUE;
65
66 return f_vtable_registered;
67 }
68

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