Patrick Venture | ca97c83 | 2018-07-25 08:48:49 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Patrick Williams | 5897fcc | 2022-12-08 06:23:37 -0600 | [diff] [blame] | 3 | function SourceModule() { |
| 4 | # shellcheck source=tools/fan_rpm_loop_test.sh |
| 5 | . fan_rpm_loop_test.sh |
Patrick Venture | ca97c83 | 2018-07-25 08:48:49 -0700 | [diff] [blame] | 6 | } |
| 7 | |
Patrick Williams | 5897fcc | 2022-12-08 06:23:37 -0600 | [diff] [blame] | 8 | function SetupShims() { |
| 9 | function MkDir() { echo "MkDir $*"; } |
| 10 | function Mv() { echo "Mv $*"; } |
| 11 | function Sleep() { echo "Sleep $*"; } |
| 12 | function SystemCtl() { echo "SystemCtl $*"; } |
| 13 | function CommandRpm() { echo "CommandRpm $*"; } |
Patrick Venture | ca97c83 | 2018-07-25 08:48:49 -0700 | [diff] [blame] | 14 | } |
| 15 | |
Patrick Williams | 5897fcc | 2022-12-08 06:23:37 -0600 | [diff] [blame] | 16 | function TestRunRpmStepsWorks() { |
| 17 | RunRpmSteps 1000 5000 3 30 || return |
| 18 | RunRpmSteps 5000 1000 3 30 || return |
| 19 | RunRpmSteps 1000 5000 1 30 || return |
| 20 | RunRpmSteps 5000 1000 1 30 || return |
Patrick Venture | ca97c83 | 2018-07-25 08:48:49 -0700 | [diff] [blame] | 21 | } |
| 22 | |
Patrick Williams | 5897fcc | 2022-12-08 06:23:37 -0600 | [diff] [blame] | 23 | function TestMainRejectsLowMinAndMax() { |
| 24 | if main 0 0; then |
| 25 | echo "main 0 0 not rejected?" |
| 26 | return 1 |
| 27 | fi |
| 28 | if main 1 0; then |
| 29 | echo "main 1 0 not rejected?" |
| 30 | return 1 |
| 31 | fi |
Patrick Venture | ca97c83 | 2018-07-25 08:48:49 -0700 | [diff] [blame] | 32 | } |
| 33 | |
Patrick Williams | 5897fcc | 2022-12-08 06:23:37 -0600 | [diff] [blame] | 34 | function TestMainWorks() { |
| 35 | main 1000 5005 || return |
Patrick Venture | ca97c83 | 2018-07-25 08:48:49 -0700 | [diff] [blame] | 36 | } |
| 37 | |
Patrick Williams | 5897fcc | 2022-12-08 06:23:37 -0600 | [diff] [blame] | 38 | function main() { |
| 39 | SourceModule || return |
| 40 | SetupShims || return |
| 41 | TestRunRpmStepsWorks || return |
| 42 | TestMainRejectsLowMinAndMax || return |
| 43 | TestMainWorks || return |
| 44 | echo "All tests completed." |
Patrick Venture | ca97c83 | 2018-07-25 08:48:49 -0700 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | return 0 2>/dev/null |
| 48 | main "$@" |
| 49 | |