Skip to content

Commit

Permalink
common: optimize search path
Browse files Browse the repository at this point in the history
Optimize search path to avoid reading .vscode folder.

Signed-off-by: Tomasz Gromadzki <tomasz.gromadzki@intel.com>
  • Loading branch information
grom72 committed Feb 20, 2024
1 parent 665e410 commit 373ebcd
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/core/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void
core_log(enum core_log_level level, int errnum, const char *file_name,
int line_no, const char *function_name, const char *message_format, ...)
{
char message[CORE_LOG_MSG_MAXPRINT] = "";
char message[_CORE_LOG_MSG_MAXPRINT] = "";
va_list arg;

va_start(arg, message_format);
Expand Down
6 changes: 3 additions & 3 deletions src/core/log_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ void core_log_init(void);
void core_log_fini(void);

/* The actual maximum expected log line is 407.
* Additional byte is used to detect buffer overflow in core_log tests.
* If actual max message lenghth is eaqual to 408, it means we have a buffer
* An additional byte is used to detect buffer overflow in core_log tests.
* If the actual max message length is equal to 408, it means we have a buffer
* overflow
*/
#define CORE_LOG_MSG_MAXPRINT 408 /* maximum expected log line */
#define _CORE_LOG_MSG_MAXPRINT 408 /* maximum expected log line + 1*/

static inline int
core_log_error_translate(int ret)
Expand Down
1 change: 0 additions & 1 deletion src/test/core_log_max/call_all.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ static uintmax_t _ju = UINTMAX_MAX;
/*
* Prevent abort() from CORE_LOG_FATAL()
*/
#undef abort
#define abort() do { ; } while(0)

#include "call_all.c.generated"
5 changes: 3 additions & 2 deletions src/test/core_log_max/core_log_max.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ test_ERR_W_ERRNO(const struct test_case *tc, int argc, char *argv[])
return NO_ARGS_CONSUMED;
}

#define TOTAL_MESSAGE_NUM_EXPECTED 178
#define TOTAL_MESSAGE_NUM_EXPECTED 212
static int Max_message_len = 0;
static int Total_message_num = 0;
static char The_longest_message[BIG_BUF_SIZE];
Expand Down Expand Up @@ -177,9 +177,10 @@ test_CORE_LOG(const struct test_case *tc, int argc, char *argv[])
call_all_CORE_LOG_ERROR();
call_all_CORE_LOG_ERROR_W_ERRNO(MAX_STRERROR_NUM);
call_all_CORE_LOG_FATAL();
call_all_CORE_LOG_FATAL_W_ERRNO(MAX_STRERROR_NUM);

UT_OUT("The_longest_message: %s", The_longest_message);
UT_ASSERTeq(Max_message_len + 2, CORE_LOG_MSG_MAXPRINT);
UT_ASSERTeq(Max_message_len + 2, _CORE_LOG_MSG_MAXPRINT);
UT_ASSERTeq(Total_message_num, TOTAL_MESSAGE_NUM_EXPECTED);

return NO_ARGS_CONSUMED;
Expand Down
17 changes: 7 additions & 10 deletions utils/call_stacks_analysis/log_call_all_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
DEBUG = False
PARSER_DEBUG = False

TOP = '../../'
OUTPUT_PATH = TOP + 'src/test/core_log_max/'
TOP = '../../src/'
OUTPUT_PATH = TOP + 'test/core_log_max/'
OUTPUT_C = OUTPUT_PATH + 'call_all.c.generated'

NOTICE = """/*
Expand Down Expand Up @@ -68,13 +68,10 @@ def extract_append_code(file_name: str, start_line: int, code: str) -> str:
return code

IGNORE_FILES = [
'.git/',
'src/core/log_internal.h',
'src/libpmem2/',
'src/libpmempool/',
'src/test/',
'utils/',
'CODING_STYLE.md',
'core/log_internal.h',
'libpmem2/',
'libpmempool/',
'test/',
]

def file_should_be_ignored(file: str) -> bool:
Expand Down Expand Up @@ -363,7 +360,7 @@ def generate_call(file, func: str, call: Dict) -> str:
args = ', ' + ', '.join(call['args'])
else:
args = ''
file.write(f'\t// {call["file"]}:{call["line"]}\n')
file.write(f'\t// src/{call["file"]}:{call["line"]}\n')
file.write(f'\t{func}("{call["format_string"]}"{args});\n')

def generate_func_with_errno(func: str, calls: List[Dict]) -> None:
Expand Down

0 comments on commit 373ebcd

Please sign in to comment.