* grub-core/tests/video_checksum.c: Increase robustness to out of memory

condition.
	* grub-core/tests/fake_input.c: Likewise.
	* grub-core/tests/cmdline_cat_test.c: Likewise.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-10-03 23:38:18 +02:00
parent e44b9a8349
commit d71b45ae8e
4 changed files with 35 additions and 13 deletions

View file

@ -1,3 +1,10 @@
2013-10-03 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/tests/video_checksum.c: Increase robustness to out of memory
condition.
* grub-core/tests/fake_input.c: Likewise.
* grub-core/tests/cmdline_cat_test.c: Likewise.
2013-10-03 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/video/capture.c: Do not do finalization when .fini

View file

@ -98,10 +98,8 @@ cmdline_cat_test (void)
grub_video_checksum ("cmdline_cat");
if (grub_test_use_gfxterm ())
return;
grub_cmdline_run (1);
if (!grub_test_use_gfxterm ())
grub_cmdline_run (1);
grub_test_use_gfxterm_end ();

View file

@ -26,6 +26,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
static int *seq;
static int seqptr, nseq;
static struct grub_term_input *saved;
static int fake_input;
static int
fake_getkey (struct grub_term_input *term __attribute__ ((unused)))
@ -44,23 +45,28 @@ static struct grub_term_input fake_input_term =
void
grub_terminal_input_fake_sequence (int *seq_in, int nseq_in)
{
if (!saved)
if (!fake_input)
saved = grub_term_inputs;
if (seq)
grub_free (seq);
seq = grub_malloc (nseq_in * sizeof (seq[0]));
if (seq)
{
grub_term_inputs = &fake_input_term;
grub_memcpy (seq, seq_in, nseq_in * sizeof (seq[0]));
}
if (!seq)
return;
grub_term_inputs = &fake_input_term;
grub_memcpy (seq, seq_in, nseq_in * sizeof (seq[0]));
nseq = nseq_in;
seqptr = 0;
fake_input = 1;
}
void
grub_terminal_input_fake_sequence_end (void)
{
if (!fake_input)
return;
fake_input = 0;
grub_term_inputs = saved;
grub_free (seq);
seq = 0;

View file

@ -764,12 +764,11 @@ grub_video_checksum_end (void)
static struct grub_term_output *saved_outputs;
static struct grub_term_output *saved_gfxnext;
static struct grub_term_output *gfxterm;
static int use_gfxterm = 0;
int
grub_test_use_gfxterm (void)
{
saved_outputs = grub_term_outputs;
FOR_ACTIVE_TERM_OUTPUTS (gfxterm)
if (grub_strcmp (gfxterm->name, "gfxterm") == 0)
break;
@ -784,10 +783,17 @@ grub_test_use_gfxterm (void)
return 1;
}
if (gfxterm->init (gfxterm))
{
grub_test_assert (0, "terminal `%s' failed: %s", "gfxterm", grub_errmsg);
return 1;
}
saved_outputs = grub_term_outputs;
saved_gfxnext = gfxterm->next;
grub_term_outputs = gfxterm;
gfxterm->next = 0;
gfxterm->init (gfxterm);
use_gfxterm = 1;
return 0;
}
@ -795,7 +801,12 @@ grub_test_use_gfxterm (void)
void
grub_test_use_gfxterm_end (void)
{
if (!use_gfxterm)
return;
use_gfxterm = 0;
gfxterm->fini (gfxterm);
gfxterm->next = saved_gfxnext;
grub_term_outputs = saved_outputs;
saved_outputs = 0;
saved_gfxnext = 0;
}