1 #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
main(int argc,char ** argv)13 int main(int argc, char **argv)
14 {
15 struct settings settings;
16 struct job_list job_list;
17 struct execute_state state;
18 int exitcode = 0;
19 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)) {
39 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;
48 }
49
50 if (!generate_results_path(settings.results_path)) {
51 exitcode = 1;
52 }
53
54 printf("Done.\n");
55 return exitcode;
56 }
57