root/trunk/freewrt/tools/afdisk/test.sh

Revision 1146, 2.2 kB (checked in by n0-1, 6 years ago)

Initially imported afdisk (neither the Linux, nor the FreeBSD one).
Designed for automated hard disk partitioning it should fit perfect
for FreeWRT to provide a portable and flexible tool for paritioning
CompactFlash? disks as target devices inside a script.
Still needs some rework, anyway thanks alot to David Roetzel (the
author of afdisk).

  • Property svn:executable set to *
Line 
1 #!/bin/sh
2 # Testing procedure for testing afdisk.
3 # Every test case must provide a description (test/desc.<name>), a config file for afdisk (test/afdisk.conf.<name>)
4 # and a file listing the hard disks (test/devices.<name>).
5 # It may provide several sfdisk dumps (test/sfdisk.<device>.<name>) and scripts that are run before and after
6 # afdisk (test/before.<name> and test/after.<name>).
7 # Output is written to a log file (test/test.log.<name>)
8
9
10 LOG="test/test.log.$1"
11
12 echo "Testing afdisk"
13 echo "Testing afdisk with test $1" > $LOG
14 echo "==================================" >> $LOG
15 echo "" >> $LOG
16
17 if test -e test/desc.$1;
18 then
19         cat test/desc.$1 >> $LOG
20         echo "" >> $LOG
21 else
22         echo "No description found for test case $1" >> $LOG
23         exit 1
24 fi
25
26 if test -e test/devices.$1;
27 then 
28         DEVICES=`cat test/devices.$1`
29 else 
30         echo "Device list missing for test case $1" >> $LOG
31         exit 1
32 fi
33
34 for dev in $DEVICES; do
35         if test -e test/sfdisk.$dev.$1;
36         then
37                 sfdisk /dev/$dev < test/sfdisk.$dev.$1
38         fi
39         echo "Partitioning of $dev before using afdisk :" >> $LOG
40         echo "------------------------------------------" >> $LOG
41         sfdisk -l /dev/$dev >> $LOG
42 done
43
44 echo "Preparing the afdisk run..." >> $LOG
45 echo "---------------------------" >> $LOG
46 if test -e test/before.$1;
47 then
48         source test/before.$1
49 fi
50
51 if test -e test/afdisk.conf.$1;
52 then
53         cp afdisk.conf afdisk.conf.old
54         cp test/afdisk.conf.$1 afdisk.conf
55 else
56         echo "Warning: No afdisk.conf provides for test case $1, using previously used configuration.\n" >> $LOG
57 fi
58
59 echo "Running afdisk with the following configuration :" >> $LOG
60 echo "-------------------------------------------------" >> $LOG
61 cat afdisk.conf >> $LOG
62 echo "afdisk output :" >> $LOG
63 echo "---------------" >> $LOG
64 ./afdisk >> $LOG
65
66 if test -e test/after.$1;
67 then
68         echo "Running post-afdisk script..." >> $LOG
69         source test/after.$1
70 fi
71
72 for dev in $DEVICES; do
73         echo "Partitioning of /dev/$dev after running afdisk :" >> $LOG
74         echo "------------------------------------------------" >> $LOG
75         sfdisk -l /dev/$dev >> $LOG
76 done
77
78 if test -e afdisk.conf.old;
79 then
80         cp afdisk.conf.old afdisk.conf
81         rm afdisk.conf.old
82 fi
83
84 echo "Test run finished." >> $LOG
85 echo "Finished test run. Output was written to $LOG"
Note: See TracBrowser for help on using the browser.