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:
Zbigniew Jędrzejewski-Szmek
2019-03-04 14:15:38 +01:00
parent 46d4d67d79
commit f68a26221c
9 changed files with 37 additions and 23 deletions
+2 -3
View File
@@ -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 -1
View File
@@ -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);
+2 -1
View File
@@ -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. */