removed unnecessary grub_test_* wrappers

This commit is contained in:
BVK Chaitanya 2010-01-14 17:17:51 +05:30
parent 4d362fde58
commit 0b8891c276
5 changed files with 48 additions and 104 deletions

View file

@ -1,3 +1,23 @@
2010-01-14 BVK Chaitanya <bvk@dbook>
Removed unnecessary grub_test_* wrappers.
* tests/lib/unit_test.c (grub_test_malloc): Removed.
(grub_test_vsprintf): Removed.
(grub_test_strdup): Removed.
(grub_test_printf): Removed.
(grub_test_free): Replaced with....
(grub_free): ...new wrapper.
* tests/lib/functional_test.c (grub_test_malloc): Removed.
(grub_test_free): Removed.
(grub_test_vsprintf): Removed.
(grub_test_strdup): Removed.
(grub_test_printf): Removed.
* tests/lib/test.c: Replaced
grub_test_{malloc,free,strdup,printf,vsprintf} methods with
grub_{malloc,free,strdup,printf,vsprintf} methods.
* include/grub/test.h: Removed prototypes for the above.
2010-01-12 BVK Chaitanya <bvk@dbook> 2010-01-12 BVK Chaitanya <bvk@dbook>
* tests/util/grub-shell.in: New --boot option. * tests/util/grub-shell.in: New --boot option.

View file

@ -64,12 +64,4 @@ void grub_test_nonzero (int cond, const char *file,
grub_test_unregister (name); \ grub_test_unregister (name); \
} }
/* Functions that are defined differently for unit and functional tests. */
void *grub_test_malloc (grub_size_t size);
void grub_test_free (void *ptr);
char *grub_test_strdup (const char *str);
int grub_test_vsprintf (char *str, const char *fmt, va_list args);
int grub_test_printf (const char *fmt, ...)
__attribute__ ((format (printf, 1, 2)));
#endif /* ! GRUB_TEST_HEADER */ #endif /* ! GRUB_TEST_HEADER */

View file

@ -3,43 +3,6 @@
#include <grub/extcmd.h> #include <grub/extcmd.h>
#include <grub/test.h> #include <grub/test.h>
void *
grub_test_malloc (grub_size_t size)
{
return grub_malloc (size);
}
void
grub_test_free (void *ptr)
{
grub_free (ptr);
}
int
grub_test_vsprintf (char *str, const char *fmt, va_list args)
{
return grub_vsprintf (str, fmt, args);
}
char *
grub_test_strdup (const char *str)
{
return grub_strdup (str);
}
int
grub_test_printf (const char *fmt, ...)
{
int r;
va_list ap;
va_start (ap, fmt);
r = grub_vprintf (fmt, ap);
va_end (ap);
return r;
}
static grub_err_t static grub_err_t
grub_functional_test (struct grub_extcmd *cmd __attribute__ ((unused)), grub_functional_test (struct grub_extcmd *cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)), int argc __attribute__ ((unused)),

View file

