Hi Canh,

Ack with a minor comment.

Regards, Vu

> -----Original Message-----
> From: Canh Van Truong <canh.v.tru...@dektech.com.au>
> Sent: Friday, August 10, 2018 2:34 PM
> To: lennart.l...@ericsson.com; vu.m.ngu...@dektech.com.au
> Cc: opensaf-devel@lists.sourceforge.net; Canh Van Truong
> <canh.v.tru...@dektech.com.au>
> Subject: [PATCH 1/1] log: fix logtest 4 58 fail [#2909]
> 
> Due to hard-disk problem, the log file has not been closed successful and
> log file has not been renamed. When previous test case (4 48) closes log
file
> fail,
> test case (4 58)  also count the size of (4 48)'s log file. This cause the
size of
> log file is not 0.
> 
> The patch update to check (grep) if the log record is in log file or not
instead
> count the log file size.
> ---
>  src/log/apitest/tet_LogOiOps.c | 54
+++++++++++++++--------------------------
> -
>  1 file changed, 19 insertions(+), 35 deletions(-)
> 
> diff --git a/src/log/apitest/tet_LogOiOps.c
b/src/log/apitest/tet_LogOiOps.c
> index 02dd20996..7aea9510b 100644
> --- a/src/log/apitest/tet_LogOiOps.c
> +++ b/src/log/apitest/tet_LogOiOps.c
> @@ -1521,9 +1521,8 @@ void verFilterOut(void)
>       SaAisErrorT rc;
>       char command[MAX_DATA];
>       const unsigned int serverity_filter = 31;
> -     FILE *fp = NULL;
> -     char fileSize_c[10];
> -     int fileSize = 0;
> +     const char *log_record =
> +               "Test filter out, log records are not writen to log file";
> 
>       rc = logInitialize();
>       if (rc != SA_AIS_OK) {
> @@ -1545,48 +1544,33 @@ void verFilterOut(void)
>               serverity_filter, SA_LOG_STREAM_APPLICATION1);
>       ret = systemCall(command);
>       if (ret != 0) {
> -             test_validate(ret, 0);
> +             rc_validate(ret, 0);
>               goto done;
>       }
> 
>       /* saflogtest sends messages */
> -     sprintf(
> -         command,
> -         "saflogtest -a saLogApplication1 --count=2 --interval=20 --
> severity=notice"
> -         " \"Test filter out, log records are not writen to log file\"");
> -     rc = system(command);
> -     if (rc == -1) {
> -             test_validate(rc, 0);
> +     sprintf(command, "saflogtest --count=2 --interval=20 --
> severity=notice "
> +         "-a saLogApplication1  \"%s\"", log_record);
> +     ret = systemCall(command);
> +     if (ret == -1) {
> +             rc_validate(ret, 0);
>               goto done;
>       }
> 
> -     /* Check if log file is empty or not*/
> +     // Find the log file then check (grep) if the log record is in
> +     // log file or not
>       sprintf(command,
>               "find %s/saflogtest -type f -mmin -1 "
>               "| egrep \"%s_([0-9]{8}_[0-9]{6}\\.log$)\" "
> -             "| xargs wc -c | awk '{printf $1}'",
> -             log_root_path, DEFAULT_APP_FILE_NAME);
> -
> -     fp = popen(command, "r");
> -
> -     if (fp == NULL) {
> -             /* Fail to read size of log file. Report test failed. */
> -             fprintf(stderr, "Failed to run command = %s\n", command);
> -             test_validate(1, 0);
> -             goto done;
> -     }
> -     /* Get file size in chars */
> -     while (fgets(fileSize_c, sizeof(fileSize_c) - 1, fp) != NULL) {
> -     };
> -     pclose(fp);
> -
> -     /* Convert chars to number */
> -     fileSize = atoi(fileSize_c);
> -
> -     if (fileSize != 0) {
> -             fprintf(stderr, "Log file has log records\n");
> -     }
> -     rc_validate(fileSize, 0);
> +             "| xargs grep \"%s\" > /dev/null",
> +             log_root_path, DEFAULT_APP_FILE_NAME, log_record);
> +
> +     ret = system(command);
> +     // Expect the log record is not found, ret != 0
> +     if (ret != 0)
> +             rc_validate(1, 1);
> +     else
> +             rc_validate(1, 0);
[Vu] Can simply replace the 04 above lines by `rc_validate(ret!=0, 1)` ?
> 
>  done:
>       logFinalize();
> --
> 2.15.1



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to