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

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

r5345@localhost: bruno | 2013-06-13 12:46:54 +0200

  • Solving #702 by adding a -F option which is meant to be used especially when mondoarchive is launched from cron, to avoid going into a loop where mondoarchive asks questions to the admin, where they cannot be answerd, which fills the logs and the underlying file system. With -F mondoarchive will exits at the first interaction request instead.
  • Property svn:eol-style set to native
File size: 2.7 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_biggielist_txt;
37char *g_filelist_full;
38char *g_filelist_imagedevs;
39char *g_imagedevs_restthese;
40
41char *g_mondo_cfg_file;
42
43char *g_mountlist_fname;
44char *g_mondo_home;
45
46char *g_getfacl;
47char *g_getfattr;
48
49extern char *MONDO_LOGFILE;
50extern int copy_from_src_to_dest(FILE * f_orig, FILE * f_archived, char direction);
51/* We don't have a cleanup function yet */
52void (*mr_cleanup)(void) = NULL;
53
54void main() {
55
56struct mountlist_itself *mountlist = NULL;
57struct raidlist_itself *raidlist = NULL;
58char *flaws_str = NULL;
59
60mr_asprintf(&MONDO_LOGFILE,"/tmp/mrtest-mountlist.log");
61
62/* Globals */
63g_loglevel = 99;
64g_text_mode = FALSE;
65g_main_pid = getpid();
66
67if (!(mountlist = malloc(sizeof(struct mountlist_itself)))) {
68 fatal_error("Cannot malloc mountlist");
69}
70if (!(raidlist = malloc(sizeof(struct raidlist_itself)))) {
71 fatal_error("Cannot malloc raidlist");
72}
73malloc_libmondo_global_strings();
74
75setup_newt_stuff();
76mr_asprintf(&g_mountlist_fname, MOUNTLIST_TEST);
77log_it("before mountlist");
78load_mountlist(mountlist, g_mountlist_fname);
79log_it("after mountlist");
80resize_mountlist_proportionately_to_suit_new_drives(mountlist);
81log_it("after resize_mountlist_proportionately_to_suit_new_drives");
82load_raidtab_into_raidlist(raidlist, RAIDTAB_TEST);
83log_it("after load_raidtab_into_raidlist");
84edit_mountlist(g_mountlist_fname, mountlist, raidlist);
85log_it("after edit_mountlist");
86
87flaws_str = evaluate_mountlist(mountlist);
88log_it("after evaluate_mountlist");
89mr_free(flaws_str);
90
91log_it("before check raidlist content");
92log_it("after check raidlist content");
93
94log_it("before create mdadm dev");
95create_raid_device_via_mdadm(raidlist,"/dev/md0",FALSE);
96create_raid_device_via_mdadm(raidlist,"/dev/md1",FALSE);
97log_it("after create mdadm dev");
98
99free(mountlist);
100free(raidlist);
101mr_free(MONDO_LOGFILE);
102mr_free(g_mountlist_fname);
103exit(0);
104}
Note: See TracBrowser for help on using the repository browser.