[ovs-dev] [vlog 3/6] tests: Call vlog_init() consistently.
Ben Pfaff
blp at nicira.com
Wed Jul 14 23:20:52 UTC 2010
I discovered that some of the Open vSwitch utilities don't call
vlog_init(). This leaves all of their log levels initially set to 0,
which is VLL_EMER, hence disabling logging entirely. That wasn't
intentional, so this commit adds those calls, plus a few missing calls to
set_program_name().
---
tests/test-hmap.c | 5 ++++-
tests/test-json.c | 2 ++
tests/test-lockfile.c | 3 +++
tests/test-reconnect.c | 4 ++++
tests/test-stp.c | 5 +++++
tests/test-timeval.c | 2 ++
6 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/tests/test-hmap.c b/tests/test-hmap.c
index 18d8f46..8bfd3c4 100644
--- a/tests/test-hmap.c
+++ b/tests/test-hmap.c
@@ -22,6 +22,7 @@
#include <string.h>
#include "hash.h"
#include "util.h"
+#include "vlog.h"
#undef NDEBUG
#include <assert.h>
@@ -286,8 +287,10 @@ run_test(void (*function)(hash_func *))
}
int
-main(void)
+main(int argc OVS_UNUSED, char *argv[])
{
+ set_program_name(argv[0]);
+ vlog_init();
run_test(test_hmap_insert_delete);
run_test(test_hmap_for_each_safe);
run_test(test_hmap_reserve_shrink);
diff --git a/tests/test-json.c b/tests/test-json.c
index f297dc2..92e15f3 100644
--- a/tests/test-json.c
+++ b/tests/test-json.c
@@ -24,6 +24,7 @@
#include <stdio.h>
#include "util.h"
+#include "vlog.h"
/* --pretty: If set, the JSON output is pretty-printed, instead of printed as
* compactly as possible. */
@@ -111,6 +112,7 @@ main(int argc, char *argv[])
bool ok;
set_program_name(argv[0]);
+ vlog_init();
for (;;) {
static const struct option options[] = {
diff --git a/tests/test-lockfile.c b/tests/test-lockfile.c
index f0f4b01..8b08a66 100644
--- a/tests/test-lockfile.c
+++ b/tests/test-lockfile.c
@@ -26,6 +26,7 @@
#include "process.h"
#include "timeval.h"
#include "util.h"
+#include "vlog.h"
#undef NDEBUG
#include <assert.h>
@@ -241,6 +242,8 @@ main(int argc, char *argv[])
set_program_name(argv[0]);
time_init();
+ vlog_init();
+ vlog_set_levels(VLM_lockfile, VLF_ANY_FACILITY, VLL_ERR);
if (argc != 2) {
ovs_fatal(0, "exactly one argument required; use \"%s help\" for help",
diff --git a/tests/test-reconnect.c b/tests/test-reconnect.c
index 2d0d441..8bafa00 100644
--- a/tests/test-reconnect.c
+++ b/tests/test-reconnect.c
@@ -27,6 +27,7 @@
#include "compiler.h"
#include "svec.h"
#include "util.h"
+#include "vlog.h"
static struct reconnect *reconnect;
static int now;
@@ -44,6 +45,9 @@ main(void)
int old_time;
char line[128];
+ vlog_init();
+ vlog_set_levels(VLM_reconnect, VLF_ANY_FACILITY, VLL_EMER);
+
now = 1000;
reconnect = reconnect_create(now);
reconnect_set_name(reconnect, "remote");
diff --git a/tests/test-stp.c b/tests/test-stp.c
index eab13d6..e033cff 100644
--- a/tests/test-stp.c
+++ b/tests/test-stp.c
@@ -23,6 +23,8 @@
#include <stdlib.h>
#include "ofpbuf.h"
#include "packets.h"
+#include "util.h"
+#include "vlog.h"
struct bpdu {
int port_no;
@@ -438,6 +440,9 @@ main(int argc, char *argv[])
FILE *input_file;
int i;
+ set_program_name(argv[0]);
+ vlog_init();
+
if (argc != 2) {
ovs_fatal(0, "usage: test-stp INPUT.STP\n");
}
diff --git a/tests/test-timeval.c b/tests/test-timeval.c
index b336f39..a8c4019 100644
--- a/tests/test-timeval.c
+++ b/tests/test-timeval.c
@@ -28,6 +28,7 @@
#include "command-line.h"
#include "daemon.h"
#include "util.h"
+#include "vlog.h"
#undef NDEBUG
#include <assert.h>
@@ -94,6 +95,7 @@ main(int argc, char *argv[])
proctitle_init(argc, argv);
set_program_name(argv[0]);
time_init();
+ vlog_init();
if (argc != 2) {
usage();
--
1.7.1
More information about the dev
mailing list