[Parted-commits] GNU Parted Official Repository: Changes to 'master'
Jim Meyering
meyering at alioth.debian.org
Fri Oct 14 19:55:10 UTC 2011
parted/command.c | 4 ++--
parted/parted.c | 4 ++--
parted/strlist.c | 22 +++++++++++-----------
parted/strlist.h | 4 ++--
parted/ui.c | 12 ++++++------
tests/t0000-basic.sh | 2 +-
tests/t0203-gpt-tiny-device-abort.sh | 2 --
tests/t1100-busy-label.sh | 2 +-
tests/t7000-scripting.sh | 6 +++---
9 files changed, 28 insertions(+), 30 deletions(-)
New commits:
commit c774ea6bf4f3112c2a5c5d8458310697d21ddcf8
Author: Richard W.M. Jones <rjones at redhat.com>
Date: Wed Oct 12 21:54:24 2011 +0100
tests: fix the tests for the case where stdout/stderr is different
tests/t0000-basic.sh:
- More than one bogus ^M[[:space:]]*^M had to be removed, hence
use s,,,g sed expression.
tests/t0203-gpt-tiny-device-abort.sh:
- Test was not expecting any output to stderr. No longer true.
tests/t1100-busy-label.sh:
- Another case of s,,,g as above.
tests/t7000-scripting.sh:
- Only testing output to stdout. Fold stdout & stderr together
and test both.
- Another case of s,,,g as above.
Some root tests still fail even with these fixes. The failures appear
to be unrelated to these changes.
diff --git a/tests/t0000-basic.sh b/tests/t0000-basic.sh
index 4d6deeb..d07177e 100755
--- a/tests/t0000-basic.sh
+++ b/tests/t0000-basic.sh
@@ -61,7 +61,7 @@ parted ---pretend-input-tty $dev mklabel msdos < in > out 2>&1 || fail=1
# Transform the actual output, to avoid spurious differences when
# $PWD contains a symlink-to-dir. Also, remove the ^M ...^M bogosity.
# normalize the actual output
-mv out o2 && sed -e "s,on /.*/$dev,on DEVICE,;s,
*
,,;s, $,," \
+mv out o2 && sed -e "s,on /.*/$dev,on DEVICE,;s,
*
,,g;s, $,," \
-e "s,^.*/lt-parted: ,parted: ," o2 > out
# Create expected output file.
diff --git a/tests/t0203-gpt-tiny-device-abort.sh b/tests/t0203-gpt-tiny-device-abort.sh
index 22c8b21..690f286 100644
--- a/tests/t0203-gpt-tiny-device-abort.sh
+++ b/tests/t0203-gpt-tiny-device-abort.sh
@@ -37,8 +37,6 @@ for i in 33 34 35 67 68 69 101 102 103; do
printf 'i\no\n' > in
parted ---pretend-input-tty bad u s p < in > out 2> err || fail=1
# don't bother comparing stdout
- # expect no stderr
- compare err /dev/null || fail=1
done
Exit $fail
diff --git a/tests/t1100-busy-label.sh b/tests/t1100-busy-label.sh
index f388308..b88adaa 100755
--- a/tests/t1100-busy-label.sh
+++ b/tests/t1100-busy-label.sh
@@ -74,7 +74,7 @@ EOF
# Transform the actual output, removing ^M ...^M.
# normalize the actual output
-mv out o2 && sed -e 's,
*
,,;s, $,,;s/^.*Warning/Warning/' \
+mv out o2 && sed -e 's,
*
,,g;s, $,,;s/^.*Warning/Warning/' \
-e 's,^.*/lt-parted: ,parted: ,' o2 > out
# check for expected failure diagnostic
diff --git a/tests/t7000-scripting.sh b/tests/t7000-scripting.sh
index 20b7d9f..1b93a58 100755
--- a/tests/t7000-scripting.sh
+++ b/tests/t7000-scripting.sh
@@ -47,7 +47,7 @@ for mkpart in mkpart; do
dd if=/dev/zero of=testfile bs=${ss}c count=$N 2> /dev/null || fail=1
# Test the scripting mode of $mkpart.
- parted -s testfile -- mklabel gpt "$mkpart" primary ext3 1s -1s > out
+ parted -s testfile -- mklabel gpt "$mkpart" primary ext3 1s -1s > out 2>&1
test $? = 1 || fail=1
# Compare the real error and the expected one
@@ -61,12 +61,12 @@ for mkpart in mkpart; do
# Test the interactive mode of $mkpart
echo n | \
parted ---pretend-input-tty testfile \
- "mklabel gpt '$mkpart' primary ext3 1s -1s" > out && fail=1
+ "mklabel gpt '$mkpart' primary ext3 1s -1s" > out 2>&1 && fail=1
# We have to format the output before comparing.
# normalize the actual output
printf x >> out || fail=1
- sed "s,
*
,,;s, x$,,;/ n$/ {N;s, n\nx,,}" out > o2 && mv -f o2 out \
+ sed "s,
*
,,g;s, x$,,;/ n$/ {N;s, n\nx,,}" out > o2 && mv -f o2 out \
|| fail=1
normalize_part_diag_ out || fail=1
commit f09c0b86bbdf3a3bf51c1b826b3e1c46514feb58
Author: Richard W.M. Jones <rjones at redhat.com>
Date: Wed Oct 12 22:16:35 2011 +0100
parted: write a few errors and warnings to stderr instead of stdout
diff --git a/parted/parted.c b/parted/parted.c
index b381768..87f30eb 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1930,8 +1930,8 @@ if (!opt_script_mode)
#ifdef HAVE_GETUID
if (getuid() != 0 && !opt_script_mode) {
- puts (_("WARNING: You are not superuser. Watch out for "
- "permissions."));
+ fputs (_("WARNING: You are not superuser. Watch out for "
+ "permissions.\n"), stderr);
}
#endif
diff --git a/parted/strlist.c b/parted/strlist.c
index 54ff8c8..46ef307 100644
--- a/parted/strlist.c
+++ b/parted/strlist.c
@@ -119,7 +119,7 @@ gettext_to_wchar (const char* str)
return result;
error:
- printf ("Error during translation: %s\n", strerror (errno));
+ fprintf (stderr, "Error during translation: %s\n", strerror (errno));
exit (EXIT_FAILURE);
}
@@ -168,7 +168,7 @@ wchar_to_str (const wchar_t* str, size_t count)
return result;
error:
- printf ("Error during translation: %s\n", strerror (errno));
+ fprintf (stderr, "Error during translation: %s\n", strerror (errno));
exit (EXIT_FAILURE);
}
diff --git a/parted/ui.c b/parted/ui.c
index 56c0304..77bb24c 100644
--- a/parted/ui.c
+++ b/parted/ui.c
@@ -340,7 +340,7 @@ sa_sigint_handler (int signum, siginfo_t* info, void *ucontext)
static void
sa_sigsegv_handler (int signum, siginfo_t* info, void* ucontext)
{
- printf (bug_msg, VERSION);
+ fprintf (stderr, bug_msg, VERSION);
_dump_history ();
if (!info)
@@ -375,7 +375,7 @@ sa_sigsegv_handler (int signum, siginfo_t* info, void* ucontext)
static void
sa_sigfpe_handler (int signum, siginfo_t* info, void* ucontext)
{
- printf (bug_msg, VERSION);
+ fprintf (stderr, bug_msg, VERSION);
_dump_history ();
if (!info)
@@ -439,7 +439,7 @@ sa_sigfpe_handler (int signum, siginfo_t* info, void* ucontext)
static void
sa_sigill_handler (int signum, siginfo_t* info, void* ucontext)
{
- printf (bug_msg, VERSION);
+ fprintf (stderr, bug_msg, VERSION);
_dump_history ();
if (!info)
@@ -617,7 +617,7 @@ _print_exception_text (PedException* ex)
wipe_line ();
if (ex->type == PED_EXCEPTION_BUG) {
- printf (bug_msg, VERSION);
+ fprintf (stderr, bug_msg, VERSION);
text = str_list_create ("\n", ex->message, "\n\n", NULL);
} else {
text = str_list_create (
commit fae153a5d7c1c029ab600ac60d47e2d3c86b6976
Author: Richard W.M. Jones <rjones at redhat.com>
Date: Wed Oct 12 22:16:34 2011 +0100
parted: strlist print functions can now send output to any FILE *
This changes the two strlist print functions so that instead of just
sending output to stdout, they can send it to any FILE *. Now the
caller can send errors to stderr instead of stdout.
diff --git a/parted/command.c b/parted/command.c
index 5a05854..2c31efb 100644
--- a/parted/command.c
+++ b/parted/command.c
@@ -119,7 +119,7 @@ void
command_print_summary (Command* cmd)
{
fputs (" ", stdout);
- str_list_print_wrap (cmd->summary, screen_width(), 2, 8);
+ str_list_print_wrap (cmd->summary, screen_width(), 2, 8, stdout);
putchar ('\n');
}
@@ -129,7 +129,7 @@ command_print_help (Command* cmd)
command_print_summary (cmd);
if (cmd->help) {
fputs ("\n\t", stdout);
- str_list_print_wrap (cmd->help, screen_width(), 8, 8);
+ str_list_print_wrap (cmd->help, screen_width(), 8, 8, stdout);
}
}
diff --git a/parted/strlist.c b/parted/strlist.c
index 798d5ae..54ff8c8 100644
--- a/parted/strlist.c
+++ b/parted/strlist.c
@@ -188,10 +188,10 @@ wchar_to_str (const wchar_t* str, size_t count)
#endif /* !ENABLE_NLS */
static void
-print_wchar (const wchar_t* str, size_t count)
+print_wchar (const wchar_t* str, size_t count, FILE *fp)
{
char* tmp = wchar_to_str (str, count);
- printf ("%s", tmp);
+ fprintf (fp, "%s", tmp);
free (tmp);
}
@@ -373,13 +373,13 @@ str_list_convert (const StrList* list)
}
void
-str_list_print (const StrList* list)
+str_list_print (const StrList* list, FILE *fp)
{
const StrList* walk;
for (walk=list; walk; walk=walk->next) {
if (walk->str)
- print_wchar (walk->str, 0);
+ print_wchar (walk->str, 0, fp);
}
}
@@ -430,7 +430,7 @@ is_space (wchar_t c)
void
str_list_print_wrap (const StrList* list, int line_length, int offset,
- int indent)
+ int indent, FILE *fp)
{
const StrList* walk;
const wchar_t* str;
@@ -481,19 +481,19 @@ str_list_print_wrap (const StrList* list, int line_length, int offset,
cut_right++);
if (cut_left > 0)
- print_wchar (str, cut_left + 1);
+ print_wchar (str, cut_left + 1, fp);
str += cut_right;
str_len -= cut_right;
line_left = line_length - indent;
if (walk->next || *str)
- printf ("\n%*s", indent, "");
+ fprintf (fp, "\n%*s", indent, "");
else if (line_break)
- putchar ('\n');
+ fputc ('\n', fp);
}
- print_wchar (str, 0);
+ print_wchar (str, 0, fp);
line_left -= wchar_strlen (str);
}
}
diff --git a/parted/strlist.h b/parted/strlist.h
index 32ad8cc..7fe9bf3 100644
--- a/parted/strlist.h
+++ b/parted/strlist.h
@@ -53,9 +53,9 @@ extern StrList* str_list_join (StrList* a, StrList* b);
extern char* str_list_convert (const StrList* list);
extern char* str_list_convert_node (const StrList* list);
-extern void str_list_print (const StrList* list);
+extern void str_list_print (const StrList* list, FILE *fp);
extern void str_list_print_wrap (const StrList* list, int line_length,
- int offset, int indent);
+ int offset, int indent, FILE *fp);
extern int str_list_match_any (const StrList* list, const char* str);
extern int str_list_match_node (const StrList* list, const char* str);
extern StrList* str_list_match (const StrList* list, const char* str);
diff --git a/parted/ui.c b/parted/ui.c
index 6d2fde1..56c0304 100644
--- a/parted/ui.c
+++ b/parted/ui.c
@@ -625,7 +625,7 @@ _print_exception_text (PedException* ex)
": ", ex->message, "\n", NULL);
}
- str_list_print_wrap (text, screen_width (), 0, 0);
+ str_list_print_wrap (text, screen_width (), 0, 0, stderr);
str_list_destroy (text);
}
@@ -1541,7 +1541,7 @@ interactive_mode (PedDevice** dev, Command* cmd_list[])
print_using_dev (*dev);
list = str_list_create (_(banner_msg), NULL);
- str_list_print_wrap (list, screen_width (), 0, 0);
+ str_list_print_wrap (list, screen_width (), 0, 0, stdout);
str_list_destroy (list);
while (1) {
More information about the Parted-commits
mailing list