Skip to content

Dynamic PTS for test runs#129

Open
sansmoraxz wants to merge 2 commits into
grid-x:masterfrom
sansmoraxz:fix/pts-dynamic
Open

Dynamic PTS for test runs#129
sansmoraxz wants to merge 2 commits into
grid-x:masterfrom
sansmoraxz:fix/pts-dynamic

Conversation

@sansmoraxz

Copy link
Copy Markdown
Contributor
  • Remove hard coded path which can break running cli apps (as these apaths are used by terminals). Use tmp based paths instead.
  • Ensure these paths are cleaned up after test run (regardless of state)
  • glide cli is not really necessary with model go. So that was cleaned up too
  • Moved this test into seperate script file

Fixes: #128

tmpdir=$(mktemp -d)

cleanup() {
pkill -P $$ 2>/dev/null || true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

pkill -P $$ kills only direct children of the current shell. If diagslave or socat spawns child processes, those will be orphaned. Consider using a process group kill (kill -- -$$) or tracking PIDs explicitly.
The || true suppresses all errors, including unexpected ones, which may hide issues in CI.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They don't spawn any but still good point.

;;
rtu)
socat -d -d pty,raw,echo=0,link="$tmpdir/pty0" pty,raw,echo=0,link="$tmpdir/pty1" &
sleep 0.5

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sleep 0.5 is a race condition
The sleep 0.5 waiting for socat to create the PTY symlinks is a classic timing hack. On a loaded CI machine this can be too short. A more robust approach would be to poll until the symlink appears, e.g. until [ -e "$tmpdir/pty0" ]; do sleep 0.05; done with a timeout guard.
Also in line 30

diagslave -m rtu "$tmpdir/pty1" &
go test -run "$TEST_FILTER" -v .
;;
ascii)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

rtu and ascii do the same thing except for the -m flag. We could avoid the copy-paste by using one shared branch/helper and just changing the MODE passed to diagslave.

Comment on lines +4 to +5
MODE=$1
TEST_FILTER=$2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

MODE and TEST_FILTER are used without much validation. MODE already falls through to the usage error if it’s missing, but an empty TEST_FILTER becomes -run "", which runs all tests. If that’s intended, maybe we should document it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

set -e won’t catch failures from background processes. If diagslave or socat fails to start, the later go test may fail with a less clear error. It would be easier to debug if we check that the background process is actually running before continuing. Wdyt?

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.

Makefile tests exec: PTS files should not be hardcoded

2 participants