summaryrefslogtreecommitdiffstats
path: root/vespalog/src/test/simple
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
commit72231250ed81e10d66bfe70701e64fa5fe50f712 (patch)
tree2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /vespalog/src/test/simple
Publish
Diffstat (limited to 'vespalog/src/test/simple')
-rw-r--r--vespalog/src/test/simple/.gitignore4
-rw-r--r--vespalog/src/test/simple/CMakeLists.txt8
-rw-r--r--vespalog/src/test/simple/expect.lctl5
-rw-r--r--vespalog/src/test/simple/logtest.cpp37
4 files changed, 54 insertions, 0 deletions
diff --git a/vespalog/src/test/simple/.gitignore b/vespalog/src/test/simple/.gitignore
new file mode 100644
index 00000000000..d3c5aa01c49
--- /dev/null
+++ b/vespalog/src/test/simple/.gitignore
@@ -0,0 +1,4 @@
+/simple.lctl
+/simple.logf
+/simple_test
+vespalog_simple_test_app
diff --git a/vespalog/src/test/simple/CMakeLists.txt b/vespalog/src/test/simple/CMakeLists.txt
new file mode 100644
index 00000000000..f915772d80f
--- /dev/null
+++ b/vespalog/src/test/simple/CMakeLists.txt
@@ -0,0 +1,8 @@
+# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+vespa_add_executable(vespalog_simple_test_app
+ SOURCES
+ logtest.cpp
+ DEPENDS
+ vespalog
+)
+vespa_add_test(NAME vespalog_simple_test_app COMMAND vespalog_simple_test_app)
diff --git a/vespalog/src/test/simple/expect.lctl b/vespalog/src/test/simple/expect.lctl
new file mode 100644
index 00000000000..5256fbb2821
--- /dev/null
+++ b/vespalog/src/test/simple/expect.lctl
@@ -0,0 +1,5 @@
+Vespa log control file version 1
+Prefix: logtest
+
+default: ON ON ON ON ON ON OFF OFF
+.log: ON ON ON ON ON ON OFF OFF
diff --git a/vespalog/src/test/simple/logtest.cpp b/vespalog/src/test/simple/logtest.cpp
new file mode 100644
index 00000000000..b532b2a4b8f
--- /dev/null
+++ b/vespalog/src/test/simple/logtest.cpp
@@ -0,0 +1,37 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include <sys/types.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+
+#include <vespa/log/log.h>
+
+LOG_SETUP("logtest",
+ "$Id: logtest.cpp 119439 2011-04-19 09:32:27Z arnej $");
+
+int
+main(int, char **argv)
+{
+ EV_STARTING("logtest");
+ LOG(info, "Starting up, called as %s", argv[0]);
+ EV_STARTED("logtest");
+ EV_RELOADING("something");
+ EV_RELOADED("something");
+ EV_CRASH("something", getpid(), SIGTERM);
+ EV_PROGRESS("batch-index", 7, 100);
+ EV_PROGRESS("unbounded-batch-index", 9);
+ EV_COUNT("hits", 3);
+ EV_VALUE("some value", 1./3);
+
+ LOG(info, "backslash: \\");
+ int n;
+ LOG(info, "Will log 20 spam messages now every 50ms");
+ for (n = 1; n <= 5; n++) {
+ LOG(spam, "log message %d/%d", n, 100);
+ usleep(50000);
+ }
+ LOG(info, "Exiting.");
+ EV_STOPPING("logtest", "clean exit");
+ EV_STOPPED("logtest", getpid(), 0);
+ exit(EXIT_SUCCESS);
+}