source: MondoRescue/branches/2.2.10/mondo/test/test-mountlist.c@ 2421

Last change on this file since 2421 was 2421, checked in by Bruno Cornec, 15 years ago
  • Remove some compiler warnings on main
  • Adds function mr_chomp and mr_strip_char and use them in mr_date and call_program_and_get_last_line_of_output
  • Fix call_program_and_get_last_line_of_output to return the right result using a temp file instead of popen
  • Fix an issue in mr_getline_int in case of eof (returns now an empty string)
  • Sequencing of Init of bkpinfo reviewed
  • Property svn:eol-style set to native
File size: 2.2 KB
Line 
1/*
2 * $Id$
3 *
4 * Test program for mountlist management at restore time
5 * Cn be used on host system with valgrind easier than with mondorestore
6 */
7#include <stdio.h>
8#include "my-stuff.h"
9#include "mr_mem.h"
10#include "../common/mondostructures.h"
11#include "../common/libmondo.h"
12#include "../mondorestore/mondorestore.h"
13#include "../mondorestore/mr-externs.h"
14
15extern void twenty_seconds_til_yikes(void);
16
17/* Reference to global bkpinfo */
18struct s_bkpinfo *bkpinfo;
19
20extern bool g_text_mode;
21extern FILE *g_fprep;
22extern double g_kernel_version;
23extern int g_partition_table_locked_up;
24extern int g_noof_rows;
25
26bool g_ISO_restore_mode = FALSE; /* are we in Iso Mode? */
27bool g_I_have_just_nuked = FALSE;
28char *g_isodir_device;
29char *g_isodir_format;
30char *g_biggielist_txt;
31char *g_filelist_full;
32char *g_filelist_imagedevs;
33char *g_imagedevs_restthese;
34
35char *g_mondo_cfg_file;
36
37char *g_mountlist_fname;
38char *g_mondo_home;
39
40char *g_getfacl;
41char *g_getfattr;
42
43extern char *MONDO_LOGFILE;
44extern int copy_from_src_to_dest(FILE * f_orig, FILE * f_archived, char direction);
45/* We don't have a cleanup function yet */
46void (*mr_cleanup)(int) = NULL;
47
48int main() {
49
50struct mountlist_itself *mountlist = NULL;
51struct raidlist_itself *raidlist = NULL;
52char *flaws_str = NULL;
53
54mr_asprintf(MONDO_LOGFILE,"/tmp/mrtest-mountlist.log");
55
56/* Globals */
57g_loglevel = 99;
58g_text_mode = FALSE;
59g_main_pid = getpid();
60
61if (!(mountlist = malloc(sizeof(struct mountlist_itself)))) {
62 fatal_error("Cannot malloc mountlist");
63}
64if (!(raidlist = malloc(sizeof(struct raidlist_itself)))) {
65 fatal_error("Cannot malloc raidlist");
66}
67malloc_libmondo_global_strings();
68
69setup_newt_stuff();
70mr_asprintf(g_mountlist_fname, "/tmp/mountlist.txt");
71log_it("before mountlist");
72load_mountlist(mountlist, g_mountlist_fname);
73log_it("after mountlist");
74resize_mountlist_proportionately_to_suit_new_drives(mountlist);
75log_it("after resize_mountlist_proportionately_to_suit_new_drives");
76load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME);
77log_it("after load_raidtab_into_raidlist");
78edit_mountlist(g_mountlist_fname, mountlist, raidlist);
79log_it("after edit_mountlist");
80
81flaws_str = evaluate_mountlist(mountlist);
82log_it("after evaluate_mountlist");
83mr_free(flaws_str);
84
85mr_free(MONDO_LOGFILE);
86exit(0);
87}
Note: See TracBrowser for help on using the repository browser.