| Practical recommendations for testing applications working with NTFS and FAT file systems |
|
|
|
| Friday, 31 July 2009 14:08 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
In this article we will talk about the file systems and files, but the most attention will be focused on the key points of testing of software that works with NTFS and FAT file systems. At the end we will give our check list for testing of software, working with the FAT and NTFS file systems - we hope that it will help you in development of testing plan for your software.
Written by: Table of Content 1. Introduction
1. IntroductionFile system is a part of the operating system. All necessary information is stored in files which we work with. So corrupted or disappeared without trace file makes us, at least, not very happy. Thus, if the developed software does not handle the storing of user information then it is synonymous to failure. In this article we will talk about the file systems and files, but the most attention will be focused on the key moments of testing of software that works with them. At the end we will give our check list for testing of software, working with the FAT and NTFS file systems - we hope that it will help you in development of testing plan for your software. For example:
2. Testing of applications workings with the file systemsIn the internet - and not only there - you can find a lot of sources on the file systems describing their type, structure, history and features. Therefore let’s believe that all readers have such knowledge. First let’s define the basic principle in our testing as following: the result of all actions must be the same to the one obtained when the operating system works without us. We can work better, but never worse. As experience shows, the operations are the first that occur when we start talking about the file systems and files. It is not difficult to list them: to create, copy, move, rename, modify and delete. Exactly this list will help us in testing. 2.1 Creation of the file systemOur testing starts where the file system is created, namely in the moment of disk formatting. During this process user chooses the system to be created: FAT or NTFS. Pay attention that all of disks are formatted with a standard (by default) cluster size.
Figure 1 Formatting dialog form Thus, we must check:
Figure 2 NTFS disk properties form This option also creates additional test surroundings - compressed\ not compressed NTFS disk - for testing of file operations.
2.2 Files\Folders and work with themVerification of file operations is the essential part of testing of software with the file systems. We will mark that talking about the file systems and files we do not mention the folders but always have them in mind. There are not a lot of file operation: it’s just reading and writing. But they look differently for user: create, copy, move, rename and delete a file(s)\ folder(s). Therefore we will test:
Take into account (!) the fact that an operation depends on the application that executes it, therefore provide yourself with a few file managers, not only Windows explorer. Let’s continue testing. Each file has a lot of properties. And if not all then many of them should be checked. 2.3 Properties of files and foldersProperties of files and folders have a lot in common, but there are differences. We test:
For example: Test1.txt
For example: Testing is the most exiting activities in the World.txt
Now let us take into account a specialty of folders: there can be subfolders. So we get additional tests on work with the subfolders. But what number of subfolders will be enough? About 10 must be enough for an ordinary user, but sometimes there are exceptions. User profile can tell more about it.
Figure 3 File properties form
Figure 4 Advanced file properties
2.4 NTFS Links.We start this section with a small piece of theoretical material. The Windows kernel supports the followings types of links:
HardLink is simply another record in the folder for this file. When hard link is created the file is not copied physically, and only appears under another name or in another place, while its old name and location remain untouched. After this moment hard link is the same to the primary record in the folder. The only difference is that the short file name is not created for the hard link, therefore it is not visible from the DOS programs. When a size or file date/time changes all corresponding records in folders are refreshed automatically. At the delete of file he does not retire physically until all of hard connections, indicative on him, will not be remote. The order of their delete of value does not have. After deleting the hard link to the recycle bin the number of links for the file remains the same. Creating hard links is possible only in the same partition where the initial file is located. NTFS since 5.0 version (Windows 2000/XP) supports symbolic links (SymLink). Folder symbolic links in Windows 2000/XP are known as «Directory junctions» - the technology that enables to represent any local folders to any other local folders. For example, if the folder D:\SYMLINK is linked to C:\WINNT\SYSTEM32 as its target, then the program addressing to D:\SYMLINK\DRIVERS will actually address to C:\WINNT\SYSTEM32\DRIVERS. Unlike hard links symbolic links not necessary address to the same partition. Thus the character links can be broken if we change the structure of partitions. Even Windows explorer is not able to work correctly with everything supported by the kernel. Therefore when testing the applications taking disk images and also different file managers you should check them for work with ntfs links. Usually there are no problems with hard links, however symbolic links sometimes behave rather strange. When testing the applications with built-in file managers you should check:
When you test applications that create disk images or mount them you should check them for link cases too. Created and mounted image should show links correctly, go to the corresponding folders following the links, including recursive ones, and should not crash at the broken links. When you test archiving and encrypting applications you should also check them with the folder containing the usual links, recursive and broken ones. The application should not crash or hang while achieving/encrypting. And links should remain working after extracting/decoding to the same partition. We can recommend the following software for working with the NTFS links: Utilities from Microsoft: mklink command was added in Windows Vista to make symbolic and hard links. Syntax and examples can be found here: http://technet.microsoft.com/en-us/library/cc753194(WS.10).aspx In Windows 2000 and higher Hard links can be created from command line by the command fsutil and its parameter hardlink. Description can be found here: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/fsutil.mspx?mfr=true Microsoft Windows Resource Kit can be used to work with junction points http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en Linkd.exe, Mountvol.exe and Delrp.exe utilities might be required for this kit – see description and examples here: http://support.microsoft.com/kb/205524 You can also use junction.exe utility from Microsoft to work with junction points. Its advantage is that you don’t have to download the whole Resource Kit. Download and description here: http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx Extensions for Explorer Additionally to all mentioned console utilities there are a number of free programs that integrate in Windows Explorer add their commands to the pop-up menus and allow to work with links of all types. In addition, they hook the Explorer calls providing normal moving/copying/deleting of the created links. NTFS Link: http://elsdoerfer.name/=ntfslink NTFS Links: http://alax.info/blog/ntfslinks Personally we recommend Link Shell Extension – it has wide functionality and detailed description: http://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html Other utilities FAR file manager (http://www.farmanager.com/) supports Hard Links and Junction Points. You can use Alt-F6 combination to create links. Junction Link Magic — easy to use free program with g\GUI to work with links except for Hard links. See it here: http://www.rekenwonder.com/linkmagic.htm 2.5 NTFS Alternative Data Streams (ADS)The alternative data streams appeared in Windows NT together with NTFS file system. It was done for providing of compatibility with HFS (old file system of Macintosh), which divided each file into the file of data and file of resources. Windows Explorer and other applications work with a standard stream and cannot read information from the alternative streams. Alternative streams are not shown in the Explorer; their size is not counted in the file size. When you copy a file to the disk with FAT system or to the network share alternative streams are not copied. They are chopped off also if you upload a file on the web server or attach it to the email. Testing To date not everybody knows about existence of ADS. Meantime, they must be taken into account when testing applications that make disk images or perform search of hidden information. While testing file managers you should check:
Testing of applications that make disk images (and also archiving and encrypting programs) requires checking that they correctly add files with ADS in the image, i.e. after mounting (extraction/decoding) of this image it is possible to browse data in the alternative streams. Creation of test data We’ll use command line to create test file. First let’s create a file in the standard stream: C:\>echo Visible text>file.txt
C:\>type file.txt
Visible text
This file can be opened in Notepad and you can see text there: Visible text. Now we can create an alternative stream in this file. To address to the alternative stream colon operator is used: C:\>echo you cannot see this text>file.txt:altstream.txt
C:\>more < file.txt:altstream.txt You cannot see this text It is also possible to see the content of alternative stream in the Notepad: C:\ notepad file.txt:altstream.txt See the size of file.txt – it is 14 byte, i.e. content of alternative stream is not counted in the file size. It is possible to create a few alternative streams for each file. An alternative stream can be attached not only to the file but also to the folder. Let’s create a folder: C:\>md folder Attach some text in the alternative stream: C:\>cd folder C:\ folder >echo Hidden text >:altstream.txt If we browse the content of the folder we can’t see hidden text: C:\ folder >dir Volume in drive C has no label. Volume Serial Number is DC9B-ABBE Directory of C:\folder 07/04/2009 10:19 AM The hidden text can be seen in the Notepad: C:\folder>notepad : altstream.txt To delete alternative streams from the file by means of standard Windows tools you can move the file to the disk with the FAT file system. Thus we can create test information as alternative streams attached to the files and folders and browse them by means of standard Windows tools. If the name of the stream is unknown we cannot address to it. To search for all streams of the file or folder Microsoft offers the simple console utility Streams.exe. To download it and learn syntax go here: http://technet.microsoft.com/en-us/sysinternals/bb897440.aspx There is also a number of GUI of utilities to work with streams. Unfortunately, basic functionality of these utilities includes only scanning a file or folder to discover ADS and deleting some of them. Not all of such programs even show content of the streams. So they are not very useful for testing purposes. We can recommend ADSTools (http://www.brothersoft.com/adstools-60658.html). This utility enables to create streams, edit, rename, delete, scan files and folders to discover ADS and has a number of other features. FAR plug-in to work with ADS is also rather useful. It enables to create streams for files and folders, browse streams of any file, delete streams etc. This plug-in is free: http://plugring.farmanager.com/cgi-bin/downld.cgi?Lang=Eng&Draw=List&Sort=Date&SelectCateg=Addons&Select=PlugIn&SelectPlugIn=234&SelectAuthor=0&SelectOther=1&SearchText= 3. Additional points from general testing principlesAnd a few words in conclusion about general things.
4. Conclusion.This theme - testing of applications workings with the file systems - is very interesting, and it’s much wider than we showed in this article. We will try to continue this theme in the following articles. On this point we say good-bye. Also we’ve added some templates of check lists which you can use for your testing. Appendix1: Check List for testing
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||










