1#!/bin/bash
2
3function SourceModule() {
4    # shellcheck source=tools/fan_rpm_loop_test.sh
5    . fan_rpm_loop_test.sh
6}
7
8function 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 $*"; }
14}
15
16function 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
21}
22
23function 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
32}
33
34function TestMainWorks() {
35    main 1000 5005 || return
36}
37
38function main() {
39    SourceModule                || return
40    SetupShims                  || return
41    TestRunRpmStepsWorks        || return
42    TestMainRejectsLowMinAndMax || return
43    TestMainWorks               || return
44    echo "All tests completed."
45}
46
47if [ "$0" = "${BASH_SOURCE[0]}" ]; then
48    # not sourced, execute main function
49    main "$@"
50fi
51
52