* 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:
parent
e44b9a8349
commit
d71b45ae8e
4 changed files with 35 additions and 13 deletions
|
@ -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>
|
2013-10-03 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/video/capture.c: Do not do finalization when .fini
|
* grub-core/video/capture.c: Do not do finalization when .fini
|
||||||
|
|
|
@ -98,9 +98,7 @@ cmdline_cat_test (void)
|
||||||
|
|
||||||
grub_video_checksum ("cmdline_cat");
|
grub_video_checksum ("cmdline_cat");
|
||||||
|
|
||||||
if (grub_test_use_gfxterm ())
|
if (!grub_test_use_gfxterm ())
|
||||||
return;
|
|
||||||
|
|
||||||
grub_cmdline_run (1);
|
grub_cmdline_run (1);
|
||||||
|
|
||||||
grub_test_use_gfxterm_end ();
|
grub_test_use_gfxterm_end ();
|
||||||
|
|
|
@ -26,6 +26,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
||||||
static int *seq;
|
static int *seq;
|
||||||
static int seqptr, nseq;
|
static int seqptr, nseq;
|
||||||
static struct grub_term_input *saved;
|
static struct grub_term_input *saved;
|
||||||
|
static int fake_input;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
fake_getkey (struct grub_term_input *term __attribute__ ((unused)))
|
fake_getkey (struct grub_term_input *term __attribute__ ((unused)))
|
||||||
|
@ -44,23 +45,28 @@ static struct grub_term_input fake_input_term =
|
||||||
void
|
void
|
||||||
grub_terminal_input_fake_sequence (int *seq_in, int nseq_in)
|
grub_terminal_input_fake_sequence (int *seq_in, int nseq_in)
|
||||||
{
|
{
|
||||||
if (!saved)
|
if (!fake_input)
|
||||||
saved = grub_term_inputs;
|
saved = grub_term_inputs;
|
||||||
if (seq)
|
if (seq)
|
||||||
grub_free (seq);
|
grub_free (seq);
|
||||||
seq = grub_malloc (nseq_in * sizeof (seq[0]));
|
seq = grub_malloc (nseq_in * sizeof (seq[0]));
|
||||||
if (seq)
|
if (!seq)
|
||||||
{
|
return;
|
||||||
|
|
||||||
grub_term_inputs = &fake_input_term;
|
grub_term_inputs = &fake_input_term;
|
||||||
grub_memcpy (seq, seq_in, nseq_in * sizeof (seq[0]));
|
grub_memcpy (seq, seq_in, nseq_in * sizeof (seq[0]));
|
||||||
}
|
|
||||||
nseq = nseq_in;
|
nseq = nseq_in;
|
||||||
seqptr = 0;
|
seqptr = 0;
|
||||||
|
fake_input = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_terminal_input_fake_sequence_end (void)
|
grub_terminal_input_fake_sequence_end (void)
|
||||||
{
|
{
|
||||||
|
if (!fake_input)
|
||||||
|
return;
|
||||||
|
fake_input = 0;
|
||||||
grub_term_inputs = saved;
|
grub_term_inputs = saved;
|
||||||
grub_free (seq);
|
grub_free (seq);
|
||||||
seq = 0;
|
seq = 0;
|
||||||
|
|
|
@ -764,12 +764,11 @@ grub_video_checksum_end (void)
|
||||||
static struct grub_term_output *saved_outputs;
|
static struct grub_term_output *saved_outputs;
|
||||||
static struct grub_term_output *saved_gfxnext;
|
static struct grub_term_output *saved_gfxnext;
|
||||||
static struct grub_term_output *gfxterm;
|
static struct grub_term_output *gfxterm;
|
||||||
|
static int use_gfxterm = 0;
|
||||||
|
|
||||||
int
|
int
|
||||||
grub_test_use_gfxterm (void)
|
grub_test_use_gfxterm (void)
|
||||||
{
|
{
|
||||||
saved_outputs = grub_term_outputs;
|
|
||||||
|
|
||||||
FOR_ACTIVE_TERM_OUTPUTS (gfxterm)
|
FOR_ACTIVE_TERM_OUTPUTS (gfxterm)
|
||||||
if (grub_strcmp (gfxterm->name, "gfxterm") == 0)
|
if (grub_strcmp (gfxterm->name, "gfxterm") == 0)
|
||||||
break;
|
break;
|
||||||
|
@ -784,10 +783,17 @@ grub_test_use_gfxterm (void)
|
||||||
return 1;
|
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;
|
saved_gfxnext = gfxterm->next;
|
||||||
grub_term_outputs = gfxterm;
|
grub_term_outputs = gfxterm;
|
||||||
gfxterm->next = 0;
|
gfxterm->next = 0;
|
||||||
gfxterm->init (gfxterm);
|
use_gfxterm = 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -795,7 +801,12 @@ grub_test_use_gfxterm (void)
|
||||||
void
|
void
|
||||||
grub_test_use_gfxterm_end (void)
|
grub_test_use_gfxterm_end (void)
|
||||||
{
|
{
|
||||||
|
if (!use_gfxterm)
|
||||||
|
return;
|
||||||
|
use_gfxterm = 0;
|
||||||
gfxterm->fini (gfxterm);
|
gfxterm->fini (gfxterm);
|
||||||
gfxterm->next = saved_gfxnext;
|
gfxterm->next = saved_gfxnext;
|
||||||
grub_term_outputs = saved_outputs;
|
grub_term_outputs = saved_outputs;
|
||||||
|
saved_outputs = 0;
|
||||||
|
saved_gfxnext = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue