aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--.github/workflows/macOS.yml15
-rw-r--r--etc/docker/Dockerfile2
-rw-r--r--src/agent/main.cpp18
-rw-r--r--src/common/logging.cpp40
-rw-r--r--src/common/logging.hpp13
-rw-r--r--src/mdns/mdns_avahi.cpp12
-rw-r--r--src/mdns/mdns_mdnssd.cpp4
-rw-r--r--src/ncp/ncp_openthread.cpp12
-rw-r--r--src/openwrt/ubus/otubus.cpp4
-rw-r--r--src/sdp_proxy/discovery_proxy.cpp10
-rw-r--r--src/web/main.cpp2
-rw-r--r--tests/mdns/main.cpp2
-rw-r--r--tests/mdns/test_subscribe.cpp2
-rw-r--r--tests/unit/test_logging.cpp24
14 files changed, 103 insertions, 57 deletions
diff --git a/.github/workflows/macOS.yml b/.github/workflows/macOS.yml
index 11f1566c..a99adde8 100644
--- a/.github/workflows/macOS.yml
+++ b/.github/workflows/macOS.yml
@@ -49,18 +49,13 @@ jobs:
submodules: true
- name: Bootstrap
run: |
- rm -f /usr/local/bin/2to3
- rm -f /usr/local/bin/2to3-3.11
- rm -f /usr/local/bin/idle3
- rm -f /usr/local/bin/idle3.11
- rm -f /usr/local/bin/pydoc3
- rm -f /usr/local/bin/pydoc3.11
- rm -f /usr/local/bin/python3
- rm -f /usr/local/bin/python3.11
- rm -f /usr/local/bin/python3-config
- rm -f /usr/local/bin/python3.11-config
+ rm -f /usr/local/bin/2to3*
+ rm -f /usr/local/bin/idle3*
+ rm -f /usr/local/bin/pydoc3*
+ rm -f /usr/local/bin/python3*
brew update
brew reinstall boost cmake cpputest dbus jsoncpp ninja protobuf@21 pkg-config
+ brew upgrade node
- name: Build
run: |
OTBR_OPTIONS="-DOTBR_BORDER_AGENT=OFF \
diff --git a/etc/docker/Dockerfile b/etc/docker/Dockerfile
index eef7a948..08f160c8 100644
--- a/etc/docker/Dockerfile
+++ b/etc/docker/Dockerfile
@@ -78,7 +78,7 @@ ENV OTBR_BUILD_DEPS apt-utils build-essential psmisc ninja-build cmake wget ca-c
libnetfilter-queue-dev
# Required for OpenThread Backbone CI
-ENV OTBR_OT_BACKBONE_CI_DEPS curl lcov wget build-essential python3-dbus python3-zeroconf
+ENV OTBR_OT_BACKBONE_CI_DEPS curl lcov wget build-essential python3-dbus python3-zeroconf socat
# Required and installed during build (script/bootstrap) when RELEASE=1, could be removed
ENV OTBR_NORELEASE_DEPS \
diff --git a/src/agent/main.cpp b/src/agent/main.cpp
index 4ed5e277..776c3e72 100644
--- a/src/agent/main.cpp
+++ b/src/agent/main.cpp
@@ -70,6 +70,7 @@ enum
OTBR_OPT_HELP = 'h',
OTBR_OPT_INTERFACE_NAME = 'I',
OTBR_OPT_VERBOSE = 'v',
+ OTBR_OPT_SYSLOG_DISABLE = 's',
OTBR_OPT_VERSION = 'V',
OTBR_OPT_SHORTMAX = 128,
OTBR_OPT_RADIO_VERSION,
@@ -90,6 +91,7 @@ static const struct option kOptions[] = {
{"help", no_argument, nullptr, OTBR_OPT_HELP},
{"thread-ifname", required_argument, nullptr, OTBR_OPT_INTERFACE_NAME},
{"verbose", no_argument, nullptr, OTBR_OPT_VERBOSE},
+ {"syslog-disable", no_argument, nullptr, OTBR_OPT_SYSLOG_DISABLE},
{"version", no_argument, nullptr, OTBR_OPT_VERSION},
{"radio-version", no_argument, nullptr, OTBR_OPT_RADIO_VERSION},
{"auto-attach", optional_argument, nullptr, OTBR_OPT_AUTO_ATTACH},
@@ -136,9 +138,10 @@ static std::vector<char *> AppendAutoAttachDisableArg(int argc, char *argv[])
static void PrintHelp(const char *aProgramName)
{
fprintf(stderr,
- "Usage: %s [-I interfaceName] [-B backboneIfName] [-d DEBUG_LEVEL] [-v] [--auto-attach[=0/1]] RADIO_URL "
- "[RADIO_URL]\n"
- " --auto-attach defaults to 1\n",
+ "Usage: %s [-I interfaceName] [-B backboneIfName] [-d DEBUG_LEVEL] [-v] [-s] [--auto-attach[=0/1]] "
+ "RADIO_URL [RADIO_URL]\n"
+ " --auto-attach defaults to 1\n"
+ " -s disables syslog and prints to standard out\n",
aProgramName);
fprintf(stderr, "%s", otSysGetRadioUrlHelpString());
}
@@ -195,6 +198,7 @@ static int realmain(int argc, char *argv[])
int ret = EXIT_SUCCESS;
const char *interfaceName = kDefaultInterfaceName;
bool verbose = false;
+ bool syslogDisable = false;
bool printRadioVersion = false;
bool enableAutoAttach = true;
const char *restListenAddress = "";
@@ -205,7 +209,7 @@ static int realmain(int argc, char *argv[])
std::set_new_handler(OnAllocateFailed);
- while ((opt = getopt_long(argc, argv, "B:d:hI:Vv", kOptions, nullptr)) != -1)
+ while ((opt = getopt_long(argc, argv, "B:d:hI:Vvs", kOptions, nullptr)) != -1)
{
switch (opt)
{
@@ -228,6 +232,10 @@ static int realmain(int argc, char *argv[])
verbose = true;
break;
+ case OTBR_OPT_SYSLOG_DISABLE:
+ syslogDisable = true;
+ break;
+
case OTBR_OPT_VERSION:
PrintVersion();
ExitNow();
@@ -269,7 +277,7 @@ static int realmain(int argc, char *argv[])
}
}
- otbrLogInit(argv[0], logLevel, verbose);
+ otbrLogInit(argv[0], logLevel, verbose, syslogDisable);
otbrLogNotice("Running %s", OTBR_PACKAGE_VERSION);
otbrLogNotice("Thread version: %s", otbr::Ncp::ControllerOpenThread::GetThreadVersion());
otbrLogNotice("Thread interface: %s", interfaceName);
diff --git a/src/common/logging.cpp b/src/common/logging.cpp
index 5a787e82..c5f70185 100644
--- a/src/common/logging.cpp
+++ b/src/common/logging.cpp
@@ -53,6 +53,7 @@ static otbrLogLevel sLevel = OTBR_LOG_INFO;
static const char sLevelString[][8] = {
"[EMERG]", "[ALERT]", "[CRIT]", "[ERR ]", "[WARN]", "[NOTE]", "[INFO]", "[DEBG]",
};
+static bool sSyslogDisabled = false;
static otbrLogLevel sDefaultLevel = OTBR_LOG_INFO;
@@ -77,8 +78,14 @@ void otbrLogSetLevel(otbrLogLevel aLevel)
sLevel = aLevel;
}
+/** Enable/disable logging with syslog */
+void otbrLogSyslogSetEnabled(bool aEnabled)
+{
+ sSyslogDisabled = !aEnabled;
+}
+
/** Initialize logging */
-void otbrLogInit(const char *aProgramName, otbrLogLevel aLevel, bool aPrintStderr)
+void otbrLogInit(const char *aProgramName, otbrLogLevel aLevel, bool aPrintStderr, bool aSyslogDisable)
{
const char *ident;
@@ -88,7 +95,12 @@ void otbrLogInit(const char *aProgramName, otbrLogLevel aLevel, bool aPrintStder
ident = strrchr(aProgramName, '/');
ident = (ident != nullptr) ? ident + 1 : aProgramName;
- openlog(ident, (LOG_CONS | LOG_PID) | (aPrintStderr ? LOG_PERROR : 0), OTBR_SYSLOG_FACILITY_ID);
+ otbrLogSyslogSetEnabled(!aSyslogDisable);
+
+ if (!sSyslogDisabled)
+ {
+ openlog(ident, (LOG_CONS | LOG_PID) | (aPrintStderr ? LOG_PERROR : 0), OTBR_SYSLOG_FACILITY_ID);
+ }
sLevel = aLevel;
sDefaultLevel = sLevel;
}
@@ -118,7 +130,7 @@ static const char *GetPrefix(const char *aLogTag)
return prefix;
}
-/** log to the syslog or log file */
+/** log to the syslog or standard out */
void otbrLog(otbrLogLevel aLevel, const char *aLogTag, const char *aFormat, ...)
{
const uint16_t kBufferSize = 1024;
@@ -129,7 +141,14 @@ void otbrLog(otbrLogLevel aLevel, const char *aLogTag, const char *aFormat, ...)
if ((aLevel <= sLevel) && (vsnprintf(buffer, sizeof(buffer), aFormat, ap) > 0))
{
- syslog(static_cast<int>(aLevel), "%s%s: %s", sLevelString[aLevel], GetPrefix(aLogTag), buffer);
+ if (sSyslogDisabled)
+ {
+ printf("%s%s: %s\n", sLevelString[aLevel], GetPrefix(aLogTag), buffer);
+ }
+ else
+ {
+ syslog(static_cast<int>(aLevel), "%s%s: %s", sLevelString[aLevel], GetPrefix(aLogTag), buffer);
+ }
}
va_end(ap);
@@ -137,7 +156,7 @@ void otbrLog(otbrLogLevel aLevel, const char *aLogTag, const char *aFormat, ...)
return;
}
-/** log to the syslog or log file */
+/** log to the syslog or standard out */
void otbrLogv(otbrLogLevel aLevel, const char *aFormat, va_list aArgList)
{
assert(aFormat);
@@ -148,9 +167,18 @@ void otbrLogv(otbrLogLevel aLevel, const char *aFormat, va_list aArgList)
}
}
+/** log to the syslog or standard out */
void otbrLogvNoFilter(otbrLogLevel aLevel, const char *aFormat, va_list aArgList)
{
- vsyslog(static_cast<int>(aLevel), aFormat, aArgList);
+ if (sSyslogDisabled)
+ {
+ vprintf(aFormat, aArgList);
+ printf("\n");
+ }
+ else
+ {
+ vsyslog(static_cast<int>(aLevel), aFormat, aArgList);
+ }
}
/** Hex dump data to the log */
diff --git a/src/common/logging.hpp b/src/common/logging.hpp
index 0acdf87a..ad36d4f5 100644
--- a/src/common/logging.hpp
+++ b/src/common/logging.hpp
@@ -78,20 +78,21 @@ void otbrLogSetLevel(otbrLogLevel aLevel);
/**
* Control log to syslog.
*
- * @param[in] enable True to log to/via syslog.
+ * @param[in] aEnabled True to enable logging to/via syslog.
*
*/
-void otbrLogEnableSyslog(bool aEnabled);
+void otbrLogSyslogSetEnabled(bool aEnabled);
/**
* This function initialize the logging service.
*
- * @param[in] aProgramName The name of this runnable program.
- * @param[in] aLevel Log level of the logger.
- * @param[in] aPrintStderr Whether to log to stderr.
+ * @param[in] aProgramName The name of this runnable program.
+ * @param[in] aLevel Log level of the logger.
+ * @param[in] aPrintStderr Whether to log to stderr.
+ * @param[in] aSyslogDisable Whether to disable logging to syslog.
*
*/
-void otbrLogInit(const char *aProgramName, otbrLogLevel aLevel, bool aPrintStderr);
+void otbrLogInit(const char *aProgramName, otbrLogLevel aLevel, bool aPrintStderr, bool aSyslogDisable);
/**
* This function log at level @p aLevel.
diff --git a/src/mdns/mdns_avahi.cpp b/src/mdns/mdns_avahi.cpp
index ba01519e..2f3984d7 100644
--- a/src/mdns/mdns_avahi.cpp
+++ b/src/mdns/mdns_avahi.cpp
@@ -570,10 +570,6 @@ void PublisherAvahi::HandleGroupState(AvahiEntryGroup *aGroup, AvahiEntryGroupSt
case AVAHI_ENTRY_GROUP_UNCOMMITED:
case AVAHI_ENTRY_GROUP_REGISTERING:
break;
-
- default:
- assert(false);
- break;
}
}
@@ -696,10 +692,6 @@ void PublisherAvahi::HandleClientState(AvahiClient *aClient, AvahiClientState aS
case AVAHI_CLIENT_CONNECTING:
otbrLogInfo("Avahi client is connecting to the server");
break;
-
- default:
- assert(false);
- break;
}
}
@@ -1047,7 +1039,7 @@ void PublisherAvahi::UnsubscribeService(const std::string &aType, const std::str
return aService->mType == aType && aService->mInstanceName == aInstanceName;
});
- assert(it != mSubscribedServices.end());
+ VerifyOrExit(it != mSubscribedServices.end());
{
std::unique_ptr<ServiceSubscription> service = std::move(*it);
@@ -1106,7 +1098,7 @@ void PublisherAvahi::UnsubscribeHost(const std::string &aHostName)
mSubscribedHosts.begin(), mSubscribedHosts.end(),
[&aHostName](const std::unique_ptr<HostSubscription> &aHost) { return aHost->mHostName == aHostName; });
- assert(it != mSubscribedHosts.end());
+ VerifyOrExit(it != mSubscribedHosts.end());
{
std::unique_ptr<HostSubscription> host = std::move(*it);
diff --git a/src/mdns/mdns_mdnssd.cpp b/src/mdns/mdns_mdnssd.cpp
index b820f4c9..689634a6 100644
--- a/src/mdns/mdns_mdnssd.cpp
+++ b/src/mdns/mdns_mdnssd.cpp
@@ -948,7 +948,7 @@ void PublisherMDnsSd::UnsubscribeService(const std::string &aType, const std::st
[&aType, &aInstanceName](const std::unique_ptr<ServiceSubscription> &aService) {
return aService->mType == aType && aService->mInstanceName == aInstanceName;
});
- assert(it != mSubscribedServices.end());
+ VerifyOrExit(it != mSubscribedServices.end());
mSubscribedServices.erase(it);
@@ -998,7 +998,7 @@ void PublisherMDnsSd::UnsubscribeHost(const std::string &aHostName)
mSubscribedHosts.begin(), mSubscribedHosts.end(),
[&aHostName](const std::unique_ptr<HostSubscription> &aHost) { return aHost->mHostName == aHostName; });
- assert(it != mSubscribedHosts.end());
+ VerifyOrExit(it != mSubscribedHosts.end());
mSubscribedHosts.erase(it);
diff --git a/src/ncp/ncp_openthread.cpp b/src/ncp/ncp_openthread.cpp
index 84a86014..df3dcd5f 100644
--- a/src/ncp/ncp_openthread.cpp
+++ b/src/ncp/ncp_openthread.cpp
@@ -60,10 +60,10 @@
namespace otbr {
namespace Ncp {
-static const uint16_t kThreadVersion11 = 2; ///< Thread Version 1.1
-static const uint16_t kThreadVersion12 = 3; ///< Thread Version 1.2
-static const uint16_t kThreadVersion13 = 4; ///< Thread Version 1.3
-static const uint16_t kThreadVersion131 = 5; ///< Thread Version 1.3.1
+static const uint16_t kThreadVersion11 = 2; ///< Thread Version 1.1
+static const uint16_t kThreadVersion12 = 3; ///< Thread Version 1.2
+static const uint16_t kThreadVersion13 = 4; ///< Thread Version 1.3
+static const uint16_t kThreadVersion14 = 5; ///< Thread Version 1.4
ControllerOpenThread::ControllerOpenThread(const char *aInterfaceName,
const std::vector<const char *> &aRadioUrls,
@@ -388,8 +388,8 @@ const char *ControllerOpenThread::GetThreadVersion(void)
case kThreadVersion13:
version = "1.3.0";
break;
- case kThreadVersion131:
- version = "1.3.1";
+ case kThreadVersion14:
+ version = "1.4";
break;
default:
otbrLogEmerg("Unexpected thread version %hu", otThreadGetVersion());
diff --git a/src/openwrt/ubus/otubus.cpp b/src/openwrt/ubus/otubus.cpp
index 4d807a9c..4dfaac2a 100644
--- a/src/openwrt/ubus/otubus.cpp
+++ b/src/openwrt/ubus/otubus.cpp
@@ -1190,8 +1190,10 @@ int UbusServer::UbusGetInformation(struct ubus_context *aContext,
ubus_send_reply(aContext, aRequest, mNetworkdataBuf.head);
if (time(nullptr) - mSecond > 10)
{
+ static constexpr uint16_t kMaxTlvs = 35;
+
struct otIp6Address address;
- uint8_t tlvTypes[OT_NETWORK_DIAGNOSTIC_TYPELIST_MAX_ENTRIES];
+ uint8_t tlvTypes[kMaxTlvs];
uint8_t count = 0;
char multicastAddr[10] = "ff03::2";
diff --git a/src/sdp_proxy/discovery_proxy.cpp b/src/sdp_proxy/discovery_proxy.cpp
index 0cf57333..ea0072aa 100644
--- a/src/sdp_proxy/discovery_proxy.cpp
+++ b/src/sdp_proxy/discovery_proxy.cpp
@@ -214,11 +214,9 @@ void DiscoveryProxy::OnServiceDiscovered(const std::string
{
case OT_DNSSD_QUERY_TYPE_BROWSE:
splitError = SplitFullServiceName(queryName, serviceName, domain);
- assert(splitError == OTBR_ERROR_NONE);
break;
case OT_DNSSD_QUERY_TYPE_RESOLVE:
splitError = SplitFullServiceInstanceName(queryName, instanceName, serviceName, domain);
- assert(splitError == OTBR_ERROR_NONE);
break;
default:
splitError = OTBR_ERROR_NOT_FOUND;
@@ -226,6 +224,7 @@ void DiscoveryProxy::OnServiceDiscovered(const std::string
}
if (splitError != OTBR_ERROR_NONE)
{
+ // Incoming service/instance was not what current query wanted to see, move on.
continue;
}
@@ -284,8 +283,13 @@ void DiscoveryProxy::OnHostDiscovered(const std::string
{
continue;
}
+
splitError = SplitFullHostName(queryName, hostName, domain);
- assert(splitError == OTBR_ERROR_NONE);
+
+ if (splitError != OTBR_ERROR_NONE)
+ {
+ continue;
+ }
if (DnsLabelsEqual(hostName, aHostName))
{
diff --git a/src/web/main.cpp b/src/web/main.cpp
index 4e25e058..922038d8 100644
--- a/src/web/main.cpp
+++ b/src/web/main.cpp
@@ -111,7 +111,7 @@ int main(int argc, char **argv)
}
}
- otbrLogInit(argv[0], logLevel, true);
+ otbrLogInit(argv[0], logLevel, true, false);
otbrLogInfo("Running %s", OTBR_PACKAGE_VERSION);
if (interfaceName == nullptr)
diff --git a/tests/mdns/main.cpp b/tests/mdns/main.cpp
index e8fe3552..acf8777c 100644
--- a/tests/mdns/main.cpp
+++ b/tests/mdns/main.cpp
@@ -482,7 +482,7 @@ int main(int argc, char *argv[])
return 1;
}
- otbrLogInit("otbr-mdns", OTBR_LOG_DEBUG, true);
+ otbrLogInit("otbr-mdns", OTBR_LOG_DEBUG, true, false);
// allow quitting elegantly
signal(SIGTERM, RecoverSignal);
switch (argv[1][0])
diff --git a/tests/mdns/test_subscribe.cpp b/tests/mdns/test_subscribe.cpp
index 554a33f0..b01be3eb 100644
--- a/tests/mdns/test_subscribe.cpp
+++ b/tests/mdns/test_subscribe.cpp
@@ -130,7 +130,7 @@ Ip6Address sAddr4;
void SetUp(void)
{
- otbrLogInit("test-mdns-subscriber", OTBR_LOG_INFO, true);
+ otbrLogInit("test-mdns-subscriber", OTBR_LOG_INFO, true, false);
SuccessOrDie(Ip6Address::FromString("2002::1", sAddr1), "");
SuccessOrDie(Ip6Address::FromString("2002::2", sAddr2), "");
SuccessOrDie(Ip6Address::FromString("2002::3", sAddr3), "");
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();