Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
runtime
提交
eba01b7f
R
runtime
项目概览
dotNET Platform
/
runtime
12 个月 前同步成功
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
runtime
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
eba01b7f
编写于
7月 12, 2022
作者:
C
Carlos Sanchez
提交者:
GitHub
7月 12, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add TAR tests that verify ExtractToFile works with special files. (#71988)
上级
07fce444
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
112 addition
and
0 deletion
+112
-0
src/libraries/System.Formats.Tar/tests/System.Formats.Tar.Tests.csproj
.../System.Formats.Tar/tests/System.Formats.Tar.Tests.csproj
+1
-0
src/libraries/System.Formats.Tar/tests/TarEntry/TarEntry.ExtractToFile.Tests.Unix.cs
...s.Tar/tests/TarEntry/TarEntry.ExtractToFile.Tests.Unix.cs
+111
-0
未找到文件。
src/libraries/System.Formats.Tar/tests/System.Formats.Tar.Tests.csproj
浏览文件 @
eba01b7f
...
...
@@ -80,6 +80,7 @@
</ItemGroup>
<!-- Unix specific files -->
<ItemGroup Condition="'$(TargetPlatformIdentifier)' != 'windows'">
<Compile Include="TarEntry\TarEntry.ExtractToFile.Tests.Unix.cs" />
<Compile Include="TarFile\TarFile.ExtractToDirectory.File.Tests.Unix.cs" />
<Compile Include="TarFile\TarFile.ExtractToDirectoryAsync.File.Tests.Unix.cs" />
<Compile Include="TarReader\TarReader.TarEntry.ExtractToFileAsync.Tests.Unix.cs" />
...
...
src/libraries/System.Formats.Tar/tests/TarEntry/TarEntry.ExtractToFile.Tests.Unix.cs
0 → 100644
浏览文件 @
eba01b7f
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using
System.Collections.Generic
;
using
System.Data
;
using
System.IO
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Xunit
;
namespace
System.Formats.Tar.Tests
{
public
class
TarEntry_ExtractToFile_Tests_Unix
:
TarTestsBase
{
public
static
IEnumerable
<
object
[
]>
GetFormatsAndSpecialFiles
()
{
foreach
(
TarEntryFormat
format
in
new
[]
{
TarEntryFormat
.
Ustar
,
TarEntryFormat
.
Pax
,
TarEntryFormat
.
Gnu
})
// V7 does not support special files
{
foreach
(
TarEntryType
entryType
in
new
[]
{
TarEntryType
.
BlockDevice
,
TarEntryType
.
CharacterDevice
,
TarEntryType
.
Fifo
})
{
yield
return
new
object
[]
{
format
,
entryType
};
}
}
}
[
ConditionalTheory
(
nameof
(
IsRemoteExecutorSupportedAndOnUnixAndSuperUser
))]
[
MemberData
(
nameof
(
GetFormatsAndSpecialFiles
))]
public
void
Extract_SpecialFiles
(
TarEntryFormat
format
,
TarEntryType
entryType
)
{
using
TempDirectory
root
=
new
TempDirectory
();
(
string
entryName
,
string
destination
,
PosixTarEntry
entry
)
=
Prepare_Extract_SpecialFiles
(
root
,
format
,
entryType
);
entry
.
ExtractToFile
(
destination
,
overwrite
:
true
);
Verify_Extract_SpecialFiles
(
destination
,
entry
,
entryType
);
}
[
ConditionalTheory
(
nameof
(
IsRemoteExecutorSupportedAndOnUnixAndSuperUser
))]
[
MemberData
(
nameof
(
GetFormatsAndSpecialFiles
))]
public
async
Task
Extract_SpecialFiles_Async
(
TarEntryFormat
format
,
TarEntryType
entryType
)
{
using
TempDirectory
root
=
new
TempDirectory
();
(
string
entryName
,
string
destination
,
PosixTarEntry
entry
)
=
Prepare_Extract_SpecialFiles
(
root
,
format
,
entryType
);
await
entry
.
ExtractToFileAsync
(
destination
,
overwrite
:
true
);
Verify_Extract_SpecialFiles
(
destination
,
entry
,
entryType
);
}
private
(
string
,
string
,
PosixTarEntry
)
Prepare_Extract_SpecialFiles
(
TempDirectory
root
,
TarEntryFormat
format
,
TarEntryType
entryType
)
{
string
entryName
=
entryType
.
ToString
();
string
destination
=
Path
.
Join
(
root
.
Path
,
entryName
);
PosixTarEntry
entry
=
InvokeTarEntryCreationConstructor
(
format
,
entryType
,
entryName
)
as
PosixTarEntry
;
Assert
.
NotNull
(
entry
);
if
(
entryType
is
TarEntryType
.
BlockDevice
)
{
entry
.
DeviceMajor
=
TestBlockDeviceMajor
;
entry
.
DeviceMinor
=
TestBlockDeviceMinor
;
}
else
if
(
entryType
is
TarEntryType
.
CharacterDevice
)
{
entry
.
DeviceMajor
=
TestCharacterDeviceMajor
;
entry
.
DeviceMinor
=
TestCharacterDeviceMinor
;
}
return
(
entryName
,
destination
,
entry
);
}
private
void
Verify_Extract_SpecialFiles
(
string
destination
,
PosixTarEntry
entry
,
TarEntryType
entryType
)
{
Assert
.
True
(
File
.
Exists
(
destination
));
Interop
.
Sys
.
FileStatus
status
=
default
;
status
.
Mode
=
default
;
status
.
Dev
=
default
;
Interop
.
CheckIo
(
Interop
.
Sys
.
LStat
(
destination
,
out
status
));
int
fileType
=
status
.
Mode
&
Interop
.
Sys
.
FileTypes
.
S_IFMT
;
if
(
entryType
is
TarEntryType
.
BlockDevice
)
{
Assert
.
Equal
(
Interop
.
Sys
.
FileTypes
.
S_IFBLK
,
fileType
);
}
else
if
(
entryType
is
TarEntryType
.
CharacterDevice
)
{
Assert
.
Equal
(
Interop
.
Sys
.
FileTypes
.
S_IFCHR
,
fileType
);
}
else
if
(
entryType
is
TarEntryType
.
Fifo
)
{
Assert
.
Equal
(
Interop
.
Sys
.
FileTypes
.
S_IFIFO
,
fileType
);
}
if
(
entryType
is
TarEntryType
.
BlockDevice
or
TarEntryType
.
CharacterDevice
)
{
uint
major
;
uint
minor
;
unsafe
{
Interop
.
Sys
.
GetDeviceIdentifiers
((
ulong
)
status
.
RDev
,
&
major
,
&
minor
);
}
Assert
.
Equal
((
int
)
major
,
entry
.
DeviceMajor
);
Assert
.
Equal
((
int
)
minor
,
entry
.
DeviceMinor
);
}
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录