summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cesar/lib/scenario/scenario.h14
-rw-r--r--cesar/lib/scenario/src/scenario.c13
2 files changed, 23 insertions, 4 deletions
diff --git a/cesar/lib/scenario/scenario.h b/cesar/lib/scenario/scenario.h
index 72e701cae7..919e7a8035 100644
--- a/cesar/lib/scenario/scenario.h
+++ b/cesar/lib/scenario/scenario.h
@@ -121,9 +121,10 @@ enum scenario_event_id_t
SCENARIO_NOP_ID,
/** Event identifier for action. */
SCENARIO_ACTION_ID,
-#define SCENARIO_DEFS_EVENTS_ID(event) PASTE (SCENARIO_EVENT_, event)
- PREPROC_FOR_EACH_COMMA (SCENARIO_DEFS_EVENTS_ID, SCENARIO_DEFS_EVENTS)
+#define SCENARIO_DEFS_EVENTS_ID(event) PASTE (SCENARIO_EVENT_, event),
+ PREPROC_FOR_EACH (SCENARIO_DEFS_EVENTS_ID, SCENARIO_DEFS_EVENTS)
#undef SCENARIO_DEFS_EVENTS_ID
+ SCENARIO_NB_ID
};
typedef enum scenario_event_id_t scenario_event_id_t;
@@ -174,6 +175,9 @@ struct scenario_t
/** Currently running scenario. */
extern scenario_t scenario;
+/** Event names. */
+extern char *scenario_event_names[];
+
/** Use this at event entry. This macro is special and can not be included in
* a do { } while (0).
*
@@ -196,8 +200,12 @@ extern scenario_t scenario;
test_within (scenario.t); \
while (scenario.current->event_id == SCENARIO_NOP_ID) \
scenario.current++; \
+ dbg_assert (scenario.current->event_id < SCENARIO_NB_ID); \
test_fail_unless (scenario.current->event_id \
- == SCENARIO_EVENT_ ## event); \
+ == SCENARIO_EVENT_ ## event, \
+ "unexpected <%s>, expecting <%s> at %d", #event, \
+ scenario_event_names[scenario.current->event_id], \
+ scenario.current - scenario.entries); \
scenario.current++
#define scenario_event_2(event, params_var) \
diff --git a/cesar/lib/scenario/src/scenario.c b/cesar/lib/scenario/src/scenario.c
index cdbc1d3f13..47403daf9f 100644
--- a/cesar/lib/scenario/src/scenario.c
+++ b/cesar/lib/scenario/src/scenario.c
@@ -16,6 +16,16 @@
scenario_t scenario;
+char *scenario_event_names[] =
+{
+ "END",
+ "NOP",
+ "ACTION",
+#define SCENARIO_DEFS_EVENTS_NAME(event) #event
+ PREPROC_FOR_EACH_COMMA (SCENARIO_DEFS_EVENTS_NAME, SCENARIO_DEFS_EVENTS)
+#undef SCENARIO_DEFS_EVENTS_NAME
+};
+
void
scenario_run (test_t t, scenario_entry_t *entries,
scenario_globals_t *globals)
@@ -36,7 +46,8 @@ scenario_run (test_t t, scenario_entry_t *entries,
else
{
test_fail_unless (scenario.current->event_id == SCENARIO_ACTION_ID,
- "Expected event did not occurs at %d",
+ "Expected event <%s> did not occurs at %d",
+ scenario_event_names[scenario.current->event_id],
scenario.current - scenario.entries);
scenario_entry_t *action = scenario.current++;
action->action_cb (globals, &action->params);