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

Annotation of /trunk/test/redirectStdStreams.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 59 - (hide annotations) (download) (as text)
Sun Oct 30 01:38:20 2005 UTC (18 years, 8 months ago) by jds
File MIME type: text/x-csrc
File size: 1788 byte(s)
- prototype unit test suite based on CUnit added.
- unit tests for base/generic/general and base/generic/utilites added.
- 2nd manual rework of doxygen documentation in general and utilities.
- bug fixes (mostly general & utilities) found during test development.
- added asc_assert prototype to redirect failures to Asc_Panic() and enable decoupling assertions from NDEBUG.
- some modifications of interface & implementation to facilitate testing.
- utilities/ascPrint & utilities/ascMalloc functions now always included in base libs to minimize recompilation when an interface chooses different options.
1 jds 59 /*
2     * Standard stream redirection 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 the program; if not, write to the Free Software Foundation,
20     * Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check the file named
21     * COPYING.
22     */
23    
24     #include <stdio.h>
25     #include <assert.h>
26     #include "utilities/ascConfig.h"
27     #include "redirectStdStreams.h"
28    
29     FILE *f_stderr_file = NULL;
30     FILE *f_stdin_file = NULL;
31    
32     FILE *redirect_stderr(CONST char *filename)
33     {
34     assert(NULL != filename);
35     if (NULL != f_stderr_file) {
36     fclose(f_stderr_file);
37     }
38     return (f_stderr_file = freopen(filename, "w", stderr));
39     }
40    
41     FILE *reset_stderr(void)
42     {
43     if (NULL != f_stderr_file) {
44     fclose(f_stderr_file);
45     }
46     return freopen("CON", "w", stderr);
47     }
48    
49     FILE *redirect_stdin(CONST char *filename)
50     {
51     assert(NULL != filename);
52     if (NULL != f_stdin_file) {
53     fclose(f_stdin_file);
54     }
55     return (f_stdin_file = freopen(filename, "r", stdin));
56     }
57    
58     FILE *reset_stdin(void)
59     {
60     if (NULL != f_stdin_file) {
61     fclose(f_stdin_file);
62     }
63     return freopen("CON", "r", stdin);
64     }
65    

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