1ca97c83dSPatrick Venture#!/bin/bash 2ca97c83dSPatrick Venture 35897fcc1SPatrick Williamsfunction SourceModule() { 4e39bbe9fSPatrick Williams # shellcheck source=tools/fan_rpm_loop_test.sh 5ca97c83dSPatrick Venture . fan_rpm_loop_test.sh 6ca97c83dSPatrick Venture} 7ca97c83dSPatrick Venture 85897fcc1SPatrick Williamsfunction SetupShims() { 95897fcc1SPatrick Williams function MkDir() { echo "MkDir $*"; } 105897fcc1SPatrick Williams function Mv() { echo "Mv $*"; } 115897fcc1SPatrick Williams function Sleep() { echo "Sleep $*"; } 125897fcc1SPatrick Williams function SystemCtl() { echo "SystemCtl $*"; } 135897fcc1SPatrick Williams function CommandRpm() { echo "CommandRpm $*"; } 14ca97c83dSPatrick Venture} 15ca97c83dSPatrick Venture 165897fcc1SPatrick Williamsfunction TestRunRpmStepsWorks() { 17ca97c83dSPatrick Venture RunRpmSteps 1000 5000 3 30 || return 18ca97c83dSPatrick Venture RunRpmSteps 5000 1000 3 30 || return 19ca97c83dSPatrick Venture RunRpmSteps 1000 5000 1 30 || return 20ca97c83dSPatrick Venture RunRpmSteps 5000 1000 1 30 || return 21ca97c83dSPatrick Venture} 22ca97c83dSPatrick Venture 235897fcc1SPatrick Williamsfunction TestMainRejectsLowMinAndMax() { 24ca97c83dSPatrick Venture if main 0 0; then 25ca97c83dSPatrick Venture echo "main 0 0 not rejected?" 26ca97c83dSPatrick Venture return 1 27ca97c83dSPatrick Venture fi 28ca97c83dSPatrick Venture if main 1 0; then 29ca97c83dSPatrick Venture echo "main 1 0 not rejected?" 30ca97c83dSPatrick Venture return 1 31ca97c83dSPatrick Venture fi 32ca97c83dSPatrick Venture} 33ca97c83dSPatrick Venture 345897fcc1SPatrick Williamsfunction TestMainWorks() { 35ca97c83dSPatrick Venture main 1000 5005 || return 36ca97c83dSPatrick Venture} 37ca97c83dSPatrick Venture 385897fcc1SPatrick Williamsfunction main() { 39ca97c83dSPatrick Venture SourceModule || return 40ca97c83dSPatrick Venture SetupShims || return 41ca97c83dSPatrick Venture TestRunRpmStepsWorks || return 42ca97c83dSPatrick Venture TestMainRejectsLowMinAndMax || return 43ca97c83dSPatrick Venture TestMainWorks || return 44ca97c83dSPatrick Venture echo "All tests completed." 45ca97c83dSPatrick Venture} 46ca97c83dSPatrick Venture 47*687d8413SJinliang Wangif [ "$0" = "${BASH_SOURCE[0]}" ]; then 48*687d8413SJinliang Wang # not sourced, execute main function 49ca97c83dSPatrick Venture main "$@" 50*687d8413SJinliang Wangfi 51ca97c83dSPatrick Venture 52