add fan_rpm_loop script
The script allows running different rpm set-points and verifying whether
the coefficients behave as intended.
Change-Id: I7bc2e5328299ee14349550edb119279c143f4a1b
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/tools/fan_rpm_loop_unittest.sh b/tools/fan_rpm_loop_unittest.sh
new file mode 100755
index 0000000..2700de1
--- /dev/null
+++ b/tools/fan_rpm_loop_unittest.sh
@@ -0,0 +1,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 "$@"
+