test-install.c revision 830964834f330836b9d33752e83de09d4f38da87
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2011 Lennart Poettering
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include "util.h"
#include "install.h"
static void dump_changes(UnitFileChange *c, unsigned n) {
unsigned i;
assert(n == 0 || c);
for (i = 0; i < n; i++) {
if (c[i].type == UNIT_FILE_UNLINK)
else if (c[i].type == UNIT_FILE_SYMLINK)
}
}
Hashmap *h;
UnitFileList *p;
Iterator i;
int r;
unsigned n_changes = 0;
assert_se(r == 0);
HASHMAP_FOREACH(p, h, i) {
p->path,
}
log_error("enable");
assert_se(r >= 0);
log_error("enable2");
assert_se(r >= 0);
log_error("disable");
n_changes = 0;
assert_se(r >= 0);
log_error("mask");
n_changes = 0;
assert_se(r >= 0);
log_error("mask2");
assert_se(r >= 0);
log_error("unmask");
n_changes = 0;
assert_se(r >= 0);
log_error("unmask2");
assert_se(r >= 0);
log_error("mask");
n_changes = 0;
assert_se(r >= 0);
log_error("disable");
n_changes = 0;
assert_se(r >= 0);
log_error("disable2");
assert_se(r >= 0);
log_error("umask");
n_changes = 0;
assert_se(r >= 0);
log_error("enable files2");
n_changes = 0;
assert_se(r >= 0);
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(files2[0])) == UNIT_FILE_ENABLED);
log_error("disable files2");
n_changes = 0;
assert_se(r >= 0);
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(files2[0])) == _UNIT_FILE_STATE_INVALID);
log_error("link files2");
n_changes = 0;
assert_se(r >= 0);
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(files2[0])) == UNIT_FILE_LINKED);
log_error("disable files2");
n_changes = 0;
assert_se(r >= 0);
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(files2[0])) == _UNIT_FILE_STATE_INVALID);
log_error("link files2");
n_changes = 0;
assert_se(r >= 0);
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(files2[0])) == UNIT_FILE_LINKED);
log_error("reenable files2");
n_changes = 0;
r = unit_file_reenable(UNIT_FILE_SYSTEM, false, NULL, (char**) files2, false, &changes, &n_changes);
assert_se(r >= 0);
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(files2[0])) == UNIT_FILE_ENABLED);
log_error("disable files2");
n_changes = 0;
assert_se(r >= 0);
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(files2[0])) == _UNIT_FILE_STATE_INVALID);
log_error("preset files");
n_changes = 0;
assert_se(r >= 0);
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(files[0])) == UNIT_FILE_ENABLED);
return 0;
}