private void FileInfo_Query_FileCompressionInfo_IsCompressionSupported(FileType fileType) { BaseTestSite.Log.Add(LogEntryKind.TestStep, "Test case steps:"); MessageStatus status; //Step 1: Create File BaseTestSite.Log.Add(LogEntryKind.TestStep, "1. Create " + fileType.ToString()); status = this.fsaAdapter.CreateFile(fileType); //Step 2: Set compression FSCTL_SET_COMPRESSION_Request setCompressionRequest = new FSCTL_SET_COMPRESSION_Request(); setCompressionRequest.CompressionState = FSCTL_SET_COMPRESSION_Request_CompressionState_Values.COMPRESSION_FORMAT_LZNT1; uint inputBufferSize = (uint)TypeMarshal.ToBytes<FSCTL_SET_COMPRESSION_Request>(setCompressionRequest).Length; BaseTestSite.Log.Add(LogEntryKind.TestStep, "2. FSCTL request with FSCTL_SET_COMPRESSION"); status = this.fsaAdapter.FsCtlSetCompression(setCompressionRequest, inputBufferSize); //Step 3: Query FILE_COMPRESSION_INFORMATION FileCompressionInformation fileCompressionInfo = new FileCompressionInformation() { Reserved = new byte[3] }; long byteCount; byte[] outputBuffer = new byte[0]; uint outputBufferSize = (uint)TypeMarshal.ToBytes<FileCompressionInformation>(fileCompressionInfo).Length; BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. QueryFileInformation with FileInfoClass.FILE_COMPRESSION_INFORMATION"); status = this.fsaAdapter.QueryFileInformation(FileInfoClass.FILE_COMPRESSION_INFORMATION, outputBufferSize, out byteCount, out outputBuffer); //Step 4: Verify test result if (this.fsaAdapter.FileSystem == FileSystem.FAT32) { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.INVALID_PARAMETER, status, "If a file system does not support a specific File Information Class, STATUS_INVALID_PARAMETER MUST be returned."); return; } fileCompressionInfo = TypeMarshal.ToStruct<FileCompressionInformation>(outputBuffer); bool isCompressionFormatLZNT1 = (fileCompressionInfo.CompressionFormat & CompressionFormat_Values.COMPRESSION_FORMAT_LZNT1) == CompressionFormat_Values.COMPRESSION_FORMAT_LZNT1; BaseTestSite.Log.Add(LogEntryKind.TestStep, "4. Verify outputBuffer.CompressionFormat"); if (this.fsaAdapter.IsCompressionSupported == true) { if (fileType == FileType.DirectoryFile && this.fsaAdapter.FileSystem == FileSystem.CSVFS) { this.fsaAdapter.AssertAreEqual(this.Manager, false, isCompressionFormatLZNT1, "CSVFS does not support setting compressed attribute on the folders, the compressionFormat should be NONE."); } else { this.fsaAdapter.AssertAreEqual(this.Manager, true, isCompressionFormatLZNT1, "Compression is supported, the object store MUST set OutputBuffer.CompressionState to COMPRESSION_FORMAT_LZNT1."); } } else { this.fsaAdapter.AssertAreEqual(this.Manager, false, isCompressionFormatLZNT1, "Compression is NOT supported, the object store MUST NOT set OutputBuffer.CompressionState to COMPRESSION_FORMAT_LZNT1."); } }
/// <summary> /// Verify data type FileCompressionInformation /// </summary> /// <param name="fileCompressionInfomation"> FileCompressionInformation type data </param> /// <param name="compressedFileSize"> A 64-bit signed integer that contains the size, in bytes, of the compressed file. </param> /// <param name="compressionFormat"> A 16-bit unsigned integer that contains the compression format. </param> /// <param name="compressionUnitShift"> An 8-bit unsigned integer that contains the compression unit shift, which is the number of bits by which to left-shift a 1 bit to arrive at the compression unit size. </param> /// <param name="chunkShift"> An 8-bit unsigned integer that contains the compression chunk size in bytes in log 2 format. </param> /// <param name="clusterShift"> An 8-bit unsigned integer that specifies, in log 2 format, the amount of space that must be saved by compression to successfully compress a compression unit. </param> /// <param name="clusterSize"> size of the cluster </param> public void VerifyDataTypeFileCompressionInformationForOld( FileCompressionInformation fileCompressionInfomation, int compressionFormat, byte chunkShift, byte clusterShift, byte clusterSize) { Site.DefaultProtocolDocShortName = "MS-FSCC"; // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1094 Actual CompressedFileSize is : {0}", fileCompressionInfomation.CompressedFileSize); // // Verify requirement 1094 // Site.CaptureRequirementIfAreEqual<Type>( typeof(Int64), fileCompressionInfomation.CompressedFileSize.GetType(), 1094, @"[In FILE_COMPRESSION_INFORMATION]CompressedFileSize (8 bytes): A 64-bit signed integer that contains the size, in bytes, of the compressed file."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1095 Actual CompressedFileSize: {0}", fileCompressionInfomation.CompressedFileSize); // // Verify requirement 1095 // Site.CaptureRequirementIfIsTrue( fileCompressionInfomation.CompressedFileSize >= 0, 1095, @"[In FILE_COMPRESSION_INFORMATION]CompressedFileSize (8 bytes): This value MUST be greater than or equal to 0."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1096 Actual CompressionFormat: {0}, Expected CompressionFormat: {1}.", fileCompressionInfomation.CompressionFormat, compressionFormat); // // Verify requirement 1096 // // Verify type and value of the CompressionFormat bool isVerifyR1096 = ( fileCompressionInfomation.CompressionFormat.GetType() == typeof(CompressionFormat_Values) && (uint)fileCompressionInfomation.CompressionFormat == compressionFormat); Site.CaptureRequirementIfIsTrue( isVerifyR1096, 1096, @"[In FILE_COMPRESSION_INFORMATION]CompressionFormat (2 bytes): A 16-bit unsigned integer that contains the compression format."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "MS-FSCC_R1098, CompressionFormat: {0}", fileCompressionInfomation.CompressionFormat); // // Verify requirement 1098 // bool isVerifyR1098 = ( (fileCompressionInfomation.CompressionFormat.GetType() == typeof(CompressionFormat_Values)) && ((fileCompressionInfomation.CompressionFormat == CompressionFormat_Values.COMPRESSION_FORMAT_DEFAULT) || (fileCompressionInfomation.CompressionFormat == CompressionFormat_Values.COMPRESSION_FORMAT_LZNT1) || (fileCompressionInfomation.CompressionFormat == CompressionFormat_Values.COMPRESSION_FORMAT_NONE))); Site.CaptureRequirementIfIsTrue( isVerifyR1098, 1098, @"[In FILE_COMPRESSION_INFORMATION]CompressionFormat (2 bytes): An implementation can associate any local compression algorithm with the values described in the following table[COMPRESSION_FORMAT_NONE 0x0000, COMPRESSION_FORMAT_DEFAULT 0x0001, COMPRESSION_FORMAT_LZNT1 0x0002, All other values] because the compressed data does not travel across the wire in the context of FSCTL, FileInformation class, or FileSystemInformation class requests or replies.<58>"); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1103 Actual CompressionUnitShift: {0}", fileCompressionInfomation.CompressionUnitShift); // // Verify requirement 1103 // Site.CaptureRequirementIfAreEqual<Type>( typeof(byte), fileCompressionInfomation.CompressionUnitShift.GetType(), 1103, @"[In FILE_COMPRESSION_INFORMATION]CompressionUnitShift (1 byte): An 8-bit unsigned integer that contains the compression unit shift, which is the number of bits by which to left-shift a 1 bit to arrive at the compression unit size."); // As the value of the CompressionUnitShift is verified above rs, we didn't verify here again // We capture this rs directly. Site.CaptureRequirement( 1104, @"[In FILE_COMPRESSION_INFORMATION]CompressionUnitShift (1 byte): The compression unit size is the number of bytes in a compression unit, that is, the number of bytes to be compressed."); // // Verify requirement 1105 // // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "MS-FSCC_R1105, CompressionUnitShift: {0}", fileCompressionInfomation.CompressedFileSize); // As the value is implementation-defined, and the <59> will be verified separately // Verify the size of CompressionUnitShift here. const int sizeOfCompressionUnitShift = 1; Site.CaptureRequirementIfAreEqual<int>( sizeOfCompressionUnitShift, Marshal.SizeOf(fileCompressionInfomation.CompressionUnitShift), 1105, @"[In FILE_COMPRESSION_INFORMATION]CompressionUnitShift (1 byte): This value is implementation- defined.<59>"); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "MS-FSCC ReqId: {0}, ChunkShift: {1}", 1108, fileCompressionInfomation.ChunkShift); // // Verify requirement 1108 // // As the value is implementation-defined, and the <60> will be verified separately // Verify the size of ChunkShift here. const int sizeOfChunkShift = 1; Site.CaptureRequirementIfAreEqual<int>( sizeOfChunkShift, Marshal.SizeOf(fileCompressionInfomation.ChunkShift), 1108, @"[In FILE_COMPRESSION_INFORMATION]ChunkShift (1 byte): This value is implementation-defined.<60>"); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "MS-FSCC ReqId: {0}, ClusterShift: {1}", 1113, fileCompressionInfomation.ClusterShift); // // Verify requirement 1113 // // As the value is implementation-defined, and the <61> will be verified separately // Verify the size of ClusterShift here. const int sizeOfClusterShift = 1; Site.CaptureRequirementIfAreEqual<int>( sizeOfClusterShift, Marshal.SizeOf(fileCompressionInfomation.ClusterShift), 1113, @"[In FILE_COMPRESSION_INFORMATION]ClusterShift (1 byte): This value is implementation defined.<61>"); // // Verify requirement 1106 // // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1106 Actual ChunkShift: {0}, Expected ChunkShift: {1}.", fileCompressionInfomation.ChunkShift, chunkShift); // Verify type and value of the ChunkShift bool isVerifyR1106 = ( fileCompressionInfomation.ChunkShift.GetType() == typeof(byte) && fileCompressionInfomation.ChunkShift == chunkShift); Site.CaptureRequirementIfIsTrue( isVerifyR1106, 1106, @"[In FILE_COMPRESSION_INFORMATION]ChunkShift (1 byte): An 8-bit unsigned integer that contains the compression chunk size in bytes in log 2 format."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1109 Actual ClusterShift: {0}, Expected ClusterShift: {1}.", fileCompressionInfomation.ClusterShift, clusterShift); // // Verify requirement 1109 // // Verify type and value of the ClusterShift bool isVerifyR1109 = ( fileCompressionInfomation.ClusterShift.GetType() == typeof(Byte) && fileCompressionInfomation.ClusterShift == clusterShift); Site.CaptureRequirementIfIsTrue( isVerifyR1109, 1109, @"[In FILE_COMPRESSION_INFORMATION]ClusterShift (1 byte): An 8-bit unsigned integer that specifies, in log 2 format, the amount of space that must be saved by compression to successfully compress a compression unit."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1112 Actual clusterSize: {0}, Expected clusterSize: {1}.", fileCompressionInfomation.ClusterShift, clusterSize); // // Verify requirement 1112 // // Verify the value of the ClusterShift // As the type of the ClusterShift is verified above, we didn't verify here again bool isVerifyR1112 = ((fileCompressionInfomation.ClusterShift << 1) == clusterSize); Site.CaptureRequirementIfIsTrue( isVerifyR1112, 1112, @"[In FILE_COMPRESSION_INFORMATION]ClusterShift (1 byte): the cluster shift is the number of bits by which to left shift a 1 bit to arrive at the size of a cluster."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1114"); // // Verify requirement 1114 // Site.CaptureRequirementIfAreEqual<int>( 3, fileCompressionInfomation.Reserved.Length, 1114, @"[In FILE_COMPRESSION_INFORMATION]Reserved (3 bytes): A 24-bit reserved value."); // As all the elements in the FILE_COMPRESSION_INFORMATION have been verified above // This rs will be captured directly Site.CaptureRequirement( 1093, @"[In FileCompressionInformation]The FILE_COMPRESSION_INFORMATION data element is as follows.: [CompressedFileSize, ..., CompressionFormat, CompressionUnitShift, ChunkShift, ClusterShift, Reserved]"); Site.DefaultProtocolDocShortName = Site.Properties["ProtocolShortName"]; }
/// <summary> /// Verify the structure of FileCompressionInformation /// </summary> /// <param name="info">the instance of this FileCompressionInformation</param> /// <param name="typeOfFileSystem">the type of file system: NTFS, FAT, exFAT or others</param> /// <param name="expectedInitializedClusterShift">cluster size set for the file system at initialization. /// NTFS is 12 by defaults</param> public void VerifyDataTypeFileCompressionInformation(FileCompressionInformation info, string typeOfFileSystem, byte expectedInitializedClusterShift) { Site.DefaultProtocolDocShortName = "MS-FSCC"; if (typeOfFileSystem == "NTFS") { // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1940"); // // Verify MS-FSCC requirement: MS-FSCC_R1940 // // expectedInitializedClusterShift is 12 by defaults or initialized with a different cluster size Site.CaptureRequirementIfAreEqual<byte>( expectedInitializedClusterShift, info.ClusterShift, 1940, @"<59> Section 2.4.9:NTFS defaults to a 4-kilobyte cluster size, resulting in a ClusterShift value of 12, but NTFS file systems can be initialized with a different cluster size, so the value may vary."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1945"); // // Verify MS-FSCC requirement: MS-FSCC_R1945 // // set to be an initialized value Site.CaptureRequirementIfAreEqual<byte>( expectedInitializedClusterShift, info.ClusterShift, 1945, @"<61> Section 2.4.9: If an NTFS file system is initialized with a different cluster size, the value of ClusterShift would be log 2 of the cluster size for that file system."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1943"); // // Verify MS-FSCC requirement: MS-FSCC_R1943 // depended on an initialized value Site.CaptureRequirementIfAreEqual<byte>( expectedInitializedClusterShift, info.ClusterShift, 1943, @"<61> Section 2.4.9: The value of this field[ClusterShift] depends on the cluster size set for the file system at initialization."); } Site.DefaultProtocolDocShortName = Site.Properties["ProtocolShortName"]; }