From caeb19b796f7045f489dbce0bf681925d49136a9 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 2 Dec 2013 08:21:49 +0100 Subject: add unittest for new sourceslist parser as well --- test/libapt/sourcelist_test.cc | 52 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 test/libapt/sourcelist_test.cc (limited to 'test/libapt/sourcelist_test.cc') diff --git a/test/libapt/sourcelist_test.cc b/test/libapt/sourcelist_test.cc new file mode 100644 index 000000000..6e83d08e0 --- /dev/null +++ b/test/libapt/sourcelist_test.cc @@ -0,0 +1,52 @@ +#include +#include + +#include "assert.h" +#include +#include +#include + +char *tempfile = NULL; +int tempfile_fd = -1; + +void remove_tmpfile(void) +{ + if (tempfile_fd > 0) + close(tempfile_fd); + if (tempfile != NULL) { + unlink(tempfile); + free(tempfile); + } +} + +int main(int argc, char *argv[]) +{ + const char contents[] = "" + "Type: deb\n" + "URL: http://ftp.debian.org/debian\n" + "Dist: stable\n" + "Section: main\n" + "Comment: Some random string\n" + " that can be very long\n" + "\n" + "Type: deb\n" + "URL: http://ftp.debian.org/debian\n" + "Dist: unstable\n" + "Section: main non-free\n" + ; + + FileFd fd; + tempfile = strdup("apt-test.XXXXXXXX"); + tempfile_fd = mkstemp(tempfile); + + /* (Re-)Open (as FileFd), write and seek to start of the temp file */ + equals(fd.OpenDescriptor(tempfile_fd, FileFd::ReadWrite), true); + equals(fd.Write(contents, strlen(contents)), true); + equals(fd.Seek(0), true); + + pkgSourceList sources(tempfile); + equals(sources.size(), 2); + + /* clean up handled by atexit handler, so just return here */ + return 0; +} -- cgit v1.2.3 From 9aaa45283b14c3c81641f3f3e38157a267b1e8f7 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 15 Jan 2014 16:14:23 +0100 Subject: actually register the tempfile removal atexit Git-Dch: Ignore --- test/libapt/sourcelist_test.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'test/libapt/sourcelist_test.cc') diff --git a/test/libapt/sourcelist_test.cc b/test/libapt/sourcelist_test.cc index 6e83d08e0..adadae6a7 100644 --- a/test/libapt/sourcelist_test.cc +++ b/test/libapt/sourcelist_test.cc @@ -36,6 +36,7 @@ int main(int argc, char *argv[]) ; FileFd fd; + atexit(remove_tmpfile); tempfile = strdup("apt-test.XXXXXXXX"); tempfile_fd = mkstemp(tempfile); -- cgit v1.2.3 From 78766f46d043c1c1eeb9869db7e1c5b4093d5274 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 16 Jan 2014 18:14:14 +0100 Subject: update libapt test --- test/libapt/sourcelist_test.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/libapt/sourcelist_test.cc') diff --git a/test/libapt/sourcelist_test.cc b/test/libapt/sourcelist_test.cc index 6e83d08e0..1d30bd85b 100644 --- a/test/libapt/sourcelist_test.cc +++ b/test/libapt/sourcelist_test.cc @@ -23,15 +23,15 @@ int main(int argc, char *argv[]) { const char contents[] = "" "Type: deb\n" - "URL: http://ftp.debian.org/debian\n" - "Dist: stable\n" + "Uri: http://ftp.debian.org/debian\n" + "Suite: stable\n" "Section: main\n" "Comment: Some random string\n" " that can be very long\n" "\n" "Type: deb\n" - "URL: http://ftp.debian.org/debian\n" - "Dist: unstable\n" + "Uri: http://ftp.debian.org/debian\n" + "Suite: unstable\n" "Section: main non-free\n" ; -- cgit v1.2.3 From 866e9fadf892368fcb50e6a192bcdd350cfe8e5c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 17 Jan 2014 20:41:55 +0100 Subject: implement suggestion by donkult (thanks!) --- test/libapt/sourcelist_test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/libapt/sourcelist_test.cc') diff --git a/test/libapt/sourcelist_test.cc b/test/libapt/sourcelist_test.cc index 1d30bd85b..6a625770f 100644 --- a/test/libapt/sourcelist_test.cc +++ b/test/libapt/sourcelist_test.cc @@ -23,14 +23,14 @@ int main(int argc, char *argv[]) { const char contents[] = "" "Type: deb\n" - "Uri: http://ftp.debian.org/debian\n" + "URI: http://ftp.debian.org/debian\n" "Suite: stable\n" "Section: main\n" "Comment: Some random string\n" " that can be very long\n" "\n" "Type: deb\n" - "Uri: http://ftp.debian.org/debian\n" + "URI: http://ftp.debian.org/debian\n" "Suite: unstable\n" "Section: main non-free\n" ; -- cgit v1.2.3 From 6c069a2247781754bcc8574687cb98b493c6ab8a Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Sat, 18 Jan 2014 20:51:03 +0100 Subject: rename "Suite/Section" to plural --- test/libapt/sourcelist_test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/libapt/sourcelist_test.cc') diff --git a/test/libapt/sourcelist_test.cc b/test/libapt/sourcelist_test.cc index 6a625770f..ae5d11f66 100644 --- a/test/libapt/sourcelist_test.cc +++ b/test/libapt/sourcelist_test.cc @@ -24,8 +24,8 @@ int main(int argc, char *argv[]) const char contents[] = "" "Type: deb\n" "URI: http://ftp.debian.org/debian\n" - "Suite: stable\n" - "Section: main\n" + "Suites: stable\n" + "Sections: main\n" "Comment: Some random string\n" " that can be very long\n" "\n" -- cgit v1.2.3 From e67b9a23d7646d2f1e21bf4039fa71cc66b628c5 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 20 Jan 2014 07:43:17 +0100 Subject: add Description tag for deb822 sources --- test/libapt/sourcelist_test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/libapt/sourcelist_test.cc') diff --git a/test/libapt/sourcelist_test.cc b/test/libapt/sourcelist_test.cc index ae5d11f66..b9dd47207 100644 --- a/test/libapt/sourcelist_test.cc +++ b/test/libapt/sourcelist_test.cc @@ -26,8 +26,8 @@ int main(int argc, char *argv[]) "URI: http://ftp.debian.org/debian\n" "Suites: stable\n" "Sections: main\n" - "Comment: Some random string\n" - " that can be very long\n" + "Description: short\n" + " long description that can be very long\n" "\n" "Type: deb\n" "URI: http://ftp.debian.org/debian\n" -- cgit v1.2.3 From 75c10df1533ede97e05fef3d1e2fc6a22fc4db00 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 20 Jan 2014 08:10:50 +0100 Subject: add support for multiple URIs in deb822 style sources.list --- test/libapt/sourcelist_test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/libapt/sourcelist_test.cc') diff --git a/test/libapt/sourcelist_test.cc b/test/libapt/sourcelist_test.cc index b9dd47207..3597b3d58 100644 --- a/test/libapt/sourcelist_test.cc +++ b/test/libapt/sourcelist_test.cc @@ -23,14 +23,14 @@ int main(int argc, char *argv[]) { const char contents[] = "" "Type: deb\n" - "URI: http://ftp.debian.org/debian\n" + "URIs: http://ftp.debian.org/debian\n" "Suites: stable\n" "Sections: main\n" "Description: short\n" " long description that can be very long\n" "\n" "Type: deb\n" - "URI: http://ftp.debian.org/debian\n" + "URIs: http://ftp.debian.org/debian\n" "Suite: unstable\n" "Section: main non-free\n" ; -- cgit v1.2.3 From 7f316a3feab95370f1dd28c08c58bc3c140bf0a0 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 20 Jan 2014 08:17:43 +0100 Subject: add support for multipl types in one line --- test/libapt/sourcelist_test.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/libapt/sourcelist_test.cc') diff --git a/test/libapt/sourcelist_test.cc b/test/libapt/sourcelist_test.cc index 3597b3d58..6ab30ba67 100644 --- a/test/libapt/sourcelist_test.cc +++ b/test/libapt/sourcelist_test.cc @@ -22,17 +22,17 @@ void remove_tmpfile(void) int main(int argc, char *argv[]) { const char contents[] = "" - "Type: deb\n" + "Types: deb\n" "URIs: http://ftp.debian.org/debian\n" "Suites: stable\n" "Sections: main\n" "Description: short\n" " long description that can be very long\n" "\n" - "Type: deb\n" + "Types: deb\n" "URIs: http://ftp.debian.org/debian\n" - "Suite: unstable\n" - "Section: main non-free\n" + "Suites: unstable\n" + "Sections: main non-free\n" ; FileFd fd; -- cgit v1.2.3 From 5d9667d92a9d6973fc001c27d618bc878a4df2ba Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 24 Jan 2014 23:29:10 +0100 Subject: fix test --- test/libapt/sourcelist_test.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/libapt/sourcelist_test.cc') diff --git a/test/libapt/sourcelist_test.cc b/test/libapt/sourcelist_test.cc index 6fc84fd93..0300ce929 100644 --- a/test/libapt/sourcelist_test.cc +++ b/test/libapt/sourcelist_test.cc @@ -21,6 +21,8 @@ void remove_tmpfile(void) int main(int argc, char *argv[]) { + _config->Set("APT::Sources::Use-Deb822", true); + const char contents[] = "" "Types: deb\n" "URIs: http://ftp.debian.org/debian\n" -- cgit v1.2.3