aboutsummaryrefslogtreecommitdiffstats
path: root/t/02packdrake.t
diff options
context:
space:
mode:
authorOlivier Thauvin <nanardon@mandriva.org>2004-12-06 23:27:42 +0000
committerOlivier Thauvin <nanardon@mandriva.org>2004-12-06 23:27:42 +0000
commitab1d5af38bb1d9133ebece45760d7d0af642d976 (patch)
tree07c23258c8087b466de6ad1ba312453e24933e42 /t/02packdrake.t
parentdcd615a5ac5759ce82db71f8aac058768e2d8ce3 (diff)
downloadrpmtools-ab1d5af38bb1d9133ebece45760d7d0af642d976.tar
rpmtools-ab1d5af38bb1d9133ebece45760d7d0af642d976.tar.gz
rpmtools-ab1d5af38bb1d9133ebece45760d7d0af642d976.tar.bz2
rpmtools-ab1d5af38bb1d9133ebece45760d7d0af642d976.tar.xz
rpmtools-ab1d5af38bb1d9133ebece45760d7d0af642d976.zip
- 5.0.05.0.0
- more test and fix
Diffstat (limited to 't/02packdrake.t')
-rwxr-xr-xt/02packdrake.t66
1 files changed, 66 insertions, 0 deletions
diff --git a/t/02packdrake.t b/t/02packdrake.t
new file mode 100755
index 0000000..26fef2f
--- /dev/null
+++ b/t/02packdrake.t
@@ -0,0 +1,66 @@
+#!/usr/bin/perl
+
+# $Id$
+
+use strict;
+use Test::More tests => 7;
+use Digest::MD5;
+
+use_ok('packdrake');
+
+-d "test" || mkdir "test" or die "Can't create directory test";
+
+my $coin = "
+ ___________
+< Coin coin >
+ -----------
+ \ ,~~.
+ \ __( o )
+ `--'==( ___/)
+ ( ( . /
+ \ '-' /
+ ~'`~'`~'`~'`~
+";
+
+sub clean_test_files {
+ -d "test" or return;
+ system("rm -fr $_") foreach (glob("test/*"));
+}
+
+clean_test_files();
+
+mkdir "test/dir" or die "Can't create 'test/dir'";
+open(my $fh, "> test/file") or die "Can't create 'test/file'";
+print $fh $coin;
+close $fh;
+
+symlink("file", "test/link") or die "Can't create symlink 'test/link'";
+
+open($fh, "> test/list") or die "can't open 'test/list'";
+print($fh join("\n", qw(dir file link)) ."\n");
+close($fh);
+
+open(my $listh, "< test/list");
+ok(packdrake::build_archive(
+ $listh,
+ "test",
+ "packtest.cz",
+ 400_000,
+ "gzip -9",
+ "gzip -d",
+), "Creating a packdrake archive");
+close($listh);
+
+clean_test_files();
+
+my $pack = packdrake->new("packtest.cz");
+ok($pack->extract_archive("test", qw(dir file link)), "Extracting files from archive");
+
+ok(open($fh, "test/file"), "Opening extract file");
+sysread($fh, my $data, 1_000);
+ok($data == $coin, "data succefully restored");
+ok(-d "test/dir", "dir succefully restored");
+ok(readlink("test/link") eq "file", "symlink succefully restored");
+
+clean_test_files();
+