Skip to content

Conversation

@keqiaozhang
Copy link
Contributor

since zephyr doesnot support sof-logger, so add a function
to disable logger trace for zephyr during the test.

Signed-off-by: Zhang Keqiao keqiao.zhang@intel.com

@keqiaozhang keqiaozhang requested a review from a team as a code owner May 24, 2021 09:05
@keqiaozhang keqiaozhang force-pushed the zephyr branch 2 times, most recently from 4cd89f6 to d19612a Compare May 24, 2021 09:39
Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

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

Can you please add one more is_zephyr() function? I mean logger_disabled() invokes is_zephyr() like this:

is_zephyr()
{
  grep something.*zephyr somefile
}

logger_disabled()
{
   if is_zephyr; then
      return 0
    else ...

Can you please give an example of this /etc/sof/manifest.txt file and a link to what code creates and deploys it?

This /etc/sof/manifest.txt file may be good enough for CI in the very short term but I don't think it will work for most developers. I compile with and without Zephyr many times every day and I also use sof-test yet my /etc/sof/ has been empty since forever.

@andyross , @kv2019i , @lyakh : any other, simple, automatable and reliable way to tell the difference between plain SOF versus SOF+Zephyr?

PS: I've been using a .tarball-version hack that shows up in dmesg but this won't work for CI

case-lib/lib.sh Outdated
manifest=/etc/sof/manifest.txt
FIRMWARE_TYPE=$(grep "firmwaretype" < "$manifest" | awk -F ':' '{print $2}' | sed -e 's/^[ ]*//g;s/\"//g')
# disable sof-logger for Zephyr built firmware
if [ "$FIRMWARE_TYPE" == "zephyr" ]; then
Copy link
Collaborator

@marc-hb marc-hb May 24, 2021

Choose a reason for hiding this comment

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

This above seems a bit long and over complicated, could this be shorten into something like this:

if grep `firmwaretype.*zephyr` /etc/sof/manifest.txt; then

Just a really simplified example: you may want a slightly more complex regular expression.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I will refine my patch.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I didn't know manifest.txt was actually a manifest.json. The standard, command-line parser for JSON is jq, please drop awk, grep etc. and use jq:

apt-get install jq
jq '.version.firmwaretype' manifest.txt
 => "zephyr"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. Thanks!

case-lib/lib.sh Outdated
{
# get the firmware type
manifest=/etc/sof/manifest.txt
FIRMWARE_TYPE=$(grep "firmwaretype" < "$manifest" | awk -F ':' '{print $2}' | sed -e 's/^[ ]*//g;s/\"//g')
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need for the <.

No need for the grep, awk can already do grep (and many other things): awk -F ':' '/firmwaretype/ {print $2 }'

Regular expressions with only special characters are time-consuming to read and deserve a comment, for instance # remove whitespace.

@keqiaozhang keqiaozhang force-pushed the zephyr branch 2 times, most recently from 7a6a8e9 to 436e2bd Compare May 25, 2021 09:59
@kv2019i
Copy link
Contributor

kv2019i commented May 25, 2021

@marc-hb wrote:

@andyross , @kv2019i , @lyakh : any other, simple, automatable and reliable way to tell the difference between plain SOF versus SOF+Zephyr?

PS: I've been using a .tarball-version hack that shows up in dmesg but this won't work for CI

Not very good ones.

The compiler string has "zephyr", but that's not reliable (plain SOF could be built with zephyr toolchain, or zephyr can be built with something else).

The FW binary has a string "ZEPHYR FATAL" that you can test with "test -n "strings /lib/firmware/intel/sof/sof-tgl.ri |grep ZEPHYR FATAL""

This comes from zephyr/kernel/fatal.c , so while it's a bit adhoc, it's likely to be a pretty reliable in practise. We have code in test-case/verify-firmware-presence.sh to parse the fw file, so this is a possibility.

Copy link
Contributor

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

I tested the patch on a system with Zephyr firmware and it did work as expected. We should make the manifest-based configuration a bit cleaner so it makes sense for standalone usage of sof-test, but otherwise this looks good.

Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

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

I suggest we merge this with the manifest.txt first to get CI started and then try to find a better test later. Only the is_zephyr() function will have to change.

return 0
else
return 1
fi
Copy link
Collaborator

Choose a reason for hiding this comment

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

Style nit/personal preference:

if is_zephyr || [[ ${OPT_VAL['s']} -ne 1 ]]; then
   return 0
fi

return 1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Concise and reasonable. Updated

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, this can probably be just:

logger_disabled()
{
   is_zephyr || [[ ${OPT_VAL['s']} -ne 1 ]
}

since zephyr doesnot support sof-logger, so add a function
to disable logger trace for zephyr during the test.

Signed-off-by: Zhang Keqiao <keqiao.zhang@intel.com>
@aiChaoSONG
Copy link

aiChaoSONG commented May 26, 2021

I think there's also a test -e "$manifest" || return 1 missing before the jq.

@marc-hb @keqiaozhang For CI devices, $manifest must exist, otherwise, the deployment failed, so the test is not started.
For personal device, this file may not exist. so I think we should regard '$manifest not exist' as 'zephyr not exist', and continue to check other options. this is for CI and personal device compatibility

Edit: If we just want to test if the FW is zephyr, a grep is enough, we can eliminate the dependency on jq. If we do want to parse json with jq, I think a function get_sof_type is better.

Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

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

LGTM but probably not for some others yet.

For personal device, this file may not exist. so I think we should regard '$manifest not exist' as 'zephyr not exist',

I think the majority of people who reviewed this PR use Zephyr without a manifest.txt and at least one had a good idea that he will submit immediately after this PR is merged :-)

Edit: If we just want to test if the FW is zephyr, a grep is enough, we can eliminate the dependency on jq

jq is awesome, it's a great dependency and in this case it makes the manifest-based test very reliable. Now if the manifest.txt test goes away soon then I agree the jq dependency will be very short lived in this case...

Copy link
Contributor

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

Fair enough @marc-hb , let's go with this.

@keyonjie
Copy link

why does zephyr not support sof-logger? without FW logs, how can we debug the SOF issues?

@marc-hb
Copy link
Collaborator

marc-hb commented May 27, 2021

We could make sof-logger compatible with Zephyr but the plan is to migrate to https://docs.zephyrproject.org/latest/reference/logging/

For now logging is provided by one of these: zephyrproject-rtos/zephyr#35186

Copy link
Contributor

@fredoh9 fredoh9 left a comment

Choose a reason for hiding this comment

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

didn't know sof-logger is not supported for Zephyr

@marc-hb
Copy link
Collaborator

marc-hb commented Jun 1, 2021

3 approvals, 8 days in review, no formal "request changes", simple and easy to maintain change: merging.

Some very good suggestions and objections: please submit incremental changes.

@marc-hb marc-hb merged commit 325e572 into thesofproject:main Jun 1, 2021
@marc-hb marc-hb requested a review from plbossart June 1, 2021 17:16
@marc-hb
Copy link
Collaborator

marc-hb commented Jul 1, 2021

SKIP check-sof-logger if is_zephyr #724

@marc-hb marc-hb added the area:logs Log and results collection, storage, etc. label Jul 3, 2021
@marc-hb
Copy link
Collaborator

marc-hb commented Nov 24, 2021

#809 just enabled sof-logger with Zephyr. Seems to work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:logs Log and results collection, storage, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants