source: MondoRescue/branches/stable/mondo/src/test/test-conf.c

Last change on this file was 1421, checked in by Bruno Cornec, 17 years ago

tests reviewed

  • Property svn:eol-style set to native
File size: 1.1 KB
Line 
1/*
2 * Test file to test the configuration file handling
3 *
4 * $Id$
5 *
6 */
7
8#include <stdio.h>
9#include <stdlib.h>
10
11#include "mr_conf.h"
12#include "mr_mem.h"
13
14int g_main_pid = 0;
15int g_buffer_pid = 0;
16
17void (*mr_cleanup)(void) = NULL;
18
19int main(void) {
20 int ret = 0;
21 int i = 0;
22 double f = 0.0;
23 char *s = NULL;
24
25 if ((ret = mr_conf_open("mondo.conf")) != 0) {
26 fprintf(stderr,"Unable to open conf file (%d)\n",ret);
27 exit(-1);
28 }
29 if ((i = mr_conf_iread("testinteger")) == 0) {
30 fprintf(stderr,"Unable to get integer\n");
31 exit(-1);
32 }
33 fprintf(stdout, "Integer : ***%d***\n",i);
34 if ((f = mr_conf_fread("testfloat")) == 0.0) {
35 fprintf(stderr,"Unable to get float\n");
36 exit(-1);
37 }
38 fprintf(stdout, "Float : ***%f***\n",f);
39 if (! (s = mr_conf_sread("teststring"))) {
40 fprintf(stderr,"Unable to get string\n");
41 exit(-1);
42 }
43 fprintf(stdout, "String : ***%s***\n",s);
44 mr_free(s);
45 if (! (s = mr_conf_sread("logfile"))) {
46 fprintf(stderr,"Unable to get string2\n");
47 exit(-1);
48 }
49 fprintf(stdout, "String2 : ***%s***\n",s);
50 mr_free(s);
51 mr_conf_close();
52 exit(0);
53}
Note: See TracBrowser for help on using the repository browser.