Hi Mohan, Note, this is not a complete review but I have taken a quick look at the code below.
Often when creating functions it may be enough to use a descriptive name to document what the function do. However for test cases (function that implements the actual test) there should always be a descriptive comment (can be used for automatically create test reports etc.) also the test cases should be clearly separated from help functions etc. that are used in several test cases. I have added comments for some of the test cases below as an example. Note: Many test cases do not have any documentation in comment or even a descriptive name. To fix that for all test cases is probably not within scope of a fix like this but no new test cases should be added without documentation and also if an existing test is fixed also its documentation should be fixed. When doing a review it should be mandatory to check that a new or changed test case is documented and that the documentation is correct. For a test case the following should generically be documented: - What object or feature is tested - What is tested for the object/feature - What is the expected result. Note: A test case normally either pass or fail (Boolean) so what I mean by "expected result" is what result is defined for "pass" - In some cases it may be needed to describe how the test is done. This is the case if for example a test case consists of many steps to setup some "prerequisites" before the actual test. Thanks Lennart -----Original Message----- From: Mohan Kanakam <mo...@hasolutions.in> Sent: den 9 november 2018 07:58 To: Lennart Lund <lennart.l...@ericsson.com>; Vu Minh Nguyen <vu.m.ngu...@dektech.com.au> Cc: opensaf-devel@lists.sourceforge.net; Mohan Kanakam <mo...@hasolutions.in> Subject: [PATCH 1/7] log: add new test case of API saLogInitialize() of apitest [#2915] --- src/log/apitest/tet_saLogInitialize.c | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/log/apitest/tet_saLogInitialize.c b/src/log/apitest/tet_saLogInitialize.c index 3d31c8e..a7cbab4 100644 --- a/src/log/apitest/tet_saLogInitialize.c +++ b/src/log/apitest/tet_saLogInitialize.c @@ -108,6 +108,35 @@ void saLogInitialize_11(void) test_validate(rc, SA_AIS_OK); } [Lennart] /* Object to test: saLogInitalize() API: * Test: Set inparameter version to NULL pointer * Result: Shall fail with return code SA_AIS_ERR_INVALID_PARAM */ +void saLogInitialize_version_NULL_pointer_error(void) +{ + rc = saLogInitialize(&logHandle, &logCallbacks, NULL); + logFinalize(); + test_validate(rc, SA_AIS_ERR_INVALID_PARAM); } + /* Object to test: saLogInitalize() API: * Test: Set inparameter logHandle (replace with name used in AIS) to NULL pointer * Result: Shall fail with return code SA_AIS_ERR_INVALID_PARAM */ +void saLogInitialize_handle_version_NULL_pointer_error_13(void) +{ + rc = saLogInitialize(NULL, &logCallbacks, NULL); + logFinalize(); + test_validate(rc, SA_AIS_ERR_INVALID_PARAM); } + +void saLogInitialize_handle_callbk_NULL_pointer_error_14(void) +{ + SaVersionT log_version = {'A', 2}; + rc = saLogInitialize(NULL, NULL, &log_version); + logFinalize(); + test_validate(rc, SA_AIS_ERR_INVALID_PARAM); } + +void saLogInitialize_handle_callbk_version_NULL_pointer_error_15(void) +{ + rc = saLogInitialize(NULL, NULL, NULL); + logFinalize(); + test_validate(rc, SA_AIS_ERR_INVALID_PARAM); } + extern void saLogSelectionObjectGet_01(void); extern void saLogSelectionObjectGet_02(void); extern void saLogFinalize_01(void); @@ -139,6 +168,15 @@ __attribute__((constructor)) static void saLibraryLifeCycle_constructor(void) "saLogInitialize() with minor version is set bigger than supported version"); test_case_add(1, saLogInitialize_11, "saLogInitialize() with minor version is not set"); + test_case_add(1, saLogInitialize_version_NULL_pointer_error, + "saLogInitialize() valid handle, valid callbacks and version as NULL"); + test_case_add(1, saLogInitialize_handle_version_NULL_pointer_error_13, + "saLogInitialize() with handle as null, version as null"); + test_case_add(1, saLogInitialize_handle_callbk_NULL_pointer_error_14, + "saLogInitialize() with handle as null and callbk as null"); + test_case_add(1, saLogInitialize_handle_callbk_version_NULL_pointer_error_15, + "saLogInitialize() with all null values"); + test_case_add(1, saLogSelectionObjectGet_01, "saLogSelectionObjectGet() OK"); test_case_add(1, saLogSelectionObjectGet_02, -- 2.7.4 _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel