summaryrefslogtreecommitdiffstats
path: root/tools/fan_rpm_loop_unittest.sh
blob: 2700de1cea61b6f0aeca53e94455364ada5c8a5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash

SourceModule() {
  . fan_rpm_loop_test.sh
}

SetupShims() {
  MkDir()      { echo "MkDir      $*"; }
  Mv()         { echo "Mv         $*"; }
  Sleep()      { echo "Sleep      $*"; }
  SystemCtl()  { echo "SystemCtl  $*"; }
  CommandRpm() { echo "CommandRpm $*"; }
}

TestRunRpmStepsWorks() {
  RunRpmSteps 1000 5000 3 30 || return
  RunRpmSteps 5000 1000 3 30 || return
  RunRpmSteps 1000 5000 1 30 || return
  RunRpmSteps 5000 1000 1 30 || return
}

TestMainRejectsLowMinAndMax() {
  if main 0 0; then
    echo "main 0 0 not rejected?"
    return 1
  fi
  if main 1 0; then
    echo "main 1 0 not rejected?"
    return 1
  fi
}

TestMainWorks() {
  main 1000 5005 || return
}

main() {
  SourceModule                || return
  SetupShims                  || return
  TestRunRpmStepsWorks        || return
  TestMainRejectsLowMinAndMax || return
  TestMainWorks               || return
  echo "All tests completed."
}

return 0 2>/dev/null
main "$@"

OpenPOWER on IntegriCloud