@ -1,3 +1,4 @@
#include <grub/mm.h>
#include <grub/misc.h> #include <grub/misc.h>
#include <grub/test.h> #include <grub/test.h>
@ -31,16 +32,16 @@ add_failure (const char *file,
char buf[1024]; char buf[1024];
grub_test_failure_t failure; grub_test_failure_t failure;
failure = (grub_test_failure_t) grub_test_malloc (sizeof (*failure)); failure = (grub_test_failure_t) grub_malloc (sizeof (*failure));
if (!failure) if (!failure)
return; return;
grub_test_vsprintf (buf, fmt, args); grub_vsprintf (buf, fmt, args);
failure->file = grub_test_strdup (file ? : "<unknown_file>"); failure->file = grub_strdup (file ? : "<unknown_file>");
failure->funp = grub_test_strdup (funp ? : "<unknown_function>"); failure->funp = grub_strdup (funp ? : "<unknown_function>");
failure->line = line; failure->line = line;
failure->message = grub_test_strdup (buf); failure->message = grub_strdup (buf);
grub_list_push (GRUB_AS_LIST_P (&failure_list), GRUB_AS_LIST (failure)); grub_list_push (GRUB_AS_LIST_P (&failure_list), GRUB_AS_LIST (failure));
} }
@ -53,15 +54,15 @@ free_failures (void)
while ((item = grub_list_pop (GRUB_AS_LIST_P (&failure_list))) != 0) while ((item = grub_list_pop (GRUB_AS_LIST_P (&failure_list))) != 0)
{ {
if (item->message) if (item->message)
grub_test_free (item->message); grub_free (item->message);
if (item->funp) if (item->funp)
grub_test_free (item->funp); grub_free (item->funp);
if (item->file) if (item->file)
grub_test_free (item->file); grub_free (item->file);
grub_test_free (item); grub_free (item);
} }
failure_list = 0; failure_list = 0;
} }
@ -86,11 +87,11 @@ grub_test_register (const char *name, void (*test_main) (void))
{ {
grub_test_t test; grub_test_t test;
test = (grub_test_t) grub_test_malloc (sizeof (*test)); test = (grub_test_t) grub_malloc (sizeof (*test));
if (!test) if (!test)
return; return;
test->name = grub_test_strdup (name); test->name = grub_strdup (name);
test->main = test_main; test->main = test_main;
grub_list_push (GRUB_AS_LIST_P (&grub_test_list), GRUB_AS_LIST (test)); grub_list_push (GRUB_AS_LIST_P (&grub_test_list), GRUB_AS_LIST (test));
@ -106,13 +107,12 @@ grub_test_unregister (const char *name)
if (test) if (test)
{ {
grub_list_remove (GRUB_AS_LIST_P (&grub_test_list), grub_list_remove (GRUB_AS_LIST_P (&grub_test_list), GRUB_AS_LIST (test));
GRUB_AS_LIST (test));
if (test->name) if (test->name)
grub_test_free (test->name); grub_free (test->name);
grub_test_free (test); grub_free (test);
} }
} }
@ -124,7 +124,7 @@ grub_test_run (grub_test_t test)
{ {
grub_test_failure_t failure = (grub_test_failure_t) item; grub_test_failure_t failure = (grub_test_failure_t) item;
grub_test_printf (" %s:%s:%u: %s\n", grub_printf (" %s:%s:%u: %s\n",
(failure->file ? : "<unknown_file>"), (failure->file ? : "<unknown_file>"),
(failure->funp ? : "<unknown_function>"), (failure->funp ? : "<unknown_function>"),
failure->line, (failure->message ? : "<no message>")); failure->line, (failure->message ? : "<no message>"));
@ -133,13 +133,13 @@ grub_test_run (grub_test_t test)
test->main (); test->main ();
grub_test_printf ("%s:\n", test->name); grub_printf ("%s:\n", test->name);
grub_list_iterate (GRUB_AS_LIST (failure_list), grub_list_iterate (GRUB_AS_LIST (failure_list),
(grub_list_hook_t) print_failure); (grub_list_hook_t) print_failure);
if (!failure_list) if (!failure_list)
grub_test_printf ("%s: PASS\n", test->name); grub_printf ("%s: PASS\n", test->name);
else else
grub_test_printf ("%s: FAIL\n", test->name); grub_printf ("%s: FAIL\n", test->name);
free_failures (); free_failures ();
return GRUB_ERR_NONE; return GRUB_ERR_NONE;

View file

@ -7,43 +7,6 @@
#include <grub/test.h> #include <grub/test.h>
#include <grub/handler.h> #include <grub/handler.h>
void *
grub_test_malloc (grub_size_t size)
{
return malloc (size);
}
void
grub_test_free (void *ptr)
{
free (ptr);
}
int
grub_test_vsprintf (char *str, const char *fmt, va_list args)
{
return vsprintf (str, fmt, args);
}
char *
grub_test_strdup (const char *str)
{
return strdup (str);
}
int
grub_test_printf (const char *fmt, ...)
{
int r;
va_list ap;
va_start (ap, fmt);
r = vprintf (fmt, ap);
va_end (ap);
return r;
}
int int
main (int argc __attribute__ ((unused)), main (int argc __attribute__ ((unused)),
char *argv[] __attribute__ ((unused))) char *argv[] __attribute__ ((unused)))
@ -70,6 +33,12 @@ main (int argc __attribute__ ((unused)),
/* Other misc. functions necessary for successful linking. */ /* Other misc. functions necessary for successful linking. */
void
grub_free (void *ptr)
{
free (ptr);
}
char * char *
grub_env_get (const char *name __attribute__ ((unused))) grub_env_get (const char *name __attribute__ ((unused)))
{ {