zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.36k stars 6.35k forks source link

Bsim: Set log level from command-line argument #75249

Closed jori-nordic closed 3 weeks ago

jori-nordic commented 1 month ago

Created from https://github.com/zephyrproject-rtos/zephyr/pull/75154#discussion_r1658529168

Not related to this PR specifically, but have we ever considered setting the log level at runtime for BSIM tests? We don't really care about memory in these, and would allow us to rerun a test with more verbosity without a recompile. The log level can simply be added as a argument in the run.sh (and similar) files.

A starting point would be implementing that for the sample bsim test. This way that pattern or library will automatically spread when people make new tests based on this sample.

https://github.com/zephyrproject-rtos/zephyr/blob/v3.7.0-rc2/tests/bsim/bluetooth/host/misc/sample_test/README.rst

00thirdeye00 commented 1 month ago

hej @jori-nordic, I am new to zephyr and would like to work on this issue. can you please guide me and give me some information/references for my understanding.

jori-nordic commented 1 month ago

Hi, yes. You should familiarize yourself with BabbleSim and read this page carefully first: https://docs.zephyrproject.org/latest/develop/test/bsim.html

Then also read all the files in the sample test's directory.

Then look at how we add arguments to the tests: We register a parsing function that will set some global variables. The arguments are passed on the command-line this way

The idea is to then:

The command line for setting e.g., LOG_LEVEL_DBG would look something like this then, for the sample test: Execute "${test_exe}" -v=${verbosity_level} -s=${simulation_id} -d=0 -rs=420 -testid=dut -argstest log_level 4.

Here are the log level defines.

Happy hacking 💻