Skip to content
Open

Test #315

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions TestSuites/FileServer/src/FSA/Adapter/FSAAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3612,6 +3612,46 @@ BufferSize bufferSize
return returnedStatus;
}

/// <summary>
/// Implement FsCtlSetObjID method
/// </summary>
/// <param name="requestType">FsControlRequestType is self-defined to indicate control type</param>
/// <param name="bufferSize">Indicate buffer size</param>
/// <returns>An NTSTATUS code that specifies the result</returns>
public MessageStatus FsCtlSetObjID(
FsControlRequestType requestType,
BufferSize bufferSize,
byte[] inbuffer
)
{
byte[] outbuffer = new byte[0];
uint ctlCode = 0;

// According to FSCC 2.3, the ctlCode should be as follows:
switch (requestType)
{
case FsControlRequestType.SET_OBJECT_ID:
ctlCode = (uint)FsControlCommand.FSCTL_SET_OBJECT_ID;
break;

case FsControlRequestType.SET_OBJECT_ID_EXTENDED:
ctlCode = (uint)FsControlCommand.FSCTL_SET_OBJECT_ID_EXTENDED;
break;

default:
ctlCode = (uint)FsControlCommand.FSCTL_SET_OBJECT_ID;
break;
}

MessageStatus returnedStatus = transAdapter.IOControl(
ctlCode,
this.transBufferSize,
inbuffer,
out outbuffer);

return returnedStatus;
}

#endregion

#region 3.1.5.9.30 FSCTL_SET_REPARSE_POINT
Expand Down
12 changes: 12 additions & 0 deletions TestSuites/FileServer/src/FSA/Adapter/IFSAAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,18 @@ MessageStatus FsCtlSetObjID(
FsControlRequestType requestType,
BufferSize bufferSize
);

/// <summary>
/// Implement FsCtlSetObjID Interface
/// </summary>
/// <param name="requestType">FsControlRequestType is self-defined to indicate control type</param>
/// <param name="bufferSize">Indicate buffer size</param>
/// <returns>An NTSTATUS code that specifies the result</returns>
MessageStatus FsCtlSetObjID(
FsControlRequestType requestType,
BufferSize bufferSize,
byte[] inbuffer
);
#endregion

