static void test_rc_conf_script_not_found(void) { puts("test_rc_conf_conf_not_found"); test_regex_reset(); assert(rtems_bsd_run_rc_conf_script("internal", rc_conf_not_found, 0, true) < 0); assert(test_regex_last_num == 0); }
static void test_rc_conf_script(void) { puts("test_rc_conf_conf"); test_regex_reset(); assert(rtems_bsd_run_rc_conf_script("internal", rc_conf_regex, 0, true) == 0); test_regex_check(); }
int rtems_bsd_run_rc_conf(const char* name, int timeout, bool verbose) { struct stat sb; int r; char* rc_conf; FILE* file; r = stat(name, &sb); if (r < 0) return r; rc_conf = malloc(sb.st_size); if (rc_conf == NULL) { errno = ENOMEM; return -1; } if (verbose) printf("rc.conf: loading: %s\n", name); file = fopen(name, "r"); if (file == NULL) { free(rc_conf); return -1; } if (fread(rc_conf, 1, sb.st_size, file) != sb.st_size) { fclose(file); free(rc_conf); return -1; } fclose(file); r = rtems_bsd_run_rc_conf_script(name, rc_conf, timeout, verbose); free(rc_conf); return r; }