mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
tests: use the test helpers in more places
This is mostly cosmetic. It makes those test binaries support SYSTEMD_LOG_* environment variables.
This commit is contained in:
parent
46d4d67d79
commit
f68a26221c
@ -15,6 +15,7 @@
|
||||
#include "lldp-network.h"
|
||||
#include "macro.h"
|
||||
#include "string-util.h"
|
||||
#include "tests.h"
|
||||
|
||||
#define TEST_LLDP_PORT "em1"
|
||||
#define TEST_LLDP_TYPE_SYSTEM_NAME "systemd-lldp"
|
||||
@ -365,7 +366,7 @@ static void test_multiple_neighbors_sorted(sd_event *e) {
|
||||
int main(int argc, char *argv[]) {
|
||||
_cleanup_(sd_event_unrefp) sd_event *e = NULL;
|
||||
|
||||
log_set_max_level(LOG_DEBUG);
|
||||
test_setup_logging(LOG_DEBUG);
|
||||
|
||||
/* LLDP reception tests */
|
||||
assert_se(sd_event_new(&e) == 0);
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "log.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "tests.h"
|
||||
|
||||
static void test_one_address(sd_bus *b,
|
||||
const char *host,
|
||||
@ -59,9 +60,7 @@ static void test_bus_set_address_system_remote(char **args) {
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
log_set_max_level(LOG_INFO);
|
||||
log_parse_environment();
|
||||
log_open();
|
||||
test_setup_logging(LOG_INFO);
|
||||
|
||||
test_bus_set_address_system_remote(argv + 1);
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "bus-introspect.h"
|
||||
#include "log.h"
|
||||
#include "tests.h"
|
||||
|
||||
static int prop_get(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) {
|
||||
return -EINVAL;
|
||||
@ -29,7 +30,7 @@ static const sd_bus_vtable vtable[] = {
|
||||
int main(int argc, char *argv[]) {
|
||||
struct introspect intro;
|
||||
|
||||
log_set_max_level(LOG_DEBUG);
|
||||
test_setup_logging(LOG_DEBUG);
|
||||
|
||||
assert_se(introspect_begin(&intro, false) >= 0);
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#include "sd-bus.h"
|
||||
|
||||
#include "main-func.h"
|
||||
#include "sd-bus.h"
|
||||
#include "tests.h"
|
||||
|
||||
static int run(int argc, char *argv[]) {
|
||||
static int test_ref_unref(void) {
|
||||
sd_bus_message *m = NULL;
|
||||
sd_bus *bus = NULL;
|
||||
int r;
|
||||
@ -41,4 +41,16 @@ static int run(int argc, char *argv[]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int run(int argc, char *argv[]) {
|
||||
int r;
|
||||
|
||||
test_setup_logging(LOG_INFO);
|
||||
|
||||
r = test_ref_unref();
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_MAIN_FUNCTION(run);
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "socket-util.h"
|
||||
#include "string-util.h"
|
||||
#include "tmpfile-util.h"
|
||||
#include "tests.h"
|
||||
|
||||
static int method_foobar(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {
|
||||
log_info("Got Foobar() call.");
|
||||
@ -198,7 +199,7 @@ int main(int argc, char *argv[]) {
|
||||
pthread_t server, client1, client2;
|
||||
char *path;
|
||||
|
||||
log_set_max_level(LOG_DEBUG);
|
||||
test_setup_logging(LOG_DEBUG);
|
||||
|
||||
/* We use /dev/shm here rather than /tmp, since some weird distros might set up /tmp as some weird fs that
|
||||
* doesn't support inotify properly. */
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "keymap-util.h"
|
||||
#include "log.h"
|
||||
#include "string-util.h"
|
||||
#include "tests.h"
|
||||
|
||||
static void test_find_language_fallback(void) {
|
||||
_cleanup_free_ char *ans = NULL, *ans2 = NULL;
|
||||
@ -189,8 +190,7 @@ static void test_x11_convert_to_vconsole(void) {
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
log_set_max_level(LOG_DEBUG);
|
||||
log_parse_environment();
|
||||
test_setup_logging(LOG_DEBUG);
|
||||
|
||||
test_find_language_fallback();
|
||||
test_find_converted_keymap();
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "log.h"
|
||||
#include "resolved-etc-hosts.h"
|
||||
#include "strv.h"
|
||||
#include "tests.h"
|
||||
#include "tmpfile-util.h"
|
||||
|
||||
static void test_parse_etc_hosts_system(void) {
|
||||
@ -137,9 +138,7 @@ static void test_parse_file(const char *fname) {
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
log_set_max_level(LOG_DEBUG);
|
||||
log_parse_environment();
|
||||
log_open();
|
||||
test_setup_logging(LOG_DEBUG);
|
||||
|
||||
if (argc == 1) {
|
||||
test_parse_etc_hosts_system();
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "log.h"
|
||||
#include "resolved-dns-packet.h"
|
||||
#include "tests.h"
|
||||
|
||||
static void test_dns_packet_new(void) {
|
||||
size_t i;
|
||||
@ -23,10 +24,7 @@ static void test_dns_packet_new(void) {
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
log_set_max_level(LOG_DEBUG);
|
||||
log_parse_environment();
|
||||
log_open();
|
||||
test_setup_logging(LOG_DEBUG);
|
||||
|
||||
test_dns_packet_new();
|
||||
|
||||
|
@ -12,11 +12,13 @@
|
||||
#include "in-addr-util.h"
|
||||
#include "local-addresses.h"
|
||||
#include "log.h"
|
||||
#include "main-func.h"
|
||||
#include "nss-util.h"
|
||||
#include "path-util.h"
|
||||
#include "stdio-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "tests.h"
|
||||
|
||||
static const char* nss_status_to_string(enum nss_status status, char *buf, size_t buf_len) {
|
||||
switch (status) {
|
||||
@ -485,7 +487,7 @@ static int parse_argv(int argc, char **argv,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
static int run(int argc, char **argv) {
|
||||
_cleanup_free_ char *dir = NULL;
|
||||
_cleanup_strv_free_ char **modules = NULL, **names = NULL;
|
||||
_cleanup_free_ struct local_address *addresses = NULL;
|
||||
@ -493,8 +495,7 @@ int main(int argc, char **argv) {
|
||||
char **module;
|
||||
int r;
|
||||
|
||||
log_set_max_level(LOG_INFO);
|
||||
log_parse_environment();
|
||||
test_setup_logging(LOG_INFO);
|
||||
|
||||
r = parse_argv(argc, argv, &modules, &names, &addresses, &n_addresses);
|
||||
if (r < 0) {
|
||||
@ -504,13 +505,15 @@ int main(int argc, char **argv) {
|
||||
|
||||
dir = dirname_malloc(argv[0]);
|
||||
if (!dir)
|
||||
return EXIT_FAILURE;
|
||||
return log_oom();
|
||||
|
||||
STRV_FOREACH(module, modules) {
|
||||
r = test_one_module(dir, *module, names, addresses, n_addresses);
|
||||
if (r < 0)
|
||||
return EXIT_FAILURE;
|
||||
return r;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_MAIN_FUNCTION(run);
|
||||
|
Loading…
Reference in New Issue
Block a user