source: MondoRescue/branches/3.3/mondo/test/test-mountlist.c@ 3885

Last change on this file since 3885 was 3879, checked in by Bruno Cornec, 4 months ago

Fix all remaining compiler errors

  • Property svn:eol-style set to native
File size: 3.1 KB
Line 
1/*
2 * $Id$
3 *
4 * Test program for mountlist management at restore time
5 * Can 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 "mondostructures.h"
11#include "mondorestore.h"
12#include "libmondo-mountlist-EXT.h"
13#include "libmondo-raid-EXT.h"
14#include "libmondo-tools-EXT.h"
15#include "newt-specific-EXT.h"
16extern void resize_mountlist_proportionately_to_suit_new_drives(struct mountlist_itself *);
17extern int edit_mountlist(char *, struct mountlist_itself *, struct raidlist_itself *);
18
19#define RAIDTAB_TEST "/tmp/raidtab"
20#define MOUNTLIST_TEST "/tmp/mountlist.txt"
21
22extern void twenty_seconds_til_yikes(void);
23
24extern bool g_text_mode;
25extern FILE *g_fprep;
26extern double g_kernel_version;
27extern int g_partition_table_locked_up;
28extern int g_noof_rows;
29
30/* Whether we should fail immediately at first error */
31bool g_fail_immediately = FALSE;
32
33bool g_ISO_restore_mode = FALSE; /* are we in Iso Mode? */
34bool g_I_have_just_nuked = FALSE;
35char *g_biggielist_txt;
36char *g_filelist_full;
37char *g_filelist_imagedevs;
38char *g_imagedevs_restthese;
39
40char *g_mondo_cfg_file;
41
42char *g_mountlist_fname;
43char *g_mondo_home = NULL;
44
45char *g_getfacl;
46char *g_getfattr;
47
48extern char *MONDO_LOGFILE;
49extern int copy_from_src_to_dest(FILE * f_orig, FILE * f_archived, char direction);
50extern int create_raid_device_via_mdadm(struct raidlist_itself *raidlist, char *device, bool test);
51
52/* Reference to global bkpinfo */
53struct s_bkpinfo *bkpinfo;
54
55/* We don't have a cleanup function yet */
56void (*mr_cleanup)(void) = NULL;
57
58int main() {
59
60struct mountlist_itself *mountlist = NULL;
61struct raidlist_itself *raidlist = NULL;
62char *flaws_str = NULL;
63
64mr_asprintf(MONDO_LOGFILE,"%s","/tmp/mrtest-mountlist.log");
65
66/* Globals */
67g_loglevel = 99;
68g_text_mode = FALSE;
69g_main_pid = getpid();
70
71if (!(mountlist = malloc(sizeof(struct mountlist_itself)))) {
72 fatal_error("Cannot malloc mountlist");
73}
74if (!(raidlist = malloc(sizeof(struct raidlist_itself)))) {
75 fatal_error("Cannot malloc raidlist");
76}
77malloc_libmondo_global_strings();
78
79setup_newt_stuff();
80mr_asprintf(g_mountlist_fname, "%s", MOUNTLIST_TEST);
81log_it("before mountlist");
82load_mountlist(mountlist, g_mountlist_fname);
83log_it("after mountlist");
84resize_mountlist_proportionately_to_suit_new_drives(mountlist);
85log_it("after resize_mountlist_proportionately_to_suit_new_drives");
86load_raidtab_into_raidlist(raidlist, RAIDTAB_TEST);
87log_it("after load_raidtab_into_raidlist");
88edit_mountlist(g_mountlist_fname, mountlist, raidlist);
89log_it("after edit_mountlist");
90
91flaws_str = evaluate_mountlist(mountlist);
92log_it("after evaluate_mountlist");
93mr_free(flaws_str);
94
95log_it("before write again raidlist content");
96save_raidlist_to_raidtab(raidlist, RAIDTAB_TEST".new");
97log_it("after write again raidlist content");
98
99log_it("before create mdadm dev");
100/*
101create_raid_device_via_mdadm(raidlist,"/dev/md0",FALSE);
102create_raid_device_via_mdadm(raidlist,"/dev/md1",FALSE);
103*/
104log_it("after create mdadm dev");
105
106free(mountlist);
107free(raidlist);
108mr_free(MONDO_LOGFILE);
109mr_free(g_mountlist_fname);
110exit(0);
111}
Note: See TracBrowser for help on using the repository browser.