Skip to content

Commit

Permalink
fix core tests, --filter=[core] --valgrind
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Aug 16, 2024
1 parent f6409b0 commit 55f73f1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
14 changes: 14 additions & 0 deletions .github/WORKFLOW-PARAMETERS.md
Original file line number Diff line number Diff line change
@@ -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"
```
3 changes: 2 additions & 1 deletion core-tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions core-tests/src/core/string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions include/swoole_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 55f73f1

Please sign in to comment.