]>
git.ipfire.org Git - people/ms/pakfire.git/blob - tests/libpakfire/jail.c
1 /*#############################################################################
3 # Pakfire - The IPFire package management system #
4 # Copyright (C) 2022 Pakfire development team #
6 # This program is free software: you can redistribute it and/or modify #
7 # it under the terms of the GNU General Public License as published by #
8 # the Free Software Foundation, either version 3 of the License, or #
9 # (at your option) any later version. #
11 # This program is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU General Public License for more details. #
16 # You should have received a copy of the GNU General Public License #
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 #############################################################################*/
21 #include <pakfire/jail.h>
23 #include "../testsuite.h"
25 static const char* cmd
[2] = {
26 "/usr/bin/does-not-exist",
29 static int test_create(const struct test
* t
) {
30 struct pakfire_jail
* jail
= NULL
;
33 ASSERT_SUCCESS(pakfire_jail_create(&jail
, t
->pakfire
));
36 ASSERT_NULL(pakfire_jail_unref(jail
));
44 static int test_env(const struct test
* t
) {
45 struct pakfire_jail
* jail
= NULL
;
48 ASSERT_SUCCESS(pakfire_jail_create(&jail
, t
->pakfire
));
50 // Fetch a non-existing environment variable
51 ASSERT_NULL(pakfire_jail_get_env(jail
, "VARIABLE"));
54 ASSERT_SUCCESS(pakfire_jail_set_env(jail
, "VARIABLE", "VALUE"));
56 // Read the value back
57 ASSERT_STRING_EQUALS(pakfire_jail_get_env(jail
, "VARIABLE"), "VALUE");
60 ASSERT_NULL(pakfire_jail_unref(jail
));
69 int main(int argc
, char** argv
) {
70 testsuite_add_test(test_create
);
71 testsuite_add_test(test_env
);
73 return testsuite_run();