~ubuntu-branches/ubuntu/vivid/apt/vivid-updates

« back to all changes in this revision

Viewing changes to test/libapt/sourcelist_test.cc

  • Committer: Package Import Robot
  • Author(s): Michael Vogt, Michael Vogt, David Kalnischkies, Trần Ngọc Quân, Theppitak Karoonboonyanan, James McCoy
  • Date: 2014-04-25 13:15:03 UTC
  • mto: (223.1.1 utopic-proposed)
  • mto: This revision was merged to the branch mainline in revision 224.
  • Revision ID: package-import@ubuntu.com-20140425131503-t4z0jwou5u64wt6s
Tags: 1.0.2
[ Michael Vogt ]
* fix apt list output for pkgs in dpkg ^rc state
* Notice the user about "apt list -a" when only a single hit if found
* fix test-failure in adt
* apt-private/acqprogress.cc: fix output when ctrl-c is hit during 
  apt update (LP: #1310548, closes: #744297)
* Fix option name DPkg::Progress-Fancy in apt.8 manpage
  (LP: #1310506)

[ David Kalnischkies ]
* don't double-count seeks in FileFd::Skip for bzip/xz
* deal with umask only if we really need to for mkstemp
* consider priorities only for downloadable pkgs in resolver
* force fancy progressbar redraw on window size change
* clear HitEof flag in FileFd::Seek
* use Google C++ Testing Framework for libapt tests
* support dist-upgrade options in full-upgrade

[ Trần Ngọc Quân ]
* l10n: vi.po (624t): Update translation

[ Theppitak Karoonboonyanan ]
* Updated Thai program translation (closes: #745120)

[ James McCoy ]
* Consistently use Dpkg::Progress* in documentation (Closes: 745452)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include <config.h>
2
2
 
3
 
#include <apt-pkg/configuration.h>
4
3
#include <apt-pkg/sourcelist.h>
5
4
#include <apt-pkg/fileutl.h>
6
5
 
9
8
#include <string.h>
10
9
#include <unistd.h>
11
10
 
12
 
#include "assert.h"
13
 
 
14
 
char *tempfile = NULL;
15
 
int tempfile_fd = -1;
16
 
 
17
 
static void remove_tmpfile(void)
18
 
{
19
 
   if (tempfile_fd > 0)
20
 
      close(tempfile_fd);
21
 
   if (tempfile != NULL) {
22
 
      unlink(tempfile);
23
 
      free(tempfile);
24
 
   }
25
 
}
26
 
 
27
 
int main()
28
 
{
29
 
  _config->Set("APT::Sources::Use-Deb822", true);
30
 
 
31
 
   const char contents[] = ""
 
11
#include <gtest/gtest.h>
 
12
 
 
13
#include "file-helpers.h"
 
14
 
 
15
class SourceList : public pkgSourceList {
 
16
   public:
 
17
      using pkgSourceList::ParseFileDeb822;
 
18
};
 
19
 
 
20
TEST(SourceListTest,ParseFileDeb822)
 
21
{
 
22
   FileFd fd;
 
23
   char * tempfile;
 
24
   createTemporaryFile("parsefiledeb822", fd, &tempfile,
32
25
      "Types: deb\n"
33
26
      "URIs: http://ftp.debian.org/debian\n"
34
27
      "Suites: stable\n"
39
32
      "Types: deb\n"
40
33
      "URIs: http://ftp.debian.org/debian\n"
41
34
      "Suites: unstable\n"
42
 
      "Sections: main non-free\n"
43
 
      ;
44
 
 
45
 
   FileFd fd;
46
 
   atexit(remove_tmpfile);
47
 
   tempfile = strdup("apt-test.XXXXXXXX");
48
 
   tempfile_fd = mkstemp(tempfile);
49
 
 
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);
54
 
 
55
 
   pkgSourceList sources(tempfile);
56
 
   equals(sources.size(), 2);
57
 
 
58
 
   /* clean up handled by atexit handler, so just return here */
59
 
   return 0;
 
35
      "Sections: main non-free\n");
 
36
   fd.Close();
 
37
 
 
38
   SourceList sources;
 
39
   EXPECT_EQ(2, sources.ParseFileDeb822(tempfile));
 
40
   EXPECT_EQ(2, sources.size());
 
41
 
 
42
   unlink(tempfile);
60
43
}