diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 17:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 17:47:29 +0000 |
commit | 4f5791ebd03eaec1c7da0865a383175b05102712 (patch) | |
tree | 8ce7b00f7a76baa386372422adebbe64510812d4 /ctdb/tests/UNIT/eventscripts/stubs/ps | |
parent | Initial commit. (diff) | |
download | samba-upstream.tar.xz samba-upstream.zip |
Adding upstream version 2:4.17.12+dfsg.upstream/2%4.17.12+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ctdb/tests/UNIT/eventscripts/stubs/ps')
-rwxr-xr-x | ctdb/tests/UNIT/eventscripts/stubs/ps | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/ctdb/tests/UNIT/eventscripts/stubs/ps b/ctdb/tests/UNIT/eventscripts/stubs/ps new file mode 100755 index 0000000..744ba3b --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/stubs/ps @@ -0,0 +1,48 @@ +#!/bin/sh + +usage () +{ + echo "ps [ -p PID | -o FORMAT | aufxww ]" + exit 1 +} + +while getopts "o:p:h:?" opt ; do + case "$opt" in + o) format="$OPTARG" ;; + p) pid="$OPTARG" ;; + \?|h) usage ;; + esac +done +shift $((OPTIND - 1)) + +if [ -n "$pid" ] && [ -n "$FAKE_PS_MAP" ] ; then + # shellcheck disable=SC1001 + case "$format" in + comm\=) + echo "$FAKE_PS_MAP" | + awk -v pid="$pid" '$1 == pid { print $2 }' + ;; + state\=) + echo "$FAKE_PS_MAP" | + awk -v pid="$pid" '$1 == pid { print $3 }' + ;; + esac + + exit +fi + +if [ "$1" != "auxfww" ] ; then + echo "option $1 not supported" + usage +fi + +cat <<EOF +USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND +root 2 0.0 0.0 0 0 ? S Aug28 0:00 [kthreadd] +root 3 0.0 0.0 0 0 ? S Aug28 0:43 \_ [ksoftirqd/0] +... +root 1 0.0 0.0 2976 624 ? Ss Aug28 0:07 init [2] +root 495 0.0 0.0 3888 1640 ? Ss Aug28 0:00 udevd --daemon +... +[MORE FAKE ps OUTPUT] +EOF |