|
|
f96e0b |
From 7a17fdeafeca824d9dec7c2a57e8f958d58b45eb Mon Sep 17 00:00:00 2001
|
|
|
f96e0b |
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
Date: Tue, 7 May 2013 12:28:59 +0200
|
|
|
f96e0b |
Subject: [PATCH 438/482] * grub-core/tests/setjmp_test.c: New test.
|
|
|
f96e0b |
|
|
|
f96e0b |
---
|
|
|
f96e0b |
ChangeLog | 4 ++
|
|
|
f96e0b |
grub-core/Makefile.core.def | 5 +++
|
|
|
f96e0b |
grub-core/tests/lib/functional_test.c | 1 +
|
|
|
f96e0b |
grub-core/tests/setjmp_test.c | 74 +++++++++++++++++++++++++++++++++++
|
|
|
f96e0b |
4 files changed, 84 insertions(+)
|
|
|
f96e0b |
create mode 100644 grub-core/tests/setjmp_test.c
|
|
|
f96e0b |
|
|
|
f96e0b |
diff --git a/ChangeLog b/ChangeLog
|
|
|
f96e0b |
index cbd5d97..aeb61cd 100644
|
|
|
f96e0b |
--- a/ChangeLog
|
|
|
f96e0b |
+++ b/ChangeLog
|
|
|
f96e0b |
@@ -1,5 +1,9 @@
|
|
|
f96e0b |
2013-05-07 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
|
|
|
f96e0b |
+ * grub-core/tests/setjmp_test.c: New test.
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+2013-05-07 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
+
|
|
|
f96e0b |
New variables 'net_default_*' to determine MAC/IP of default interface.
|
|
|
f96e0b |
|
|
|
f96e0b |
2013-05-07 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
|
|
|
f96e0b |
index 56a1ec3..7dc106e 100644
|
|
|
f96e0b |
--- a/grub-core/Makefile.core.def
|
|
|
f96e0b |
+++ b/grub-core/Makefile.core.def
|
|
|
f96e0b |
@@ -1743,6 +1743,11 @@ module = {
|
|
|
f96e0b |
};
|
|
|
f96e0b |
|
|
|
f96e0b |
module = {
|
|
|
f96e0b |
+ name = setjmp_test;
|
|
|
f96e0b |
+ common = tests/setjmp_test.c;
|
|
|
f96e0b |
+};
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+module = {
|
|
|
f96e0b |
name = videotest_checksum;
|
|
|
f96e0b |
common = tests/videotest_checksum.c;
|
|
|
f96e0b |
};
|
|
|
f96e0b |
diff --git a/grub-core/tests/lib/functional_test.c b/grub-core/tests/lib/functional_test.c
|
|
|
f96e0b |
index 957354e..8f66fe3 100644
|
|
|
f96e0b |
--- a/grub-core/tests/lib/functional_test.c
|
|
|
f96e0b |
+++ b/grub-core/tests/lib/functional_test.c
|
|
|
f96e0b |
@@ -56,6 +56,7 @@ grub_functional_all_tests (grub_extcmd_context_t ctxt __attribute__ ((unused)),
|
|
|
f96e0b |
grub_dl_load ("exfctest");
|
|
|
f96e0b |
grub_dl_load ("videotest_checksum");
|
|
|
f96e0b |
grub_dl_load ("gfxterm_menu");
|
|
|
f96e0b |
+ grub_dl_load ("setjmp_test");
|
|
|
f96e0b |
|
|
|
f96e0b |
FOR_LIST_ELEMENTS (test, grub_test_list)
|
|
|
f96e0b |
ok = !grub_test_run (test) && ok;
|
|
|
f96e0b |
diff --git a/grub-core/tests/setjmp_test.c b/grub-core/tests/setjmp_test.c
|
|
|
f96e0b |
new file mode 100644
|
|
|
f96e0b |
index 0000000..29aab25
|
|
|
f96e0b |
--- /dev/null
|
|
|
f96e0b |
+++ b/grub-core/tests/setjmp_test.c
|
|
|
f96e0b |
@@ -0,0 +1,74 @@
|
|
|
f96e0b |
+/*
|
|
|
f96e0b |
+ * GRUB -- GRand Unified Bootloader
|
|
|
f96e0b |
+ * Copyright (C) 2013 Free Software Foundation, Inc.
|
|
|
f96e0b |
+ *
|
|
|
f96e0b |
+ * GRUB is free software: you can redistribute it and/or modify
|
|
|
f96e0b |
+ * it under the terms of the GNU General Public License as published by
|
|
|
f96e0b |
+ * the Free Software Foundation, either version 3 of the License, or
|
|
|
f96e0b |
+ * (at your option) any later version.
|
|
|
f96e0b |
+ *
|
|
|
f96e0b |
+ * GRUB is distributed in the hope that it will be useful,
|
|
|
f96e0b |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f96e0b |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
f96e0b |
+ * GNU General Public License for more details.
|
|
|
f96e0b |
+ *
|
|
|
f96e0b |
+ * You should have received a copy of the GNU General Public License
|
|
|
f96e0b |
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
|
|
f96e0b |
+ */
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+#include <grub/test.h>
|
|
|
f96e0b |
+#include <grub/dl.h>
|
|
|
f96e0b |
+#include <grub/setjmp.h>
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+GRUB_MOD_LICENSE ("GPLv3+");
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+static grub_jmp_buf jmp_point;
|
|
|
f96e0b |
+static int expected, ctr;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+static void
|
|
|
f96e0b |
+jmp0 (void)
|
|
|
f96e0b |
+{
|
|
|
f96e0b |
+ grub_longjmp (jmp_point, 0);
|
|
|
f96e0b |
+}
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+static void
|
|
|
f96e0b |
+jmp1 (void)
|
|
|
f96e0b |
+{
|
|
|
f96e0b |
+ grub_longjmp (jmp_point, 1);
|
|
|
f96e0b |
+}
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+static void
|
|
|
f96e0b |
+jmp2 (void)
|
|
|
f96e0b |
+{
|
|
|
f96e0b |
+ grub_longjmp (jmp_point, 2);
|
|
|
f96e0b |
+}
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+static void
|
|
|
f96e0b |
+setjmp_test (void)
|
|
|
f96e0b |
+{
|
|
|
f96e0b |
+ int val;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ expected = 0;
|
|
|
f96e0b |
+ val = grub_setjmp (jmp_point);
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ grub_test_assert (val == expected, "setjmp returned %d instead of %d",
|
|
|
f96e0b |
+ val, expected);
|
|
|
f96e0b |
+ switch (ctr++)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ case 0:
|
|
|
f96e0b |
+ expected = 1;
|
|
|
f96e0b |
+ jmp0 ();
|
|
|
f96e0b |
+ case 1:
|
|
|
f96e0b |
+ expected = 1;
|
|
|
f96e0b |
+ jmp1 ();
|
|
|
f96e0b |
+ case 2:
|
|
|
f96e0b |
+ expected = 2;
|
|
|
f96e0b |
+ jmp2 ();
|
|
|
f96e0b |
+ case 3:
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+ grub_test_assert (0, "setjmp didn't return enough times");
|
|
|
f96e0b |
+}
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+/* Register example_test method as a functional test. */
|
|
|
f96e0b |
+GRUB_FUNCTIONAL_TEST (setjmp_test, setjmp_test);
|
|
|
f96e0b |
--
|
|
|
f96e0b |
1.8.2.1
|
|
|
f96e0b |
|