blob: d5a20e8082b4b0db3e467b2128a02560e5c3d660 [file] [log] [blame]
Petri Latvala18c1e752018-08-08 14:07:00 +03001#include <errno.h>
2#include <fcntl.h>
3#include <stdio.h>
4#include <string.h>
5#include <sys/stat.h>
6#include <sys/types.h>
7
8#include "settings.h"
9#include "job_list.h"
10#include "executor.h"
11#include "resultgen.h"
12
13int main(int argc, char **argv)
14{
15 struct settings settings;
16 struct job_list job_list;
17 struct execute_state state;
Petri Latvala368e7612019-02-18 15:10:14 +020018 int exitcode = 0;
Petri Latvala18c1e752018-08-08 14:07:00 +030019 int dirfd;
20
21 init_settings(&settings);
22 init_job_list(&job_list);
23
24 if (argc < 2) {
25 fprintf(stderr, "Usage: %s results-directory\n", argv[0]);
26 return 1;
27 }
28
29 if ((dirfd = open(argv[1], O_RDONLY | O_DIRECTORY)) < 0) {
30 fprintf(stderr, "Failure opening %s: %s\n", argv[1], strerror(errno));
31 return 1;
32 }
33
34 if (!initialize_execute_state_from_resume(dirfd, &state, &settings, &job_list)) {
35 return 1;
36 }
37
38 if (!execute(&state, &settings, &job_list)) {
Petri Latvala368e7612019-02-18 15:10:14 +020039 exitcode = 1;
40 }
41
42 if (state.time_left == 0.0) {
43 /*
44 * Overall timeout happened. Results generation can
45 * override this
46 */
47 exitcode = 2;
Petri Latvala18c1e752018-08-08 14:07:00 +030048 }
49
50 if (!generate_results_path(settings.results_path)) {
Petri Latvala368e7612019-02-18 15:10:14 +020051 exitcode = 1;
Petri Latvala18c1e752018-08-08 14:07:00 +030052 }
53
54 printf("Done.\n");
Petri Latvala368e7612019-02-18 15:10:14 +020055 return exitcode;
Petri Latvala18c1e752018-08-08 14:07:00 +030056}