コード例 #1
0
        public void TestExtractUnixArchiveWithHardlink()
        {
            using (var extractor = new TarExtractor(typeof(TarExtractorTest).GetEmbeddedStream("testArchive.tar"), _sandbox))
                extractor.Run();

            FileUtils.AreHardlinked(Path.Combine(_sandbox, "subdir1", "regular"), Path.Combine(_sandbox, "hardlink"))
            .Should().BeTrue(because: "'regular' and 'hardlink' should be hardlinked together");
        }
コード例 #2
0
        public void TestExtractUnixArchiveWithExecutable()
        {
            using (var extractor = new TarExtractor(typeof(TarExtractorTest).GetEmbeddedStream("testArchive.tar"), _sandbox))
                extractor.Run();

            if (UnixUtils.IsUnix)
            {
                FileUtils.IsExecutable(Path.Combine(_sandbox, "subdir2/executable")).Should().BeTrue(because: "File 'executable' should be marked as executable");
            }
            else
            {
                string xbitFileContent = File.ReadAllText(Path.Combine(_sandbox, FlagUtils.XbitFile)).Trim();
                xbitFileContent.Should().Be("/subdir2/executable");
            }
        }
コード例 #3
0
        public void TestExtractUnixArchiveWithExecutable()
        {
            using (var stream = typeof(ExtractorTest).GetEmbeddedStream("testArchive.tar"))
                using (var extractor = new TarExtractor(stream, _sandbox))
                    extractor.Run();

            if (UnixUtils.IsUnix)
            {
                Assert.IsTrue(FileUtils.IsExecutable(Path.Combine(_sandbox, "subdir2/executable")), "File 'executable' should be marked as executable");
            }
            else
            {
                string xbitFileContent = File.ReadAllText(Path.Combine(_sandbox, FlagUtils.XbitFile)).Trim();
                Assert.AreEqual("/subdir2/executable", xbitFileContent);
            }
        }
コード例 #4
0
        public void TestExtractUnixArchiveWithSymlink()
        {
            using (var extractor = new TarExtractor(typeof(TarExtractorTest).GetEmbeddedStream("testArchive.tar"), _sandbox))
                extractor.Run();

            string target;
            string source = Path.Combine(_sandbox, "symlink");

            if (UnixUtils.IsUnix)
            {
                FileUtils.IsSymlink(source, out target).Should().BeTrue();
            }
            else
            {
                CygwinUtils.IsSymlink(source, out target).Should().BeTrue();
            }

            target.Should().Be("subdir1/regular", because: "Symlink should point to 'regular'");
        }
コード例 #5
0
        public void TestExtractUnixArchiveWithSymlink()
        {
            using (var stream = typeof(ExtractorTest).GetEmbeddedStream("testArchive.tar"))
                using (var extractor = new TarExtractor(stream, _sandbox))
                    extractor.Run();

            string target;

            if (UnixUtils.IsUnix)
            {
                Assert.IsTrue(FileUtils.IsSymlink(Path.Combine(_sandbox, "symlink"), out target));
            }
            else
            {
                string symlinkFileContent = File.ReadAllText(Path.Combine(_sandbox, FlagUtils.SymlinkFile)).Trim();
                Assert.AreEqual("/symlink", symlinkFileContent);
                target = File.ReadAllText(Path.Combine(_sandbox, "symlink"));
            }
            Assert.AreEqual("subdir1/regular", target, "Symlink should point to 'regular'");
        }
コード例 #6
0
        public void TestExtractUnixArchiveWithSymlink()
        {
            using (var extractor = new TarExtractor(this.GetEmbedded("testArchive.tar"), _sandbox))
                extractor.Run();

            string target;
            if (UnixUtils.IsUnix)
                Assert.IsTrue(FileUtils.IsSymlink(Path.Combine(_sandbox, "symlink"), out target));
            else
            {
                string symlinkFileContent = File.ReadAllText(Path.Combine(_sandbox, FlagUtils.SymlinkFile)).Trim();
                Assert.AreEqual("/symlink", symlinkFileContent);
                target = File.ReadAllText(Path.Combine(_sandbox, "symlink"));
            }
            Assert.AreEqual("subdir1/regular", target, "Symlink should point to 'regular'");
        }
コード例 #7
0
        public void TestExtractUnixArchiveWithHardlink()
        {
            using (var extractor = new TarExtractor(this.GetEmbedded("testArchive.tar"), _sandbox))
                extractor.Run();

            Assert.IsTrue(
                FileUtils.AreHardlinked(Path.Combine(_sandbox, "subdir1", "regular"), Path.Combine(_sandbox, "hardlink")),
                "'regular' and 'hardlink' should be hardlinked together");
        }
コード例 #8
0
        public void TestExtractUnixArchiveWithExecutable()
        {
            using (var extractor = new TarExtractor(this.GetEmbedded("testArchive.tar"), _sandbox))
                extractor.Run();

            if (UnixUtils.IsUnix)
                Assert.IsTrue(FileUtils.IsExecutable(Path.Combine(_sandbox, "subdir2/executable")), "File 'executable' should be marked as executable");
            else
            {
                string xbitFileContent = File.ReadAllText(Path.Combine(_sandbox, FlagUtils.XbitFile)).Trim();
                Assert.AreEqual("/subdir2/executable", xbitFileContent);
            }
        }
コード例 #9
0
        public void TestExtractUnixArchiveWithHardlink()
        {
            using (var extractor = new TarExtractor(typeof(TarExtractorTest).GetEmbeddedStream("testArchive.tar"), _sandbox))
                extractor.Run();

            FileUtils.AreHardlinked(Path.Combine(_sandbox, "subdir1", "regular"), Path.Combine(_sandbox, "hardlink"))
                .Should().BeTrue(because: "'regular' and 'hardlink' should be hardlinked together");
        }
コード例 #10
0
        public void TestExtractUnixArchiveWithSymlink()
        {
            using (var extractor = new TarExtractor(typeof(TarExtractorTest).GetEmbeddedStream("testArchive.tar"), _sandbox))
                extractor.Run();

            string target;
            string source = Path.Combine(_sandbox, "symlink");
            if (UnixUtils.IsUnix) FileUtils.IsSymlink(source, out target).Should().BeTrue();
            else CygwinUtils.IsSymlink(source, out target).Should().BeTrue();

            target.Should().Be("subdir1/regular", because: "Symlink should point to 'regular'");
        }
コード例 #11
0
        public void TestExtractUnixArchiveWithExecutable()
        {
            using (var extractor = new TarExtractor(typeof(TarExtractorTest).GetEmbeddedStream("testArchive.tar"), _sandbox))
                extractor.Run();

            if (UnixUtils.IsUnix)
                FileUtils.IsExecutable(Path.Combine(_sandbox, "subdir2/executable")).Should().BeTrue(because: "File 'executable' should be marked as executable");
            else
            {
                string xbitFileContent = File.ReadAllText(Path.Combine(_sandbox, FlagUtils.XbitFile)).Trim();
                xbitFileContent.Should().Be("/subdir2/executable");
            }
        }