tests: explain some errors messages are expected and check for safety checks.

Many people try "make check" and then complain they have some error
messages, but they are actually expected... but even for the
experienced is hard to know whenever it was expected or not, so
explicitly say that.

Also check if safety checks are enabled or not before doing "break"
tests, otherwise we'll end with segfaults and tests failing. (I have
not tested with them disabled, but should be okay).



SVN revision: 42360
This commit is contained in:
Gustavo Sverzut Barbieri 2009-09-09 01:53:40 +00:00
parent 93b28743c5
commit d909319998
4 changed files with 34 additions and 4 deletions

View File

@ -25,6 +25,7 @@
#include "eina_suite.h"
#include "Eina.h"
#include "eina_safety_checks.h"
START_TEST(eina_counter_simple)
{
@ -73,7 +74,6 @@ END_TEST
START_TEST(eina_counter_break)
{
Eina_Counter *cnt;
char *dump;
eina_init();
@ -84,10 +84,17 @@ START_TEST(eina_counter_break)
eina_counter_free(cnt);
dump = eina_counter_dump(NULL);
fail_if(dump);
#ifdef EINA_SAFETY_CHECKS
{
char *dump;
free(dump);
fprintf(stderr, "you should have a safety check failure below:\n");
dump = eina_counter_dump(NULL);
fail_if(dump);
fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED);
free(dump);
}
#endif
eina_shutdown();
}

View File

@ -21,10 +21,12 @@
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "eina_suite.h"
#include "Eina.h"
#include "eina_safety_checks.h"
START_TEST(eina_file_split_simple)
{
@ -32,8 +34,12 @@ START_TEST(eina_file_split_simple)
eina_init();
#ifdef EINA_SAFETY_CHECKS
fprintf(stderr, "you should have a safety check failure below:\n");
ea = eina_file_split(NULL);
fail_if(ea);
fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED);
#endif
ea = eina_file_split(strdup("/this/is/a/small/test"));

View File

@ -21,6 +21,7 @@
#endif
#include <stdlib.h>
#include <stdio.h>
#include "eina_suite.h"
#include "Eina.h"
@ -98,12 +99,14 @@ START_TEST(eina_inlist_simple)
}
#ifdef EINA_SAFETY_CHECKS
fprintf(stderr, "you should have a safety check failure below:\n");
{
Eina_Inlist *tmp2 = eina_inlist_remove(NULL, EINA_INLIST_GET(tmp));
fail_if(tmp2 != NULL);
fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED);
}
fprintf(stderr, "you should have a safety check failure below:\n");
lst = eina_inlist_remove(lst, NULL);
fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED);
#endif

View File

@ -21,12 +21,14 @@
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define EINA_MAGIC_DEBUG
#include "eina_suite.h"
#include "Eina.h"
#include "eina_safety_checks.h"
#define EINA_MAGIC_TEST 0x7781fee7
#define EINA_MAGIC_TEST2 0x42241664
@ -45,8 +47,17 @@ START_TEST(eina_magic_simple)
eina_init();
eina_magic_string_set(EINA_MAGIC_TEST, EINA_MAGIC_STRING);
#ifdef EINA_SAFETY_CHECKS
fprintf(stderr, "you should have a safety check failure below:\n");
eina_magic_string_set(EINA_MAGIC_TEST2, NULL);
fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED);
fprintf(stderr, "you should have a safety check failure below:\n");
eina_magic_string_set(EINA_MAGIC_TEST2, NULL);
fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED);
#endif
eina_magic_string_set(EINA_MAGIC_TEST2, EINA_MAGIC_STRING);
fail_if(eina_magic_string_get(EINA_MAGIC_TEST) == NULL);
@ -54,6 +65,7 @@ START_TEST(eina_magic_simple)
#ifdef EINA_MAGIC_DEBUG
fail_if(EINA_MAGIC_CHECK(ems, EINA_MAGIC_TEST));
fprintf(stderr, "you should see 'Input handle pointer is NULL' below\n");
EINA_MAGIC_FAIL(ems, EINA_MAGIC_TEST);
ems = malloc(sizeof (Eina_Magic_Struct));
@ -63,9 +75,11 @@ START_TEST(eina_magic_simple)
fail_if(!EINA_MAGIC_CHECK(ems, EINA_MAGIC_TEST));
EINA_MAGIC_SET(ems, EINA_MAGIC_NONE);
fprintf(stderr, "you should see 'Input handle has already been freed' below\n");
EINA_MAGIC_FAIL(ems, EINA_MAGIC_TEST);
EINA_MAGIC_SET(ems, 42424242);
fprintf(stderr, "you should see 'Input handle is wrong type' below\n");
EINA_MAGIC_FAIL(ems, EINA_MAGIC_TEST);
#endif