#region 3.1.5.9.32 FSCTL_SET_SPARSE
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.Protocols.TestSuites.FileSharing.Common.Adapter;
using Microsoft.Protocols.TestSuites.FileSharing.FSA.Adapter;
using Microsoft.Protocols.TestTools;
using Microsoft.Protocols.TestTools.StackSdk;
using Microsoft.Protocols.TestTools.StackSdk.FileAccessService.Fscc;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace Microsoft.Protocols.TestSuites.FileSharing.FSA.TestSuite
{
public partial class FsCtlTestCases : PtfTestClassBase
{
#region Test cases

#region FsCtl_SetObjectId_IsSupported

[TestMethod()]
[TestCategory(TestCategories.Bvt)]
[TestCategory(TestCategories.Fsa)]
[TestCategory(TestCategories.IoCtlRequest)]
[TestCategory(TestCategories.NonSmb)]
[TestCategory(TestCategories.Positive)]
[Description("Send FSCTL_SET_OBJECT_ID request to a file.")]
public void BVT_FsCtl_SetObjectId_File_IsSupported()
{
FsCtl_SetObjectId_Test(FileType.DataFile);
}

[TestMethod()]
[TestCategory(TestCategories.Bvt)]
[TestCategory(TestCategories.Fsa)]
[TestCategory(TestCategories.IoCtlRequest)]
[TestCategory(TestCategories.NonSmb)]
[TestCategory(TestCategories.Positive)]
[Description("Send FSCTL_SET_OBJECT_ID request to a directory.")]
public void BVT_FsCtl_SetObjectId_Dir_IsSupported()
{
FsCtl_SetObjectId_Test(FileType.DirectoryFile);
}

#endregion

#region OutputBufferSize_TooSmall Tests

[TestMethod()]
[TestCategory(TestCategories.Fsa)]
[TestCategory(TestCategories.IoCtlRequest)]
[TestCategory(TestCategories.NonSmb)]
[Description("Send FSCTL_SET_OBJECT_ID request to a file.")]
public void FsCtl_SetObjectId_File_OutputBufferSize_TooSmall()
{
FsCtl_SetObjectId_Test(FileType.DataFile, BufferSize.LessThanFILE_OBJECTID_BUFFER);
}

[TestMethod()]
[TestCategory(TestCategories.Fsa)]
[TestCategory(TestCategories.IoCtlRequest)]
[TestCategory(TestCategories.NonSmb)]
[Description("Send FSCTL_SET_OBJECT_ID request to a directory.")]
public void FsCtl_SetObjectId_Dir_OutputBufferSize_TooSmall()
{
FsCtl_SetObjectId_Test(FileType.DirectoryFile, BufferSize.LessThanFILE_OBJECTID_BUFFER);
}

#endregion

#endregion

#region Test Case Utility

private void FsCtl_SetObjectId_Test(FileType fileType, BufferSize bufferSize = BufferSize.BufferSizeSuccess)
{
BaseTestSite.Log.Add(LogEntryKind.TestStep, "Test case steps:");
MessageStatus status;

//Step 1: Create file
BaseTestSite.Log.Add(LogEntryKind.TestStep, "1. Create " + fileType.ToString());
status = fsaAdapter.CreateFile(fileType);
BaseTestSite.Assert.AreEqual(MessageStatus.SUCCESS, status, "Create should succeed.");


//Step 2: FSCTL request with FSCTL_SET_OBJECT_ID
BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. FSCTL request with FSCTL_SET_OBJECT_ID");
FILE_OBJECTID_BUFFER_Type_1 inputBuffer = new()
{
ObjectId = Guid.NewGuid()
};
status = fsaAdapter.FsCtlSetObjID(FsControlRequestType.SET_OBJECT_ID, bufferSize, TypeMarshal.ToBytes(inputBuffer));

//Step 3: Verify test result
BaseTestSite.Log.Add(LogEntryKind.TestStep, "4. Verify returned NTSTATUS code.");
// MS-FSA 2.1.5.10.35 FSCTL_SET_OBJECT_ID
// <132> Section 2.1.5.10.35: This is only implemented by the NTFS file systems.
if (fsaAdapter.IsObjectIDsSupported)
{
if (bufferSize == BufferSize.LessThanFILE_OBJECTID_BUFFER)
{
fsaAdapter.AssertAreEqual(Manager, MessageStatus.INVALID_PARAMETER, status, "FSCTL_SET_OBJECT_ID is supported, If OutputBufferSize is less than sizeof(FILE_OBJECTID_BUFFER), the operation MUST be failed with STATUS_INVALID_PARAMETER.");
}
else
{
fsaAdapter.AssertAreEqual(Manager, MessageStatus.SUCCESS, status, "FSCTL_SET_OBJECT_ID is supported, status set to STATUS_SUCCESS.");
}
}
else
{
fsaAdapter.AssertAreEqual(Manager, MessageStatus.INVALID_DEVICE_REQUEST, status,
"If the object store does not implement this functionality, the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST.");
}
}

#endregion
}
}
4 changes: 2 additions & 2 deletions pipelines/github/GitHubPR-Regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ stages:
steps:
- checkout: none

- script: "git clone -b $(extRepo.branchName) $(extRepo.url) $(extRepo.dir)"
- script: "git clone -b $(extRepo.branchName) $(extRepo.v2.url) $(extRepo.dir)"
displayName: "Fetch Helper"

- task: PowerShell@2
displayName: "Queue Regression"
inputs:
targetType: filePath
filePath: "$(extRepo.dir)/RegressionRunScripts/Common/Queue-SinglePipelineWithParameters.ps1"
arguments: '-AccessToken "$(System.AccessToken)" -ApiUrl "$(build.apiUrl)" -RemoteAccessToken "$(tokens.pipelineTriggerToken)" -RemoteApiUrl "$(extRepo.apiUrl)" -PipelineName "$(test.regressionPipelineName)" -TargetRepoBranch "$(extRepo.branchName)" -PipelineParameters "`"targetRepo.csvFile`": `"$(test.targetRepoCsvFile)`", `"test.filter`": `"$(test.filter)`", `"test.buildId`": `"$(Build.BuildId)`", `"test.remoteApiUrl`": `"$(build.apiUrl)`", `"test.remoteAccessToken`": `"$(System.AccessToken)`"" -BuildIdVariableName "test.regressionBuildId" -Reason "manual" -ReportInfo $false'
arguments: '-AccessToken "$(System.AccessToken)" -ApiUrl "$(build.apiUrl)" -RemoteAccessToken "$(tokens.pipelineTriggerTokenV2)" -RemoteApiUrl "$(extRepo.apiUrl)" -PipelineName "$(test.regressionPipelineName)" -TargetRepoBranch "$(extRepo.branchName)" -PipelineParameters "`"targetRepo.csvFile`": `"$(test.targetRepoCsvFile)`", `"test.filter`": `"$(test.filter)`", `"test.buildId`": `"$(Build.BuildId)`", `"test.remoteApiUrl`": `"$(build.apiUrl)`", `"test.remoteAccessToken`": `"$(System.AccessToken)`"" -BuildIdVariableName "test.regressionBuildId" -Reason "manual" -ReportInfo $false'
workingDirectory: "$(extRepo.dir)/RegressionRunScripts/Common"

- task: PowerShell@2
Expand Down