2 * libdpkg - Debian packaging suite library routines
3 * t-pkginfo.c - test pkginfo handling
5 * Copyright © 2009-2010,2012-2014 Guillem Jover <guillem@debian.org>
7 * This is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 #include <dpkg/test.h>
25 #include <dpkg/dpkg-db.h>
29 test_pkginfo_informative(void)
34 test_fail(pkg_is_informative(&pkg, &pkg.installed));
36 pkg_set_want(&pkg, PKG_WANT_PURGE);
37 test_pass(pkg_is_informative(&pkg, &pkg.installed));
40 pkg.installed.description = "test description";
41 test_pass(pkg_is_informative(&pkg, &pkg.installed));
43 /* FIXME: Complete. */
47 test_pkginfo_eflags(void)
52 test_pass(pkg.eflag == PKG_EFLAG_OK);
54 pkg_set_eflags(&pkg, PKG_EFLAG_REINSTREQ);
55 test_pass(pkg.eflag == PKG_EFLAG_REINSTREQ);
57 pkg_clear_eflags(&pkg, PKG_EFLAG_REINSTREQ);
58 test_pass(pkg.eflag == PKG_EFLAG_OK);
60 pkg_set_eflags(&pkg, 0x11);
61 test_pass(pkg.eflag == 0x11);
62 pkg_reset_eflags(&pkg);
63 test_pass(pkg.eflag == PKG_EFLAG_OK);
67 test_pkginfo_instance_tracking(void)
70 struct pkginfo pkg2, pkg3, pkg4;
77 test_pass(pkgset_installed_instances(&set) == 0);
79 /* Link the other instances into the pkgset. */
80 pkgset_link_pkg(&set, &pkg4);
81 pkgset_link_pkg(&set, &pkg3);
82 pkgset_link_pkg(&set, &pkg2);
84 /* Test installation state transitions. */
85 pkg_set_status(&pkg4, PKG_STAT_INSTALLED);
86 test_pass(pkgset_installed_instances(&set) == 1);
88 pkg_set_status(&pkg4, PKG_STAT_INSTALLED);
89 test_pass(pkgset_installed_instances(&set) == 1);
91 pkg_set_status(&pkg4, PKG_STAT_TRIGGERSPENDING);
92 test_pass(pkgset_installed_instances(&set) == 1);
94 pkg_set_status(&pkg4, PKG_STAT_TRIGGERSAWAITED);
95 test_pass(pkgset_installed_instances(&set) == 1);
97 pkg_set_status(&pkg4, PKG_STAT_HALFCONFIGURED);
98 test_pass(pkgset_installed_instances(&set) == 1);
100 pkg_set_status(&pkg4, PKG_STAT_UNPACKED);
101 test_pass(pkgset_installed_instances(&set) == 1);
103 pkg_set_status(&pkg4, PKG_STAT_HALFINSTALLED);
104 test_pass(pkgset_installed_instances(&set) == 1);
106 pkg_set_status(&pkg4, PKG_STAT_CONFIGFILES);
107 test_pass(pkgset_installed_instances(&set) == 1);
109 pkg_set_status(&pkg4, PKG_STAT_NOTINSTALLED);
110 test_pass(pkgset_installed_instances(&set) == 0);
112 pkg_set_status(&pkg4, PKG_STAT_NOTINSTALLED);
113 test_pass(pkgset_installed_instances(&set) == 0);
115 /* Toggle installation states on various packages. */
116 pkg_set_status(&pkg4, PKG_STAT_INSTALLED);
117 test_pass(pkgset_installed_instances(&set) == 1);
119 pkg_set_status(&pkg2, PKG_STAT_HALFINSTALLED);
120 test_pass(pkgset_installed_instances(&set) == 2);
122 pkg_set_status(&set.pkg, PKG_STAT_CONFIGFILES);
123 test_pass(pkgset_installed_instances(&set) == 3);
125 pkg_set_status(&pkg3, PKG_STAT_NOTINSTALLED);
126 test_pass(pkgset_installed_instances(&set) == 3);
128 pkg_set_status(&pkg3, PKG_STAT_UNPACKED);
129 test_pass(pkgset_installed_instances(&set) == 4);
131 pkg_set_status(&set.pkg, PKG_STAT_NOTINSTALLED);
132 test_pass(pkgset_installed_instances(&set) == 3);
134 pkg_set_status(&pkg2, PKG_STAT_NOTINSTALLED);
135 test_pass(pkgset_installed_instances(&set) == 2);
137 pkg_set_status(&pkg3, PKG_STAT_NOTINSTALLED);
138 test_pass(pkgset_installed_instances(&set) == 1);
140 pkg_set_status(&pkg4, PKG_STAT_NOTINSTALLED);
141 test_pass(pkgset_installed_instances(&set) == 0);
148 test_pkginfo_informative();
149 test_pkginfo_eflags();
150 test_pkginfo_instance_tracking();
152 /* FIXME: Complete. */