-
Notifications
You must be signed in to change notification settings - Fork 16
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
Rewrite expect script in C to avoid multiple issues with shell #341
base: main
Are you sure you want to change the base?
Conversation
d6e262d
to
6ee67e1
Compare
@liquidaty very sorry about the issues with testing. Could you try running the tests on this branch and take a look at I haven't moved the shell script into the Makefile because it is used in more than one Makefile, but I have commented it. |
Thank you @richiejp, When I build and run from scratch as follows:
I still get the below error:
Tried in both |
I have identified at least one issue: it is looking for So it appears the issue is that the CC variable value used when test-expect is built, is assumed to be, but in reality might not be, the same as the CC variable value used when the test is run. Maybe we should consolidate the configure scripts so that there is only one-- but that is a separate issue. Based on the above, as expected, if I make both config.mk's identical (./ and ./app,
|
6ee67e1
to
13717b0
Compare
sorry after seeing this I realised I in fact hard coded gcc in the Makefile instead of writing ${CC}.
Looking at the output it performed the transformation and indexing, but then it should scroll to the bottom when This could be due to an error when seeking from the index, so I added an assert as a quick and temporary way to confirm or deny that if you get a chance to quickly try running it with DEBUG=1. |
Is there any way to remove the dependency on the |
Somewhat simple if we sacrifice precision. Arithmetic in shell is limited, so initially I got this which contains awk, but there is also the issue that I'm using now_seconds() {
printf "%.2f" "$(date +%s.%N)"
}
start_time=$(now_seconds)
while true; do
tmux capture-pane -t "$TARGET" -p > "$CAPTURE"
t=$(now_seconds)
if ${CMP} -s "$CAPTURE" "$EXPECTED"; then
matched=true
break
fi
timedout=$(echo "$start_time" "$t" "$EXPECT_TIMEOUT" | awk '{ if ($2 - $1 > $3) print "true" }')
if [ "$timedout" = "true" ] ; then
break
fi
sleep 0.025
done
elapsed=$(echo "$start_time" "$t" | awk '{ printf "%.2f", $2 - $1 }') The last remaining option is to limit the precision to whole seconds. I wanted to keep the precision for recording the timings. For the timeout it doesn't matter. now_seconds() {
date +%s
}
start_time=$(now_seconds)
while true; do
tmux capture-pane -t "$TARGET" -p > "$CAPTURE"
t=$(now_seconds)
if ${CMP} -s "$CAPTURE" "$EXPECTED"; then
matched=true
break
fi
if [ $(( t - start_time )) -gt "$EXPECT_TIMEOUT" ]; then
break
fi
sleep 0.025
done
elapsed=$(( t - start_time ))
if [ "$matched" = "true" ]; then
echo "$TARGET$STAGE took ${elapsed}s"
printf ", %s" "$elapsed" >> "${TIMINGS_CSV}"
fi full changes: https://github.com/liquidaty/zsv/compare/main...richiejp:expect-sans-timeout?expand=1 |
Thanks @richiejp. Could you pls remind me: what was the original problem that the expect script is solving? If it is just the intermittent test failures, could we not just far more simply address by the combination of sleeping for a longer time and in the case of comparing timestamps, broadening the window of acceptable timestamp values? I'm wondering if this added complexity is worth it, compared to how the tests used to work which was very simple |
Good question, yes it is about stopping intermittent test failures, but without increasing the time it takes to do testing. I found on some steps the sleep needed to be 1-3 seconds at least to avoid random failures. Meanwhile these screens take 0.01 to 0.3 seconds to match on average. I guess this is partially a matter of personal preference, but I find it quite disruptive if a process takes a few minutes and it'll only get worse as more tests are added. In fact it will get exponentially worse because the longer the test suite runs, the more likely you are to hit an outlier (e.g. when the VM is interrupted in CI) and you have to increase the sleeps. I saw this a lot when working in QA. As for comparing timestamps; yes I agree we can just lower the precision. There are some other things which the script/utility do which increase the complexity a bit. For example it allows matching intermediate screens so that I could test multiple steps. These could be handled another way, but would still increase the complexity of any solution or we'd just have to have less comprehensive/observable testing. |
The shell expect script tried to repeatedly capture the tmux pane and match the output until either it matched or it timed out.
This had a large number of issues between the platforms with it finally working on my machine and in CI but failing on @liquadity's setup.
This is a bit extreme, but unreliable and unpredictable testing is costing and time and I want to firmly squash it. Hopefully the C code will be easier to manage and will do what is expected.