removed unnecessary grub_test_* wrappers
This commit is contained in:
parent
4d362fde58
commit
0b8891c276
5 changed files with 48 additions and 104 deletions
|
@ -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>
|
||||
|
||||
* tests/util/grub-shell.in: New --boot option.
|
||||
|
|
|
@ -64,12 +64,4 @@ void grub_test_nonzero (int cond, const char *file,
|
|||
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 */
|
||||
|
|
|
@ -3,43 +3,6 @@
|
|||
#include <grub/extcmd.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
|
||||
grub_functional_test (struct grub_extcmd *cmd __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/test.h>
|
||||
|
||||
|
@ -31,16 +32,16 @@ add_failure (const char *file,
|
|||
char buf[1024];
|
||||
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)
|
||||
return;
|
||||
|
||||
grub_test_vsprintf (buf, fmt, args);
|
||||
grub_vsprintf (buf, fmt, args);
|
||||
|
||||
failure->file = grub_test_strdup (file ? : "<unknown_file>");
|
||||
failure->funp = grub_test_strdup (funp ? : "<unknown_function>");
|
||||
failure->file = grub_strdup (file ? : "<unknown_file>");
|
||||
failure->funp = grub_strdup (funp ? : "<unknown_function>");
|
||||
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));
|
||||
}
|
||||
|
@ -53,15 +54,15 @@ free_failures (void)
|
|||
while ((item = grub_list_pop (GRUB_AS_LIST_P (&failure_list))) != 0)
|
||||
{
|
||||
if (item->message)
|
||||
grub_test_free (item->message);
|
||||
grub_free (item->message);
|
||||
|
||||
if (item->funp)
|
||||
grub_test_free (item->funp);
|
||||
grub_free (item->funp);
|
||||
|
||||
if (item->file)
|
||||
grub_test_free (item->file);
|
||||
grub_free (item->file);
|
||||
|
||||
grub_test_free (item);
|
||||
grub_free (item);
|
||||
}
|
||||
failure_list = 0;
|
||||
}
|
||||
|
@ -86,11 +87,11 @@ grub_test_register (const char *name, void (*test_main) (void))
|
|||
{
|
||||
grub_test_t test;
|
||||
|
||||
test = (grub_test_t) grub_test_malloc (sizeof (*test));
|
||||
test = (grub_test_t) grub_malloc (sizeof (*test));
|
||||
if (!test)
|
||||
return;
|
||||
|
||||
test->name = grub_test_strdup (name);
|
||||
test->name = grub_strdup (name);
|
||||
test->main = test_main;
|
||||
|
||||
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)
|
||||
{
|
||||
grub_list_remove (GRUB_AS_LIST_P (&grub_test_list),
|
||||
GRUB_AS_LIST (test));
|
||||
grub_list_remove (GRUB_AS_LIST_P (&grub_test_list), GRUB_AS_LIST (test));
|
||||
|
||||
if (test->name)
|
||||
grub_test_free (test->name);
|
||||
grub_free (test->name);
|
||||
|
||||
grub_test_free (test);
|
||||
grub_free (test);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,22 +124,22 @@ grub_test_run (grub_test_t test)
|
|||
{
|
||||
grub_test_failure_t failure = (grub_test_failure_t) item;
|
||||
|
||||
grub_test_printf (" %s:%s:%u: %s\n",
|
||||
(failure->file ? : "<unknown_file>"),
|
||||
(failure->funp ? : "<unknown_function>"),
|
||||
failure->line, (failure->message ? : "<no message>"));
|
||||
grub_printf (" %s:%s:%u: %s\n",
|
||||
(failure->file ? : "<unknown_file>"),
|
||||
(failure->funp ? : "<unknown_function>"),
|
||||
failure->line, (failure->message ? : "<no message>"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
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_hook_t) print_failure);
|
||||
if (!failure_list)
|
||||
grub_test_printf ("%s: PASS\n", test->name);
|
||||
grub_printf ("%s: PASS\n", test->name);
|
||||
else
|
||||
grub_test_printf ("%s: FAIL\n", test->name);
|
||||
grub_printf ("%s: FAIL\n", test->name);
|
||||
|
||||
free_failures ();
|
||||
return GRUB_ERR_NONE;
|
||||
|
|
|
@ -7,43 +7,6 @@
|
|||
#include <grub/test.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
|
||||
main (int argc __attribute__ ((unused)),
|
||||
char *argv[] __attribute__ ((unused)))
|
||||
|
@ -70,6 +33,12 @@ main (int argc __attribute__ ((unused)),
|
|||
|
||||
/* Other misc. functions necessary for successful linking. */
|
||||
|
||||
void
|
||||
grub_free (void *ptr)
|
||||
{
|
||||
free (ptr);
|
||||
}
|
||||
|
||||
char *
|
||||
grub_env_get (const char *name __attribute__ ((unused)))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue