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

[BUG] sof-test output is messy when run test case locally #1151

Closed
aiChaoSONG opened this issue Jan 16, 2024 · 5 comments
Closed

[BUG] sof-test output is messy when run test case locally #1151

aiChaoSONG opened this issue Jan 16, 2024 · 5 comments
Assignees
Labels
P3 Low-impact bugs or features type:bug Something doesn't work as expected

Comments

@aiChaoSONG
Copy link

aiChaoSONG commented Jan 16, 2024

Describe the bug
When run test case locally, the output of the test case is messy. Log doesn't start from the beginning of a line. This makes the log hard to follow.
Screenshot from 2024-01-16 16-31-02

To Reproduce
Just run a test case, say check-playback.sh on any device, and check the output.

EDIT, duplicate of:

@aiChaoSONG
Copy link
Author

comment out this line, issue could not be reproduced

sudo "${mtraceCmd[@]}" >& "$clogfile" &

not sure why a redirect break the current shell.

@aiChaoSONG
Copy link
Author

sudo bash -c "${mtraceCmd[@]} >& $clogfile &", this will workaround the issue

aiChaoSONG pushed a commit to aiChaoSONG/sof-test that referenced this issue Jan 17, 2024
If sof-test test case is run manually and locally,
the output of sof-test is messy, the lines are not
aligned left at the beginning of each line, some
lines start in the middle of a line, which makes
the output log hard to follow.

This patch helps to workaround the above issue.

Link: thesofproject#1151

Signed-off-by: Chao Song <[email protected]>
aiChaoSONG pushed a commit to aiChaoSONG/sof-test that referenced this issue Jan 17, 2024
If sof-test test case is run manually and locally,
the output of sof-test is messy, the lines are not
aligned left at the beginning of each line, some
lines start in the middle of a line, which makes
the output log hard to follow.

This patch helps to workaround the above issue.

Link: thesofproject#1151

Signed-off-by: Chao Song <[email protected]>
aiChaoSONG pushed a commit to aiChaoSONG/sof-test that referenced this issue Jan 17, 2024
If sof-test test case is run manually and locally,
the output of sof-test is messy, the lines are not
aligned left at the beginning of each line, some
lines start in the middle of a line, which makes
the output log hard to follow.

This patch helps to workaround the above issue.

Link: thesofproject#1151

Signed-off-by: Chao Song <[email protected]>
aiChaoSONG pushed a commit that referenced this issue Jan 19, 2024
If sof-test test case is run manually and locally,
the output of sof-test is messy, the lines are not
aligned left at the beginning of each line, some
lines start in the middle of a line, which makes
the output log hard to follow.

This patch helps to workaround the above issue.

Link: #1151

Signed-off-by: Chao Song <[email protected]>
@marc-hb
Copy link
Collaborator

marc-hb commented Jan 30, 2024

Let's leave open as low priority because it's just a workaround and we have no idea why it works.

@marc-hb marc-hb reopened this Jan 30, 2024
@marc-hb marc-hb added type:bug Something doesn't work as expected P3 Low-impact bugs or features labels Jan 30, 2024
@marc-hb
Copy link
Collaborator

marc-hb commented Mar 15, 2024

I've just observed the same effect in a totally different (build) context. I think it happens when multiple processes write to the same terminal concurrently and one of them uses control codes (e.g. color). I suspect control codes are not "atomic" which means another problem can insert characters in the middle and break them.

Maybe the workaround #1154 disables control codes by hiding the terminal.

This would also explains why CI results are not affected: they don't use a terminal.

EDIT: | cat could be a simpler workaround than sudo

@marc-hb
Copy link
Collaborator

marc-hb commented Jul 12, 2024

The workaround in #1154 works for Zephyr but not stable-v2.2

I got tired of this and I tested further. This is a problem only when using sudo + &

/bin/sudo      sleep 1 &   # garbage
/bin/sudo -b   sleep 1     # clean
/bin/sudo      sleep 1     # clean
/bin/sudo -C 2 sleep 1     # clean
/bin/sudo -C 3 sleep 1     # garbage
2>&- /bin/sudo sleep 1 &   # garbage
--- a/case-lib/lib.sh
+++ b/case-lib/lib.sh
@@ -463,7 +463,7 @@ func_sof_logger_collect()
     dlogi "Starting ${loggerCmd[*]} > $logfile &"
     # Cleaned up by func_exit_handler() in hijack.sh
     # shellcheck disable=SC2024
-    sudo "${loggerCmd[@]}" > "$logfile" &
+    /bin/sudo sleep 1 &
 }

Backgrounding sudo is a bad idea anyway:
https://stackoverflow.com/questions/26109878/running-a-program-in-the-background-as-sudo

-b looks great but we can't use it because we have the crazy "sudo hijack" stuff in 1a4ea98

marc-hb added a commit to marc-hb/sof-test that referenced this issue Jul 12, 2024
Should finally fix terminal corruption issue thesofproject#1151.

Commit 8341638 was a good workaround but it was applied only for
Zephyr's mtrace.

- Apply the same workaround for stable-v2.2 sof-logger
- Explain better in the source what causes the corruption
- Change owner of mtrace.txt logs to "ubuntu" instead of root.

Signed-off-by: Marc Herbert <[email protected]>
marc-hb added a commit that referenced this issue Jul 16, 2024
Should finally fix terminal corruption issue #1151.

Commit 8341638 was a good workaround but it was applied only for
Zephyr's mtrace.

- Apply the same workaround for stable-v2.2 sof-logger
- Explain better in the source what causes the corruption
- Change owner of mtrace.txt logs to "ubuntu" instead of root.

Signed-off-by: Marc Herbert <[email protected]>
@marc-hb marc-hb closed this as completed Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 Low-impact bugs or features type:bug Something doesn't work as expected
Projects
None yet
Development

No branches or pull requests

2 participants