private void FileInfo_Query_FileAttributeTagInfo_IsIntegritySupported(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() + " with FileAttribute.INTEGRITY_STREAM"); status = this.fsaAdapter.CreateFile( FileAttribute.NORMAL | FileAttribute.INTEGRITY_STREAM, // Set Integrity field fileType == FileType.DataFile ? CreateOptions.NON_DIRECTORY_FILE : CreateOptions.DIRECTORY_FILE, fileType == FileType.DataFile ? StreamTypeNameToOPen.DATA : StreamTypeNameToOPen.INDEX_ALLOCATION, //Stream Type FileAccess.GENERIC_READ | FileAccess.GENERIC_WRITE | FileAccess.FILE_WRITE_DATA | FileAccess.FILE_WRITE_ATTRIBUTES, ShareAccess.FILE_SHARE_READ | ShareAccess.FILE_SHARE_WRITE, CreateDisposition.OPEN_IF, StreamFoundType.StreamIsFound, SymbolicLinkType.IsNotSymbolicLink, fileType, FileNameStatus.PathNameValid); this.fsaAdapter.AssertIfNotSuccess(status, "Create file operation failed"); //Step 2: Query FILE_ATTRIBUTETAG_INFORMATION long byteCount; byte[] outputBuffer; FileAttributeTagInformation fileAttributeTagInfo = new FileAttributeTagInformation(); uint outputBufferSize = (uint)TypeMarshal.ToBytes<FileAttributeTagInformation>(fileAttributeTagInfo).Length; BaseTestSite.Log.Add(LogEntryKind.TestStep, "2. QueryFileInformation with FileInfoClass.FILE_ATTRIBUTETAG_INFORMATION"); status = this.fsaAdapter.QueryFileInformation(FileInfoClass.FILE_ATTRIBUTETAG_INFORMATION, outputBufferSize, out byteCount, out outputBuffer); //Step 3: 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; } fileAttributeTagInfo = TypeMarshal.ToStruct<FileAttributeTagInformation>(outputBuffer); bool isIntegrityStreamSet = (fileAttributeTagInfo.FileAttributes & (uint)FileAttribute.INTEGRITY_STREAM) == (uint)FileAttribute.INTEGRITY_STREAM; BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. Verify outputBuffer.FileAttributes.FILE_ATTRIBUTE_INTEGRITY_STREAM"); if (this.fsaAdapter.IsIntegritySupported == true) { this.fsaAdapter.AssertAreEqual(this.Manager, true, isIntegrityStreamSet, "If integrity is supported, the object store MUST set FILE_ATTRIBUTE_INTEGRITY_STREAM in OutputBuffer.FileAttributes."); } else { this.fsaAdapter.AssertAreEqual(this.Manager, false, isIntegrityStreamSet, "Integrity is not supported, FILE_ATTRIBUTE_INTEGRITY_STREAM MUST NOT set."); } }
/// <summary> /// Verify data type FileAttributeTagInformation /// </summary> /// <param name="fileAttributeTagInformation"> FileAttributeTagInformation type data </param> /// <param name="fileAttributes"> A 32-bit unsigned integer that contains the file attributes. </param> public void VerifyDataTypeFileAttributeTagInformation( FileAttributeTagInformation fileAttributeTagInformation, uint fileAttributes) { Site.DefaultProtocolDocShortName = "MS-FSCC"; // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1016 Actual size of FileAttributes: {0}, Expected size of FileAttributes: {1}.", fileAttributeTagInformation.FileAttributes, fileAttributes); // // Verify requirement 1016 // // Verify type and value of the fileAttributeTagInformation bool isVerifyR1016 = ( fileAttributeTagInformation.FileAttributes.GetType() == typeof(UInt32) && fileAttributeTagInformation.FileAttributes == fileAttributes); Site.CaptureRequirementIfIsTrue( isVerifyR1016, 1016, @"[In FILE_ATTRIBUTE_TAG_INFORMATION]FileAttributes (4 bytes): A 32-bit unsigned integer that contains the file attributes."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1017, actual FileAttributes:{0}", fileAttributeTagInformation.FileAttributes); // // Verify requirement 1017 // const int sizeOfFileAttributes = 4; // Verify the size and the value of FileAttributes, and the values are: // FILE_ATTRIBUTE_ARCHIVE 0x00000020, FILE_ATTRIBUTE_COMPRESSED 0x00000800, // FILE_ATTRIBUTE_DIRECTORY 0x00000010, FILE_ATTRIBUTE_ENCRYPTED 0x00004000, // FILE_ATTRIBUTE_HIDDEN 0x00000002, FILE_ATTRIBUTE_NORMAL 0x00000080, // FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000, FILE_ATTRIBUTE_OFFLINE 0x00001000, // FILE_ATTRIBUTE_READONLY 0x00000001, FILE_ATTRIBUTE_REPARSE_POINT 0x00000400, // FILE_ATTRIBUTE_SPARSE_FILE 0x00000200, FILE_ATTRIBUTE_SYSTEM 0x00000004, // FILE_ATTRIBUTE_TEMPORARY 0x00000100] uint bitUsed = ( 0x00000020 | 0x00000800 | 0x00000010 | 0x00004000 | 0x00000002 | 0x00000080 | 0x00002000 | 0x00001000 | 0x00000001 | 0x00000400 | 0x00000200 | 0x00000004 | 0x00000100); // Get the bits which the file attributes not used uint bitUnused = ~bitUsed; bool isVerifyR1017 = ((sizeOfFileAttributes == Marshal.SizeOf(fileAttributeTagInformation.FileAttributes)) && ((bitUnused & fileAttributeTagInformation.FileAttributes) == 0x00000000)); Site.CaptureRequirementIfIsTrue( isVerifyR1017, 1017, @"[In FILE_ATTRIBUTE_TAG_INFORMATION]FileAttributes (4 bytes): Valid file attributes are as specified in section 2.6."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1018, Actual ReparseTag: {0}.", fileAttributeTagInformation.ReparseTag); // // Verify requirement 1018 // // Verify type of the ReparseTag // As the ReparseTag is not defined clearly in this rs, we didn't verify the value here Site.CaptureRequirementIfAreEqual<Type>( typeof(UInt32), fileAttributeTagInformation.ReparseTag.GetType(), 1018, @"[In FILE_ATTRIBUTE_TAG_INFORMATION]ReparseTag (4 bytes): A 32-bit unsigned integer that specifies the reparse point tag."); // If the FileAttributes member includes the FILE_ATTRIBUTE_REPARSE_POINT attribute flag // FILE_ATTRIBUTE_REPARSE_POINT value is 0x00000400 if ((fileAttributeTagInformation.FileAttributes & 0x00000400) == 0x00000400) { // // Verify requirement 1019 // // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1019, Actual ReparseTag: {0}", fileAttributeTagInformation.ReparseTag); // When the FileAttributes member includes the FILE_ATTRIBUTE_REPARSE_POINT attribute flag // We only verify the size of ReparseTag here int sizeOfReparseTag = 4; Site.CaptureRequirementIfAreEqual<int>( sizeOfReparseTag, Marshal.SizeOf(fileAttributeTagInformation.ReparseTag), 1019, @"[In FILE_ATTRIBUTE_TAG_INFORMATION]ReparseTag (4 bytes): If the FileAttributes member includes the FILE_ATTRIBUTE_REPARSE_POINT attribute flag, this member specifies the reparse tag."); } // As all the elements in the FILE_ATTRIBUTE_TAG_INFORMATION have been verified above // This rs will be captured directly Site.CaptureRequirement( 1015, @"[In FileAttributeTagInformation]The FILE_ATTRIBUTE_TAG_INFORMATION data element is as follows: [FileAttributes, ReparseTag]."); Site.DefaultProtocolDocShortName = Site.Properties["ProtocolShortName"]; }