代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/grubby 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From d220ed2d9db1a2f9e2fde3195727a871c393e8cc Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 2 Jul 2015 12:34:30 -0400
Subject: [PATCH 07/60] Add a bunch of tests for various
--default-{kernel,title,index}.
... and fix some failures where we see them.
Related: rhbz#1184014
(though I can't actually replicate his failure.)
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grubby.c | 50 ++++++++++++++++++++++++-----------------
test.sh | 10 +++++++++
test/results/defaultkernel/g.1 | 1 +
test/results/defaultkernel/l1.1 | 1 +
test/results/defaultkernel/z.1 | 1 +
test/results/defaulttitle/z.1 | 1 +
6 files changed, 44 insertions(+), 20 deletions(-)
create mode 100644 test/results/defaultkernel/g.1
create mode 100644 test/results/defaultkernel/l1.1
create mode 100644 test/results/defaultkernel/z.1
create mode 100644 test/results/defaulttitle/z.1
diff --git a/grubby.c b/grubby.c
index 649597e..0bb4869 100644
--- a/grubby.c
+++ b/grubby.c
@@ -428,7 +428,7 @@ char *grub2ExtractTitle(struct singleLine * line) {
/* bail out if line does not start with menuentry */
if (strcmp(line->elements[0].item, "menuentry"))
- return NULL;
+ return NULL;
i = 1;
current = line->elements[i].item;
@@ -437,10 +437,12 @@ char *grub2ExtractTitle(struct singleLine * line) {
/* if second word is quoted, strip the quotes and return single word */
if (isquote(*current) && isquote(current[current_len - 1])) {
char *tmp;
-
- tmp = strdup(current);
- *(tmp + current_len - 1) = '\0';
- return ++tmp;
+
+ tmp = strdup(current+1);
+ if (!tmp)
+ return NULL;
+ tmp[strlen(tmp)-1] = '\0';
+ return tmp;
}
/* if no quotes, return second word verbatim */
@@ -453,11 +455,11 @@ char *grub2ExtractTitle(struct singleLine * line) {
char * result;
/* need to ensure that ' does not match " as we search */
char quote_char = *current;
-
+
resultMaxSize = sizeOfSingleLine(line);
result = malloc(resultMaxSize);
snprintf(result, resultMaxSize, "%s", ++current);
-
+
i++;
for (; i < line->numElements; ++i) {
current = line->elements[i].item;
@@ -4648,27 +4650,35 @@ int main(int argc, const char ** argv) {
struct singleLine * line;
struct singleEntry * entry;
- if (config->defaultImage == -1) return 0;
+ if (config->defaultImage == -1)
+ return 0;
if (config->defaultImage == DEFAULT_SAVED_GRUB2 &&
cfi->defaultIsSaved)
config->defaultImage = 0;
entry = findEntryByIndex(config, config->defaultImage);
- if (!entry) return 0;
+ if (!entry)
+ return 0;
if (!configureGrub2) {
- line = getLineByType(LT_TITLE, entry->lines);
- if (!line) return 0;
- printf("%s\n", line->elements[1].item);
-
+ char *title;
+ line = getLineByType(LT_TITLE, entry->lines);
+ if (!line)
+ return 0;
+ title = extractTitle(config, line);
+ if (!title)
+ return 0;
+ printf("%s\n", title);
+ free(title);
} else {
- char * title;
+ char * title;
- dbgPrintf("This is GRUB2, default title is embeded in menuentry\n");
- line = getLineByType(LT_MENUENTRY, entry->lines);
- if (!line) return 0;
- title = grub2ExtractTitle(line);
- if (title)
- printf("%s\n", title);
+ dbgPrintf("This is GRUB2, default title is embeded in menuentry\n");
+ line = getLineByType(LT_MENUENTRY, entry->lines);
+ if (!line)
+ return 0;
+ title = grub2ExtractTitle(line);
+ if (title)
+ printf("%s\n", title);
}
return 0;
diff --git a/test.sh b/test.sh
index 6379698..96e0087 100755
--- a/test.sh
+++ b/test.sh
@@ -298,6 +298,9 @@ grubDisplayTest grub.9 defaulttitle/g.9 --default-title
grubDisplayTest grub.10 defaulttitle/g.10 --default-title
grubDisplayTest grub.11 defaulttitle/g.11 --default-title
+testing="GRUB display default kernel"
+grubDisplayTest grub.1 defaultkernel/g.1 --default-kernel
+
testing="LILO default directive"
liloTest lilo.1 default/l1.1 --set-default=/boot/vmlinuz-2.4.18-4
liloTest lilo.1 default/l1.2 --remove-kernel=/boot/vmlinuz-2.4.18-4smp
@@ -305,10 +308,17 @@ liloTest lilo.1 default/l1.3 --add-kernel /boot/kernel --title label \
--copy-default
liloTest lilo.1 default/l1.4 --add-kernel /boot/kernel --title label \
--copy-default --make-default
+liloDisplayTest lilo.1 defaultkernel/l1.1 --default-kernel
testing="Z/IPL default directive"
ziplTest zipl.1 default/z1.1 --add-kernel /boot/new-kernel --title test
ziplTest zipl.1 default/z1.2 --add-kernel /boot/new-kernel --title test --make-default
+testing="Z/IPL display default index"
+ziplDisplayTest zipl.1 defaultindex/0 --default-index
+testing="Z/IPL display default title"
+ziplDisplayTest zipl.1 defaulttitle/z.1 --default-title
+testing="Z/IPL display default kernel"
+ziplDisplayTest zipl.1 defaultkernel/z.1 --default-kernel
testing="GRUB fallback directive"
grubTest grub.5 fallback/g5.1 --remove-kernel=/boot/vmlinuz-2.4.7-ac3 \
diff --git a/test/results/defaultkernel/g.1 b/test/results/defaultkernel/g.1
new file mode 100644
index 0000000..2c3ac11
--- /dev/null
+++ b/test/results/defaultkernel/g.1
@@ -0,0 +1 @@
+/boot/vmlinuz-2.4.7-2
diff --git a/test/results/defaultkernel/l1.1 b/test/results/defaultkernel/l1.1
new file mode 100644
index 0000000..fd22b1b
--- /dev/null
+++ b/test/results/defaultkernel/l1.1
@@ -0,0 +1 @@
+/boot/vmlinuz-2.4.18-4smp
diff --git a/test/results/defaultkernel/z.1 b/test/results/defaultkernel/z.1
new file mode 100644
index 0000000..2c62e98
--- /dev/null
+++ b/test/results/defaultkernel/z.1
@@ -0,0 +1 @@
+/boot/vmlinuz-2.4.9-37
diff --git a/test/results/defaulttitle/z.1 b/test/results/defaulttitle/z.1
new file mode 100644
index 0000000..a08e1f3
--- /dev/null
+++ b/test/results/defaulttitle/z.1
@@ -0,0 +1 @@
+linux
--
1.8.3.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。