+Specific user error for loading MS Cabinet files (*.??_).
[captive.git] / src / install / acquire / compatibility-test.sh
1 #! /bin/sh
2
3 # $Id$
4 # Test compatibility of the "ntfs.sys" and "ntoskrnl.exe" files.
5 # Copyright (C) 2005 Jan Kratochvil <project-captive@jankratochvil.net>
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; exactly version 2 of June 1991 is required
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
20
21 # Example result:
22 # <!--
23 #  - Test of ntfs.sys and ntoskrnl.exe compatibility:
24 #  - export_fail means: Export not found for: %d:%s
25 #  - 9499==ntfs(5+extra(2))*ntoskrnl(1352+extra(5))==export_fail(2130)+ok(7369)
26 #  -->
27
28
29 set -e
30 #set -x
31
32 # Directory containing /ntfs.sys/* and /ntoskrnl.exe/* files to test. 
33 out="$1"
34
35 # Second directory containing files exactly like $out; appended.
36 out_extra="$2"
37
38 # Binary regular file containing NTFS image with >=1500k of free space.
39 # This file is never modified.
40 image="$3"
41
42
43 test -d "$out"
44 test -d "$out_extra"
45 test -f "$image"
46
47 # Test commit() at the written 1MB:
48 head -qc 1500k /dev/urandom >/tmp/captive-sanity-orig.bin
49 rm -rf /tmp/captive-sanity-module
50 mkdir /tmp/captive-sanity-module
51
52 : >/tmp/captive-sanity-out-all
53
54 count_ntfs=`    echo $out/ntfs.sys/*     $out_extra/ntfs.sys/*    |tr ' ' '\n'|wc -l`
55 count_ntoskrnl=`echo $out/ntoskrnl.exe/* $out_extra/ntoskrnl.exe/*|tr ' ' '\n'|wc -l`
56 count_combo=$[$count_ntfs*$count_ntoskrnl]
57
58 total_passed=0
59 total_export=0
60 total_error=0
61 total_ok=0
62
63 cat <<HERE >/tmp/captive-sanity-command
64 put /tmp/captive-sanity-orig.bin sanity.bin
65 get sanity.bin /tmp/captive-sanity-copy.bin
66 quit
67 HERE
68
69 for ntfs_sys     in $out/ntfs.sys/*     $out_extra/ntfs.sys/*    ;do
70 rm -f /tmp/captive-sanity-module/ntfs.sys
71 ln $ntfs_sys /tmp/captive-sanity-module/ntfs.sys
72
73 for ntoskrnl_exe in $out/ntoskrnl.exe/* $out_extra/ntoskrnl.exe/*;do
74 rm -f /tmp/captive-sanity-module/ntoskrnl.exe
75 ln $ntoskrnl_exe /tmp/captive-sanity-module/ntoskrnl.exe
76
77 rm -f /tmp/captive-sanity-copy.bin
78 set +e
79 ../../client/cmdline/captive-cmdline </tmp/captive-sanity-command \
80                 --sandbox-server="./src/client/sandbox-server/captive-sandbox-server --setuid=- --setgid=- --chroot=- --no-rlimit" \
81                 --disk --blind \
82                 --filesystem=/tmp/captive-sanity-module/ntfs.sys \
83                 --load-module=/tmp/captive-sanity-module/ntoskrnl.exe \
84                 "$image" \
85                 &>/tmp/captive-sanity-out
86 error=$?
87 set -e
88 if grep -q 'Export not found for: ' /tmp/captive-sanity-out;then
89         total_export=$[$total_export+1]
90 elif [ $error -ne 0 ];then
91         total_error=$[$total_error+1]
92         cat /tmp/captive-sanity-out
93         cat <<HERE >>/tmp/captive-sanity-out-all
94 --------
95 ntfs.sys=$ntfs_sys
96 ntoskrnl.exe=$ntoskrnl_exe
97 HERE
98         cat /tmp/captive-sanity-out >>/tmp/captive-sanity-out-all
99 else
100         cmp /tmp/captive-sanity-orig.bin /tmp/captive-sanity-copy.bin
101         total_ok=$[$total_ok+1]
102 fi
103 rm -f /tmp/captive-sanity-copy.bin
104
105 total_passed=$[$total_passed+1]
106 echo "done: $total_passed of $count_combo [total_export=$total_export total_error=$total_error total_ok=$total_ok]"
107
108 done
109 done 2>&1 | grep -v 'sanity: line .*: .* Aborted.*captive-cmdline'
110
111 rm -rf /tmp/captive-sanity-module
112 rm -f /tmp/captive-sanity-orig.bin
113 rm -f /tmp/captive-sanity-command
114
115 echo "--------"
116 cat /tmp/captive-sanity-out-all
117
118 echo "--------"
119 echo /tmp/captive-sanity-out-all
120
121 # Do not: echo "total_export=$total_export"
122 #         echo "total_error=$total_error"
123 #         echo "total_ok=$total_ok"
124 # as the variables will not pass out of the 'for...done' loop above.