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
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"
[3879]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 *);
[2202]18
[2990]19#define RAIDTAB_TEST "/tmp/raidtab"
20#define MOUNTLIST_TEST "/tmp/mountlist.txt"
21
[2202]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
[3141]30/* Whether we should fail immediately at first error */
31bool g_fail_immediately = FALSE;
32
[2202]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;
[3819]43char *g_mondo_home = NULL;
[2202]44
[3819]45char *g_getfacl;
46char *g_getfattr;
[2202]47
48extern char *MONDO_LOGFILE;
[2209]49extern int copy_from_src_to_dest(FILE * f_orig, FILE * f_archived, char direction);
[3374]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
[2209]55/* We don't have a cleanup function yet */
56void (*mr_cleanup)(void) = NULL;
[2202]57
[3374]58int main() {
[2202]59
[2234]60struct mountlist_itself *mountlist = NULL;
[2350]61struct raidlist_itself *raidlist = NULL;
62char *flaws_str = NULL;
[2204]63
[3825]64mr_asprintf(MONDO_LOGFILE,"%s","/tmp/mrtest-mountlist.log");
[2202]65
[2234]66/* Globals */
67g_loglevel = 99;
68g_text_mode = FALSE;
69g_main_pid = getpid();
[2206]70
[2234]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();
[2202]78
79setup_newt_stuff();
[3825]80mr_asprintf(g_mountlist_fname, "%s", MOUNTLIST_TEST);
[2206]81log_it("before mountlist");
[2202]82load_mountlist(mountlist, g_mountlist_fname);
[2206]83log_it("after mountlist");
[2204]84resize_mountlist_proportionately_to_suit_new_drives(mountlist);
[2206]85log_it("after resize_mountlist_proportionately_to_suit_new_drives");
[2990]86load_raidtab_into_raidlist(raidlist, RAIDTAB_TEST);
[2206]87log_it("after load_raidtab_into_raidlist");
[2204]88edit_mountlist(g_mountlist_fname, mountlist, raidlist);
[2206]89log_it("after edit_mountlist");
[2234]90
[2394]91flaws_str = evaluate_mountlist(mountlist);
[2234]92log_it("after evaluate_mountlist");
[2350]93mr_free(flaws_str);
[2235]94
[3566]95log_it("before write again raidlist content");
96save_raidlist_to_raidtab(raidlist, RAIDTAB_TEST".new");
97log_it("after write again raidlist content");
[2990]98
99log_it("before create mdadm dev");
[3566]100/*
[2990]101create_raid_device_via_mdadm(raidlist,"/dev/md0",FALSE);
[2991]102create_raid_device_via_mdadm(raidlist,"/dev/md1",FALSE);
[3566]103*/
[2990]104log_it("after create mdadm dev");
105
[2991]106free(mountlist);
107free(raidlist);
[2235]108mr_free(MONDO_LOGFILE);
[2991]109mr_free(g_mountlist_fname);
[2204]110exit(0);
[2202]111}
Note: See TracBrowser for help on using the repository browser.