} else {
secondary_config_path = format("%s/ccache.conf", TO_STRING(SYSCONFDIR));
if (!conf_read(conf, secondary_config_path, &errmsg)) {
- if (access(secondary_config_path, R_OK) == 0) {
+ if (errno == 0) {
// We could read the file but it contained errors.
fatal("%s", errmsg);
}
bool should_create_initial_config = false;
if (!conf_read(conf, primary_config_path, &errmsg)) {
- if (access(primary_config_path, R_OK) == 0) {
+ if (errno == 0) {
// We could read the file but it contained errors.
fatal("%s", errmsg);
}
char *errmsg;
create_file("ccache.conf", "no equal sign");
CHECK(!conf_read(conf, "ccache.conf", &errmsg));
+ CHECK_INT_EQ(errno, 0);
CHECK_STR_EQ_FREE2("ccache.conf:1: missing equal sign",
errmsg);
conf_free(conf);
char *errmsg;
create_file("ccache.conf", "# Comment\nfoo = bar");
CHECK(!conf_read(conf, "ccache.conf", &errmsg));
+ CHECK_INT_EQ(errno, 0);
CHECK_STR_EQ_FREE2("ccache.conf:2: unknown configuration option \"foo\"",
errmsg);
conf_free(conf);
create_file("ccache.conf", "disable=");
CHECK(!conf_read(conf, "ccache.conf", &errmsg));
+ CHECK_INT_EQ(errno, 0);
CHECK_STR_EQ_FREE2("ccache.conf:1: not a boolean value: \"\"",
errmsg);
create_file("ccache.conf", "disable=foo");
CHECK(!conf_read(conf, "ccache.conf", &errmsg));
+ CHECK_INT_EQ(errno, 0);
CHECK_STR_EQ_FREE2("ccache.conf:1: not a boolean value: \"foo\"",
errmsg);
conf_free(conf);
char *errmsg;
create_file("ccache.conf", "base_dir = ${foo");
CHECK(!conf_read(conf, "ccache.conf", &errmsg));
+ CHECK_INT_EQ(errno, 0);
CHECK_STR_EQ_FREE2("ccache.conf:1: syntax error: missing '}' after \"foo\"",
errmsg);
// Other cases tested in test_util.c.
char *errmsg;
create_file("ccache.conf", "max_size = foo");
CHECK(!conf_read(conf, "ccache.conf", &errmsg));
+ CHECK_INT_EQ(errno, 0);
CHECK_STR_EQ_FREE2("ccache.conf:1: invalid size: \"foo\"",
errmsg);
// Other cases tested in test_util.c.
char *errmsg;
create_file("ccache.conf", "sloppiness = file_macro, foo");
CHECK(!conf_read(conf, "ccache.conf", &errmsg));
+ CHECK_INT_EQ(errno, 0);
CHECK_STR_EQ_FREE2("ccache.conf:1: unknown sloppiness: \"foo\"",
errmsg);
conf_free(conf);
create_file("ccache.conf", "max_files =");
CHECK(!conf_read(conf, "ccache.conf", &errmsg));
+ CHECK_INT_EQ(errno, 0);
CHECK_STR_EQ_FREE2("ccache.conf:1: invalid unsigned integer: \"\"",
errmsg);
conf_free(conf);
}
+TEST(conf_read_missing_config_file)
+{
+ struct conf *conf = conf_create();
+ char *errmsg;
+ CHECK(!conf_read(conf, "ccache.conf", &errmsg));
+ CHECK_INT_EQ(errno, ENOENT);
+}
+
TEST(verify_absolute_base_dir)
{
struct conf *conf = conf_create();