Presentation is loading. Please wait.

Presentation is loading. Please wait.

Cabinet.dll Conformance Test Wine 3 Aleksandr Liber Rizwan Kassim.

Similar presentations


Presentation on theme: "Cabinet.dll Conformance Test Wine 3 Aleksandr Liber Rizwan Kassim."— Presentation transcript:

1 Cabinet.dll Conformance Test Wine 3 Aleksandr Liber Rizwan Kassim

2 Purpose of the test Check for functional equivalence of Microsoft and WINE implementations Check for functional equivalence of Microsoft and WINE implementations Not really focusing on finding bugs, but in verifying that the WINE version outputs exactly what the Microsoft version does Not really focusing on finding bugs, but in verifying that the WINE version outputs exactly what the Microsoft version does

3 What is a Cabinet? Microsoft archive format Microsoft archive format Used in the Windows installation, Microsoft installers, and ActiveX component downloads Used in the Windows installation, Microsoft installers, and ActiveX component downloads Large Cab files can be split into groups of smaller ones and then combined back together Large Cab files can be split into groups of smaller ones and then combined back together

4 Cabinet File Format Each file is stored in a folder. A folder can have many files. Each file is stored in a folder. A folder can have many files. Files are compressed as a single unit for improved compression ratios Files are compressed as a single unit for improved compression ratios Random Access speed however is adversely affected. Random Access speed however is adversely affected. Cabinet currently supports: MSZip and LXW compression Cabinet currently supports: MSZip and LXW compression

