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

Last change on this file since 531 was 531, checked in by bcornec, 18 years ago

Introduction of new functions in mondorescue library to handle the new configuration files developped for mondo/mindi
As well a rudimentary test suite was developped to test these functions
valgrind usage revealed no memory leak.
These 2 methods will be further extended to the rest of mr.

File size: 869 bytes
Line 
1/*
2 * Test file to test the configuration file handling
3 *
4 * $Id$
5 *
6 */
7
8#include <stdio.h>
9#include "my-stuff.h"
10#include "libmondo-conf.h"
11
12int g_main_pid = 0;
13int g_buffer_pid = 0;
14
15main() {
16 int ret = 0;
17 int i = 0;
18 double f = 0.0;
19 char *s = NULL;
20
21 if ((ret = mrconf_open("mondo.conf")) != 0) {
22 fprintf(stderr,"Unable to open conf file (%d)\n",ret);
23 exit(-1);
24 }
25 if ((i = mrconf_iread("testinteger")) == 0) {
26 fprintf(stderr,"Unable to get integer\n");
27 exit(-1);
28 }
29 fprintf(stdout, "Integer : ***%d***\n",i);
30 if ((f = mrconf_fread("testfloat")) == 0.0) {
31 fprintf(stderr,"Unable to get float\n");
32 exit(-1);
33 }
34 fprintf(stdout, "Float : ***%f***\n",f);
35 if (! (s = mrconf_sread("teststring"))) {
36 fprintf(stderr,"Unable to get string\n");
37 exit(-1);
38 }
39 fprintf(stdout, "String : ***%s***\n",s);
40 paranoid_free(s);
41 mrconf_close();
42 exit(0);
43}
Note: See TracBrowser for help on using the repository browser.