-
Notifications
You must be signed in to change notification settings - Fork 48
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
Reduce usage of SCRIPT_NAME #546
base: main
Are you sure you want to change the base?
Conversation
v2 https://sof-ci.01.org/softestpr/PR546/build488/devicetest is all green |
# but the result could not be stored in the array | ||
readarray -t cmd_lst < <(pgrep -P $$ -a|grep -v "$SCRIPT_NAME") | ||
# can't run pgrep in any subshell because the latter would pollute the list | ||
if pgrep -P $$ -a > "$LOG_ROOT/children_left.txt"; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see any need to use a tmp file here, this will bring more trouble with sub-test
why not use readarray -t cmd_lst < <(pgrep -P $$ -a)
And the whole logic is changed to me, the parent will still be killed by itself now.
How is # can't run pgrep in any subshell because the latter would pollute the list
take effect here
# NOTICE: already test with $BASHPID: | ||
# it can output the same result of $$ | ||
# but the result could not be stored in the array | ||
readarray -t cmd_lst < <(pgrep -P $$ -a|grep -v "$SCRIPT_NAME") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked pgrep -P $$ -a
it will show the script it self, how do you remove it from the list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong, demo:
hostname:~$ pgrep -P $$ -a
hostname:~$ sleep 1000 &
[1] 140297
hostname:~$
hostname:~$ ps f
PID TTY STAT TIME COMMAND
140238 pts/3 Ss 0:00 -bash
140297 pts/3 S 0:00 \_ sleep 1000
140298 pts/3 R+ 0:00 \_ ps f
139197 pts/2 Ss+ 0:00 -bash
138772 pts/1 Ss+ 0:00 /bin/sh -i
hostname:~$ echo $$
140238
hostname:~$ pgrep -P $$ -a
140297 sleep 1000
The new file is not temporary, it's part of the error logs. Most tests should fail when a process is unexpectedly left behind... but off-topic for now.
Try removing just
Good point, I think I missed that.
The logic is exactly the same, the only difference is removing the subshell to avoid the awkward filtering.
I wonder what you tested because if you run just FYI a lot of actual testing went into this PR (except for the subtests, my bad) |
@marc-hb Try with
The output is interesting
See the log try to kill test_a.sh
Above test_b.sh will only kill the aplay.
And that is why I said the logic is different here as I see different behavior with above test scripts. |
@marc-hb is this still relevant or needs to be closed? |
I've been using this locally and successfully for months. I got confused by some Xiuli's review, will take another look. No one else reviewed unfortunately. |
No, the old code used So the only issue left is to make sure sub-tests don't collide their respective children_left.txt files. You can see the PID is NOT the main shell if you add
You cannot see the subshell |
Use a new children_left.txt log file instead. Using a subshell forced us to filter it out with grep -v $SCRIPT_NAME which is more complicated, incompatible with exec wrappers like multiple-pipeline-capture/playback.sh and incompatible with running concurrent instances. Signed-off-by: Marc Herbert <[email protected]>
The SCRIPT_NAME indirection is not required and confusing. Signed-off-by: Marc Herbert <[email protected]>
Just simplifying and reducing the usage of the SCRIPT_NAME indirection, see commit messages.
v1 was fixing 1398cf4 which broke logging by moving the logs of both tests into the same
logs/multiple-pipeline/
subdirectory but @xiulipan and @aiChaoSONG said we don't need to move the logs back to where they were, so this PR does not move anything anymore, it's just cleanups now.For v1 https://sof-ci.01.org/softestpr/PR546/build487/devicetest/ was all green