test-catalog.c revision c059b62fe696516855813ff03f432375333a2737
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2012 Lennart Poettering
Copyright 2013 Zbigniew Jędrzejewski-Szmek
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <fcntl.h>
#include <locale.h>
#include <unistd.h>
#include "sd-messages.h"
#include "alloc-util.h"
#include "catalog.h"
#include "fd-util.h"
#include "fileio.h"
#include "log.h"
#include "macro.h"
#include "string-util.h"
#include "util.h"
static const char *catalog_dirs[] = {
NULL,
};
static const char *no_catalog_dirs[] = {
};
int r;
char name[] = "/tmp/test-catalog.XXXXXX";
_cleanup_close_ int fd;
Hashmap *h;
if (size < 0)
r = catalog_import_file(h, name);
return h;
}
static void test_catalog_import_invalid(void) {
assert_se(hashmap_isempty(h));
}
static void test_catalog_import_badid(void) {
const char *input =
"-- 0027229ca0644181a76c4e92458afaff dededededededededededededededede\n" \
"Subject: message\n" \
"\n" \
"payload\n";
}
static void test_catalog_import_one(void) {
char *payload;
Iterator j;
const char *input =
"-- 0027229ca0644181a76c4e92458afaff dededededededededededededededed\n" \
"Subject: message\n" \
"\n" \
"payload\n";
const char *expect =
"Subject: message\n" \
"\n" \
"payload\n";
HASHMAP_FOREACH(payload, h, j) {
}
}
static void test_catalog_import_merge(void) {
char *payload;
Iterator j;
const char *input =
"-- 0027229ca0644181a76c4e92458afaff dededededededededededededededed\n" \
"Subject: message\n" \
"Defined-By: me\n" \
"\n" \
"payload\n" \
"\n" \
"-- 0027229ca0644181a76c4e92458afaff dededededededededededededededed\n" \
"Subject: override subject\n" \
"X-Header: hello\n" \
"\n" \
"override payload\n";
const char *combined =
"Subject: override subject\n" \
"X-Header: hello\n" \
"Subject: message\n" \
"Defined-By: me\n" \
"\n" \
"override payload\n";
HASHMAP_FOREACH(payload, h, j) {
}
}
static void test_catalog_import_merge_no_body(void) {
char *payload;
Iterator j;
const char *input =
"-- 0027229ca0644181a76c4e92458afaff dededededededededededededededed\n" \
"Subject: message\n" \
"Defined-By: me\n" \
"\n" \
"payload\n" \
"\n" \
"-- 0027229ca0644181a76c4e92458afaff dededededededededededededededed\n" \
"Subject: override subject\n" \
"X-Header: hello\n" \
"\n";
const char *combined =
"Subject: override subject\n" \
"X-Header: hello\n" \
"Subject: message\n" \
"Defined-By: me\n" \
"\n" \
"payload\n";
HASHMAP_FOREACH(payload, h, j) {
}
}
static void test_catalog_update(void) {
static char name[] = "/tmp/test-catalog.XXXXXX";
int r;
assert_se(r >= 0);
/* Test what happens if there are no files. */
assert_se(r >= 0);
/* Test what happens if there are no files in the directory. */
assert_se(r >= 0);
/* Make sure that we at least have some files loaded or the
catalog_list below will fail. */
assert_se(r >= 0);
}
static void test_catalog_file_lang(void) {
}
int r;
log_open();
assert_se(r >= 0);
assert_se(r >= 0);
if (database)
return 0;
}