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

Last change on this file was 3185, checked in by Bruno Cornec, 11 years ago

Simplify the interface of mr_getline and mr_asprintf. With 3.1 compatibility now will allow backports from this branch into 3.0

  • Property svn:eol-style set to native
File size: 2.7 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
[3141]29/* Whether we should fail immediately at first error */
30bool g_fail_immediately = FALSE;
31
[2202]32bool g_ISO_restore_mode = FALSE; /* are we in Iso Mode? */
33bool g_I_have_just_nuked = FALSE;
34char *g_biggielist_txt;
35char *g_filelist_full;
36char *g_filelist_imagedevs;
37char *g_imagedevs_restthese;
38
39char *g_mondo_cfg_file;
40
41char *g_mountlist_fname;
42char *g_mondo_home;
43
44char *g_getfacl;
45char *g_getfattr;
46
47extern char *MONDO_LOGFILE;
[2209]48extern int copy_from_src_to_dest(FILE * f_orig, FILE * f_archived, char direction);
49/* We don't have a cleanup function yet */
50void (*mr_cleanup)(void) = NULL;
[2202]51
52void main() {
53
[2234]54struct mountlist_itself *mountlist = NULL;
[2350]55struct raidlist_itself *raidlist = NULL;
56char *flaws_str = NULL;
[2204]57
[3185]58mr_asprintf(MONDO_LOGFILE,"/tmp/mrtest-mountlist.log");
[2202]59
[2234]60/* Globals */
61g_loglevel = 99;
62g_text_mode = FALSE;
63g_main_pid = getpid();
[2206]64
[2234]65if (!(mountlist = malloc(sizeof(struct mountlist_itself)))) {
66 fatal_error("Cannot malloc mountlist");
67}
68if (!(raidlist = malloc(sizeof(struct raidlist_itself)))) {
69 fatal_error("Cannot malloc raidlist");
70}
71malloc_libmondo_global_strings();
[2202]72
73setup_newt_stuff();
[3185]74mr_asprintf(g_mountlist_fname, MOUNTLIST_TEST);
[2206]75log_it("before mountlist");
[2202]76load_mountlist(mountlist, g_mountlist_fname);
[2206]77log_it("after mountlist");
[2204]78resize_mountlist_proportionately_to_suit_new_drives(mountlist);
[2206]79log_it("after resize_mountlist_proportionately_to_suit_new_drives");
[2990]80load_raidtab_into_raidlist(raidlist, RAIDTAB_TEST);
[2206]81log_it("after load_raidtab_into_raidlist");
[2204]82edit_mountlist(g_mountlist_fname, mountlist, raidlist);
[2206]83log_it("after edit_mountlist");
[2234]84
[2394]85flaws_str = evaluate_mountlist(mountlist);
[2234]86log_it("after evaluate_mountlist");
[2350]87mr_free(flaws_str);
[2235]88
[2990]89log_it("before check raidlist content");
90log_it("after check raidlist content");
91
92log_it("before create mdadm dev");
93create_raid_device_via_mdadm(raidlist,"/dev/md0",FALSE);
[2991]94create_raid_device_via_mdadm(raidlist,"/dev/md1",FALSE);
[2990]95log_it("after create mdadm dev");
96
[2991]97free(mountlist);
98free(raidlist);
[2235]99mr_free(MONDO_LOGFILE);
[2991]100mr_free(g_mountlist_fname);
[2204]101exit(0);
[2202]102}
Note: See TracBrowser for help on using the repository browser.