diff options
author | Andre Moreira Magalhaes (andrunko) <andre.magalhaes@collabora.co.uk> | 2012-06-13 13:01:41 -0300 |
---|---|---|
committer | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2012-06-18 09:29:52 +0100 |
commit | d82591dd218891f3fb52cf523cec1446b4d67f11 (patch) | |
tree | 238ed93f8decb7479524af1bf084f6c0e4557d5f | |
parent | 7fadf0d43f5d015c873be1c5cd5682c185ef0080 (diff) |
insanitytest: Add global parameter to add_checklist_item.
-rw-r--r-- | lib/insanity/insanitytest.c | 18 | ||||
-rw-r--r-- | lib/insanity/insanitytest.h | 2 | ||||
-rw-r--r-- | tests/insanity-test-blank.c | 4 |
3 files changed, 20 insertions, 4 deletions
diff --git a/lib/insanity/insanitytest.c b/lib/insanity/insanitytest.c index 33205ef..1189286 100644 --- a/lib/insanity/insanitytest.c +++ b/lib/insanity/insanitytest.c @@ -217,6 +217,7 @@ typedef struct _Argument typedef struct _ChecklistItem { + gboolean global; char *label; char *description; char *likely_error; @@ -544,6 +545,8 @@ void insanity_test_validate_checklist_item (InsanityTest * test, const char *label, gboolean success, const char *description) { + const ChecklistItem *item; + g_return_if_fail (INSANITY_IS_TEST (test)); g_return_if_fail (label != NULL); g_return_if_fail (check_valid_label (label)); @@ -552,6 +555,14 @@ insanity_test_validate_checklist_item (InsanityTest * test, const char *label, LOCK (test); + item = g_hash_table_lookup (test->priv->test_checklist, label); + if (!item->global &&test->priv->runlevel != rl_started + && test->priv->runlevel != rl_setup) { + g_critical ("Non-global checklist item '%s' requested to validate but " + "not set up yet\n", label); + goto done; + } + insanity_test_ping_unlocked (test); /* if the item has already been (in)validated, then we invalidate if success is FALSE, @@ -582,6 +593,8 @@ insanity_test_validate_checklist_item (InsanityTest * test, const char *label, g_hash_table_insert (test->priv->checklist_results, g_strdup (label), (success ? ((gpointer) 1) : ((gpointer) 0))); + +done: UNLOCK (test); } @@ -1466,6 +1479,7 @@ output_checklist_table (InsanityTest * test, FILE * f) fprintf (f, "%s \"%s\" : \n", comma, label); fprintf (f, " {\n"); + fprintf (f, " \"global\" : %s,\n", (i->global ? "true" : "false")); fprintf (f, " \"description\" : \"%s\"", i->description); if (i->likely_error) { fprintf (f, ",\n \"likely_error\" : \"%s\"", i->likely_error); @@ -2172,6 +2186,7 @@ insanity_add_metadata_entry (GHashTable * hash, const char *label, * @label: the new checklist item's label * @description: a one line description of that item * @error_hint: (allow-none): an optional explanatory description of why this error may happen + * @global: if this is a global item * * This function adds a checklist item declaration to the test. * @@ -2180,7 +2195,7 @@ insanity_add_metadata_entry (GHashTable * hash, const char *label, */ void insanity_test_add_checklist_item (InsanityTest * test, const char *label, - const char *description, const char *error_hint) + const char *description, const char *error_hint, gboolean global) { ChecklistItem *i; @@ -2195,6 +2210,7 @@ insanity_test_add_checklist_item (InsanityTest * test, const char *label, i->label = g_strdup (label); i->description = g_strdup (description); i->likely_error = g_strdup (error_hint); + i->global = global; g_hash_table_insert (test->priv->test_checklist, g_strdup (label), i); } diff --git a/lib/insanity/insanitytest.h b/lib/insanity/insanitytest.h index 3bd9ac2..0da1124 100644 --- a/lib/insanity/insanitytest.h +++ b/lib/insanity/insanitytest.h @@ -93,7 +93,7 @@ struct _InsanityTestClass GType insanity_test_get_type (void); InsanityTest *insanity_test_new(const char *name, const char *description, const char *full_description); -void insanity_test_add_checklist_item(InsanityTest *test, const char *label, const char *description, const char *error_hint); +void insanity_test_add_checklist_item(InsanityTest *test, const char *label, const char *description, const char *error_hint, gboolean global); void insanity_test_add_shared_checklist_item (InsanityTest * test, const gchar * label); void insanity_test_add_argument(InsanityTest *test, const char *label, const char *description, const char *full_description, gboolean global, const GValue *default_value); void insanity_test_add_output_file(InsanityTest *test, const char *label, const char *description, gboolean global); diff --git a/tests/insanity-test-blank.c b/tests/insanity-test-blank.c index 6f9c2c6..0d465e5 100644 --- a/tests/insanity-test-blank.c +++ b/tests/insanity-test-blank.c @@ -128,9 +128,9 @@ main (int argc, char **argv) insanity_test_add_checklist_item (test, "random-checklist-item", "Some random checklist item, nothing much", - "Probably something wrong here"); + "Probably something wrong here", FALSE); insanity_test_add_checklist_item (test, "random-other-checklist-item", - "Some random checklist item, nothing much", "Not going to happen"); + "Some random checklist item, nothing much", "Not going to happen", FALSE); insanity_test_add_extra_info (test, "random-extra-info", "Some random extra info"); |