Skip to content

Commit a87d789

Browse files
committed
tests: Remove two of the four outerloop tests as they're too heavy for the system. Keep one sync and another async instead.
1 parent 0ad6c39 commit a87d789

File tree

1 file changed

+0
-112
lines changed

1 file changed

+0
-112
lines changed

src/libraries/System.IO.Compression/tests/ZipArchive/zip_LargeFiles.cs

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -45,123 +45,11 @@ public static void UnzipOver4GBZipFile()
4545
}
4646
}
4747

48-
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMobile), nameof(PlatformDetection.Is64BitProcess))] // don't run it on slower runtimes
49-
[OuterLoop("It requires almost 12 GB of free disk space")]
50-
public static async Task UnzipOver4GBZipFile_Async()
51-
{
52-
byte[] buffer = GC.AllocateUninitializedArray<byte>(1_000_000_000); // 1 GB
53-
54-
string zipArchivePath = Path.Combine(Path.GetTempPath(), "over4GB.zip");
55-
DirectoryInfo tempDir = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), "over4GB"));
56-
57-
try
58-
{
59-
for (byte i = 0; i < 6; i++)
60-
{
61-
await File.WriteAllBytesAsync(Path.Combine(tempDir.FullName, $"{i}.test"), buffer);
62-
}
63-
64-
await ZipFile.CreateFromDirectoryAsync(tempDir.FullName, zipArchivePath, CompressionLevel.NoCompression, includeBaseDirectory: false);
65-
66-
await using ZipArchive zipArchive = await ZipFile.OpenReadAsync(zipArchivePath);
67-
foreach (ZipArchiveEntry entry in zipArchive.Entries)
68-
{
69-
await using Stream entryStream = await entry.OpenAsync();
70-
71-
Assert.True(entryStream.CanRead);
72-
Assert.Equal(buffer.Length, entryStream.Length);
73-
}
74-
}
75-
finally
76-
{
77-
File.Delete(zipArchivePath);
78-
79-
tempDir.Delete(recursive: true);
80-
}
81-
}
82-
8348
private static void FillWithHardToCompressData(byte[] buffer)
8449
{
8550
Random.Shared.NextBytes(buffer);
8651
}
8752

88-
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMobile), nameof(PlatformDetection.Is64BitProcess))] // don't run it on slower runtimes
89-
[OuterLoop("It requires 5~6 GB of free disk space and a lot of CPU time for compressed tests")]
90-
[MemberData(nameof(Get_Booleans_Data))]
91-
public static void CheckZIP64VersionIsSet_ForSmallFilesAfterBigFiles(bool isCompressed)
92-
{
93-
// issue #94899
94-
95-
CompressionLevel compressLevel = isCompressed ? CompressionLevel.Optimal : CompressionLevel.NoCompression;
96-
byte[] smallBuffer = GC.AllocateUninitializedArray<byte>(1000);
97-
byte[] largeBuffer = GC.AllocateUninitializedArray<byte>(1_000_000_000); // ~1 GB
98-
string zipArchivePath = Path.Combine(Path.GetTempPath(), "over4GB.zip");
99-
string LargeFileName = "largefile";
100-
string SmallFileName = "smallfile";
101-
uint ZipLocalFileHeader_OffsetToVersionFromHeaderStart = 4;
102-
ushort Zip64Version = 45;
103-
104-
try
105-
{
106-
using FileStream fs = File.Open(zipArchivePath, FileMode.Create, FileAccess.ReadWrite);
107-
108-
// Create
109-
using (ZipArchive archive = new(fs, ZipArchiveMode.Create, true))
110-
{
111-
ZipArchiveEntry file = archive.CreateEntry(LargeFileName, compressLevel);
112-
113-
using (Stream stream = file.Open())
114-
{
115-
// Write 5GB of data
116-
for (var i = 0; i < 5; i++)
117-
{
118-
if (isCompressed)
119-
{
120-
FillWithHardToCompressData(largeBuffer);
121-
}
122-
123-
stream.Write(largeBuffer);
124-
}
125-
}
126-
127-
file = archive.CreateEntry(SmallFileName, compressLevel);
128-
129-
using (Stream stream = file.Open())
130-
{
131-
stream.Write(smallBuffer);
132-
}
133-
}
134-
135-
fs.Position = 0;
136-
137-
// Validate
138-
using (ZipArchive archive = new(fs, ZipArchiveMode.Read))
139-
{
140-
using var reader = new BinaryReader(fs);
141-
142-
FieldInfo offsetOfLHField = typeof(ZipArchiveEntry).GetField("_offsetOfLocalHeader", BindingFlags.NonPublic | BindingFlags.Instance);
143-
144-
if (offsetOfLHField is null || offsetOfLHField.FieldType != typeof(long))
145-
{
146-
Assert.Fail("Cannot find the private field of _offsetOfLocalHeader in ZipArchiveEntry or the type is not long. Code may be changed after the test is written.");
147-
}
148-
149-
foreach (ZipArchiveEntry entry in archive.Entries)
150-
{
151-
fs.Position = (long)offsetOfLHField.GetValue(entry) + ZipLocalFileHeader_OffsetToVersionFromHeaderStart;
152-
ushort versionNeeded = reader.ReadUInt16();
153-
154-
// Version is not ZIP64 for files with Local Header at >4GB offset.
155-
Assert.Equal(Zip64Version, versionNeeded);
156-
}
157-
}
158-
}
159-
finally
160-
{
161-
File.Delete(zipArchivePath);
162-
}
163-
}
164-
16553
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMobile), nameof(PlatformDetection.Is64BitProcess))] // don't run it on slower runtimes
16654
[OuterLoop("It requires 5~6 GB of free disk space and a lot of CPU time for compressed tests")]
16755
[MemberData(nameof(Get_Booleans_Data))]

0 commit comments

Comments
 (0)