Commit 88539e4431cd6a596da316f81b644c4df606dbd9
Committed by
Simon Glass
1 parent
d908898333
Exists in
v2017.01-smarct4x
and in
37 other branches
sandbox: Return '-c command' exit value as sandbox exit code
When a command is passed into sandbox using the '-c' argument the command is run directly. This is most helpful when running tests (such as test-dm.sh). Previously the exit code was an unused enum. Change it to be the actual return code from the command so that the script calling sandbox can know if the command succeeded (tests passed). Also remove the now completely unused "exit_state" in sandbox. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
Showing 3 changed files with 4 additions and 22 deletions Side-by-side Diff
arch/sandbox/cpu/start.c
... | ... | @@ -78,11 +78,13 @@ |
78 | 78 | |
79 | 79 | /* Execute command if required */ |
80 | 80 | if (state->cmd) { |
81 | + int retval; | |
82 | + | |
81 | 83 | cli_init(); |
82 | 84 | |
83 | - run_command_list(state->cmd, -1, 0); | |
85 | + retval = run_command_list(state->cmd, -1, 0); | |
84 | 86 | if (!state->interactive) |
85 | - os_exit(state->exit_type); | |
87 | + os_exit(retval); | |
86 | 88 | } |
87 | 89 | |
88 | 90 | return 0; |
arch/sandbox/cpu/state.c
... | ... | @@ -13,11 +13,6 @@ |
13 | 13 | static struct sandbox_state main_state; |
14 | 14 | static struct sandbox_state *state; /* Pointer to current state record */ |
15 | 15 | |
16 | -void state_record_exit(enum exit_type_id exit_type) | |
17 | -{ | |
18 | - state->exit_type = exit_type; | |
19 | -} | |
20 | - | |
21 | 16 | static int state_ensure_space(int extra_size) |
22 | 17 | { |
23 | 18 | void *blob = state->state_fdt; |
arch/sandbox/include/asm/state.h
... | ... | @@ -10,13 +10,6 @@ |
10 | 10 | #include <stdbool.h> |
11 | 11 | #include <linux/stringify.h> |
12 | 12 | |
13 | -/* How we exited U-Boot */ | |
14 | -enum exit_type_id { | |
15 | - STATE_EXIT_NORMAL, | |
16 | - STATE_EXIT_COLD_REBOOT, | |
17 | - STATE_EXIT_POWER_OFF, | |
18 | -}; | |
19 | - | |
20 | 13 | /** |
21 | 14 | * Selects the behavior of the serial terminal. |
22 | 15 | * |
... | ... | @@ -50,7 +43,6 @@ |
50 | 43 | const char *cmd; /* Command to execute */ |
51 | 44 | bool interactive; /* Enable cmdline after execute */ |
52 | 45 | const char *fdt_fname; /* Filename of FDT binary */ |
53 | - enum exit_type_id exit_type; /* How we exited U-Boot */ | |
54 | 46 | const char *parse_err; /* Error to report from parsing */ |
55 | 47 | int argc; /* Program arguments */ |
56 | 48 | char **argv; /* Command line arguments */ |
... | ... | @@ -137,13 +129,6 @@ |
137 | 129 | .write = _write, \ |
138 | 130 | .compat = _compat, \ |
139 | 131 | } |
140 | - | |
141 | -/** | |
142 | - * Record the exit type to be reported by the test program. | |
143 | - * | |
144 | - * @param exit_type Exit type to record | |
145 | - */ | |
146 | -void state_record_exit(enum exit_type_id exit_type); | |
147 | 132 | |
148 | 133 | /** |
149 | 134 | * Gets a pointer to the current state. |