# stress-ng tab completion for bash. # # Copyright (C) 2020-2021 Canonical # Copyright (C) 2022-2026 Colin Ian King # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. _stress_ng() { local cur prev cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} COMREPLY=() case "$prev" in '--class') local classes=$($1 --class which 2>&1 | cut -d':' -f3) COMPREPLY=( $(compgen -W "$classes" -- $cur) ) compopt -o nosort return 0 ;; '--ionice-class') local classes=$($1 --ionice-class which 2>&1 | cut -d':' -f2) COMPREPLY=( $(compgen -W "$classes" -- $cur) ) return 0 ;; '--ionice-level') COMPREPLY=( $(compgen -W "0 1 2 3 4 5 6 7" -- $cur) ) return 0 ;; '--job' | '--logfile' | '--yam') COMPREPLY=( $(compgen -f -d $cur) ) return 0 ;; '--sched') local classes=$($1 --sched which 2>&1 | cut -d':' -f2) COMPREPLY=( $(compgen -W "$classes" -- $cur) ) return 0 ;; '--temp-path') COMPREPLY=( $(compgen -o plusdirs $cur) ) return 0 ;; '--exclude') local stressors=$($1 --stressors) COMPREPLY=( $(compgen -W "$stressors" $cur) ) return 0 ;; '--zlib-level') COMPREPLY=( $(compgen -W "0 1 2 3 4 5 6 7 8 9" -- $cur) ) return 0 ;; '--bad-ioctl-method' | \ '--besselmath-method' | \ '--bitops-method' | \ '--bsearch-method' | \ '--bubblesort-method' | \ '--cacheline-method' | \ '--chyperbolic-method' | \ '--cpu-method' | \ '--crypt-method' | \ '--ctrig-method' | \ '--cyclic-method' | \ '--dfp-method' | \ '--eigen-method' | \ '--exec-fork-method' | \ '--exec-method' | \ '--expmath-method' | \ '--fp-method' | \ '--fractal-method' | \ '--funccall-method' | \ '--funcret-method' | \ '--hash-method' | \ '--heapsort-method' | \ '--hsearch-method' | \ '--hyperbolic-method' | \ '--intmath-method' | \ '--ipsec-mb-method' | \ '--l1cache-method' | \ '--list-method' | \ '--logmath-method' | \ '--lsearch-method' | \ '--matrix-method' | \ '--matrix-3d-method' | \ '--memcpy-method' | \ '--memrate-method' | \ '--memthrash-method' | \ '--mergesort-method' | \ '--misaligned-method' | \ '--monte-carlo-method' | \ '--nanosleep-method' | \ '--opcode-method' | \ '--plugin-method' | \ '--powmath-method' | \ '--prefetch-method' | \ '--prime-method' | \ '--qsort-method' | \ '--race-sched-method' | \ '--radixsort-method' | \ '--rawdev-method' | \ '--rotate-method' | \ '--sparsematrix-method' | \ '--spinmem-method' | \ '--str-method' | \ '--strnum-method' | \ '--switch-method' | \ '--syscall-method' | \ '--touch-method' | \ '--tree-method' | \ '--trig-method' | \ '--varyload-method' | \ '--vecfp-method' | \ '--vecshuf-method' | \ '--vm-method' | \ '--vm-addr-method' | \ '--vnni-method' | \ '--wcs-method' | \ '--workload-method' | \ '--zlib-method') local methods=$($1 $prev which 2>&1 | cut -d':' -f2) COMPREPLY=( $(compgen -W "$methods" -- $cur) ) return 0 ;; '--dccp-domain' | \ '--epoll-domain' | \ '--sctp-domain' | \ '--sock-domain' | \ '--udp-domain' | \ '--udp-flood-domain') local domains=$($1 $prev which 2>&1 | cut -d':' -f3) COMPREPLY=( $(compgen -W "$domains" -- $cur) ) return 0 ;; '--cyclic-policy' | \ '--dccp-opts' | \ '--filename-opts' | \ '--hdd-opts' | \ '--sock-opts' | \ '--sock-type' | \ '--sock-protocol' | \ '--revio-opts' | \ '--touch-opts') local options=$($1 $prev which 2>&1 | cut -d':' -f2) COMPREPLY=( $(compgen -W "$options" -- $cur) ) return 0 ;; '--dentry-order') local options=$($1 $prev which 2>&1 | cut -d':' -f2) COMPREPLY=( $(compgen -W "$options" -- $cur) ) return 0 ;; '--stream-madvise' | '--vm-madvise') local options=$($1 $prev which 2>&1 | cut -d':' -f2) COMPREPLY=( $(compgen -W "$options" -- $cur) ) return 0 ;; esac case "$cur" in # # args without further options # '--abort' | \ '--acl-rand' | \ '--af-alg-dump' | \ '--affinity-pin' | \ '--affinity-rand' | \ '--aggressive' | \ '--autogroup' | \ '--bigheap-mlock' | \ '--brk-mlock' | \ '--brk-notouch' | \ '--buildinfo' | \ '--c-states' | \ '--cache-cldemote' | \ '--cache-clflushopt' | \ '--cache-clwb' | \ '--cache-enable-all' | \ '--cache-fence' | \ '--cache-flush' | \ '--cache-no-affinity' | \ '--cache-permute' | \ '--cache-prefetch' | \ '--cache-prefetchw' | \ '--cache-sfence' | \ '--cachehammer-numa' | \ '--cacheline-affinity' | \ '--compact-memory' | \ '--change-cpu' | \ '--config' | \ '--cpu-online-affinity,' | \ '--cpu-online-all' | \ '--daemon-wait' | \ '--dry-run' | \ '--eventfd-nonblock' | \ '--exec-no-pthread' | \ '--far-branch-flush' | \ '--far-branch-pageout' | \ '--fd-race-dev' | \ '--fd-race-proc' | \ '--fma-libc' | \ '--fork-pageout' | \ '--fork-unmap' | \ '--fork-vm' | \ '--forkheavy-mlock' | \ '--ftrace' | \ '--get-slow-sync' | \ '--hrtimers-adjust' | \ '--help' | \ '--ignite-cpu' | \ '--interrupts' | \ '--intmath-fast' | \ '--io-uring-rand' | \ '--itimer-rand' | \ '--keep-files' | \ '--keep-name' | \ '--klog-check' | \ '--ksm' | \ '--l1cache-mlock' | \ '--link-sync' | \ '--llc-affinity-clflush' | \ '--llc-affinity-mlock' | \ '--llc-affinity-numa' | \ '--lockbus-nosplit' | \ '--lockf-nonblock' | \ '--log-brief' | \ '--log-lockless' | \ '--madvise-hwpoison' | \ '--make-it-fail' | \ '--malloc-mlock' | \ '--malloc-touch' | \ '--malloc-trim' | \ '--malloc-zerofree' | \ '--matrix-yx' | \ '--matrix-3d-zyx' | \ '--maximize' | \ '--mcontend-numa' | \ '--memfd-madvise' | \ '--memfd-mlock' | \ '--memfd-numa' | \ '--memfd-zap-pte' | \ '--memhotplug-mmap' | \ '--memrate-discontiguous' | \ '--memrate-flush' | \ '--metrics' | \ '--metrics-brief' | \ '--mincore-random' | \ '--min-nanosleep-sched,' | \ '--minimize' | \ '--mmap-async' | \ '--mmap-file' | \ '--mmap-madvise' | \ '--mmap-mergeable' | \ '--mmap-mlock' | \ '--mmap-mprotect' | \ '--mmap-mmap2' | \ '--mmap-numa' | \ '--mmap-odirect' | \ '--mmap-osync' | \ '--mmap-slow-munmap' | \ '--mmap-stressful' | \ '--mmap-write-check' | \ '--mmapaddr-mlock' | \ '--mmapcow-free' | \ '--mmapcow-fork' | \ '--mmapcow-mlock' | \ '--mmapcow-numa' | \ '--mmapfiles-numa' | \ '--mmapfiles-populate' | \ '--mmapfiles-shared' | \ '--mmapfixed-mlock' | \ '--mmapfixed-numa' | \ '--mmaphuge-file' | \ '--mmaphuge-mlock' | \ '--mmaphuge-numa' | \ '--mmapmany-mlock' | \ '--mmapmany-numa' | \ '--mmaprandom-mappings' | \ '--mmaprandom-maxpages' | \ '--module-no-modver' | \ '--module-no-unload' | \ '--module-no-vermag' | \ '--monte-carlo-samples' | \ '--mremap-mlock' | \ '--mremap-numa' | \ '--mutex-affinity' | \ '--no-madvise' | \ '--no-oom-adjust' | \ '--no-rand-seed' | \ '--null-write' | \ '--numa-shuffle-addr' | \ '--numa-shuffle-node' | \ '--oomable' | \ '--oom-no-child' | \ '--oom-avoid' | \ '--open-fd' | \ '--page-in' | \ '--pagemove-mlock' | \ '--pagemove-numa' | \ '--pathological' | \ '--perf' | \ '--physpage-mtrr' | \ '--physmmap-read' | \ '--pipe-vmsplice' | \ '--pipeherd-yield' | \ '--prime-progress' | \ '--progress' | \ '--pseek-rand' | \ '--quiet' | \ '--ramfs-fill' | \ '--randlist-compact' | \ '--randprocname' | \ '--rapl' | \ '--rdrand-seed' | \ '--regs-bitflip' | \ '--remap-mlock' | \ '--resources-mlock' | \ '--ring-pipe-splice' | \ '--sched-reclaim' | \ '--schedpolicy-rand' | \ '--seek-punch' | \ '--sem-shared' | \ '--sem-sysv-setall' | \ '--settings' | \ '--shm-mlock' | \ '--shm-sysv-mlock' | \ '--skip-silent' | \ '--smart' | \ '--sn' | \ '--sock-nodelay' | \ '--sock-zerocopy' | \ '--sockfd-reuse' | \ '--sparsematrix-method' | \ '--spinmem-affinity' | \ '--spinmem-numa' | \ '--spinmem-yield' | \ '--stack-fill' | \ '--stack-mlock' | \ '--stack-pageout' | \ '--stack-unmap' | \ '--stderr' | \ '--stdout' | \ '--stream-discontiguous' | \ '--stream-mlock' | \ '--stream-prefetch' | \ '--stressors' | \ '--stressor-time' | \ '--stream-mlock' | \ '--swap-self' | \ '--symlink-sync' | \ '--sync-start' | \ '--syslog' | \ '--taskset-random' | \ '--timer-rand' | \ '--timerfd-rand' | \ '--tmpfs-mmap-async' | \ '--tmpfs-mmap-file' | \ '--tsc-lfence' | \ '--tsc-rdtscp' | \ '--thrash' | \ '--times' | \ '--timestamp' | \ '--tz' | \ '--tun-tap' | \ '--udp-gro' | \ '--udp-lite' | \ '--utime-fsync' | \ '--verbose' | \ '--verify' | \ '--verifiable' | \ '--version' | \ '--vforkmany-vm' | \ '--vm-discontiguous' | \ '--vm-flush' | \ '--vm-keep' | \ '--vm-locked' | \ '--vm-populate' | \ '--vm-addr-mlock' | \ '--vm-addr-numa' | \ '--vnni-intrinsic' | \ '--zero-read' | \ '--zombie-clone') return 0 ;; -*) local options=$( _parse_help "$1" --help ) COMPREPLY=( $( compgen -W "${all_tests} ${options}" -- "$cur" ) ) return 0; ;; esac return 0 } # load the completion complete -F _stress_ng stress-ng