Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test] Port LD-logger tests to python #3153

Merged

Conversation

steakhal
Copy link
Contributor

Simply port the BASH tests to python 3.
Also adds a few other test-cases, one of which demonstrates a current limitation.
In the XFAIL test, the logger produces an invalid json.


Maybe we should set pylint for the tests as well.

@steakhal steakhal requested a review from bruntib as a code owner January 19, 2021 14:19
@steakhal steakhal force-pushed the port-logger-tests-to-python branch 2 times, most recently from 576cc56 to 4960ada Compare January 19, 2021 14:22
@csordasmarton csordasmarton added the test ☑️ Adding or refactoring tests label Jan 19, 2021
@csordasmarton csordasmarton added this to the release 6.16.0 milestone Jan 19, 2021
@csordasmarton csordasmarton modified the milestones: release 6.16.0, release 6.16.1 Jun 2, 2021
@csordasmarton csordasmarton modified the milestones: release 6.16.1, release 6.17.1 Sep 7, 2021
@csordasmarton csordasmarton modified the milestones: release 6.17.1, release 6.18.0 Nov 4, 2021
@steakhal steakhal force-pushed the port-logger-tests-to-python branch 4 times, most recently from 3018537 to 5f7ab80 Compare January 21, 2022 15:07
@steakhal steakhal force-pushed the port-logger-tests-to-python branch from 5f7ab80 to b8098d8 Compare January 31, 2022 12:08
Copy link
Contributor

@csordasmarton csordasmarton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find some test cases which were available previously: test_backslashes, test_vectical_tab, test_carriage_return, test_valid_json

function test_backslashes {
bash -c "gcc -Wall -Wextra -DVARIABLE=\\\\\\\\\\\\\\\\built\\\\\\\\ages\\ \\\"ago\\\"\\\\\\\\ $source_file"
assert_json \
"-Wall -Wextra -DVARIABLE=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\built\\\\\\\\\\\\\\\\ages\\\\ \\\\\\\"ago\\\\\\\"\\\\\\\\\\\\\\\\ $source_file" \
gcc \
"$source_file"
# - - \ \ b u i l t \ a g e s " a g o " \ - -
assert_run_stdout_hexdump "2d 2d 5c 5c 62 75 69 6c 74 5c 61 67 65 73 20 22 61 67 6f 22 5c 2d 2d" ./a.out
}
function test_vectical_tab {
bash -c "gcc -Wall -Wextra -DVARIABLE=\\\\\\\\ZZ\\\\x0bYYYY\\\\\\\\ $source_file"
assert_json \
"-Wall -Wextra -DVARIABLE=\\\\\\\\\\\\\\\\ZZ\\\\\\\\x0bYYYY\\\\\\\\\\\\\\\\ $source_file" \
gcc \
"$source_file"
# --\ZZ\vYYYY\-- as hex
# ^^ ---- vertical tab --------------vv
# - - \ Z Z \v Y Y Y Y \ - -
assert_run_stdout_hexdump "2d 2d 5c 5a 5a 0b 59 59 59 59 5c 2d 2d" ./a.out
}
function test_carriage_return {
bash -c "gcc -Wall -Wextra -DVARIABLE=\\\\\\\\ZZ\\\\x0dYYYY\\\\\\\\ $source_file"
assert_json \
"-Wall -Wextra -DVARIABLE=\\\\\\\\\\\\\\\\ZZ\\\\\\\\x0dYYYY\\\\\\\\\\\\\\\\ $source_file" \
gcc \
"$source_file"
# --\ZZ\rYYYY\-- as hex
# ^^ ---- carriage return -----------vv
# - - \ Z Z \r Y Y Y Y \ - -
assert_run_stdout_hexdump "2d 2d 5c 5a 5a 0d 59 59 59 59 5c 2d 2d" ./a.out
}

function test_valid_json {
bash -c "gcc 2>/dev/null"
echo -ne "[\n]" > $reference_file
diff $reference_file $CC_LOGGER_FILE
}

It would be good not to remove any test case with this patch.

Also adds some failing tests, documenting existing behavior.
@steakhal steakhal force-pushed the port-logger-tests-to-python branch from b8098d8 to ebc8213 Compare February 1, 2022 13:34
@steakhal
Copy link
Contributor Author

steakhal commented Feb 1, 2022

I didn't find some test cases which were available previously: test_backslashes, test_vectical_tab, test_carriage_return,

test_backslashes was renamed to test_space_backslashes

verticaltab is included in test_control_characters
And basically, the expected test output was wrong.
The right escape sequence for '\v' would have been ['\\', 'v'] instead of ['\\', '\v'].
The '\r' is similarly should have been escaped as ['\\', 'r'] instead of ['\\', '\r'].
This is also included in test_control_characters.


test_valid_json
It would be good not to remove any test case with this patch.

Oh yes, I re-added this test case.

Copy link
Contributor

@csordasmarton csordasmarton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@csordasmarton csordasmarton added this to the release 6.19.0 milestone Feb 1, 2022
@csordasmarton csordasmarton merged commit 7df76b0 into Ericsson:master Feb 1, 2022
@steakhal steakhal deleted the port-logger-tests-to-python branch February 2, 2022 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test ☑️ Adding or refactoring tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants