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

tests/semantic: Add architecture specific testcase support #1641

Merged
merged 1 commit into from
Nov 23, 2020

Conversation

lostjeffle
Copy link

commit 48d4051 ("bpftrace: Add architecture specific testcase
support") added architecture specific support for runtime tests.
Still there are architecture specific testcases in semantic_analyser,
where 'ip' register is hard coded in semantic_analyser.call_reg and
semantic_analyser.builtin_functions.

These testcases are all c/c++ files and thus we need conditional compiling.

Signed-off-by: Jeffle Xu jefflexu@linux.alibaba.com

#1137 had ever noted that some architecture specific test cases are hard coded, and thus will fail in some architectures not supported.

  • some runtime-test had been fixed by commit 48d4051 ("bpftrace: Add architecture specific testcase support")
  • opensnoop/statsnoop in tools-parsing-test had been fixed by commit 330953c ("fix build failed on aarch64")

This patch is supposed to fix the failure in semantic_analyser.builtin_functions, semantic_analyser.call_reg.

Checklist
  • Language changes are updated in docs/reference_guide.md
  • User-visible and non-trivial changes updated in CHANGELOG.md
  • The new behaviour is covered by tests

@lostjeffle lostjeffle force-pushed the jingbo/dev branch 2 times, most recently from 01d9912 to de7c021 Compare November 20, 2020 05:54
CHANGELOG.md Outdated
@@ -106,6 +106,8 @@ and this project adheres to
- [#1580](https://github.com/iovisor/bpftrace/pull/1580)
- Printing of small integers with `printf`
- [#1532](https://github.com/iovisor/bpftrace/pull/1532)
- Add architecture specific testcase support for semantic_analyser
Copy link
Contributor

Choose a reason for hiding this comment

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

We only put the enduser facing changes in the changelog, internal test changes are not relevant for them so you can remove this :)

Copy link
Author

Choose a reason for hiding this comment

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

Regards.

@@ -2,6 +2,19 @@ add_compile_options("-Wno-undef")
add_compile_options("-Wno-switch-default")
add_compile_options("-Wno-switch-enum")

# Architecture-specific preprocessor macro for *.cpp/*.c
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
add_definitions(-DARCH_AARCH64)
Copy link
Member

Choose a reason for hiding this comment

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

I think it's a bit nicer to use the target_compile_definitions

Suggested change
add_definitions(-DARCH_AARCH64)
target_compile_definitions(bpftrace_test PRIVATE ARCH_AARCH64)

Copy link
Author

@lostjeffle lostjeffle Nov 21, 2020

Choose a reason for hiding this comment

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

Actually 'target_compile_definitions' is used in the original patch, but failed with several automatic build test triggered by GitHub, warning that "target_compile_definitions is not defined". Maybe it's related to the version of cmake, since target_compile_definitions is added since cmake3?

I'm not familiar with cmake and really look forward you guys' professional opinion. Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you have a link to the failed builds? It should work. We use it in a quite a few places and we require cmake 3.something anyway:

tests/CMakeLists.txt
69:  target_compile_definitions(bpftrace_test PRIVATE HAVE_LIBBPF_MAP_BATCH)
73:  target_compile_definitions(bpftrace_test PRIVATE HAVE_NAME_TO_HANDLE_AT=1)
76:  target_compile_definitions(bpftrace_test PRIVATE HAVE_BCC_PROG_LOAD)
79:  target_compile_definitions(bpftrace_test PRIVATE HAVE_BCC_CREATE_MAP)

Maybe you placed it before the bpftrace_test target definition? Needs to go on line 69 or later

I'm not familiar with cmake and really look forward you guys' professional opinion. Thanks.

We all struggle with cmake ;)

commit 48d4051 ("bpftrace: Add architecture specific testcase
support") added architecture specific support for runtime tests.
Still there are architecture specific testcases in semantic_analyser,
where 'ip' register is hard coded in semantic_analyser.call_reg and
semantic_analyser.builtin_functions.

Besides registers such as 'ip' and 'bp' are also hard codes in some
codegen tests.

These testcases are all c/c++ files and thus we need conditional compiling.

Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
@lostjeffle
Copy link
Author

@fbs @danobi
Changes since v1:

  • remove changes in CHANGELOG.md
  • use 'target_compile_definitions' instead
  • skip some arch specific codegen test cases when arch not supports

@fbs fbs merged commit 2aa294b into bpftrace:master Nov 23, 2020
@fbs
Copy link
Contributor

fbs commented Nov 23, 2020

thanks!

If we add a lot of cases it might be nice to change the expected value instead of just removing the test but this is fine for now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants