source: MondoRescue/branches/3.2/mondo/test/test-mountlist.c@ 3566

Last change on this file since 3566 was 3566, checked in by Bruno Cornec, 8 years ago
  • Fix a bug in mr_strip_space (end of string was on char too far)
  • Dynamic memory allocation for load_raidtab_into_raidlist and get_next_raidtab_line
  • Add a test to test_mountlist to rewrite the raitab, allowing comparison with original
  • Fix #780, #781 and #757 with a new raitab handling as a consequence
  • Property svn:eol-style set to native
File size: 2.9 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#include "../mondorestore/libmondo-mountlist-EXT.h"
15
16
17#define RAIDTAB_TEST "/tmp/raidtab"
18#define MOUNTLIST_TEST "/tmp/mountlist.txt"
19
20extern void twenty_seconds_til_yikes(void);
21
22extern bool g_text_mode;
23extern FILE *g_fprep;
24extern double g_kernel_version;
25extern int g_partition_table_locked_up;
26extern int g_noof_rows;
27
28/* Whether we should fail immediately at first error */
29bool g_fail_immediately = FALSE;
30
31bool g_ISO_restore_mode = FALSE; /* are we in Iso Mode? */
32bool g_I_have_just_nuked = FALSE;
33char *g_biggielist_txt;
34char *g_filelist_full;
35char *g_filelist_imagedevs;
36char *g_imagedevs_restthese;
37
38char *g_mondo_cfg_file;
39
40char *g_mountlist_fname;
41char *g_mondo_home;
42
43char *g_getfacl;
44char *g_getfattr;
45
46extern char *MONDO_LOGFILE;
47extern int copy_from_src_to_dest(FILE * f_orig, FILE * f_archived, char direction);
48extern int create_raid_device_via_mdadm(struct raidlist_itself *raidlist, char *device, bool test);
49
50/* Reference to global bkpinfo */
51struct s_bkpinfo *bkpinfo;
52
53/* We don't have a cleanup function yet */
54void (*mr_cleanup)(void) = NULL;
55
56int main() {
57
58struct mountlist_itself *mountlist = NULL;
59struct raidlist_itself *raidlist = NULL;
60char *flaws_str = NULL;
61
62mr_asprintf(MONDO_LOGFILE,"/tmp/mrtest-mountlist.log");
63
64/* Globals */
65g_loglevel = 99;
66g_text_mode = FALSE;
67g_main_pid = getpid();
68
69if (!(mountlist = malloc(sizeof(struct mountlist_itself)))) {
70 fatal_error("Cannot malloc mountlist");
71}
72if (!(raidlist = malloc(sizeof(struct raidlist_itself)))) {
73 fatal_error("Cannot malloc raidlist");
74}
75malloc_libmondo_global_strings();
76
77setup_newt_stuff();
78mr_asprintf(g_mountlist_fname, MOUNTLIST_TEST);
79log_it("before mountlist");
80load_mountlist(mountlist, g_mountlist_fname);
81log_it("after mountlist");
82resize_mountlist_proportionately_to_suit_new_drives(mountlist);
83log_it("after resize_mountlist_proportionately_to_suit_new_drives");
84load_raidtab_into_raidlist(raidlist, RAIDTAB_TEST);
85log_it("after load_raidtab_into_raidlist");
86edit_mountlist(g_mountlist_fname, mountlist, raidlist);
87log_it("after edit_mountlist");
88
89flaws_str = evaluate_mountlist(mountlist);
90log_it("after evaluate_mountlist");
91mr_free(flaws_str);
92
93log_it("before write again raidlist content");
94save_raidlist_to_raidtab(raidlist, RAIDTAB_TEST".new");
95log_it("after write again raidlist content");
96
97log_it("before create mdadm dev");
98/*
99create_raid_device_via_mdadm(raidlist,"/dev/md0",FALSE);
100create_raid_device_via_mdadm(raidlist,"/dev/md1",FALSE);
101*/
102log_it("after create mdadm dev");
103
104free(mountlist);
105free(raidlist);
106mr_free(MONDO_LOGFILE);
107mr_free(g_mountlist_fname);
108exit(0);
109}
Note: See TracBrowser for help on using the repository browser.