| 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) 2022 Thomas Weißschuh <[email protected]> |
| 4 | # |
| 5 | # This file is part of util-linux. |
| 6 | # |
| 7 | # This file is free software; you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by |
| 9 | # the Free Software Foundation; either version 2 of the License, or |
| 10 | # (at your option) any later version. |
| 11 | # |
| 12 | # This file is distributed in the hope that it will be useful, |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | # GNU General Public License for more details. |
| 16 | # |
| 17 | TS_TOPDIR="${0%/*}/../.." |
| 18 | TS_DESC="procfs library" |
| 19 | |
| 20 | . "$TS_TOPDIR"/functions.sh |
| 21 | ts_init "$*" |
| 22 | |
| 23 | ts_check_test_command "$TS_HELPER_PROCFS" |
| 24 | |
| 25 | test_data="$TS_SELF/procfs-data" |
| 26 | test_cmd() { |
| 27 | "$TS_HELPER_PROCFS" --prefix "$test_data" "$@" \ |
| 28 | 2>> "$TS_ERRLOG" \ |
| 29 | | sed -e 's/ UID: .*/ UID: [redacted]/' \ |
| 30 | >> "$TS_OUTPUT" |
| 31 | } |
| 32 | |
| 33 | ts_init_subtest "one-process" |
| 34 | |
| 35 | test_cmd --one 1 |
| 36 | test_cmd --one 2 |
| 37 | test_cmd --one 3 |
| 38 | |
| 39 | ts_finalize_subtest |
| 40 | |
| 41 | |
| 42 | ts_init_subtest "stat-nth" |
| 43 | |
| 44 | test_cmd --stat-nth 1 1 |
| 45 | test_cmd --stat-nth 1 2 |
| 46 | test_cmd --stat-nth 1 3 |
| 47 | test_cmd --stat-nth 1 4 |
| 48 | |
| 49 | test_cmd --stat-nth 2 1 |
| 50 | test_cmd --stat-nth 2 4 |
| 51 | |
| 52 | test_cmd --stat-nth 3 1 |
| 53 | test_cmd --stat-nth 3 4 |
| 54 | |
| 55 | ts_finalize_subtest |
| 56 | |
| 57 | ts_finalize |