source: MondoRescue/branches/3.0/mondo/test/test-mountlist.c@ 2991

Last change on this file since 2991 was 2991, checked in by Bruno Cornec, 12 years ago
  • Fix #596 for good as well as #473 and #500: now mondorestore will recreate correctly md devices with their original UUIDs and original metadata format.
  • Property svn:eol-style set to native
File size: 2.6 KB
RevLine 
[2211]1/*
2 * $Id$
3 *
4 * Test program for mountlist management at restore time
[2990]5 * Can be used on host system with valgrind easier than with mondorestore
[2211]6 */
[2202]7#include <stdio.h>
8#include "my-stuff.h"
[2211]9#include "mr_mem.h"
[2202]10#include "../common/mondostructures.h"
11#include "../common/libmondo.h"
12#include "../mondorestore/mondorestore.h"
[2204]13#include "../mondorestore/mr-externs.h"
[2202]14
[2990]15#define RAIDTAB_TEST "/tmp/raidtab"
16#define MOUNTLIST_TEST "/tmp/mountlist.txt"
17
[2202]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
29bool g_ISO_restore_mode = FALSE; /* are we in Iso Mode? */
30bool g_I_have_just_nuked = FALSE;
31char *g_isodir_device;
32char *g_isodir_format;
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;
[2209]47extern int copy_from_src_to_dest(FILE * f_orig, FILE * f_archived, char direction);
48/* We don't have a cleanup function yet */
49void (*mr_cleanup)(void) = NULL;
[2202]50
51void main() {
52
[2234]53struct mountlist_itself *mountlist = NULL;
[2350]54struct raidlist_itself *raidlist = NULL;
55char *flaws_str = NULL;
[2204]56
[2234]57mr_asprintf(&MONDO_LOGFILE,"/tmp/mrtest-mountlist.log");
[2202]58
[2234]59/* Globals */
60g_loglevel = 99;
61g_text_mode = FALSE;
62g_main_pid = getpid();
[2206]63
[2234]64if (!(mountlist = malloc(sizeof(struct mountlist_itself)))) {
65 fatal_error("Cannot malloc mountlist");
66}
67if (!(raidlist = malloc(sizeof(struct raidlist_itself)))) {
68 fatal_error("Cannot malloc raidlist");
69}
70malloc_libmondo_global_strings();
[2202]71
72setup_newt_stuff();
[2990]73mr_asprintf(&g_mountlist_fname, MOUNTLIST_TEST);
[2206]74log_it("before mountlist");
[2202]75load_mountlist(mountlist, g_mountlist_fname);
[2206]76log_it("after mountlist");
[2204]77resize_mountlist_proportionately_to_suit_new_drives(mountlist);
[2206]78log_it("after resize_mountlist_proportionately_to_suit_new_drives");
[2990]79load_raidtab_into_raidlist(raidlist, RAIDTAB_TEST);
[2206]80log_it("after load_raidtab_into_raidlist");
[2204]81edit_mountlist(g_mountlist_fname, mountlist, raidlist);
[2206]82log_it("after edit_mountlist");
[2234]83
[2394]84flaws_str = evaluate_mountlist(mountlist);
[2234]85log_it("after evaluate_mountlist");
[2350]86mr_free(flaws_str);
[2235]87
[2990]88log_it("before check raidlist content");
89log_it("after check raidlist content");
90
91log_it("before create mdadm dev");
92create_raid_device_via_mdadm(raidlist,"/dev/md0",FALSE);
[2991]93create_raid_device_via_mdadm(raidlist,"/dev/md1",FALSE);
[2990]94log_it("after create mdadm dev");
95
[2991]96free(mountlist);
97free(raidlist);
[2235]98mr_free(MONDO_LOGFILE);
[2991]99mr_free(g_mountlist_fname);
[2204]100exit(0);
[2202]101}
Note: See TracBrowser for help on using the repository browser.