Skip to content

Commit

Permalink
examples/log_dump: Add check to verify log dump size api
Browse files Browse the repository at this point in the history
	- This commit add code in log_dump_main app to
	  verify working of log_dump_get_size() api. It
	  calculates total length of compressed logs by
	  continuously reading throught a fixed buffer and
	  then verify the size with the value returned from
	  log_dump_get_size() api.

	  followings are the logs from log_dump_main app:
          (Note the compressed output is commented because it gives
           garbage value , we are only printing to check log dump
           size comparison with total read value from buffer)

          TASH>>log_dump
          TASH>>This Log Should NOT be saved!!!

          *********************   LOG DUMP START  *********************
          This Log Should be saved!!!
          log_dump_size = 2892, and total_read = 2892, Both should be equal

          *********************   LOG DUMP END  ***********************
  • Loading branch information
ritesh55555 authored and kishore-sn committed Sep 17, 2024
1 parent d3d3737 commit 2f722e6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apps/examples/log_dump/log_dump_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ int log_dump_main(int argc, char *argv[])
#endif
{
int ret = 1;
int total_read = 0;
char buf[READ_BUFFER_SIZE];
int fd = OPEN_LOGDUMP();

Expand Down Expand Up @@ -78,10 +79,12 @@ int log_dump_main(int argc, char *argv[])

while (ret > 0) {
ret = READ_LOGDUMP(fd, buf, sizeof(buf));
total_read += ret;
for (int i = 0; i < ret; i++) {
printf("%c", buf[i]);
}
}
printf("log_dump_size = %d, and total_read = %d, Both should be equal\n", GET_LOGDUMP_SIZE(fd), total_read);

printf("\n********************* LOG DUMP END ***********************\n");

Expand Down

0 comments on commit 2f722e6

Please sign in to comment.