[Toybox] [PATCH] taskset: Test with ps -o psr=
Jesse Rosenstock
jmr at google.com
Sun Sep 28 10:57:10 PDT 2025
A comment indicates that `ps -o cpu` was desired. `-o psr` is the same
(except actually implemented). This seems clearer than reading from the
39th field of /proc/self/stat.
---
tests/taskset.test | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/tests/taskset.test b/tests/taskset.test
index 5732e23f0e..bd92922f24 100755
--- a/tests/taskset.test
+++ b/tests/taskset.test
@@ -22,12 +22,13 @@
testing 'set mask to last' \
'(taskset $LAST taskset -p 0 | sed "s/.*: //")' "$LAST\n" '' ''
-# alas procps-ng always says "-" for -o cpu so fetch the field from /proc
+# alas procps-ng only added support for -o cpu in fb33dfb6e5eb (2025-07)
+# so use -o psr. This commit is *not* in v4.0.6, but should be in the
+# following release.
testing 'run on first' \
- 'X=$(taskset 1 cat /proc/self/stat); x() { echo ${39};}; x $X' \
- '0\n' '' ''
+ 'taskset 1 bash -c "ps -o psr= \$\$" | sed "s/^ *//"' '0\n' '' ''
testing 'run on last' \
- 'X=$(taskset $LAST cat /proc/self/stat); x() { echo ${39};}; x $X' \
+ 'taskset $LAST bash -c "ps -o psr= \$\$" | sed "s/^ *//"' \
"$((CPUS-1))\n" '' ''
testing "long mask doesn't segfault" \
-------------- next part --------------
A non-text attachment was scrubbed...
Name: taskset-test-ps-psr.patch
Type: text/x-patch
Size: 906 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20250928/3d4a7a84/attachment.bin>
More information about the Toybox
mailing list