aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/test_logging.cpp
diff options
context:
space:
mode:
authorHanda Wang <handaw@google.com>2024-04-08 03:12:17 +0000
committerHanda Wang <handaw@google.com>2024-04-08 03:12:17 +0000
commita7f6b2393e664bfbbe3148b11b8fdfc4a6fb82b0 (patch)
tree3cf630729906f56334d852e45d9450e886b78420 /tests/unit/test_logging.cpp
parenta9b3d914c69dde849bb50f96b393a224eef1f1db (diff)
parentcec64774fc7bfce43f8d173a905c6a2c9a7cdeac (diff)
downloadot-br-posix-a7f6b2393e664bfbbe3148b11b8fdfc4a6fb82b0.tar.gz
[Github Sync] Merge github/main to aosp/main
Bug: 333301206 * github/main: submodule: bump third_party/openthread/repo from `38418ae` to `65bc830` (#2240) submodule: bump third_party/openthread/repo from `0e36799` to `38418ae` (#2239) [continuous-integration] install `socat` for docker-based BR tests (#2236) submodule: bump third_party/openthread/repo from `d099d78` to `0e36799` (#2238) submodule: bump third_party/openthread/repo from `37144f0` to `d099d78` (#2237) submodule: bump third_party/openthread/repo from `58b230f` to `37144f0` (#2235) submodule: bump third_party/openthread/repo from `7d4a1f8` to `58b230f` (#2234) [border-agent] remove duplicate Thread state callback registrations (#2233) submodule: bump third_party/openthread/repo from `4db6520` to `7d4a1f8` (#2232) submodule: bump third_party/openthread/repo from `90adc86` to `4db6520` (#2231) [version] introduce `OT_THREAD_VERSION_1_4` (#2229) submodule: bump third_party/openthread/repo from `51ab865` to `90adc86` (#2230) submodule: bump third_party/openthread/repo from `8b906eb` to `51ab865` (#2227) submodule: bump third_party/openthread/repo from `9d6321b` to `8b906eb` (#2225) [meshcop] support runtime custom vendor and product name (#2200) submodule: bump third_party/openthread/repo from `3ebc3d3` to `9d6321b` (#2224) submodule: bump third_party/openthread/repo from `8769898` to `3ebc3d3` (#2222) submodule: bump third_party/openthread/repo from `8e9d58f` to `8769898` (#2221) [ncp] clear handlers and callbacks in `NcpOpenThread::Deinit()` (#2220) [mdns-avahi] handle potential unknown Avahi states gracefully (#2210) submodule: bump third_party/openthread/repo from `53382ec` to `8e9d58f` (#2219) [logging] add command line arg to disable syslog (#2102) [github-actions] fix macOS CI (#2218) submodule: bump third_party/openthread/repo from `39fcc5e` to `53382ec` (#2215) submodule: bump third_party/openthread/repo from `d63da4f` to `39fcc5e` (#2214) submodule: bump third_party/openthread/repo from `08a7600` to `d63da4f` (#2213) [mdns-avahi] allow `UnsubscribeService/Host()` to remove non-present entries (#2209) submodule: bump third_party/openthread/repo from `41526d5` to `08a7600` (#2212) submodule: bump third_party/openthread/repo from `b9dcdbc` to `41526d5` (#2211) [discovery-proxy] remove `assert` checks on query name parse errors (#2208) [mdns] allow `UnsubscribeService/Host()` to remove non-present entries (#2206) submodule: bump third_party/openthread/repo from `f0b6fce` to `b9dcdbc` (#2205) [github-actions] add `brew upgrade node` (#2204) submodule: bump third_party/openthread/repo from `6cfe14c` to `f0b6fce` (#2199) [openwrt] remove usage of `OT_NETWORK_DIAGNOSTIC_TYPELIST_MAX_ENTRIES` (#2198) submodule: bump third_party/openthread/repo from `33574ad` to `6cfe14c` (#2196) Change-Id: Idf632ab5b108304a6d875bf501cf482e7aaefd78
Diffstat (limited to 'tests/unit/test_logging.cpp')
-rw-r--r--tests/unit/test_logging.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/tests/unit/test_logging.cpp b/tests/unit/test_logging.cpp
index 30bd476c..c2997035 100644
--- a/tests/unit/test_logging.cpp
+++ b/tests/unit/test_logging.cpp
@@ -43,7 +43,7 @@ TEST(Logging, TestLoggingHigherLevel)
char ident[20];
snprintf(ident, sizeof(ident), "otbr-test-%ld", clock());
- otbrLogInit(ident, OTBR_LOG_INFO, true);
+ otbrLogInit(ident, OTBR_LOG_INFO, true, false);
otbrLog(OTBR_LOG_DEBUG, OTBR_LOG_TAG, "cool-higher");
otbrLogDeinit();
sleep(0);
@@ -58,7 +58,7 @@ TEST(Logging, TestLoggingEqualLevel)
char ident[20];
snprintf(ident, sizeof(ident), "otbr-test-%ld", clock());
- otbrLogInit(ident, OTBR_LOG_INFO, true);
+ otbrLogInit(ident, OTBR_LOG_INFO, true, false);
otbrLog(OTBR_LOG_INFO, OTBR_LOG_TAG, "cool-equal");
otbrLogDeinit();
sleep(0);
@@ -69,13 +69,29 @@ TEST(Logging, TestLoggingEqualLevel)
CHECK(0 == system(cmd));
}
+TEST(Logging, TestLoggingEqualLevelNoSyslog)
+{
+ char ident[20];
+
+ snprintf(ident, sizeof(ident), "otbr-test-%ld", clock());
+ otbrLogInit(ident, OTBR_LOG_INFO, true, true);
+ otbrLog(OTBR_LOG_INFO, OTBR_LOG_TAG, "cool-equal");
+ otbrLogDeinit();
+ sleep(0);
+
+ char cmd[128];
+ snprintf(cmd, sizeof(cmd), "grep '%s.*cool-equal' /var/log/syslog", ident);
+ printf("CMD = %s\n", cmd);
+ CHECK(0 != system(cmd));
+}
+
TEST(Logging, TestLoggingLowerLevel)
{
char ident[20];
char cmd[128];
snprintf(ident, sizeof(ident), "otbr-test-%ld", clock());
- otbrLogInit(ident, OTBR_LOG_INFO, true);
+ otbrLogInit(ident, OTBR_LOG_INFO, true, false);
otbrLog(OTBR_LOG_WARNING, OTBR_LOG_TAG, "cool-lower");
otbrLogDeinit();
sleep(0);
@@ -90,7 +106,7 @@ TEST(Logging, TestLoggingDump)
char cmd[128];
snprintf(ident, sizeof(ident), "otbr-test-%ld", clock());
- otbrLogInit(ident, OTBR_LOG_DEBUG, true);
+ otbrLogInit(ident, OTBR_LOG_DEBUG, true, false);
const char s[] = "one super long string with lots of text";
otbrDump(OTBR_LOG_INFO, "Test", "foobar", s, sizeof(s));
otbrLogDeinit();