Skip to content

Commit 67ede85

Browse files
authored
stty: Changing shell command to add recognizing a TTY for stty tests (#9336)
1 parent dd118e0 commit 67ede85

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

.github/workflows/GnuTests.yml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ env:
2727
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
2828
TEST_FULL_SUMMARY_FILE: 'gnu-full-result.json'
2929
TEST_ROOT_FULL_SUMMARY_FILE: 'gnu-root-full-result.json'
30+
TEST_STTY_FULL_SUMMARY_FILE: 'gnu-stty-full-result.json'
3031
TEST_SELINUX_FULL_SUMMARY_FILE: 'selinux-gnu-full-result.json'
3132
TEST_SELINUX_ROOT_FULL_SUMMARY_FILE: 'selinux-root-gnu-full-result.json'
3233

@@ -137,12 +138,34 @@ jobs:
137138
path_GNU='gnu'
138139
path_UUTILS='uutils'
139140
bash "uutils/util/run-gnu-test.sh" run-root
141+
140142
- name: Extract testing info from individual logs (run as root) into JSON
141143
shell: bash
142144
run : |
143145
path_UUTILS='uutils'
144146
python uutils/util/gnu-json-result.py gnu/tests > ${{ env.TEST_ROOT_FULL_SUMMARY_FILE }}
145147
148+
### This shell has been changed from "bash" to this command
149+
### "script" will start a pty and the -q command removes the "script" initiation log
150+
### the -e flag makes it propagate the error code and -c runs the command in a pty
151+
### the primary purpose of this change is to run the tty GNU tests
152+
### The reason its separated from the rest of the tests is because one test can corrupt the other
153+
### tests through the use of the shared terminal and it changes the environment that the other
154+
### tests are run in, which can cause different results.
155+
- name: Run GNU stty tests
156+
shell: 'script -q -e -c "bash {0}"'
157+
run: |
158+
## Run GNU root tests
159+
path_GNU='gnu'
160+
path_UUTILS='uutils'
161+
bash "uutils/util/run-gnu-test.sh" run-tty
162+
163+
- name: Extract testing info from individual logs (stty) into JSON
164+
shell: bash
165+
run : |
166+
path_UUTILS='uutils'
167+
python uutils/util/gnu-json-result.py gnu/tests > ${{ env.TEST_STTY_FULL_SUMMARY_FILE }}
168+
146169
### Upload artifacts
147170
- name: Upload full json results
148171
uses: actions/upload-artifact@v5
@@ -154,6 +177,12 @@ jobs:
154177
with:
155178
name: gnu-root-full-result
156179
path: ${{ env.TEST_ROOT_FULL_SUMMARY_FILE }}
180+
- name: Upload stty json results
181+
uses: actions/upload-artifact@v5
182+
with:
183+
name: gnu-stty-full-result
184+
path: ${{ env.TEST_STTY_FULL_SUMMARY_FILE }}
185+
157186
- name: Compress test logs
158187
shell: bash
159188
run : |
@@ -358,6 +387,13 @@ jobs:
358387
name: gnu-root-full-result
359388
path: results
360389
merge-multiple: true
390+
- name: Download stty json results
391+
uses: actions/download-artifact@v6
392+
with:
393+
name: gnu-stty-full-result
394+
path: results
395+
merge-multiple: true
396+
361397
- name: Download selinux json results
362398
uses: actions/download-artifact@v6
363399
with:
@@ -380,7 +416,7 @@ jobs:
380416
path_UUTILS='uutils'
381417
382418
json_count=$(ls -l results/*.json | wc -l)
383-
if [[ "$json_count" -ne 4 ]]; then
419+
if [[ "$json_count" -ne 5 ]]; then
384420
echo "::error ::Failed to download all results json files (expected 4 files, found $json_count); failing early"
385421
ls -lR results || true
386422
exit 1

util/run-gnu-test.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,18 @@ if test $# -ge 1; then
5454
done
5555
fi
5656

57-
if [[ "$1" == "run-root" && "$has_selinux_tests" == true ]]; then
57+
if [[ "$1" == "run-tty" ]]; then
58+
# Handle TTY tests - dynamically find tests requiring TTY and run each individually
59+
shift
60+
TTY_TESTS=$(grep -r "require_controlling_input_terminal" tests --include="*.sh" --include="*.pl" -l 2>/dev/null)
61+
echo "Running TTY tests individually:"
62+
# If a test fails, it can break the implementation of the other tty tests. By running them separately this stops the different tests from being able to break each other
63+
for test in $TTY_TESTS; do
64+
echo " Running: $test"
65+
script -qec "timeout -sKILL 5m '${MAKE}' check TESTS='$test' SUBDIRS=. RUN_EXPENSIVE_TESTS=yes VERBOSE=no gl_public_submodule_commit='' srcdir='${path_GNU}'" /dev/null || :
66+
done
67+
exit 0
68+
elif [[ "$1" == "run-root" && "$has_selinux_tests" == true ]]; then
5869
# Handle SELinux root tests separately
5970
shift
6071
if test -n "$CI"; then
@@ -63,7 +74,7 @@ if [[ "$1" == "run-root" && "$has_selinux_tests" == true ]]; then
6374
sudo "${MAKE}" -j "$("${NPROC}")" check TESTS="$*" SUBDIRS=. RUN_EXPENSIVE_TESTS=yes RUN_VERY_EXPENSIVE_TESTS=yes VERBOSE=no gl_public_submodule_commit="" srcdir="${path_GNU}" TEST_SUITE_LOG="tests/test-suite-root.log" || :
6475
fi
6576
exit 0
66-
elif test "$1" != "run-root"; then
77+
elif test "$1" != "run-root" && test "$1" != "run-tty"; then
6778
if test $# -ge 1; then
6879
# if set, run only the tests passed
6980
SPECIFIC_TESTS=""
@@ -91,7 +102,7 @@ fi
91102
# * `srcdir=..` specifies the GNU source directory for tests (fixing failing/confused 'tests/factor/tNN.sh' tests and causing no harm to other tests)
92103
#shellcheck disable=SC2086
93104

94-
if test "$1" != "run-root"; then
105+
if test "$1" != "run-root" && test "$1" != "run-tty"; then
95106
# run the regular tests
96107
if test $# -ge 1; then
97108
timeout -sKILL 4h "${MAKE}" -j "$("${NPROC}")" check TESTS="$SPECIFIC_TESTS" SUBDIRS=. RUN_EXPENSIVE_TESTS=yes RUN_VERY_EXPENSIVE_TESTS=yes VERBOSE=no gl_public_submodule_commit="" srcdir="${path_GNU}" || : # Kill after 4 hours in case something gets stuck in make

0 commit comments

Comments
 (0)