5 Cabinet API FCI (File Compression Interface) FCICreate - Create an FCI context. FCICreate - Create an FCI context. FCIAddFile - Add a file to the cabinet being created. FCIAddFile - Add a file to the cabinet being created. FCIFlushCabinet - Complete the cabinet. FCIFlushCabinet - Complete the cabinet. FCIFlushFolder - Complete the folder and begin a new one. FCIFlushFolder - Complete the folder and begin a new one. FCIDestroy - Destroy the FCI context. FCIDestroy - Destroy the FCI context. FDI (File Decompression Interface FDICreate - Create an FDI context. FDICreate - Create an FDI context. FDIIsCabinet – Check whether or not a file is a cabinet, if it is the function returns information about it. FDIIsCabinet – Check whether or not a file is a cabinet, if it is the function returns information about it. FDICopy - Extract files from the cabinet. FDICopy - Extract files from the cabinet. FDIDestroy – Destroy the FDI context. FDIDestroy – Destroy the FDI context.

6 Callback Functions The API makes extensive use of callback functions The API makes extensive use of callback functions Most are for memory management and file I/O. Most are for memory management and file I/O. Others: Notify, Decrypt Others: Notify, Decrypt

7

8 Cabinet API in WINE FCI not implemented since the majority of operations are done with extraction FCI not implemented since the majority of operations are done with extraction FDI appears to be fully implemented. FDI appears to be fully implemented. So our decision was to focus on FDI So our decision was to focus on FDI

9 Patch Description Wine cabinet.dll FDI Conformance Test Patch Raw files available at : http://www.geekymedia.com/viewcvs/cgi/viewcvs.cgi/group3/wine/ This patch adds tests for the cabinet dll, specifically testing the functions FDICreate, FDIDestroy, FDICopy and FDIIsCabinet. As the FCI functions are still marked *FIXME* in wine, they haven't been tested. The package is self containing, allowing additional cabinet features to be tested by preparing other cabinets in the same manner that ours were. A patch of -p1 will be needed. This patch has been successfully applied to the wine tree and ran. http://www.geekymedia.com/viewcvs/cgi/viewcvs.cgi/group3/wine/

10 Files Included Modified Makefile.in(s) and configure.ac Modified Makefile.in(s) and configure.ac cabinet_fdi.c - the actual code of the test for FDI cabinet_fdi.c - the actual code of the test for FDI data.h - cabinet files and files used to make then stored in hex using C arrays data.h - cabinet files and files used to make then stored in hex using C arrays genfiles.sh - shell script that can recreate data.h, useful for expansions to the test genfiles.sh - shell script that can recreate data.h, useful for expansions to the test tvfs.h - Our virtual file system interface tvfs.h - Our virtual file system interface tvfs.c - Implementation of the above tvfs.c - Implementation of the above chexify.pl - Perl script that does the actual translation of a binary file to an array of hexadecimal values and creates C code out of it. chexify.pl - Perl script that does the actual translation of a binary file to an array of hexadecimal values and creates C code out of it.

11 Running of the Test TestCreate() TestCreate() Tests creation of an FDI context Tests creation of an FDI context Just uses allocation functions Just uses allocation functions TestInfo() TestInfo() “Creates” simple.cab, opens and reads it. Checks CABINFO struct. Repeat for complex.cab “Creates” simple.cab, opens and reads it. Checks CABINFO struct. Repeat for complex.cab TestCopy() TestCopy() “Creates” simple.cab, open, reads it. Enumerates files in cabinet and prints list. Extracts all files in cabinet to virtual file system and byte-compares them with reference. Repeat for complex. “Creates” simple.cab, open, reads it. Enumerates files in cabinet and prints list. Extracts all files in cabinet to virtual file system and byte-compares them with reference. Repeat for complex. TestDestroy() TestDestroy() Destroys FDI context Destroys FDI context Only fails if its pointed to a non context Only fails if its pointed to a non context

12 Compilation Options To build outside Wine tree, compile with cl -DSTANDALONE -D_X86_ tvfs.c cabinet_fdi.c FDI.lib To build outside Wine tree, compile with cl -DSTANDALONE -D_X86_ tvfs.c cabinet_fdi.c FDI.lib For verbose output in the test, compile with -DVERBOSE For verbose output in the test, compile with -DVERBOSE To enable debugging output in the virtual file system use -DTVFS_DEBUG To enable debugging output in the virtual file system use -DTVFS_DEBUG

13 Virtual File System TVFS-trivial virtual file system TVFS-trivial virtual file system Provides virtual versions of the file system calls needed by FDI: open, read, write, lseek, close. Provides virtual versions of the file system calls needed by FDI: open, read, write, lseek, close. Each returns the same return values as the corresponding _open, _read, _write, _lseek, _close calls in Win32 Each returns the same return values as the corresponding _open, _read, _write, _lseek, _close calls in Win32 Functions for creating whole files from binary arrays, and comparing whole files to binary arrays as a testing aid Functions for creating whole files from binary arrays, and comparing whole files to binary arrays as a testing aid Allows debugging insertion of various errors, “Disk Full” “Access Denied” “CRC Error” Allows debugging insertion of various errors, “Disk Full” “Access Denied” “CRC Error”

14 Virtual File System Structure Two arrays of structs, “files” and “handlers” Two arrays of structs, “files” and “handlers” tvfs_create creates a “file” with a specific name, size and content tvfs_create creates a “file” with a specific name, size and content tvfs_open checks for existing file and assigns a handler tvfs_open checks for existing file and assigns a handler tvfs_free performs bookkeeping, freeing dynamically associated memory. tvfs_free performs bookkeeping, freeing dynamically associated memory.

15 Cabinet File Generation data.h is generated using the genfiles shell script. data.h is generated using the genfiles shell script. This allow for easy addition of new cab files to the test. This allow for easy addition of new cab files to the test. It uses cabarc.exe to create the cabinet files, and then uses chexify.pl to convert the file into a hexadecimal C array It uses cabarc.exe to create the cabinet files, and then uses chexify.pl to convert the file into a hexadecimal C array

16 Snippets of genfiles.sh set -ex set -ex test -f cabsdk.exe || wget -c http://download.microsoft.com/download/platformsdk/cab/2.0/w98nt42kmexp/en-us/cabsdk.exe test -f cabsdk.exe || wget -c http://download.microsoft.com/download/platformsdk/cab/2.0/w98nt42kmexp/en-us/cabsdk.exe mkdir cabsdk; cd cabsdk mkdir cabsdk; cd cabsdk unzip../cabsdk.exe ; cd.. unzip../cabsdk.exe ; cd.. chmod 744 cabsdk/BIN/CABARC.EXE chmod 744 cabsdk/BIN/CABARC.EXE # Simple archive, just one 42 byte file # Simple archive, just one 42 byte file echo > simple.txt echo > simple.txt wine cabsdk/BIN/CABARC.EXE N simple.cab simple.txt wine cabsdk/BIN/CABARC.EXE N simple.cab simple.txt # More complicated archive, with two files # More complicated archive, with two files cp../../../README README cp../../../README README cp../../../COPYING.LIB lgpl.txt cp../../../COPYING.LIB lgpl.txt wine cabsdk/BIN/CABARC.EXE N complex.cab README lgpl.txt wine cabsdk/BIN/CABARC.EXE N complex.cab README lgpl.txt # Pack source files and archives into hex arrays # Pack source files and archives into hex arrays perl../../../tools/chexify.pl simple.txt README lgpl.txt simple.cab complex.cab > data.h perl../../../tools/chexify.pl simple.txt README lgpl.txt simple.cab complex.cab > data.h

17 Sample data.h const static char name_simple_txt[] = "simple.txt"; const static char name_simple_txt[] = "simple.txt"; const static char file_simple_txt[] = {0x53, 0x6f, 0x20, 0x6c, 0x6f, 0x6e, 0x67, 0x2c, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x74, 0x68, 0x61, 0x6e, 0x6b, 0x73, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x74, 0x68, 0x65, 0x20, 0x66, 0x69, 0x73, 0x68, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x0a}; const static char file_simple_txt[] = {0x53, 0x6f, 0x20, 0x6c, 0x6f, 0x6e, 0x67, 0x2c, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x74, 0x68, 0x61, 0x6e, 0x6b, 0x73, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x74, 0x68, 0x65, 0x20, 0x66, 0x69, 0x73, 0x68, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x0a}; const static int size_simple_txt = sizeof(file_simple_txt); const static int size_simple_txt = sizeof(file_simple_txt); 'So long, and thanks for all the fish.....' 'So long, and thanks for all the fish.....'

18 Current Tests Simple.cab – contains a single text file whose contents are “So long and thanks for all the fish….” Simple.cab – contains a single text file whose contents are “So long and thanks for all the fish….” Complex.cab – a larger cabinet consisting of two text files, the wine README and lgpl.txt. (Previous versions compressed “A Midsummer’s Nights Dream”) Complex.cab – a larger cabinet consisting of two text files, the wine README and lgpl.txt. (Previous versions compressed “A Midsummer’s Nights Dream”)

19 Further Plans Current patch size with complex.cab Current patch size with complex.cab 300k. (“Too big” – AJ) 300k. (“Too big” – AJ) Data.h representation bloats filesize x5 Data.h representation bloats filesize x5 Implement programmatic series to generate data Implement programmatic series to generate data Rand() with given srand Rand() with given srand Fibonacci series % 255 Fibonacci series % 255 Use this data as the ‘raw uncompressed data’ Use this data as the ‘raw uncompressed data’ Data.h will just contain the compressed cabinet Data.h will just contain the compressed cabinet Add features to tvfs Add features to tvfs “Disk full”, etc notifications via ENOENT. “Disk full”, etc notifications via ENOENT. Directory structure? Directory structure?

20 Further Information Wiki www.geekymedia.com/twiki/bin/view.cgi/ WineDev/Group3 Wiki www.geekymedia.com/twiki/bin/view.cgi/ WineDev/Group3 www.geekymedia.com/twiki/bin/view.cgi/ WineDev/Group3 www.geekymedia.com/twiki/bin/view.cgi/ WineDev/Group3 CVS www.geekymedia.com/viewcvs/cgi/viewcv s.cgi/group3/wine/ CVS www.geekymedia.com/viewcvs/cgi/viewcv s.cgi/group3/wine/ www.geekymedia.com/viewcvs/cgi/viewcv s.cgi/group3/wine/ www.geekymedia.com/viewcvs/cgi/viewcv s.cgi/group3/wine/


Download ppt "Cabinet.dll Conformance Test Wine 3 Aleksandr Liber Rizwan Kassim."

Similar presentations


Ads by Google