Update contrib.
2 # Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
4 # This component and the accompanying materials are made available
5 # under the terms of the License "Eclipse Public License v1.0"
6 # which accompanies this distribution, and is available
7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 # Initial Contributors:
10 # Nokia Corporation - initial contribution.
33 my %opts = ( 'spread=i' => \$spread,
40 GetOptions(%opts) || pod2usage(2);
41 pod2usage(-exitval => 1, -verbose => 2) if $help;
44 $drive .= "/" unless ($drive =~ m/\/$/);
45 $spread = 1 if $spread < 1;
46 $depth = 1 if $depth < 1;
47 $size = 1 if $size < 1;
50 # ME : "Windows" "4.90"
51 # 2k : "Windows NT" "5.0"
52 # XP : "Windows NT" "5.1"
53 # Mac: "Darwin" "7.4.1"
54 print((uname)[0] . " v" . (uname)[2] . ":" . (uname)[3] . "\n");
56 my @folders = createfolders($drive, $spread, $depth);
58 my %digests = createfiles(\@folders, $size, $spread);
62 print "Unplug and replug the USB cable, then press enter...";
66 checkfiles(\%digests);
67 removefiles(\%digests);
68 removefolders(\@folders);
79 return unless $depth > 0;
81 for (my $i = 0; $i < $spread; $i++)
83 my $dir = sprintf("%sdir%05d/", $fbase, $i + 1);
85 createfolder($dirlist, $dir, $spread, $depth - 1);
93 $drive = "" unless defined $drive;
95 $spread = 1 unless defined $spread;
97 $depth = 1 unless defined $depth;
100 createfolder(\@dirlist, $drive, $spread, $depth);
108 for (my $i = 0; $i < $length; $i++)
110 push @list, int((91 - 65) * rand()) + 65;
112 return pack "C$length", @list;
121 open(FILE, ">$file") or warn ("Unable to open $file for writing: $!\n");
122 my $md5 = Digest::MD5->new();
125 my $data = makeblock(($length > $block) ? $block : $length);
131 return $md5->hexdigest();
138 open(FILE, $file) or warn ("Unable to open $file for reading: $!\n");
139 my $md5 = Digest::MD5->new();
140 $md5->addfile(*FILE);
142 return $md5->hexdigest();
150 $size = 1024 unless defined $size;
152 $nfiles = 1 unless defined $nfiles;
158 for (my $i = 0; $i < $nfiles; $i++)
160 my $file = sprintf("${_}file%04d.txt", $i + 1);
161 $digest{$file} = writefile($file, $size);
171 foreach (sort keys %$digests)
173 my $readDigest = readfile($_);
174 print "$_\t$digests->{$_}\t$readDigest\t" . ($digests->{$_} eq $readDigest ? "ok" : "ERROR") . "\n";
182 my @cant = grep {not unlink} (keys %$digests);
183 warn "Unable to remove @cant\n" if @cant;
194 rmtree($_) or warn "Unable to remove $_: $!\n";
200 ######################################################################
206 usbinterop1.pl - Create directories and files, read back and compare
210 usage: usbinterop1.pl [options]
216 =item --spread=<number of directories and files>
218 Spread is the number of directories and files that are created at each
219 level of the created tree. For example, a spread of three would
220 create three directories and three files in each of the directories.
221 Spread is a measure of the "bushiness" of the directory tree.
223 Default value is "3".
225 =item --depth=<directory nesting level>
227 Each directory can have subdirectories up to the limit of the depth
228 parameter. Depth is a measure of the "height" of the directory tree.
230 Default value is "1".
232 =item --size=<size of files to create>
234 The size in bytes for each test file. Be careful as the disk space
235 used is a function of this parameter as well as the depth and spread
238 total size = size*(sp^(dep+1)+sp^(dep)+sp^(dep-1)+..+sp^2)
240 Default value is "1024".
242 =item --drive=<USB drive location>
244 The path to the USB drive in which to write the files.
246 Default value is ".", the current working directory.
256 This is a simple utility to create folders and files with varying
257 levels of nesting and sizes on a USB drive, and read them back to
258 verify their contents.
260 =head2 Test Case Specification
262 TestCaseID: Interoperability_1
264 TestCaseDesc: Test Mass Storage functionality on different platforms
265 (Windows 2000/XP/ME, MacOS) (Manual test)
266 FssID: Base/emstore/1.1.1
267 FssID: Base/emstore/3.1.1
270 Connect device to a host PC. Enable MS. Start perl script on
271 PC. This script formats drive and creates several folders with
272 levels of nested folders and writes set of files to them. File sizes
273 varied from several kilobytes to several megabytes. The number of
274 folders, nest depth, number of files placed in each folder and there
275 sizes should be configurable. Then script prompt ask to unplug/plug
276 USB cable (to flash OS read cache) and then read all files back and
280 Read data from files should match with written.
284 Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.