]>
git.saurik.com Git - apt.git/blob - test/libapt/sourcelist_test.cc
3 #include <apt-pkg/configuration.h>
4 #include <apt-pkg/sourcelist.h>
5 #include <apt-pkg/fileutl.h>
14 char *tempfile
= NULL
;
17 static void remove_tmpfile(void)
21 if (tempfile
!= NULL
) {
29 _config
->Set("APT::Sources::Use-Deb822", true);
31 const char contents
[] = ""
33 "URIs: http://ftp.debian.org/debian\n"
36 "Description: short\n"
37 " long description that can be very long\n"
40 "URIs: http://ftp.debian.org/debian\n"
42 "Sections: main non-free\n"
46 atexit(remove_tmpfile
);
47 tempfile
= strdup("apt-test.XXXXXXXX");
48 tempfile_fd
= mkstemp(tempfile
);
50 /* (Re-)Open (as FileFd), write and seek to start of the temp file */
51 equals(fd
.OpenDescriptor(tempfile_fd
, FileFd::ReadWrite
), true);
52 equals(fd
.Write(contents
, strlen(contents
)), true);
53 equals(fd
.Seek(0), true);
55 pkgSourceList
sources(tempfile
);
56 equals(sources
.size(), 2);
58 /* clean up handled by atexit handler, so just return here */