Skip to contentSkip to conversation

tcl: rewrite ptest (again)

PATCH Superseded Ross Burton 2 participants 4 messages Mar 3 – Mar 5

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 tcl: rewrite ptest (again)

I discovered that running a single test case with tcltest doesn't let you know if the test failed or not, so when run-ptest moved away from using all.tcl[1] we were always marking the tests as passing.

So, revert that commit and use all.tcl as a test runner. This is more noisy, but importantly will let us know if a test failed.

Remove our un-upstreamable tweaks to the interp tests and instead skip the test that is known to be fragile, so we don't have to carry a patch forever.

Don't install another copy of the entire Tcl library for the tests, as there is no real point. This does then expose a bug in the tests where clock-59.2 assumes that it is running in a source tree and behaves differently if the system tzdata is being used. This is being worked on upstream[2], for now skip this test.

Clean up musl overriding so it's more resiliant.

Exit 1 if a test fails.

[1] oe-core 9c41887f2a ("tcl: improve test execution loop")
[2] https://core.tcl-lang.org/tcl/tktview/51aa53616067cb63900b17ca1d71f07b094ffa1a

---
 .../0005-tcl-fix-race-in-interp.test.patch    | 40 -------------------
 meta/recipes-devtools/tcltk/tcl/run-ptest     | 24 +++++++++--
 meta/recipes-devtools/tcltk/tcl_9.0.3.bb      |  6 +--
 3 files changed, 21 insertions(+), 49 deletions(-)
 delete mode 100644 meta/recipes-devtools/tcltk/tcl/0005-tcl-fix-race-in-interp.test.patch
meta/recipes-devtools/tcltk/tcl/0005-tcl-fix-race-in-interp.test.patch deleted +0 -40
deleted file mode 100644
index 07912da5b3..0000000000
@@ -1,40 +0,0 @@
-From fd75e3613613726786c54a25ee611c5176b33510 Mon Sep 17 00:00:00 2001
-From: Ross Burton <[email protected]>
-Date: Mon, 12 Jul 2021 14:50:13 +0100
-Subject: [PATCH] tcl: fix race in interp.test
-
-The interp-36.7 patch has race conditions and is missing cleanup.  This patch by
-a Tcl maintainer should improve matters.
-
-Upstream-Status: Pending
-Signed-off-by: Ross Burton <[email protected]>
----
- tests/interp.test | 7 ++++---
- 1 file changed, 4 insertions(+), 3 deletions(-)
-
-diff --git a/tests/interp.test b/tests/interp.test
-index 0092a03..eecfd3b 100644
---- a/tests/interp.test
-+++ b/tests/interp.test
-@@ -3614,17 +3614,18 @@ test interp-36.7 {ChildBgerror sets error handler of child [1999035]} -setup {
- 	variable result
- 	set result [lindex $args 0]
-     }
-+    set tout [after 5000 {set result timeout}]
- } -body {
-     child eval {
- 	variable done {}
- 	after 0 error foo
--	after 10 [list ::set [namespace which -variable done] {}]
--	vwait [namespace which -variable done]
-     }
-+    vwait result
-     set result
- } -cleanup {
-+    after cancel $tout
-     variable result {}
--    unset -nocomplain result
-+    unset -nocomplain result tout
-     interp delete child
- } -result foo
- 
meta/recipes-devtools/tcltk/tcl/run-ptest +20 -4
index 506529eada..dc61d66cc1 100644
@@ -1,13 +1,19 @@
 #!/bin/sh
 
-export TCL_LIBRARY=@libdir@/tcl/ptest/library
-export ERROR_ON_FAILURES=1
+set -u
+
 export LANG=en-US.UTF-8
 
+# Tell all.tcl to exit with an error code if there are failing tests
+export ERROR_ON_FAILURES=1
+
 # Some tests are overly strict with timings and fail on loaded systems.
 SKIP=""
 # 15321
 SKIP="$SKIP async-\* event-\*"
+# This test behaves differently when using a system tzdata, skip until fixed upstream
+# https://core.tcl-lang.org/tcl/tktview/51aa53616067cb63900b17ca1d71f07b094ffa1a
+SKIP="$SKIP clock-59.2\*"
 # 14882
 SKIP="$SKIP cmdMZ-6.6"
 # 15081
