-
Notifications
You must be signed in to change notification settings - Fork 478
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: Add Rust basic testcase #1839
base: master
Are you sure you want to change the base?
Conversation
@MichelleJin12 I updated some codes. :) Thanks for your first drafts. |
533930e
to
d02f7bf
Compare
tests/runtest.py
Outdated
@@ -1000,6 +1068,7 @@ def parse_argument(): | |||
patch_size = { | |||
'x86_64' : 5, | |||
'aarch64' : 2, | |||
'riscv' : 2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gichoel I think same with aarch64. We need to double checking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you may already know, the RISC-V architecture does not yet support dynamic tracing
. Therefore, related code must be added after introducing Dynamic Tracing
in the RISC-V architecture.
For the above reasons and to reduce confusion, I think you should remove riscv
from the patch_size
variable in that code, so that the string fpatchable-function-entry not support on current platform
is printed and the program exits.
Additionally, although I'm not sure yet, there is a commit that forces RISC-V kernels to use -fpatchable-function-entry=8
, so you should check if you can use the same value as aarch64
.
ref. https://git.kernel.org/torvalds/c/afc76b8b8011
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review. I will include both @MichelleJin12 @gichoel feedback. :)
@@ -1029,6 +1098,9 @@ def has_compiler(compiler): | |||
compilers = [] | |||
if arg.python: | |||
compilers.append('python') | |||
elif arg.rust: | |||
if has_compiler('rustc') and os.system('rustup default nightly > /dev/null') == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there nice nightly checking? This because Rust compiler flags +nightly -Z instrument-mcount
needed. :)
618.405 us [1008471] | pthread_getattr_np(); | ||
0.389 us [1008471] | pthread_attr_getstack(); | ||
0.371 us [1008471] | pthread_attr_destroy(); | ||
0.166 us [1008471] | malloc(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is some point of non-deterministic behavior occurred.
How about splitting it into a commit for risc-v and a commit for rust test? |
@MichelleJin12 I thought a lot about whether to include that code or not, so I added it, but it makes sense. |
$ ./runtest.py -vdp -R 001
info: using existing install for 'nightly-x86_64-unknown-linux-gnu'
info: default toolchain set to 'nightly-x86_64-unknown-linux-gnu'
Start 1 tests without worker pool
Compiler rustc
Runtime test case pg
------------------------:
build command: rustc +nightly -Z instrument-mcount s-abc.rs
test command: /home/vagrant/uftrace_nh/uftrace live --no-pager --no-event --libmcount-path=/home/vagrant/uftrace_nh -N memcpy /home/vagrant/uftrace_nh/tests/s-abc
uftrace: /home/vagrant/uftrace_nh/cmds/record.c:1564:find_in_path
ERROR: Cannot trace '/home/vagrant/uftrace_nh/tests/s-abc': No such executable file.
r001_basic: returns 1
001 basic : NZ
$ rustc +nightly -Z instrument-mcount s-abc.rs
$ ./runtest.py -vdp -R 001
info: using existing install for 'nightly-x86_64-unknown-linux-gnu'
info: default toolchain set to 'nightly-x86_64-unknown-linux-gnu'
Start 1 tests without worker pool
Compiler rustc
Runtime test case pg
------------------------:
build command: rustc +nightly -Z instrument-mcount s-abc.rs
test command: /home/vagrant/uftrace_nh/uftrace live --no-pager --no-event --libmcount-path=/home/vagrant/uftrace_nh -N memcpy /home/vagrant/uftrace_nh/tests/s-abc
uftrace: /home/vagrant/uftrace_nh/cmds/record.c:1671:check_binary
ERROR: Can't find 'mcount' symbol in the '/home/vagrant/uftrace_nh/tests/s-abc'.
It seems not to be compiled with -pg or -finstrument-functions flag.
You can rebuild your program with it or use -P option for dynamic tracing.
r001_basic: returns 1
001 basic : NZ
$ rustc +nightly -Z instrument-mcount -C passes='ee-instrument<post-inline>' s-abc.rs
$ ./runtest.py -vdp -R 001
info: using existing install for 'nightly-x86_64-unknown-linux-gnu'
info: default toolchain set to 'nightly-x86_64-unknown-linux-gnu'
Start 1 tests without worker pool
Compiler rustc
Runtime test case pg
------------------------:
build command: rustc +nightly -Z instrument-mcount s-abc.rs
test command: /home/vagrant/uftrace_nh/uftrace live --no-pager --no-event --libmcount-path=/home/vagrant/uftrace_nh -N memcpy /home/vagrant/uftrace_nh/tests/s-abc
=========== original ===========
...
=========== result ===========
std::rt::lang_start() {
poll();
signal();
sigaction();
sigaction();
sigaction();
sigaltstack();
sysconf();
mmap64();
sysconf();
mprotect();
sysconf();
sigaltstack();
sysconf();
pthread_self();
pthread_getattr_np();
pthread_attr_getstack();
pthread_attr_destroy();
malloc();
malloc();
__cxa_thread_atexit_impl();
std::rt::lang_start::_{{closure}}() {
std::sys_common::backtrace::__rust_begin_short_backtrace() {
core::ops::function::FnOnce::call_once() {
s_abc::main() {
s_abc::a() {
s_abc::b() {
s_abc::c() {
getpid();
} /* s_abc::c */
} /* s_abc::b */
} /* s_abc::a */
} /* s_abc::main */
} /* core::ops::function::FnOnce::call_once */
} /* std::sys_common::backtrace::__rust_begin_short_backtrace */
_<()>::report();
} /* std::rt::lang_start::_{{closure}} */
sigaltstack();
sysconf();
sysconf();
munmap();
} /* std::rt::lang_start */
free();
free();
=========== expected ===========
getauxval();
getauxval();
getauxval();
std::rt::lang_start() {
poll();
signal();
sigaction();
sigaction();
sigaction();
sigaltstack();
sysconf();
mmap64();
sysconf();
mprotect();
sysconf();
sigaltstack();
sysconf();
pthread_self();
pthread_getattr_np();
pthread_attr_getstack();
pthread_attr_destroy();
malloc();
malloc();
__cxa_thread_atexit_impl();
std::rt::lang_start::_{{closure}}() {
std::sys_common::backtrace::__rust_begin_short_backtrace() {
core::ops::function::FnOnce::call_once() {
s_abc::main() {
s_abc::a() {
s_abc::b() {
s_abc::c() {
getpid();
} /* s_abc::c */
} /* s_abc::b */
} /* s_abc::a */
} /* s_abc::main */
} /* core::ops::function::FnOnce::call_once */
} /* std::sys_common::backtrace::__rust_begin_short_backtrace */
_<()>::report();
} /* std::rt::lang_start::_{{closure}} */
sigaltstack();
sysconf();
sysconf();
munmap();
} /* std::rt::lang_start */
free();
free();
r001_basic: diff result of gcc
--- expect 2023-10-29 07:22:33.441598625 +0000
+++ result 2023-10-29 07:22:33.441598625 +0000
@@ -1,4 +1 @@
- getauxval();
- getauxval();
- getauxval();
std::rt::lang_start() {
001 basic : NG |
I think you need to delete
|
@MichelleJin12 I tested with my rpi 4. There's something I haven't tested, I'll double check what you said. My Rust-lang version are latest version. |
@MichelleJin12 Appreciate for review! 😊🫡 |
d02f7bf
to
af1e43d
Compare
I tested on aarch64 rpi4. Nice :)
And i tested on x86_64 WSL2 Ubuntu 20.04. I saw some different point in the internal behavior.
|
@namhyung @honggyukim If Rust have a architectural dependent routine, How can i make answer py script? |
Add Rust-lang abc test for rust uftrace supports. Signed-off-by: Paran Lee <[email protected]> Co-authored-by: Michelle Jin <[email protected]> Reviewed-by: Gichoel Choi <[email protected]>
af1e43d
to
e9a832f
Compare
Is there anything like rustc compiler option for different optimization modes like |
When we use |
I think we can test all 0,1,2,3,s levels like we do for C/C++. Maybe it can be added to the existing runtest rather than adding a new Rust test set. But I'm not sure what's the better way. Do you think you will add a lot more tests for Rust? |
Add Rust-lang abc test for rust supports.
Signed-off-by: Michelle Jin [email protected]
Co-authored-by: Paran Lee [email protected]