Re: [devel] [PATCH 2/3] log: Add test cases of make facility id configurable [#3131]
Hi Thien, Ack with comments inline. Regards, Vu On 1/20/20 2:59 PM, thien.m.huynh wrote: Adding 05 new test case into a new testsuite 22 --- src/log/Makefile.am | 7 +- src/log/apitest/log_server.cc | 43 +++ src/log/apitest/log_server.h | 35 +++ .../apitest/tet_saLogStreamConfigFacilityId.c | 273 ++ src/log/tests/lgs_dest_test.cc| 3 + 5 files changed, 359 insertions(+), 2 deletions(-) create mode 100644 src/log/apitest/log_server.cc create mode 100644 src/log/apitest/log_server.h create mode 100644 src/log/apitest/tet_saLogStreamConfigFacilityId.c diff --git a/src/log/Makefile.am b/src/log/Makefile.am index a2a98baec..2dad3cfb1 100644 --- a/src/log/Makefile.am +++ b/src/log/Makefile.am @@ -190,7 +190,8 @@ bin_PROGRAMS += bin/logtest bin/saflogtest bin/logtestfr noinst_HEADERS += \ src/log/apitest/logtest.h \ src/log/apitest/logutil.h \ - src/log/apitest/imm_tstutil.h + src/log/apitest/imm_tstutil.h \ + src/log/apitest/log_server.h bin_logtest_CFLAGS = $(AM_CFLAGS) -Wformat=1 @@ -227,7 +228,9 @@ bin_logtest_SOURCES = \ src/log/apitest/tet_Log_clm.c \ src/log/apitest/tet_cfg_destination.c \ src/log/apitest/tet_multiple_thread.c \ - src/log/apitest/tet_saLogWriteLogAsync_cache.c + src/log/apitest/tet_saLogWriteLogAsync_cache.c \ + src/log/apitest/tet_saLogStreamConfigFacilityId.c \ + src/log/apitest/log_server.cc bin_logtest_LDADD = \ lib/libapitest.la \ diff --git a/src/log/apitest/log_server.cc b/src/log/apitest/log_server.cc new file mode 100644 index 0..25f7894e0 --- /dev/null +++ b/src/log/apitest/log_server.cc @@ -0,0 +1,43 @@ +/* -*- OpenSAF -*- + * + * Copyright Ericsson AB 2020 - All Rights Reserved. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed + * under the GNU Lesser General Public License Version 2.1, February 1999. + * The complete license can be accessed from the following location: + * http://opensource.org/licenses/lgpl-license.php + * See the Copying file included with the OpenSAF distribution for full + * licensing terms. + * + * Author(s): Ericsson AB + * + */ + +#include "log/apitest/log_server.h" +#include "base/unix_server_socket.h" + +static base::UnixServerSocket* server = nullptr; + +void StartUnixServer() { + server = new base::UnixServerSocket("/tmp/test.sock", + base::UnixSocket::kBlocking, 0777); + server->fd(); +} + +bool FindPRI(const char* pri_field, const char* msg) { + char buf[1024]; + bool found = false; + do { +memset(buf, 0, sizeof(buf)); +size_t len = server->Recv(buf, 1024); +buf[len] = '\0'; +if (!strncmp(buf, pri_field, strlen(pri_field))) { + found = true; +} + } while (!strstr(buf, msg)); + return found; +} [Vu] The while loop may be blocked forever. Should add a mechanism to break the loop based on number of retries. + +void StopUnixServer() { delete server; } diff --git a/src/log/apitest/log_server.h b/src/log/apitest/log_server.h new file mode 100644 index 0..e36f885fa --- /dev/null +++ b/src/log/apitest/log_server.h @@ -0,0 +1,35 @@ +/* -*- OpenSAF -*- + * + * Copyright Ericsson AB 2020 - All Rights Reserved. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed + * under the GNU Lesser General Public License Version 2.1, February 1999. + * The complete license can be accessed from the following location: + * http://opensource.org/licenses/lgpl-license.php + * See the Copying file included with the OpenSAF distribution for full + * licensing terms. + * + * Author(s): Ericsson AB + * + */ + +#ifndef LOG_APITEST_LOG_SERVER_H_ +#define LOG_APITEST_LOG_SERVER_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void StartUnixServer(); +bool FindPRI(const char* pri_field, const char* msg); +void StopUnixServer(); + +#ifdef __cplusplus +} // closing brace for extern "C" +#endif + +#endif // LOG_APITEST_LOG_SERVER_H_ diff --git a/src/log/apitest/tet_saLogStreamConfigFacilityId.c b/src/log/apitest/tet_saLogStreamConfigFacilityId.c new file mode 100644 index 0..276642d69 --- /dev/null +++ b/src/log/apitest/tet_saLogStreamConfigFacilityId.c @@ -0,0 +1,273 @@ +/* -*- OpenSAF -*- + * + * Copyright Ericsson AB 2020 - All Rights Reserved. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed + * unde
[devel] [PATCH 2/3] log: Add test cases of make facility id configurable [#3131]
Adding 05 new test case into a new testsuite 22 --- src/log/Makefile.am | 7 +- src/log/apitest/log_server.cc | 43 +++ src/log/apitest/log_server.h | 35 +++ .../apitest/tet_saLogStreamConfigFacilityId.c | 273 ++ src/log/tests/lgs_dest_test.cc| 3 + 5 files changed, 359 insertions(+), 2 deletions(-) create mode 100644 src/log/apitest/log_server.cc create mode 100644 src/log/apitest/log_server.h create mode 100644 src/log/apitest/tet_saLogStreamConfigFacilityId.c diff --git a/src/log/Makefile.am b/src/log/Makefile.am index a2a98baec..2dad3cfb1 100644 --- a/src/log/Makefile.am +++ b/src/log/Makefile.am @@ -190,7 +190,8 @@ bin_PROGRAMS += bin/logtest bin/saflogtest bin/logtestfr noinst_HEADERS += \ src/log/apitest/logtest.h \ src/log/apitest/logutil.h \ - src/log/apitest/imm_tstutil.h + src/log/apitest/imm_tstutil.h \ + src/log/apitest/log_server.h bin_logtest_CFLAGS = $(AM_CFLAGS) -Wformat=1 @@ -227,7 +228,9 @@ bin_logtest_SOURCES = \ src/log/apitest/tet_Log_clm.c \ src/log/apitest/tet_cfg_destination.c \ src/log/apitest/tet_multiple_thread.c \ - src/log/apitest/tet_saLogWriteLogAsync_cache.c + src/log/apitest/tet_saLogWriteLogAsync_cache.c \ + src/log/apitest/tet_saLogStreamConfigFacilityId.c \ + src/log/apitest/log_server.cc bin_logtest_LDADD = \ lib/libapitest.la \ diff --git a/src/log/apitest/log_server.cc b/src/log/apitest/log_server.cc new file mode 100644 index 0..25f7894e0 --- /dev/null +++ b/src/log/apitest/log_server.cc @@ -0,0 +1,43 @@ +/* -*- OpenSAF -*- + * + * Copyright Ericsson AB 2020 - All Rights Reserved. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed + * under the GNU Lesser General Public License Version 2.1, February 1999. + * The complete license can be accessed from the following location: + * http://opensource.org/licenses/lgpl-license.php + * See the Copying file included with the OpenSAF distribution for full + * licensing terms. + * + * Author(s): Ericsson AB + * + */ + +#include "log/apitest/log_server.h" +#include "base/unix_server_socket.h" + +static base::UnixServerSocket* server = nullptr; + +void StartUnixServer() { + server = new base::UnixServerSocket("/tmp/test.sock", + base::UnixSocket::kBlocking, 0777); + server->fd(); +} + +bool FindPRI(const char* pri_field, const char* msg) { + char buf[1024]; + bool found = false; + do { +memset(buf, 0, sizeof(buf)); +size_t len = server->Recv(buf, 1024); +buf[len] = '\0'; +if (!strncmp(buf, pri_field, strlen(pri_field))) { + found = true; +} + } while (!strstr(buf, msg)); + return found; +} + +void StopUnixServer() { delete server; } diff --git a/src/log/apitest/log_server.h b/src/log/apitest/log_server.h new file mode 100644 index 0..e36f885fa --- /dev/null +++ b/src/log/apitest/log_server.h @@ -0,0 +1,35 @@ +/* -*- OpenSAF -*- + * + * Copyright Ericsson AB 2020 - All Rights Reserved. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed + * under the GNU Lesser General Public License Version 2.1, February 1999. + * The complete license can be accessed from the following location: + * http://opensource.org/licenses/lgpl-license.php + * See the Copying file included with the OpenSAF distribution for full + * licensing terms. + * + * Author(s): Ericsson AB + * + */ + +#ifndef LOG_APITEST_LOG_SERVER_H_ +#define LOG_APITEST_LOG_SERVER_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void StartUnixServer(); +bool FindPRI(const char* pri_field, const char* msg); +void StopUnixServer(); + +#ifdef __cplusplus +} // closing brace for extern "C" +#endif + +#endif // LOG_APITEST_LOG_SERVER_H_ diff --git a/src/log/apitest/tet_saLogStreamConfigFacilityId.c b/src/log/apitest/tet_saLogStreamConfigFacilityId.c new file mode 100644 index 0..276642d69 --- /dev/null +++ b/src/log/apitest/tet_saLogStreamConfigFacilityId.c @@ -0,0 +1,273 @@ +/* -*- OpenSAF -*- + * + * Copyright Ericsson AB 2020 - All Rights Reserved. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed + * under the GNU Lesser General Public License Version 2.1, February 1999. + * The complete license can be accessed from the following location: + * http://opensource.org/licenses/lgpl-license.php + * See the Copying file included wi
Re: [devel] [PATCH 2/3] log: Add test cases of make facility id configurable [#3131]
Hi Thien, See my comments inline. Regards, Vu On 1/16/20 11:08 AM, thien.m.huynh wrote: Adding 05 new test case into a new testsuite 22 --- .../test_saImmOiRtObjectCreate_2.c| 9 +- .../implementer/test_saImmOiRtObjectDelete.c | 4 +- .../test_saImmOiRtObjectUpdate_2.c| 4 +- src/log/Makefile.am | 7 +- src/log/apitest/log_server.cc | 47 +++ src/log/apitest/log_server.h | 35 +++ .../apitest/tet_saLogStreamConfigFacilityId.c | 279 ++ src/log/tests/lgs_dest_test.cc| 3 + 8 files changed, 381 insertions(+), 7 deletions(-) create mode 100644 src/log/apitest/log_server.cc create mode 100644 src/log/apitest/log_server.h create mode 100644 src/log/apitest/tet_saLogStreamConfigFacilityId.c diff --git a/src/imm/apitest/implementer/test_saImmOiRtObjectCreate_2.c b/src/imm/apitest/implementer/test_saImmOiRtObjectCreate_2.c index df260a9d5..709332954 100644 --- a/src/imm/apitest/implementer/test_saImmOiRtObjectCreate_2.c +++ b/src/imm/apitest/implementer/test_saImmOiRtObjectCreate_2.c @@ -59,9 +59,11 @@ static SaImmAttrValuesT_2 v10 = {"saLogStreamSeverityFilter", SA_IMM_ATTR_SAUINT32T, 1, (void **)int1Values}; static SaImmAttrValuesT_2 v11 = {"saLogStreamCreationTimestamp", SA_IMM_ATTR_SATIMET, 1, (void **)lint1Values}; +static SaImmAttrValuesT_2 v12 = {"saLogStreamFacilityId", + SA_IMM_ATTR_SAUINT32T, 1, (void **)int1Values}; static const SaImmAttrValuesT_2 *attrValues[] = { -&v1, &v2, &v3, &v4, &v5, &v6, &v7, &v8, &v9, &v10, &v11, NULL}; +&v1, &v2, &v3, &v4, &v5, &v6, &v7, &v8, &v9, &v10, &v11, &v12, NULL}; static const SaImmClassNameT className = "SaLogStream"; void saImmOiRtObjectCreate_2_01(void) @@ -188,8 +190,9 @@ void saImmOiRtObjectCreate_2_07(void) // const SaNameT *nameValues27[] = {&rdnObj27}; const SaImmAttrValuesT_2 v27 = {"safLgStr", SA_IMM_ATTR_SASTRINGT, 1, (void **)nameValues27}; - const SaImmAttrValuesT_2 *attrValues27[] = { - &v1, &v27, &v3, &v4, &v5, &v6, &v7, &v8, &v9, &v10, &v11, NULL}; + const SaImmAttrValuesT_2 *attrValues27[] = {&v1, &v27, &v3, &v4, &v5, + &v6, &v7, &v8, &v9, &v10, + &v11, &v12, NULL}; SaNameT tmpName; diff --git a/src/imm/apitest/implementer/test_saImmOiRtObjectDelete.c b/src/imm/apitest/implementer/test_saImmOiRtObjectDelete.c index 986ec88aa..341d5144a 100644 --- a/src/imm/apitest/implementer/test_saImmOiRtObjectDelete.c +++ b/src/imm/apitest/implementer/test_saImmOiRtObjectDelete.c @@ -59,9 +59,11 @@ static SaImmAttrValuesT_2 v10 = {"saLogStreamSeverityFilter", SA_IMM_ATTR_SAUINT32T, 1, (void **)int1Values}; static SaImmAttrValuesT_2 v11 = {"saLogStreamCreationTimestamp", SA_IMM_ATTR_SATIMET, 1, (void **)lint1Values}; +static SaImmAttrValuesT_2 v12 = {"saLogStreamFacilityId", + SA_IMM_ATTR_SAUINT32T, 1, (void **)int1Values}; static const SaImmAttrValuesT_2 *attrValues[] = { -&v1, &v2, &v3, &v4, &v5, &v6, &v7, &v8, &v9, &v10, &v11, NULL}; +&v1, &v2, &v3, &v4, &v5, &v6, &v7, &v8, &v9, &v10, &v11, &v12, NULL}; static const SaImmClassNameT className = "SaLogStream"; void saImmOiRtObjectDelete_01(void) diff --git a/src/imm/apitest/implementer/test_saImmOiRtObjectUpdate_2.c b/src/imm/apitest/implementer/test_saImmOiRtObjectUpdate_2.c index 1a551fd9f..2f2b941dc 100644 --- a/src/imm/apitest/implementer/test_saImmOiRtObjectUpdate_2.c +++ b/src/imm/apitest/implementer/test_saImmOiRtObjectUpdate_2.c @@ -55,9 +55,11 @@ static SaImmAttrValuesT_2 v10 = {"saLogStreamSeverityFilter", SA_IMM_ATTR_SAUINT32T, 1, (void **)int1Values}; static SaImmAttrValuesT_2 v11 = {"saLogStreamCreationTimestamp", SA_IMM_ATTR_SATIMET, 1, (void **)lint1Values}; +static SaImmAttrValuesT_2 v12 = {"saLogStreamFacilityId", + SA_IMM_ATTR_SAUINT32T, 1, (void **)int1Values}; static const SaImmAttrValuesT_2 *attrValues[] = { -&v1, &v2, &v3, &v4, &v5, &v6, &v7, &v8, &v9, &v10, &v11, NULL}; +&v1, &v2, &v3, &v4, &v5, &v6, &v7, &v8, &v9, &v10, &v11, &v12, NULL}; static const SaImmClassNameT className = "SaLogStream"; diff --git a/src/log/Makefile.am b/src/log/Makefile.am index a2a98baec..2dad3cfb1 100644 --- a/src/log/Makefile.am +++ b/src/log/Makefile.am @@ -190,7 +190,8 @@ bin_PROGRAMS += bin/logtest bin/saflogtest bin/logtestfr noinst_HEADERS += \ src/log/apitest/logtest.h \ src/log/apitest/logutil.h \ - src/log/apitest/imm_tstutil.h + src/log/apitest/imm_tstutil.h \ + src/log/apitest/lo
[devel] [PATCH 2/3] log: Add test cases of make facility id configurable [#3131]
Adding 05 new test case into a new testsuite 22 --- .../test_saImmOiRtObjectCreate_2.c| 9 +- .../implementer/test_saImmOiRtObjectDelete.c | 4 +- .../test_saImmOiRtObjectUpdate_2.c| 4 +- src/log/Makefile.am | 7 +- src/log/apitest/log_server.cc | 47 +++ src/log/apitest/log_server.h | 35 +++ .../apitest/tet_saLogStreamConfigFacilityId.c | 279 ++ src/log/tests/lgs_dest_test.cc| 3 + 8 files changed, 381 insertions(+), 7 deletions(-) create mode 100644 src/log/apitest/log_server.cc create mode 100644 src/log/apitest/log_server.h create mode 100644 src/log/apitest/tet_saLogStreamConfigFacilityId.c diff --git a/src/imm/apitest/implementer/test_saImmOiRtObjectCreate_2.c b/src/imm/apitest/implementer/test_saImmOiRtObjectCreate_2.c index df260a9d5..709332954 100644 --- a/src/imm/apitest/implementer/test_saImmOiRtObjectCreate_2.c +++ b/src/imm/apitest/implementer/test_saImmOiRtObjectCreate_2.c @@ -59,9 +59,11 @@ static SaImmAttrValuesT_2 v10 = {"saLogStreamSeverityFilter", SA_IMM_ATTR_SAUINT32T, 1, (void **)int1Values}; static SaImmAttrValuesT_2 v11 = {"saLogStreamCreationTimestamp", SA_IMM_ATTR_SATIMET, 1, (void **)lint1Values}; +static SaImmAttrValuesT_2 v12 = {"saLogStreamFacilityId", + SA_IMM_ATTR_SAUINT32T, 1, (void **)int1Values}; static const SaImmAttrValuesT_2 *attrValues[] = { -&v1, &v2, &v3, &v4, &v5, &v6, &v7, &v8, &v9, &v10, &v11, NULL}; +&v1, &v2, &v3, &v4, &v5, &v6, &v7, &v8, &v9, &v10, &v11, &v12, NULL}; static const SaImmClassNameT className = "SaLogStream"; void saImmOiRtObjectCreate_2_01(void) @@ -188,8 +190,9 @@ void saImmOiRtObjectCreate_2_07(void) // const SaNameT *nameValues27[] = {&rdnObj27}; const SaImmAttrValuesT_2 v27 = {"safLgStr", SA_IMM_ATTR_SASTRINGT, 1, (void **)nameValues27}; - const SaImmAttrValuesT_2 *attrValues27[] = { - &v1, &v27, &v3, &v4, &v5, &v6, &v7, &v8, &v9, &v10, &v11, NULL}; + const SaImmAttrValuesT_2 *attrValues27[] = {&v1, &v27, &v3, &v4, &v5, + &v6, &v7, &v8, &v9, &v10, + &v11, &v12, NULL}; SaNameT tmpName; diff --git a/src/imm/apitest/implementer/test_saImmOiRtObjectDelete.c b/src/imm/apitest/implementer/test_saImmOiRtObjectDelete.c index 986ec88aa..341d5144a 100644 --- a/src/imm/apitest/implementer/test_saImmOiRtObjectDelete.c +++ b/src/imm/apitest/implementer/test_saImmOiRtObjectDelete.c @@ -59,9 +59,11 @@ static SaImmAttrValuesT_2 v10 = {"saLogStreamSeverityFilter", SA_IMM_ATTR_SAUINT32T, 1, (void **)int1Values}; static SaImmAttrValuesT_2 v11 = {"saLogStreamCreationTimestamp", SA_IMM_ATTR_SATIMET, 1, (void **)lint1Values}; +static SaImmAttrValuesT_2 v12 = {"saLogStreamFacilityId", + SA_IMM_ATTR_SAUINT32T, 1, (void **)int1Values}; static const SaImmAttrValuesT_2 *attrValues[] = { -&v1, &v2, &v3, &v4, &v5, &v6, &v7, &v8, &v9, &v10, &v11, NULL}; +&v1, &v2, &v3, &v4, &v5, &v6, &v7, &v8, &v9, &v10, &v11, &v12, NULL}; static const SaImmClassNameT className = "SaLogStream"; void saImmOiRtObjectDelete_01(void) diff --git a/src/imm/apitest/implementer/test_saImmOiRtObjectUpdate_2.c b/src/imm/apitest/implementer/test_saImmOiRtObjectUpdate_2.c index 1a551fd9f..2f2b941dc 100644 --- a/src/imm/apitest/implementer/test_saImmOiRtObjectUpdate_2.c +++ b/src/imm/apitest/implementer/test_saImmOiRtObjectUpdate_2.c @@ -55,9 +55,11 @@ static SaImmAttrValuesT_2 v10 = {"saLogStreamSeverityFilter", SA_IMM_ATTR_SAUINT32T, 1, (void **)int1Values}; static SaImmAttrValuesT_2 v11 = {"saLogStreamCreationTimestamp", SA_IMM_ATTR_SATIMET, 1, (void **)lint1Values}; +static SaImmAttrValuesT_2 v12 = {"saLogStreamFacilityId", + SA_IMM_ATTR_SAUINT32T, 1, (void **)int1Values}; static const SaImmAttrValuesT_2 *attrValues[] = { -&v1, &v2, &v3, &v4, &v5, &v6, &v7, &v8, &v9, &v10, &v11, NULL}; +&v1, &v2, &v3, &v4, &v5, &v6, &v7, &v8, &v9, &v10, &v11, &v12, NULL}; static const SaImmClassNameT className = "SaLogStream"; diff --git a/src/log/Makefile.am b/src/log/Makefile.am index a2a98baec..2dad3cfb1 100644 --- a/src/log/Makefile.am +++ b/src/log/Makefile.am @@ -190,7 +190,8 @@ bin_PROGRAMS += bin/logtest bin/saflogtest bin/logtestfr noinst_HEADERS += \ src/log/apitest/logtest.h \ src/log/apitest/logutil.h \ - src/log/apitest/imm_tstutil.h + src/log/apitest/imm_tstutil.h \ + src/log/apitest/log_server.h bin_logtest_CFLAGS = $(AM_CFLAGS) -Wformat=1 @@ -227,7 +228,9 @@ bin_logtest_SOURCES = \ src/log/apites