source: MondoRescue/branches/3.1/mondo/test/test-mountlist.c@ 3161

Last change on this file since 3161 was 3161, checked in by Bruno Cornec, 11 years ago
  • Apply fixes to 3.1 tree so that at least mondo compiles again (but that branch probably doesn't work at all again).
  • Property svn:eol-style set to native
File size: 2.6 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 "../common/mondostructures.h"
11#include "../common/libmondo.h"
12#include "../mondorestore/mondorestore.h"
13#include "../mondorestore/mr-externs.h"
14
15#define RAIDTAB_TEST "/tmp/raidtab"
16#define MOUNTLIST_TEST "/tmp/mountlist.txt"
17
18extern void twenty_seconds_til_yikes(void);
19
20/* Reference to global bkpinfo */
21struct s_bkpinfo *bkpinfo;
22
23extern bool g_text_mode;
24extern FILE *g_fprep;
25extern double g_kernel_version;
26extern int g_partition_table_locked_up;
27extern int g_noof_rows;
28
29/* Whether we should fail immediately at first error */
30bool g_fail_immediately = FALSE;
31
32bool g_ISO_restore_mode = FALSE; /* are we in Iso Mode? */
33bool g_I_have_just_nuked = FALSE;
34char *g_isodir_device;
35char *g_isodir_format;
36char *g_filelist_full;
37char *g_filelist_imagedevs;
38char *g_imagedevs_restthese;
39
40char *g_mondo_home;
41
42char *g_getfacl;
43char *g_getfattr;
44
45extern char *MONDO_LOGFILE;
46extern int copy_from_src_to_dest(FILE * f_orig, FILE * f_archived, char direction);
47/* We don't have a cleanup function yet */
48void (*mr_cleanup)(int) = NULL;
49
50int main() {
51
52struct mountlist_itself *mountlist = NULL;
53struct raidlist_itself *raidlist = NULL;
54char *flaws_str = NULL;
55
56mr_asprintf(MONDO_LOGFILE,"/tmp/mrtest-mountlist.log");
57
58/* Globals */
59g_loglevel = 99;
60g_text_mode = FALSE;
61g_main_pid = getpid();
62
63if (!(mountlist = malloc(sizeof(struct mountlist_itself)))) {
64 fatal_error("Cannot malloc mountlist");
65}
66if (!(raidlist = malloc(sizeof(struct raidlist_itself)))) {
67 fatal_error("Cannot malloc raidlist");
68}
69malloc_libmondo_global_strings();
70
71setup_newt_stuff();
72log_it("before mountlist");
73load_mountlist(mountlist, MINDI_CACHE"/mountlist.txt");
74log_it("after mountlist");
75resize_mountlist_proportionately_to_suit_new_drives(mountlist);
76log_it("after resize_mountlist_proportionately_to_suit_new_drives");
77load_raidtab_into_raidlist(raidlist, RAIDTAB_TEST);
78log_it("after load_raidtab_into_raidlist");
79edit_mountlist(MINDI_CACHE"/mountlist.txt", mountlist, raidlist);
80log_it("after edit_mountlist");
81
82flaws_str = evaluate_mountlist(mountlist);
83log_it("after evaluate_mountlist");
84mr_free(flaws_str);
85
86log_it("before check raidlist content");
87log_it("after check raidlist content");
88
89log_it("before create mdadm dev");
90create_raid_device_via_mdadm(raidlist,"/dev/md0",FALSE);
91create_raid_device_via_mdadm(raidlist,"/dev/md1",FALSE);
92log_it("after create mdadm dev");
93
94free(mountlist);
95free(raidlist);
96mr_free(MONDO_LOGFILE);
97exit(0);
98}
Note: See TracBrowser for help on using the repository browser.