diff --git a/.github/WORKFLOW-PARAMETERS.md b/.github/WORKFLOW-PARAMETERS.md new file mode 100644 index 00000000000..151a3eb9332 --- /dev/null +++ b/.github/WORKFLOW-PARAMETERS.md @@ -0,0 +1,14 @@ +# Workflow Parameters +Adding parameters in the Git commit log can control the workflow. + +## --filter +This parameter specifies which workflows to run, instead of running all of them. +The command format is: `--filter=[flow1][flow2][flow...]` , +and it supports setting multiple workflows, with names matching the filename of the yml file. + +## --valgrind +Setting this parameter will cause the test program to be run with `valgrind`. + +```shell +git commit -m "commit message --filter=[core][unit] --valgrind" +``` diff --git a/core-tests/run.sh b/core-tests/run.sh index 7a90563a303..ec04e22dfac 100755 --- a/core-tests/run.sh +++ b/core-tests/run.sh @@ -7,7 +7,8 @@ tasks=$(./bin/core_tests --gtest_list_tests | awk '/\./') for task in $tasks; do if [ "${SWOOLE_VALGRIND}" = 1 ]; then - execute_command="valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./bin/core_tests" + # --leak-check=full --show-leak-kinds=all --track-origins=yes + execute_command="valgrind ./bin/core_tests" else execute_command="./bin/core_tests" fi diff --git a/core-tests/src/core/string.cpp b/core-tests/src/core/string.cpp index 7b2a1a2040c..6e285616e34 100644 --- a/core-tests/src/core/string.cpp +++ b/core-tests/src/core/string.cpp @@ -262,10 +262,10 @@ TEST(string, ends_with) { TEST(string, append_number) { string data = "hello"; - auto str = swoole::make_string(data.length()); + auto str = swoole::make_string(data.length() + 32); str->append(data.c_str(), data.length()); str->append(123); - str->str[str->length] = '\0'; + str->set_null_terminated(); EXPECT_STREQ(str->str, data.append("123").c_str()); str->print(true); diff --git a/include/swoole_string.h b/include/swoole_string.h index e89f0e9ecab..45b5e6916c9 100644 --- a/include/swoole_string.h +++ b/include/swoole_string.h @@ -246,6 +246,13 @@ class String { } } + void set_null_terminated() { + if (length == size) { + extend(length + 1); + } + str[length] = '\0'; + } + int append(int value); ssize_t split(const char *delimiter, size_t delimiter_length, const StringExplodeHandler &handler);