authorgravatar for igor.anic@gmail.comIgor Anić <igor.anic@gmail.com> 2024-02-25 10:35:18+01:00
committergravatar for igor.anic@gmail.comIgor Anić <igor.anic@gmail.com> 2024-02-25 10:35:18+01:00
log96e4d568195602afde3486c2d9de890a383a1c4b
tree9b66e18579705496dddbfce486a0c64154c357ff
parentb84301c8e5362be1692c7812bf86e64c2ee5a850

std.tar add case sensitive file name test

Like in issue #18089, this tar contains, same file name in two case sensitive name version. Unpack should fail on case insensitive file systems and succeed on case sensitive. $ tar tvf 18089.tar 18089/ 18089/alacritty/ 18089/alacritty/darkermatrix.yml 18089/alacritty/Darkermatrix.yml

2 files changed, 26 insertions(+), 0 deletions(-)

lib/std/tar/test.zig+26
...@@ -426,3 +426,29 @@ test "tar should not overwrite existing file" {...@@ -426,3 +426,29 @@ test "tar should not overwrite existing file" {
426 try tar.pipeToFileSystem(root2.dir, fsb.reader(), .{ .mode_mode = .ignore, .strip_components = 0 });426 try tar.pipeToFileSystem(root2.dir, fsb.reader(), .{ .mode_mode = .ignore, .strip_components = 0 });
427}427}
428428
429test "tar case sensitivity" {
430 // Mimicking issue #18089, this tar contains, same file name in two case
431 // sensitive name version. Should fail on case insensitive file systems.
432 //
433 // $ tar tvf 18089.tar
434 // 18089/
435 // 18089/alacritty/
436 // 18089/alacritty/darkermatrix.yml
437 // 18089/alacritty/Darkermatrix.yml
438 //
439 const data = @embedFile("testdata/18089.tar");
440 var fsb = std.io.fixedBufferStream(data);
441
442 var root = std.testing.tmpDir(.{});
443 defer root.cleanup();
444
445 tar.pipeToFileSystem(root.dir, fsb.reader(), .{ .mode_mode = .ignore, .strip_components = 1 }) catch |err| {
446 // on case insensitive fs we fail on overwrite existing file
447 try testing.expectEqual(error.PathAlreadyExists, err);
448 return;
449 };
450
451 // on case sensitive os both files are created
452 try testing.expect((try root.dir.statFile("alacritty/darkermatrix.yml")).kind == .file);
453 try testing.expect((try root.dir.statFile("alacritty/Darkermatrix.yml")).kind == .file);
454}
lib/std/tar/testdata/18089.tar created
Binary files /dev/null and b/lib/std/tar/testdata/18089.tar differ