mirror of
https://github.com/wassname/ray.git
synced 2026-07-18 12:40:56 +08:00
Replace UT string in redis tests (#1211)
* Replace UT arg formatting with vsnprintf * Fix bug with va_list usage
This commit is contained in:
committed by
Philipp Moritz
parent
009f59defc
commit
9a7b15447b
@@ -21,16 +21,20 @@ const char *test_value = "bar";
|
||||
std::vector<int> connections;
|
||||
|
||||
void write_formatted_log_message(int socket_fd, const char *format, ...) {
|
||||
UT_string *cmd;
|
||||
va_list ap;
|
||||
|
||||
utstring_new(cmd);
|
||||
/* Get cmd size */
|
||||
va_start(ap, format);
|
||||
utstring_printf_va(cmd, format, ap);
|
||||
size_t cmd_size = vsnprintf(nullptr, 0, format, ap) + 1;
|
||||
va_end(ap);
|
||||
|
||||
write_log_message(socket_fd, utstring_body(cmd));
|
||||
utstring_free(cmd);
|
||||
/* Print va to cmd */
|
||||
char cmd[cmd_size];
|
||||
va_start(ap, format);
|
||||
vsnprintf(cmd, cmd_size, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
write_log_message(socket_fd, cmd);
|
||||
}
|
||||
|
||||
int async_redis_socket_test_callback_called = 0;
|
||||
|
||||
Reference in New Issue
Block a user