roc-streaming / roc-toolkit

Real-time audio streaming over the network.
https://roc-streaming.org
Mozilla Public License 2.0
1.06k stars 213 forks source link

Add command-line option to enable tracing in tests #363

Closed gavv closed 4 years ago

gavv commented 4 years ago

Our tests has -v option, which enables debug logging (LogDebug level). Example:

bin/x86_64-pc-linux-gnu/roc-test-core -v

It would be very useful to have another option to enable even more verbose trace logging (LogTrace). Ideally, by specifying -vv (like in our tools), but a separate option is okay too.

The tricky part here is that the command-line is parsed by CppUTest and we should find a way to register our own options or implement some workaround.

The parsing happens in test_main.cpp.

pvimal816 commented 4 years ago

Anyone working on this issue? If not I want to work on it. My approach is to pass '-v' two time when we want more verbosity level. Then we just count number of time this option passes in test_main.cpp itself and accordingly set logLevel.

gavv commented 4 years ago

@pvimal816 AFAIK it's free.

My approach is to pass '-v' two time when we want more verbosity level. Then we just count number of time this option passes in test_main.cpp itself and accordingly set logLevel.

Well, sounds good, if:

pvimal816 commented 4 years ago

I have checked that following command which gets accepted by CppUTest: bin/x86_64-pc-linux-gnu/roc-test-core -v -v

But CppUTest generates error on following command: bin/x86_64-pc-linux-gnu/roc-test-core -vv

So we can use first command to implement our feature.

But I have one question here. Can I assume that accessing argv variable in test_main.cpp does not make code non-portable?

gavv commented 4 years ago

Well if -vv does not work, which is the usual way to specify an option multiple times, then I suggest to use some other letter, e.g. -t (t for trace).

Can I assume that accessing argv variable in test_main.cpp does not make code non-portable?

Yeah, argc/argv should be available everywhere. (Unlike getopt function which is POSIX).

pvimal816 commented 4 years ago

Hi gavv,

Sorry to interrupt you. But can you please check this Travis CI error and guide me a little. --- https://travis-ci.org/github/roc-streaming/roc-toolkit/jobs/703784921

gavv commented 4 years ago

@pvimal816 Yep, I saw your messages on IRC, but I can't reply you when you're offline. You just wont receive the reply, IRC doesn't support offline messages.

The problem is specific to brew on old macos versions, I'm already looking into it. It's not specific to your PR.

PS. To be able to see messages sent to the channel when you were offline, you can join the channel using matrix as mentioned here: https://roc-streaming.org/toolkit/docs/about_project/contacts.html

gavv commented 4 years ago

The issue is fixed, please rebase on fresh develop.

gavv commented 4 years ago

Merged.