From dae879f222ad9bb082f6b064370e9bb47827ba47 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sun, 13 Mar 2016 10:01:46 +0100 Subject: [PATCH] add check, if the cores are successfully booted --- hermit/tools/proxy.c | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/hermit/tools/proxy.c b/hermit/tools/proxy.c index 04ee594ad..d765f6a41 100644 --- a/hermit/tools/proxy.c +++ b/hermit/tools/proxy.c @@ -70,6 +70,7 @@ static int init_env(void) char* str; FILE* file; char isle_path[MAX_PATH]; + char* result; str = getenv("HERMIT_ISLE"); if (str) @@ -128,13 +129,49 @@ static int init_env(void) str = getenv("HERMIT_CPUS"); if (str) - fprintf(file, "%s", str); + ret = fprintf(file, "%s", str); else - fprintf(file, "%s", "1"); + ret = fprintf(file, "%s", "1"); fclose(file); - //sleep(3); + // check result + file = fopen(isle_path, "r"); + if (!file) { + perror("fopen"); + exit(1); + } + + if (str) + result = (char*) malloc(strlen(str)+128); + else + result = (char*) malloc(128); + + if (!result) + { + perror("malloc"); + exit(1); + } + + fscanf(file, "%s", result); + + fclose(file); + + if (str) { + if (strcmp(result, str) != 0) { + free(result); + fprintf(stderr, "Unable to boot cores %s\n", str); + exit(1); + } + } else { + if (strcmp(result, "1") != 0) { + free(result); + fprintf(stderr, "Unable to boot core 1"); + exit(1); + } + } + + free(result); return 0; }