4 # Test compatibility of the "ntfs.sys" and "ntoskrnl.exe" files.
5 # Copyright (C) 2005 Jan Kratochvil <project-captive@jankratochvil.net>
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
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.
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
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)
32 # Directory containing /ntfs.sys/* and /ntoskrnl.exe/* files to test.
35 # Second directory containing files exactly like $out; appended.
38 # Binary regular file containing NTFS image with >=1500k of free space.
39 # This file is never modified.
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
52 : >/tmp/captive-sanity-out-all
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]
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
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
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
77 rm -f /tmp/captive-sanity-copy.bin
79 ../../client/cmdline/captive-cmdline </tmp/captive-sanity-command \
80 --sandbox-server="./src/client/sandbox-server/captive-sandbox-server --setuid=- --setgid=- --chroot=- --no-rlimit" \
82 --filesystem=/tmp/captive-sanity-module/ntfs.sys \
83 --load-module=/tmp/captive-sanity-module/ntoskrnl.exe \
85 &>/tmp/captive-sanity-out
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
96 ntoskrnl.exe=$ntoskrnl_exe
98 cat /tmp/captive-sanity-out >>/tmp/captive-sanity-out-all
100 cmp /tmp/captive-sanity-orig.bin /tmp/captive-sanity-copy.bin
101 total_ok=$[$total_ok+1]
103 rm -f /tmp/captive-sanity-copy.bin
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]"
109 done 2>&1 | grep -v 'sanity: line .*: .* Aborted.*captive-cmdline'
111 rm -rf /tmp/captive-sanity-module
112 rm -f /tmp/captive-sanity-orig.bin
113 rm -f /tmp/captive-sanity-command
116 cat /tmp/captive-sanity-out-all
119 echo /tmp/captive-sanity-out-all
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.