@@ -16,6 +22,8 @@ SKIP="$SKIP exit-1.\*"
 SKIP="$SKIP \*io-46.1"
 # io-13.6 explicitly says it can fail on slow/loaded machines
 SKIP="$SKIP \*io-13.6"
+# Has race conditions and is missing cleanup
+SKIP="$SKIP interp-36.7"
 # The socket tests seem to be problematic with tight timing conditions, skip them all.
 # 14825 15495
 SKIP="$SKIP socket-\* socket_inet\* socket_inet6\*"
@@ -25,11 +33,19 @@ SKIP="$SKIP http11-\*"
 # tries to access google.com
 SKIP="$SKIP httpProxy-\*"
 
-for name in tests/*.test; do
-    ./tcltest $name -skip "$SKIP"
+# Run all tests in tests/*.test unless tests are specified as arguments
+TESTS=${*:-tests/*.test}
+
+exitcode=0
+for name in $TESTS; do
+    ./tcltest tests/all.tcl -file $(basename $name) -tmpdir /tmp -skip "$SKIP"
     if [ $? -eq 0 ]; then
         echo "PASS: $name"
     else
         echo "FAIL: $name"
+        exitcode=1
     fi
+    echo
 done
+
+exit $exitcode
meta/recipes-devtools/tcltk/tcl_9.0.3.bb +1 -5
index 21a6cbb23d..3c0a257238 100644
@@ -21,7 +21,6 @@ SRC_URI = "${SOURCEFORGE_MIRROR}/tcl/tcl-core${PV}-src.tar.gz \
            file://0002-tcl-fix-a-build-issue.patch \
            file://0003-tcl-install-tcl-to-lib64-instead-of-lib-on-64bit-tar.patch \
            file://0004-tcl-update-the-header-location.patch \
-           file://0005-tcl-fix-race-in-interp.test.patch \
            "
 SRC_URI[sha256sum] = "407a073ee8f718200c3a004bc2186deccc33356ee5112a71d8b01b55230f4ee4"
 
@@ -80,15 +79,12 @@ do_compile_ptest() {
 
 do_install_ptest() {
 	cp ${B}/tcltest ${D}${PTEST_PATH}
-	cp -r ${S}/library ${D}${PTEST_PATH}
 	cp -r ${S}/tests ${D}${PTEST_PATH}
-        # handle multilib
-        sed -i s:@libdir@:${libdir}:g ${D}${PTEST_PATH}/run-ptest
 }
 
 do_install_ptest:append:libc-musl () {
 	# Assumes locales other than provided by musl-locales
-	sed -i '/SKIP="$SKIP socket.*$/a # unixInit-3* is suppressed due to hardcoded locale assumptions\nSKIP="$SKIP unixInit-3\\\*"' ${D}${PTEST_PATH}/run-ptest
+	sed -i '/SKIP="$SKIP.*$/a # unixInit-3* is suppressed due to hardcoded locale assumptions\nSKIP="$SKIP unixInit-3\\\*"' ${D}${PTEST_PATH}/run-ptest
 }
 
 # Fix some paths that might be used by Tcl extensions
Signature · 1 line
2.43.0
#1 lore raw

PATCH 2/2 tcl8: rewrite ptest (again)

Backport the previous commit's changes for tcl9 to the tc8 recipe:

I discovered that running a single test case with tcltest doesn't let you know if the test failed or not, so when run-ptest moved away from using all.tcl[1] we were always marking the tests as passing.

So, revert that commit and use all.tcl as a test runner. This is more noisy, but importantly will let us know if a test failed.

Remove our un-upstreamable tweaks to the interp tests and instead skip the test that is known to be fragile, so we don't have to carry a patch forever.

Don't install another copy of the entire Tcl library for the tests, as there is no real point. This does then expose a bug in the tests where clock-59.2 assumes that it is running in a source tree and behaves differently if the system tzdata is being used. This is being worked on upstream[2], for now skip this test.

Clean up musl overriding so it's more resiliant.

Exit 1 if a test fails.

[1] oe-core 9c41887f2a ("tcl: improve test execution loop")
[2] https://core.tcl-lang.org/tcl/tktview/51aa53616067cb63900b17ca1d71f07b094ffa1a

---
 .../recipes-devtools/tcltk8/tcl8/interp.patch | 40 -------------------
 meta/recipes-devtools/tcltk8/tcl8/run-ptest   | 32 ++++++++++-----
 meta/recipes-devtools/tcltk8/tcl8_8.6.17.bb   |  5 +--
 3 files changed, 23 insertions(+), 54 deletions(-)
 delete mode 100644 meta/recipes-devtools/tcltk8/tcl8/interp.patch
meta/recipes-devtools/tcltk8/tcl8/interp.patch deleted +0 -40
deleted file mode 100644
index c6412e7775..0000000000
@@ -1,40 +0,0 @@
-From 2d959d1fdfbd7e020f5177b1a7ff6a08809536ca Mon Sep 17 00:00:00 2001
-From: Ross Burton <[email protected]>
-Date: Mon, 12 Jul 2021 14:50:13 +0100
-Subject: [PATCH] tcl: fix race in interp.test
-
-The interp-36.7 patch has race conditions and is missing cleanup.  This patch by
-a Tcl maintainer should improve matters.
-
-Upstream-Status: Inappropriate [tcl 8.x is obsolete; upstream submission should be for 9.x patches]
-Signed-off-by: Ross Burton <[email protected]>
----
- tests/interp.test | 7 ++++---
- 1 file changed, 4 insertions(+), 3 deletions(-)
-
-diff --git a/tests/interp.test b/tests/interp.test
-index d64fdd4..9931dd1 100644
---- a/tests/interp.test
-+++ b/tests/interp.test
-@@ -3651,17 +3651,18 @@ test interp-36.7 {ChildBgerror sets error handler of child [1999035]} -setup {
-         variable result
-         set result [lindex $args 0]
-     }
-+    set tout [after 5000 {set result timeout}]
- } -body {
-     child eval {
-         variable done {}
-         after 0 error foo
--        after 10 [list ::set [namespace which -variable done] {}]
--        vwait [namespace which -variable done]
-     }
-+    vwait result
-     set result
- } -cleanup {
-+    after cancel $tout
-     variable result {}
--    unset -nocomplain result
-+    unset -nocomplain result tout
-     interp delete child
- } -result foo
- 
meta/recipes-devtools/tcltk8/tcl8/run-ptest +22 -10
index 0422e28a9d..dc61d66cc1 100644
@@ -1,16 +1,19 @@
 #!/bin/sh
 
-# clock.test needs a timezone to be set
-export TZ="Europe/London"
-export TCL_LIBRARY=@libdir@/tcl8/ptest/library
+set -u
+
+export LANG=en-US.UTF-8
+
+# Tell all.tcl to exit with an error code if there are failing tests
 export ERROR_ON_FAILURES=1
-export LC_ALL=en_US.UTF-8
-export LANG=en_US.UTF-8
 
 # Some tests are overly strict with timings and fail on loaded systems.
 SKIP=""
 # 15321
 SKIP="$SKIP async-\* event-\*"
+# This test behaves differently when using a system tzdata, skip until fixed upstream
+# https://core.tcl-lang.org/tcl/tktview/51aa53616067cb63900b17ca1d71f07b094ffa1a
+SKIP="$SKIP clock-59.2\*"
 # 14882
 SKIP="$SKIP cmdMZ-6.6"
 # 15081
@@ -19,6 +22,8 @@ SKIP="$SKIP exit-1.\*"
 SKIP="$SKIP \*io-46.1"
 # io-13.6 explicitly says it can fail on slow/loaded machines
 SKIP="$SKIP \*io-13.6"
+# Has race conditions and is missing cleanup
+SKIP="$SKIP interp-36.7"
 # The socket tests seem to be problematic with tight timing conditions, skip them all.
 # 14825 15495
 SKIP="$SKIP socket-\* socket_inet\* socket_inet6\*"
@@ -28,12 +33,19 @@ SKIP="$SKIP http11-\*"
 # tries to access google.com
 SKIP="$SKIP httpProxy-\*"
 
-for i in tests/*.test; do
-    i=$(basename $i)
-    ./tcltest tests/all.tcl -file $i -skip "$SKIP"
+# Run all tests in tests/*.test unless tests are specified as arguments
+TESTS=${*:-tests/*.test}
+
+exitcode=0
+for name in $TESTS; do
+    ./tcltest tests/all.tcl -file $(basename $name) -tmpdir /tmp -skip "$SKIP"
     if [ $? -eq 0 ]; then
-        echo "PASS: $i"
+        echo "PASS: $name"
     else
-        echo "FAIL: $i"
+        echo "FAIL: $name"
+        exitcode=1
     fi
+    echo
 done
+
+exit $exitcode
meta/recipes-devtools/tcltk8/tcl8_8.6.17.bb +1 -4
index b97b20abd5..0f829a9d1b 100644
@@ -21,7 +21,6 @@ SRC_URI = "${BASE_SRC_URI} \
            file://fix_non_native_build_issue.patch \
            file://tcl-remove-hardcoded-install-path.patch \
            file://alter-includedir.patch \
-           file://interp.patch \
            file://run-ptest \
            file://0001-generic-tcl.h-use-Tcl_WideInt-for-seconds-in-Tcl_Tim.patch \
            "
@@ -84,14 +83,12 @@ do_compile_ptest() {
 
 do_install_ptest() {
 	cp ${B}/tcltest ${D}${PTEST_PATH}
-	cp -r ${S}/library ${D}${PTEST_PATH}
 	cp -r ${S}/tests ${D}${PTEST_PATH}
-	sed -i s:@libdir@:${libdir}:g ${D}${PTEST_PATH}/run-ptest
 }
 
 do_install_ptest:append:libc-musl () {
 	# Assumes locales other than provided by musl-locales
-	sed -i '/SKIP="$SKIP socket.*$/a # unixInit-3* is suppressed due to hardcoded locale assumptions\nSKIP="$SKIP unixInit-3\\\*"' ${D}${PTEST_PATH}/run-ptest
+	sed -i '/SKIP="$SKIP.*$/a # unixInit-3* is suppressed due to hardcoded locale assumptions\nSKIP="$SKIP unixInit-3\\\*"' ${D}${PTEST_PATH}/run-ptest
 }
 
 # Fix some paths that might be used by Tcl extensions
Signature · 1 line
2.43.0
#2 lore raw
In reply to Ross Burton
Quoted 19 lines · Ross Burton via lists.openembedded.org

I discovered that running a single test case with tcltest doesn't let you know if the test failed or not, so when run-ptest moved away from using all.tcl[1] we were always marking the tests as passing.

So, revert that commit and use all.tcl as a test runner. This is more noisy, but importantly will let us know if a test failed.

Remove our un-upstreamable tweaks to the interp tests and instead skip the test that is known to be fragile, so we don't have to carry a patch forever.

Don't install another copy of the entire Tcl library for the tests, as there is no real point. This does then expose a bug in the tests where clock-59.2 assumes that it is running in a source tree and behaves differently if the system tzdata is being used. This is being worked on upstream[2], for now skip this test.

Clean up musl overriding so it's more resiliant.

Quoted 7 lines

Exit 1 if a test fails.

[1] oe-core 9c41887f2a ("tcl: improve test execution loop")
[2] https://core.tcl-lang.org/tcl/tktview/51aa53616067cb63900b17ca1d71f07b094ffa1a

---

Hi Ross,

So now, of course we have ptest failures :)

Both for tcl and tcl8:

Failed ptests:
{'tcl8': ['tests/unixFile.test']}
...
Failed ptests:
{'tcl': ['tests/cmdAH.test', 'tests/unixFile.test', 'tests/zipfs.test']}

https://autobuilder.yoctoproject.org/valkyrie/#/builders/61/builds/3180
https://autobuilder.yoctoproject.org/valkyrie/#/builders/73/builds/3209

Ptest logs are there:

https://valkyrie.yocto.io/pub/non-release/20260305-50/testresults/qemuarm64-ptest/core-image-ptest-tcl8/
https://valkyrie.yocto.io/pub/non-release/20260305-50/testresults/qemuarm64-ptest/core-image-ptest-tcl/

https://valkyrie.yocto.io/pub/non-release/20260305-50/testresults/qemux86-64-ptest/core-image-ptest-tcl8/
https://valkyrie.yocto.io/pub/non-release/20260305-50/testresults/qemux86-64-ptest/core-image-ptest-tcl/

Can you have a look at these?

Thanks,
Mathieu

Signature · 3 lines
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw
Quoted 7 lines · Mathieu Dubois-Briand

Both for tcl and tcl8:

Failed ptests:
{'tcl8': ['tests/unixFile.test']}
...
Failed ptests:
{'tcl': ['tests/cmdAH.test', 'tests/unixFile.test', 'tests/zipfs.test’]}

<splutter>

I’ve ran the ptests so many times in the last few days…

Ross