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

Explicitly invoke start_test() in every test-case/*.sh #1187

Merged
merged 2 commits into from
May 6, 2024

Conversation

marc-hb
Copy link
Collaborator

@marc-hb marc-hb commented May 1, 2024

2 commits, main one:

Stop unconditionally imposing start_test() to everything sourcing lib.sh

This makes it possible to source lib.sh without running anything which
can be useful for debugging.

For now this should be a no-op for all tests except two files in tools/ which
were never really "tests" in the first place:

  • tools/kmod/sof_remove.sh
  • tools/sof-kernel-log-check.sh

In these, start_test() never made sense it never really run thanks the
(awkward) "is_subtest()" escape.

There are other tests where start_test() should not be invoked either,
most notably test-case/verify-kernel-boot-log.sh in order to fix
#1112 but this is a huge
commit already; one change at a time.

Long overdue.

Zero code change.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Stop unconditionally imposing start_test() to everything sourcing lib.sh

This makes it possible to source lib.sh without running anything which
can be useful for debugging.

For now this should be a no-op for all tests except two files in `tools/` which
were never really "tests" in the first place:

- tools/kmod/sof_remove.sh
- tools/sof-kernel-log-check.sh

In these, start_test() never made sense it never really run thanks the
(awkward) "is_subtest()" escape.

There are other tests where start_test() should not be invoked either,
most notably test-case/verify-kernel-boot-log.sh in order to fix
thesofproject#1112 but this is a huge
commit already; one change at a time.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
@marc-hb
Copy link
Collaborator Author

marc-hb commented May 2, 2024

@marc-hb marc-hb marked this pull request as ready for review May 2, 2024 00:10
@marc-hb marc-hb requested a review from a team as a code owner May 2, 2024 00:10
# 3. Register the func_exit_handler() EXIT trap that collects logs, kills
# loggers and prints test results.
#
# 4. Waits for the FW to be successfully booted (can be disabled)
Copy link
Contributor

Choose a reason for hiding this comment

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

How can it be disabled?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

NO_POLL_FW_LOADING 30 lines below, it's not that long of a function (as no function should be)

Also documented in config.sh

#
# 4. Waits for the FW to be successfully booted (can be disabled)
#
#
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: one blank line should be enough?

Copy link
Collaborator

Choose a reason for hiding this comment

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

agree it's nitpick

@@ -73,6 +73,8 @@ frequency=${OPT_VAL['F']}
sigmak=${OPT_VAL['k']}
frames=${OPT_VAL['n']}

start_test

Copy link
Contributor

Choose a reason for hiding this comment

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

In commit message, what is the meaning of the opening sentence in relation to moving the start_test from lib.sh to test cases?
Stop unconditionally imposing start_test() to everything sourcing lib.sh

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure I understand the question...
Now it's explicit, so each test has a choice to call start_test or not. That's all this PR is about.

When start_test was in lib.sh, tests had no choice but to run start_test

start_test started as a small thing so running it unconditionally was a "small bug" but it has kept growing.

@@ -41,6 +41,8 @@ loop_cnt=${OPT_VAL['l']}
func_pipeline_export "$tplg" "eq:any"
sofcard=${SOFCARD:-0}

start_test
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the start_test used to run at line 21?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes this is a minor change: start_test is now running after option parsing. It was confusing to "start" a test and run the exit handler, etc. when no testing had started yet because a wrong option was passed.

@@ -57,6 +57,7 @@ loop_cnt=${OPT_VAL['l']}
out_dir=${OPT_VAL['o']}
file_prefix=${OPT_VAL['f']}

start_test
Copy link
Contributor

Choose a reason for hiding this comment

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

All of this churn is to keep the systemctl_show_pulseaudio in tools/kmod/sof_remove.sh instead of just dropping it from the sof_remove.sh along with sourcing the case-lib/lib.sh and be done?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, the main benefit for sof_remove.sh is the ability to run it more than once. It used to fail when the firmware wasn't running. Also avoids some confusing logs: sof_remove.sh is not a "test"

There will be a much bigger and much more important bug fix not related to sof_remove.sh, see commit message.

Also restores the ability to source lib.sh interactively, also mentioned in the commit message

Copy link
Collaborator Author

@marc-hb marc-hb May 3, 2024

Choose a reason for hiding this comment

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

instead of just dropping it from the sof_remove.sh along with sourcing the case-lib/lib.sh

The (non-mandatory) pulseaudio check is debatable. Including lib.sh is much less so. There's no reason to copy/paste routines when it can easily be avoided.

Anyway the most important and urgent benefit of this design fix is preparing the fix for #1036 and #1112. The same design fix just happens to help with some other scripts like sof_remove.sh.

@@ -18,6 +18,11 @@ set -e
# shellcheck source=case-lib/lib.sh
source "$(dirname "${BASH_SOURCE[0]}")"/../case-lib/lib.sh

start_test
# TODO: replace start_test with this:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This TODO will be next PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes immediately after this one. I want at least one run of daily tests between the two.

Copy link
Collaborator

@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.

Initially start_test from lib.sh was making sense. but now it doesn't cover every case.

Explicit invoking start_test() is making sense now.

@marc-hb
Copy link
Collaborator Author

marc-hb commented May 6, 2024

Thanks @fredoh9 !

@marc-hb marc-hb merged commit 7c2ede0 into thesofproject:main May 6, 2024
4 of 7 checks passed
@marc-hb marc-hb deleted the explicit-start-step branch May 6, 2024 18:13
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.

3 participants