]>
git.saurik.com Git - apt.git/blob - test/libapt/extracttar_test.cc
1 #include <apt-pkg/error.h>
2 #include <apt-pkg/extracttar.h>
6 #include <gtest/gtest.h>
9 class Stream
: public pkgDirStream
13 Stream () { count
= 0; }
14 virtual bool DoItem(Item
&Itm
,int &Fd
) { (void)Itm
; (void)Fd
; count
++; return true; }
15 virtual bool Fail(Item
&Itm
,int Fd
) { (void)Itm
; (void)Fd
; return true; }
16 virtual bool FinishedFile(Item
&Itm
,int Fd
) { (void)Itm
; (void)Fd
; return true; }
17 virtual bool Process(Item
&Itm
,const unsigned char * Data
, unsigned long Size
,unsigned long Pos
) { (void)Itm
; (void) Data
; (void) Size
; (void) Pos
; return true; }
21 TEST(ExtractTar
, ExtractTar
)
23 EXPECT_EQ(system("tar c makefile | gzip > tar.tgz"), 0);
25 FileFd
fd("tar.tgz", FileFd::ReadOnly
);
27 ExtractTar
tar(fd
, -1, "gzip");
29 // Run multiple times, because we want to check not only that extraction
30 // works, but also that it works multiple times (important for python-apt)
31 for (int i
= 0; i
< 5; i
++) {
35 if (_error
->PendingError()) {
39 EXPECT_EQ(stream
.count
, 1);