Update unit tests for fan speed auto-detection
Fixes #164. References #114.
This commit is contained in:
parent
b0cdfd4c27
commit
1716d9d877
4 changed files with 16 additions and 7 deletions
8
mbpfan.conf.test0
Normal file
8
mbpfan.conf.test0
Normal file
|
@ -0,0 +1,8 @@
|
|||
[general]
|
||||
# see https://ineed.coffee/3838/a-beginners-tutorial-for-mbpfan-under-ubuntu for the values
|
||||
min_fan_speed = 2000 # put the *lowest* value of "cat /sys/devices/platform/applesmc.768/fan*_min"
|
||||
max_fan_speed = 6200 # put the *highest* value of "cat /sys/devices/platform/applesmc.768/fan*_max"
|
||||
low_temp = 63 # try ranges 55-63, default is 63
|
||||
high_temp = 66 # try ranges 58-66, default is 66
|
||||
max_temp = 86 # take highest number returned by "cat /sys/devices/platform/coretemp.*/hwmon/hwmon*/temp*_max", divide by 1000
|
||||
polling_interval = 7 # default is 7 seconds
|
|
@ -110,7 +110,7 @@ static int read_value(const char *path)
|
|||
}
|
||||
|
||||
|
||||
static void set_defaults(void)
|
||||
void set_defaults(void)
|
||||
{
|
||||
int i;
|
||||
char *path;
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
void check_requirements();
|
||||
void set_defaults();
|
||||
|
|
|
@ -117,8 +117,6 @@ static const char *test_config_file()
|
|||
return 0;
|
||||
}
|
||||
|
||||
mu_assert("Could not read min_fan_speed from config file",settings_get_int(settings, "general", "min_fan_speed") != 0);
|
||||
mu_assert("Could not read max_fan_speed from config file",settings_get_int(settings, "general", "max_fan_speed") != 0);
|
||||
mu_assert("Could not read low_temp from config file",settings_get_int(settings, "general", "low_temp") != 0);
|
||||
mu_assert("Could not read high_temp from config file",settings_get_int(settings, "general", "high_temp") != 0);
|
||||
mu_assert("Could not read max_temp from config file",settings_get_int(settings, "general", "max_temp") != 0);
|
||||
|
@ -131,10 +129,12 @@ static const char *test_config_file()
|
|||
|
||||
static const char *test_settings()
|
||||
{
|
||||
set_defaults();
|
||||
retrieve_settings("./mbpfan.conf.test1");
|
||||
mu_assert("max_fan_speed value is not 6200", max_fan_speed == 6200);
|
||||
mu_assert("polling_interval is not 1", polling_interval == 1);
|
||||
retrieve_settings("./mbpfan.conf");
|
||||
set_defaults();
|
||||
retrieve_settings("./mbpfan.conf.test0");
|
||||
mu_assert("min_fan_speed value is not 2000", min_fan_speed == 2000);
|
||||
mu_assert("polling_interval is not 7", polling_interval == 7);
|
||||
return 0;
|
||||
|
@ -170,11 +170,11 @@ static const char *test_settings_reload()
|
|||
signal(SIGHUP, handler);
|
||||
retrieve_settings("./mbpfan.conf");
|
||||
printf("Testing the _supplied_ mbpfan.conf (not the one you are using)..\n");
|
||||
mu_assert("min_fan_speed value is not 2000 before SIGHUP", min_fan_speed == 2000);
|
||||
mu_assert("polling_interval is not 7 before SIHUP", polling_interval == 7);
|
||||
// cannot tests min_fan_speed since it is not set and thus auto-detected
|
||||
mu_assert("polling_interval is not 7 before SIGHUP", polling_interval == 7);
|
||||
raise(SIGHUP);
|
||||
mu_assert("min_fan_speed value is not 6200 after SIGHUP", min_fan_speed == 6200);
|
||||
mu_assert("polling_interval is not 1 after SIHUP", polling_interval == 1);
|
||||
mu_assert("polling_interval is not 1 after SIGHUP", polling_interval == 1);
|
||||
retrieve_settings("./mbpfan.conf");
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue