Compare commits

...

No commits in common. "c8" and "c10s" have entirely different histories.
c8 ... c10s

43 changed files with 1744 additions and 350 deletions

1
.fmf/version Normal file
View File

@ -0,0 +1 @@
1

8
.gitignore vendored
View File

@ -1 +1,7 @@
SOURCES/sed-4.5.tar.xz
sed-4.2.1.tar.bz2
/sed-4.2.2.tar.bz2
/sed-4.3.tar.xz
/sed-4.4.tar.xz
/sed-4.5.tar.xz
/sed-4.8.tar.xz
/sed-4.9.tar.xz

View File

@ -1 +0,0 @@
6635c344956ef928cc33aca798ad20c6c1ea25f7 SOURCES/sed-4.5.tar.xz

View File

@ -1,281 +0,0 @@
diff -urN sed-4.3/sed/execute.c sed-4.3.new00/sed/execute.c
--- sed-4.3/sed/execute.c 2012-03-16 10:13:31.000000000 +0100
+++ sed-4.3.new00/sed/execute.c 2014-02-10 14:40:25.603629422 +0100
@@ -703,11 +703,13 @@
if (strcmp(in_place_extension, "*") != 0)
{
char *backup_file_name = get_backup_file_name(target_name);
- ck_rename (target_name, backup_file_name, input->out_file_name);
+ (copy_instead_of_rename?ck_fccopy:ck_rename)
+ (target_name, backup_file_name, input->out_file_name);
free (backup_file_name);
}
- ck_rename (input->out_file_name, target_name, input->out_file_name);
+ (copy_instead_of_rename?ck_fcmove:ck_rename)
+ (input->out_file_name, target_name, input->out_file_name);
cancel_cleanup ();
free (input->out_file_name);
}
diff -urN sed-4.3/sed/sed.c sed-4.3.new00/sed/sed.c
--- sed-4.3/sed/sed.c 2012-03-16 10:13:31.000000000 +0100
+++ sed-4.3.new00/sed/sed.c 2014-02-10 17:37:19.381273509 +0100
@@ -56,6 +56,10 @@
/* How do we edit files in-place? (we don't if NULL) */
char *in_place_extension = NULL;
+ /* Do we use copy or rename when in in-place edit mode? (boolean
+ value, non-zero for copy, zero for rename).*/
+ int copy_instead_of_rename = 0;
+
/* The mode to use to read/write files, either "r"/"w" or "rb"/"wb". */
char const *read_mode = "r";
char const *write_mode = "w";
@@ -117,11 +121,16 @@
fprintf(out, _(" -i[SUFFIX], --in-place[=SUFFIX]\n\
edit files in place (makes backup if SUFFIX supplied)\n"));
-#if defined WIN32 || defined _WIN32 || defined __CYGWIN__ \
- || defined MSDOS || defined __EMX__
- fprintf(out, _(" -b, --binary\n\
- open files in binary mode (CR+LFs are not" \
- " processed specially)\n"));
+ fprintf(out, _(" -c, --copy\n\
+ use copy instead of rename when shuffling files in -i mode\n"));
+ fprintf(out, _(" -b, --binary\n"
+#if ! ( defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(MSDOS) || defined(__EMX__) )
+" does nothing; for compatibility with WIN32/CYGWIN/MSDOS/EMX (\n"
+#endif
+" open files in binary mode (CR+LFs are not treated specially)"
+#if ! ( defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(MSDOS) || defined(__EMX__) )
+ ")"
#endif
+ "\n"));
fprintf(out, _(" -l N, --line-length=N\n\
specify the desired line-wrap length for the `l' command\n"));
fprintf(out, _(" --posix\n\
@@ -138,8 +149,10 @@
the output buffers more often\n"));
fprintf(out, _(" -z, --null-data\n\
separate lines by NUL characters\n"));
- fprintf(out, _(" --help display this help and exit\n"));
- fprintf(out, _(" --version output version information and exit\n"));
+ fprintf(out, _(" --help\n\
+ display this help and exit\n"));
+ fprintf(out, _(" --version\n\
+ output version information and exit\n"));
fprintf(out, _("\n\
If no -e, --expression, -f, or --file option is given, then the first\n\
non-option argument is taken as the sed script to interpret. All\n\
@@ -158,9 +171,9 @@
main (int argc, char **argv)
{
#ifdef REG_PERL
-#define SHORTOPTS "bsnrzRuEe:f:l:i::V:"
+#define SHORTOPTS "bcsnrzRuEe:f:l:i::"
#else
-#define SHORTOPTS "bsnrzuEe:f:l:i::V:"
+#define SHORTOPTS "bcsnrzuEe:f:l:i::"
#endif
enum { SANDBOX_OPTION = CHAR_MAX+1 };
@@ -172,6 +185,7 @@
{"expression", 1, NULL, 'e'},
{"file", 1, NULL, 'f'},
{"in-place", 2, NULL, 'i'},
+ {"copy", 0, NULL, 'c'},
{"line-length", 1, NULL, 'l'},
{"null-data", 0, NULL, 'z'},
{"zero-terminated", 0, NULL, 'z'},
@@ -246,6 +260,10 @@
follow_symlinks = true;
break;
+ case 'c':
+ copy_instead_of_rename = true;
+ break;
+
case 'i':
separate_files = true;
if (optarg == NULL)
@@ -272,9 +290,11 @@
posixicity = POSIXLY_BASIC;
break;
- case 'b':
+ case 'b':
+#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(MSDOS) || defined(__EMX__)
read_mode = "rb";
write_mode = "wb";
+#endif
break;
case 'E':
@@ -314,6 +334,12 @@
}
}
+ if (copy_instead_of_rename && in_place_extension == NULL)
+ {
+ fprintf (stderr, _("Error: -c used without -i.\n"));
+ usage(4);
+ }
+
if (!the_program)
{
if (optind < argc)
diff -urN sed-4.3/sed/sed.h sed-4.3.new00/sed/sed.h
--- sed-4.3/sed/sed.h 2012-07-25 12:33:09.000000000 +0200
+++ sed-4.3.new00/sed/sed.h 2014-02-10 14:40:25.602629419 +0100
@@ -230,6 +230,10 @@
/* How do we edit files in-place? (we don't if NULL) */
extern char *in_place_extension;
+/* Do we use copy or rename when in in-place edit mode? (boolean
+ value, non-zero for copy, zero for rename).*/
+extern int copy_instead_of_rename;
+
/* The mode to use to read and write files, either "rt"/"w" or "rb"/"wb". */
extern char const *read_mode;
extern char const *write_mode;
diff -urN sed-4.3/sed/utils.c sed-4.3.new00/sed/utils.c
--- sed-4.3/sed/utils.c 2012-03-16 10:13:31.000000000 +0100
+++ sed-4.3.new00/sed/utils.c 2014-02-10 14:40:25.603629422 +0100
@@ -27,6 +27,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include <limits.h>
+#include <fcntl.h>
#include "unlocked-io.h"
#include "utils.h"
@@ -363,31 +364,106 @@
#endif /* ENABLE_FOLLOW_SYMLINKS */
}
-/* Panic on failing rename */
+/* Panic on failing unlink */
void
-ck_rename (const char *from, const char *to, const char *unlink_if_fail)
+ck_unlink (const char *name)
{
- int rd = rename (from, to);
- if (rd != -1)
- return;
+ if (unlink (name) == -1)
+ panic (_("cannot remove %s: %s"), name, strerror (errno));
+}
- if (unlink_if_fail)
+/* Attempt to unlink denoted file if operation rd failed. */
+static int
+_unlink_if_fail (rd, unlink_if_fail)
+ int rd;
+ const char *unlink_if_fail;
+{
+ if (rd == -1 && unlink_if_fail)
{
int save_errno = errno;
+ ck_unlink (unlink_if_fail);
+ errno = save_errno;
+ }
+
+ return rd != -1;
+}
+
+/* Copy contents between files. */
+static int
+_copy (from, to)
+ const char *from, *to;
+{
+ static char buf[4096];
+
+ FILE *infile, *outfile;
+ int c, retval = 0;
errno = 0;
- unlink (unlink_if_fail);
- /* Failure to remove the temporary file is more severe,
- so trigger it first. */
- if (errno != 0)
- panic (_("cannot remove %s: %s"), unlink_if_fail, strerror (errno));
+ infile = fopen (from, "r");
+ if (infile == NULL)
+ return -1;
- errno = save_errno;
+ outfile = fopen (to, "w");
+ if (outfile == NULL)
+ {
+ fclose (infile);
+ return -1;
+ }
+
+ while (1)
+ {
+ size_t bytes_in = fread (buf, 1, sizeof (buf), infile);
+ size_t bytes_out;
+ if (bytes_in == 0)
+ {
+ if (ferror (infile))
+ retval = -1;
+ break;
+ }
+
+ bytes_out = fwrite (buf, 1, bytes_in, outfile);
+ if (bytes_out != bytes_in)
+ {
+ retval = -1;
+ break;
+ }
}
+ fclose (outfile);
+ fclose (infile);
+
+ return retval;
+}
+
+/* Panic on failing rename */
+void
+ck_rename (from, to, unlink_if_fail)
+ const char *from, *to;
+ const char *unlink_if_fail;
+{
+ if (!_unlink_if_fail (rename (from, to), unlink_if_fail))
panic (_("cannot rename %s: %s"), from, strerror (errno));
}
+/* Attempt to copy file contents between the files. */
+void
+ck_fccopy (from, to, unlink_if_fail)
+ const char *from, *to;
+ const char *unlink_if_fail;
+{
+ if (!_unlink_if_fail (_copy (from, to), unlink_if_fail))
+ panic (_("cannot copy %s to %s: %s"), from, to, strerror (errno));
+}
+
+/* Copy contents between files, and then unlink the source. */
+void
+ck_fcmove (from, to, unlink_if_fail)
+ const char *from, *to;
+ const char *unlink_if_fail;
+{
+ ck_fccopy (from, to, unlink_if_fail);
+ ck_unlink (from);
+}
diff -urN sed-4.3/sed/utils.h sed-4.3.new00/sed/utils.h
--- sed-4.3/sed/utils.h 2012-03-16 10:13:31.000000000 +0100
+++ sed-4.3.new00/sed/utils.h 2014-02-10 14:40:25.603629422 +0100
@@ -33,6 +33,8 @@
FILE * ck_mkstemp (char **p_filename, const char *tmpdir, const char *base,
const char *mode) _GL_ARG_NONNULL ((1, 2, 3, 4));
void ck_rename (const char *from, const char *to, const char *unlink_if_fail);
+void ck_fccopy (const char *from, const char *to, const char *unlink_if_fail);
+void ck_fcmove (const char *from, const char *to, const char *unlink_if_fail);
void *ck_malloc (size_t size);
void *xmalloc (size_t size);

View File

@ -1,13 +0,0 @@
diff --git a/sed/utils.c b/sed/utils.c
index 4028d98..2e74654 100644
--- a/sed/utils.c
+++ b/sed/utils.c
@@ -181,7 +181,7 @@ ck_mkstemp (char **p_filename, const char *tmpdir,
/* The ownership might change, so omit some permissions at first
so unauthorized users cannot nip in before the file is ready.
mkstemp forces O_BINARY on cygwin, so use mkostemp instead. */
- mode_t save_umask = umask (0700);
+ mode_t save_umask = umask (0077);
int fd = mkostemp (template, 0);
umask (save_umask);
if (fd == -1)

View File

@ -1,12 +0,0 @@
--- a/sed-4.5/testsuite/inplace-selinux.sh 2018-03-31 06:33:01.000000000 +0200
+++ b/sed-4.5/testsuite/inplace-selinux.sh 2021-10-05 17:10:32.259956822 +0200
@@ -24,6 +24,9 @@
chcon -u system_u a || skip_ "chcon doesn't work"
chcon -u user_u a || skip_ "chcon doesn't work"
+cp --preserve=context ./a ./b 2>&1 | grep "cannot preserve security context" >/dev/null && skip_ "cannot preserve security context without an SELinux-enabled kernel"
+
+
# Create the first file and symlink pointing at it.
echo "Hello World" > inplace-selinux-file || framework_failure_
ln -s ./inplace-selinux-file inplace-selinux-link || framework_failure_

11
STAGE1-sed Normal file
View File

@ -0,0 +1,11 @@
srpm $1
mcd $BUILDDIR/$1
$SRC/${1}-*/configure $TCONFIGARGS
notparallel
# Touch sed.1 so that it will not be built.
# The makefile in the sed/doc directory attempts to run the
# built sed binary in order to extract the --help output, but
# this fails because the sed binary is a cross-tool.
touch doc/sed.1
make $J V=1
make $J install DESTDIR=${ROOTFS}

2
ci.fmf Normal file
View File

@ -0,0 +1,2 @@
# Docs: https://docs.fedoraproject.org/en-US/ci/tmt/#_multiple_plans
resultsdb-testcase: separate

6
gating.yaml Normal file
View File

@ -0,0 +1,6 @@
--- !Policy
product_versions:
- rhel-*
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build./plans/tier1-internal.functional}

9
plans.fmf Normal file
View File

@ -0,0 +1,9 @@
/tier1-internal:
discover:
how: fmf
url: https://gitlab.com/redhat/rhel/tests/sed.git
execute:
how: tmt
adjust:
enabled: false
when: distro == centos-stream or distro == fedora

30
sed-b-flag.patch Normal file
View File

@ -0,0 +1,30 @@
From f40556883a40ed7aaa4f44c9c9c95215c95eab9f Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Tue, 30 Jan 2024 10:31:57 +0100
Subject: [PATCH 1/3] enable the -b option on all platforms
Content-Type: text/plain; charset=UTF-8
---
sed/sed.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/sed/sed.c b/sed/sed.c
index af83065..bdf590b 100644
--- a/sed/sed.c
+++ b/sed/sed.c
@@ -153,7 +153,12 @@ Usage: %s [OPTION]... {script-only-if-no-other-script} [input-file]...\n\
fprintf (out, _(" -b, --binary\n\
open files in binary mode (CR+LFs are not" \
" processed specially)\n"));
+#else
+ fprintf (out, _(" -b, --binary\n\
+ does nothing; for compatibility with WIN32/CYGWIN/MSDOS/EMX \n\
+ (open files in binary mode; CR+LF are not processed specially)\n" ));
#endif
+
fprintf (out, _(" -l N, --line-length=N\n\
specify the desired line-wrap length for the `l' command\n"));
fprintf (out, _(" --posix\n\
--
2.43.0

226
sed-c-flag.patch Normal file
View File

@ -0,0 +1,226 @@
From 100738652ca35e39f21742b8c54c1181efb38a0f Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Tue, 30 Jan 2024 10:38:50 +0100
Subject: [PATCH 2/3] -c flag
Content-Type: text/plain; charset=UTF-8
---
sed/execute.c | 10 ++++--
sed/sed.c | 20 +++++++++++-
sed/sed.h | 4 +++
sed/utils.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++
sed/utils.h | 2 ++
5 files changed, 119 insertions(+), 3 deletions(-)
diff --git a/sed/execute.c b/sed/execute.c
index 485bca7..8d0cde7 100644
--- a/sed/execute.c
+++ b/sed/execute.c
@@ -673,11 +673,17 @@ closedown (struct input *input)
if (strcmp (in_place_extension, "*") != 0)
{
char *backup_file_name = get_backup_file_name (target_name);
- ck_rename (target_name, backup_file_name);
+ if (copy_instead_of_rename)
+ ck_fccopy (target_name, backup_file_name);
+ else
+ ck_rename (target_name, backup_file_name);
free (backup_file_name);
}
- ck_rename (input->out_file_name, target_name);
+ if (copy_instead_of_rename)
+ ck_fcmove (input->out_file_name, target_name);
+ else
+ ck_rename (input->out_file_name, target_name);
cancel_cleanup ();
free (input->out_file_name);
}
diff --git a/sed/sed.c b/sed/sed.c
index bdf590b..cebef70 100644
--- a/sed/sed.c
+++ b/sed/sed.c
@@ -67,6 +67,10 @@ bool debug = false;
/* How do we edit files in-place? (we don't if NULL) */
char *in_place_extension = NULL;
+/* Do we use copy or rename when in in-place edit mode? (boolean
+ + value, non-zero for copy, zero for rename).*/
+int copy_instead_of_rename = 0;
+
/* The mode to use to read/write files, either "r"/"w" or "rb"/"wb". */
char const *read_mode = "r";
char const *write_mode = "w";
@@ -149,6 +153,10 @@ Usage: %s [OPTION]... {script-only-if-no-other-script} [input-file]...\n\
#endif
fprintf (out, _(" -i[SUFFIX], --in-place[=SUFFIX]\n\
edit files in place (makes backup if SUFFIX supplied)\n"));
+
+ fprintf(out, _(" -c, --copy\n\
+ use copy instead of rename when shuffling files in -i mode\n"));
+
#if O_BINARY
fprintf (out, _(" -b, --binary\n\
open files in binary mode (CR+LFs are not" \
@@ -193,7 +201,7 @@ specified, then the standard input is read.\n\
int
main (int argc, char **argv)
{
-#define SHORTOPTS "bsnrzuEe:f:l:i::V:"
+#define SHORTOPTS "bcsnrzuEe:f:l:i::V:"
enum { SANDBOX_OPTION = CHAR_MAX+1,
DEBUG_OPTION
@@ -207,6 +215,7 @@ main (int argc, char **argv)
{"file", 1, NULL, 'f'},
{"in-place", 2, NULL, 'i'},
{"line-length", 1, NULL, 'l'},
+ {"copy", 0, NULL, 'c'},
{"null-data", 0, NULL, 'z'},
{"zero-terminated", 0, NULL, 'z'},
{"quiet", 0, NULL, 'n'},
@@ -285,6 +294,10 @@ main (int argc, char **argv)
follow_symlinks = true;
break;
+ case 'c':
+ copy_instead_of_rename = true;
+ break;
+
case 'i':
separate_files = true;
IF_LINT (free (in_place_extension));
@@ -355,6 +368,11 @@ main (int argc, char **argv)
}
}
+ if (copy_instead_of_rename && in_place_extension == NULL)
+ {
+ fprintf (stderr, _("Error: -c used without -i.\n"));
+ usage(4);
+ }
if (!the_program)
{
if (optind < argc)
diff --git a/sed/sed.h b/sed/sed.h
index 1c96bc5..2de60ae 100644
--- a/sed/sed.h
+++ b/sed/sed.h
@@ -241,6 +241,10 @@ extern countT lcmd_out_line_len;
/* How do we edit files in-place? (we don't if NULL) */
extern char *in_place_extension;
+/* Do we use copy or rename when in in-place edit mode? (boolean
+ value, non-zero for copy, zero for rename).*/
+extern int copy_instead_of_rename;
+
/* The mode to use to read and write files, either "rt"/"w" or "rb"/"wb". */
extern char const *read_mode;
extern char const *write_mode;
diff --git a/sed/utils.c b/sed/utils.c
index 4bd6587..05f7a44 100644
--- a/sed/utils.c
+++ b/sed/utils.c
@@ -25,6 +25,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include <limits.h>
+#include <fcntl.h>
#include "binary-io.h"
#include "eloop-threshold.h"
@@ -408,7 +409,78 @@ ck_rename (const char *from, const char *to)
panic (_("cannot rename %s: %s"), from, strerror (errno));
}
+/* Downstream -c related functions */
+/* Panic on failing unlink */
+void
+ck_unlink (const char *name)
+{
+ if (unlink (name) == -1)
+ panic (_("cannot remove %s: %s"), name, strerror (errno));
+}
+
+/* Copy contents between files. */
+static int
+_copy (from, to)
+ const char *from, *to;
+{
+ static char buf[4096];
+
+ FILE *infile, *outfile;
+ int retval = 0;
+ errno = 0;
+
+ infile = fopen (from, "r");
+ if (infile == NULL)
+ return -1;
+
+ outfile = fopen (to, "w");
+ if (outfile == NULL)
+ {
+ fclose (infile);
+ return -1;
+ }
+
+ while (1)
+ {
+ size_t bytes_in = fread (buf, 1, sizeof (buf), infile);
+ size_t bytes_out;
+ if (bytes_in == 0)
+ {
+ if (ferror (infile))
+ retval = -1;
+ break;
+ }
+
+ bytes_out = fwrite (buf, 1, bytes_in, outfile);
+ if (bytes_out != bytes_in)
+ {
+ retval = -1;
+ break;
+ }
+ }
+
+ fclose (outfile);
+ fclose (infile);
+
+ return retval;
+}
+
+/* Attempt to copy file contents between the files. */
+void
+ck_fccopy (const char *from, const char *to)
+{
+ if (_copy (from, to) == -1)
+ panic (_("cannot copy %s to %s: %s"), from, to, strerror (errno));
+}
+
+/* Copy contents between files, and then unlink the source. */
+void
+ck_fcmove (const char *from, const char *to)
+{
+ ck_fccopy (from, to);
+ ck_unlink (from);
+}
/* Implement a variable sized buffer of `stuff'. We don't know what it is,
diff --git a/sed/utils.h b/sed/utils.h
index cac8a05..93bbcf2 100644
--- a/sed/utils.h
+++ b/sed/utils.h
@@ -41,6 +41,8 @@ size_t ck_getdelim (char **text, size_t *buflen, char buffer_delimiter,
FILE * ck_mkstemp (char **p_filename, const char *tmpdir, const char *base,
const char *mode) _GL_ARG_NONNULL ((1, 2, 3, 4));
void ck_rename (const char *from, const char *to);
+void ck_fccopy (const char *from, const char *to);
+void ck_fcmove (const char *from, const char *to);
void *ck_malloc (size_t size);
void *ck_realloc (void *ptr, size_t size);
--
2.43.0

View File

@ -0,0 +1,46 @@
From 7dbe9c0c2b3f2cac602ce352cad11dab4defe896 Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Tue, 30 Jan 2024 10:41:40 +0100
Subject: [PATCH 3/3] covscan annotations
Content-Type: text/plain; charset=UTF-8
---
lib/malloca.c | 1 +
sed/compile.c | 2 ++
2 files changed, 3 insertions(+)
diff --git a/lib/malloca.c b/lib/malloca.c
index 1e19978..11783b4 100644
--- a/lib/malloca.c
+++ b/lib/malloca.c
@@ -71,6 +71,7 @@ mmalloca (size_t n)
[mem, mem + nplus). */
p[-1] = offset;
/* p ≡ sa_alignment_max mod 2*sa_alignment_max. */
+ /* cppcheck-suppress memleak */
return p;
}
}
diff --git a/sed/compile.c b/sed/compile.c
index f96fbca..52759a5 100644
--- a/sed/compile.c
+++ b/sed/compile.c
@@ -830,6 +830,7 @@ setup_replacement (struct subst *sub, const char *text, size_t length)
tail->next = NULL;
sub->replacement = root.next;
+ /* coverity [leaked_storage] */
}
static void
@@ -1328,6 +1329,7 @@ compile_program (struct vector *vector)
bad_prog (_(Y_CMD_LEN));
IF_LINT (free (src_lens));
+ /* coverity [leaked_storage] */
}
else
{
--
2.43.0

View File

@ -0,0 +1,25 @@
From 2d1641d76c0254e3c95f461d9a0fd080e0f29c3c Mon Sep 17 00:00:00 2001
From: Jakub Martisko <jamartis@redhat.com>
Date: Fri, 23 Jan 2026 13:21:41 +0100
Subject: [PATCH] increase tr count
---
lib/dfa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/dfa.c b/lib/dfa.c
index 0b694e1..d76e9ec 100644
--- a/lib/dfa.c
+++ b/lib/dfa.c
@@ -354,7 +354,7 @@ typedef struct
/* Maximum for any transition table count. This should be at least 3,
for the initial state setup. */
-enum { MAX_TRCOUNT = 1024 };
+enum { MAX_TRCOUNT = 2048 };
/* A bracket operator.
e.g., [a-c], [[:alpha:]], etc. */
--
2.52.0

View File

@ -2,20 +2,30 @@
Summary: A GNU stream text editor
Name: sed
Version: 4.5
Version: 4.9
Release: 5%{?dist}
License: GPLv3+
Group: Applications/Text
License: GPL-3.0-or-later
URL: http://sed.sourceforge.net/
Source0: ftp://ftp.gnu.org/pub/gnu/sed/sed-%{version}.tar.xz
Source1: http://sed.sourceforge.net/sedfaq.txt
Patch0: sed-4.2.2-binary_copy_args.patch
Patch2: sed-fuse.patch
Patch3: sed-selinux-testsuite.patch
BuildRequires: glibc-devel, libselinux-devel, libacl-devel, automake, autoconf
Patch0: sed-b-flag.patch
Patch1: sed-c-flag.patch
Patch2: sed-covscan-annotations.patch
Patch3: sed-regexp-cache-size.patch
BuildRequires: make
BuildRequires: glibc-devel, libselinux-devel, libacl-devel, automake, autoconf, gcc
BuildRequires: perl-Getopt-Long
Requires(post): /sbin/install-info
Requires(preun): /sbin/install-info
BuildRequires: perl(FileHandle)
# for tests. More tests require a ja_JP locale, but glibc-langpack-ja gives:
# invalid-mb-seq-UMR.sh: skipped test: locale 'ja_JP' is buggy
# mb-charclass-non-utf8.sh: skipped test: ja_JP shift-jis locale not found
BuildRequires: glibc-langpack-el, glibc-langpack-en
BuildRequires: glibc-langpack-ru
%ifarch %{valgrind_arches}
BuildRequires: valgrind
%endif
Provides: /bin/sed
@ -30,14 +40,11 @@ that sed performs (substitutions, deletions, insertions, etc.) can be
specified in a script file or from the command line.
%prep
%setup -q
%patch0 -p1 -b .copy
%patch2 -p1
%patch3 -p2
%autosetup -p1
%build
%configure --without-included-regex
make %{_smp_mflags}
%make_build
install -m 644 -p %{SOURCE1} sedfaq.txt
gzip -9 sedfaq.txt
@ -48,50 +55,118 @@ echo ====================TESTING END=====================
%install
rm -rf ${RPM_BUILD_ROOT}
make DESTDIR=$RPM_BUILD_ROOT install
%make_install
rm -f ${RPM_BUILD_ROOT}/%{_infodir}/dir
%find_lang %{name}
%post
/sbin/install-info %{_infodir}/sed.info.gz %{_infodir}/dir || &> /dev/null
:
%preun
if [ $1 = 0 ]; then
/sbin/install-info --delete %{_infodir}/sed.info.gz %{_infodir}/dir || &> /dev/null
fi
:
%files -f %{name}.lang
%defattr(-,root,root)
%{!?_licensedir:%global license %%doc}
%license COPYING
%doc BUGS NEWS THANKS README AUTHORS sedfaq.txt.gz
%{_bindir}/sed
%{_infodir}/*.info*
%{_mandir}/man*/*
%{_infodir}/sed.info*
%{_mandir}/man1/sed.1*
%changelog
* Tue Oct 05 2021 Jakub Martisko <jamartis@redhat.com> - 4.5-5
- Minor cleanup - remove unused patch from the spec file too (related to 4.5-3)
- Resolves: rhbz#1869253
* Fri Jan 23 2026 Jakub Martisko <jamartis@redhat.com> - 4.9-5
- lib/dfa.c: Increase the maximum size of the transitions table
- After changes introduced between sed 4.2 and 4.4, some regexps
started to hit the table size limits. This lead to repeated deletion
and rebuilding of the table, leading to massive performance drops.
While the core issue is still present, this change should at least
help by moving the threshold of the regexp complexity that triggers the
table rebuilds.
- Resolves: RHEL-144027
* Tue Oct 05 2021 Jakub Martisko <jamartis@redhat.com> - 4.5-4
- Skip selinux test when selinux is not working
- Resolves: rhbz#1905777
* Fri Apr 18 2025 David Abdurachmanov <davidlt@rivosinc.com> - 4.9-4
- Properly check valgrind arches (fixes riscv64 build)
Resolves: RHEL-87803
* Tue Oct 05 2021 Jakub Martisko <jamartis@redhat.com> - 4.5-3
- Minor cleanup - remove unused patch from the git
- Resolves: rhbz#1869253
* Tue Oct 29 2024 Troy Dawson <tdawson@redhat.com> - 4.9-3
- Bump release for October 2024 mass rebuild:
Resolves: RHEL-64018
* Mon May 18 2020 Jakub Martisko <jamartis@redhat.com> - 4.5-2
- fix "in-place edits on FUSE filesystems create files with all-zero mode bits"
- Resolves: #1835761
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 4.9-2
- Bump release for June 2024 mass rebuild
* Mon Apr 09 2018 Jakub Martisko <jamartis@redhat.com> - 4.5-1
* Tue Jan 30 2024 Paolo Bonzini <pbonzini@redhat.com> - 4.9-1
- Rebase to 4.9
- Update downstream patches
- Resolves: rhbz#2140486
- Remove change to gnulib tests, they pass anyway
- Install valgrind and langpacks to increase test coverage
* Sat Jan 27 2024 Fedora Release Engineering <releng@fedoraproject.org> - 4.8-15
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Sat Jul 22 2023 Fedora Release Engineering <releng@fedoraproject.org> - 4.8-14
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
* Tue Apr 11 2023 Lukáš Zaoral <lzaoral@redhat.com> - 4.8-13
- migrate to SPDX license format
* Sat Jan 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 4.8-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
* Sat Jul 23 2022 Fedora Release Engineering <releng@fedoraproject.org> - 4.8-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
* Sat Jan 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 4.8-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
* Tue Nov 16 2021 Jakub Martisko <jamartis@redhat.com> - 4.8-9
- Add annotations to disable false positives in the covscan
- Related: rhbz#1938867
* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 4.8-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 4.8-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Mon Aug 17 2020 Jakub Martisko <jamartis@redhat.com> - 4.8-6
- Minor spec cleanup
* Mon Aug 03 2020 Jakub Martisko <jamartis@redhat.com> - 4.8-5
- Use make macros
* Mon Aug 03 2020 Jakub Martisko <jamartis@redhat.com> - 4.8-4
- Replace some hardcoded constants in the gnulib-testsuite
... that caused build failures on arm7
* Sat Aug 01 2020 Fedora Release Engineering <releng@fedoraproject.org> - 4.8-3
- Second attempt - Rebuilt for
https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 4.8-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Tue Feb 11 2020 Jakub Martisko <jamartis@redhat.com> - 4.8-1
- Rebase to 4.8
- Refresh the downstream patch and split it into two
* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 4.5-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 4.5-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 4.5-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 4.5-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Tue Apr 03 2018 Jakub Martisko <jamartis@redhat.com> - 4.5-1
- Rebase to 4.5
- Drop patch from 4.4-4 (is included in the upstream archive)
- Drop patches from 4.4-4 and 4.4-7
* Thu Mar 08 2018 Jakub Martisko <jamartis@redhat.com> - 4.4-7
- Fix build failure with glibc-2.28
* Thu Mar 08 2018 Jakub Martisko <jamartis@redhat.com> - 4.4-6
- Add gcc to BuildRequires
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 4.4-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

1
sources Normal file
View File

@ -0,0 +1 @@
SHA512 (sed-4.9.tar.xz) = 36157a4b4a2430cf421b7bd07f1675d680d9f1616be96cf6ad6ee74a9ec0fe695f8d0b1e1f0b008bbb33cc7fcde5e1c456359bbbc63f8aebdd4fedc3982cf6dc

View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/sed/Regression/backup-file-not-cleared
# Description: Test for tmp file not clear after registered to rhevm
# Author: Petr Muller <pmuller@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2012 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/sed/Regression/backup-file-not-cleared
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
test -x runtest.sh || chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Petr Muller <pmuller@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test for tmp file not clear after registered to rhevm" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 5m" >> $(METADATA)
@echo "RunFor: sed" >> $(METADATA)
@echo "Requires: sed" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,4 @@
PURPOSE of /CoreOS/sed/Regression/backup-file-not-cleared
Description: Test for tmp file not clear after registered to rhevm
Author: Petr Muller <pmuller@redhat.com>
Bug summary: tmp file not clear after registered to rhevm

View File

@ -0,0 +1,106 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/sed/Regression/backup-file-not-cleared
# Description: Test for tmp file not clear after registered to rhevm
# Author: Petr Muller <pmuller@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2012 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh
PACKAGE="sed"
rlJournalStart
rlPhaseStartSetup
rlRun "mkdir TMP"
rlRun "cd TMP"
rlRun "echo 'some content' > somefile"
rlRun "echo 'changed content' > somefile-expected"
rlRun "touch filelist"
cat > filelist-golden << EOF
./filelist
./filelist-golden
./somefile
./somefile-expected
EOF
rlPhaseEnd
rlPhaseStartTest
rlRun "sed -i --copy 's/some/changed/' somefile"
rlRun "find . -type f | sort -f > filelist"
rlAssertNotDiffer filelist filelist-golden
if [ $? -ne 0 ]
then
rlLog "Differences found: "
diff -u filelist-golden filelist | while read line
do
rlLog "\"$line\""
done
fi
rlAssertNotDiffer somefile somefile-expected
if [ $? -ne 0 ]
then
rlLog "Differences found: "
diff -u somefile-expected somefile | while read line
do
rlLog "\"$line\""
done
fi
rlRun "rm -f sed*"
rlRun "echo 'some content' > somefile"
rlRun "sed -i-fxpected --copy 's/some/changed/' somefile"
rlRun "find . -type f | sort > filelist"
echo "./somefile-fxpected" >> filelist-golden
rlAssertExists somefile-fxpected
sort filelist-golden -o filelist-golden
rlAssertNotDiffer filelist filelist-golden
if [ $? -ne 0 ]
then
rlLog "Differences found: "
diff -u filelist-golden filelist | while read line
do
rlLog "\"$line\""
done
fi
rlAssertNotDiffer somefile somefile-expected
if [ $? -ne 0 ]
then
rlLog "Differences found: "
diff -u somefile-expected somefile | while read line
do
rlLog "\"$line\""
done
fi
rlPhaseEnd
rlPhaseStartCleanup
rlRun "cd .."
rlRun "rm -rf TMP"
rlPhaseEnd
rlJournalEnd

View File

@ -0,0 +1,49 @@
# The toplevel namespace within which the test lives.
TOPLEVEL_NAMESPACE=/CoreOS
# The name of the package under test:
PACKAGE_NAME=sed
# The path of the test below the package:
RELATIVE_PATH=handle-escapes-correctly
# Version of the Test. Used with make tag.
export TESTVERSION=1.1
# The compiled namespace of the test.
export TEST=$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH)
.PHONY: all install download clean
BUILT_FILES= # executables to be built should be added here, they will be generated on the system under test.
FILES=$(METADATA) runtest.sh Makefile handle-escapes-correctly.sh
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
chmod a+x ./runtest.sh
chmod a+x ./handle-escapes-correctly.sh
clean:
rm -f *~ $(BUILT_FILES)
# Include Common Makefile
include /usr/share/rhts/lib/rhts-make.include
# Generate the testinfo.desc here:
$(METADATA): Makefile
@touch $(METADATA)
@echo "Owner: Bastien Nocera <bnocera@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "License: RH Internal Test" >> $(METADATA)
@echo "Description: Tests if sed handles escapes correctly">> $(METADATA)
@echo "TestTime: 1m" >> $(METADATA)
@echo "RunFor: $(PACKAGE_NAME) " >> $(METADATA) # add any other packages for which your test ought to run here
@echo "Requires: $(PACKAGE_NAME) " >> $(METADATA) # add any other requirements for the script to run here
@echo "Priority: Normal" >> $(METADATA)
@echo "Type: Regression " >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,21 @@
#!/bin/bash
# Tests if sed handles escapes correctly
ACTUALFILE=`mktemp`
EXPECTEDFILE=`mktemp`
RETVAL=1
echo '' | sed -e ' i\\co' > $ACTUALFILE
printf '\x0f\n\n' > $EXPECTEDFILE
if diff $EXPECTEDFILE $ACTUALFILE > /dev/null; then
RETVAL=0
echo "Succeeded"
else
echo "Failed"
fi
rm -f $ACTUALFILE $EXPECTEDFILE
exit $RETVAL

View File

@ -0,0 +1,33 @@
#!/bin/sh
# Package: Package under test (will be used to get version info on executed
# tests). If RPM query results on PACKAGE are null, then pass value of
# PACKAGE variable for Version
PACKAGE=sed
# source the test script helpers
# BUG: This line is intentionally left commented out.
# When I have the helper packages installed the line below should be
# uncommented
. /usr/bin/rhts-environment.sh
# Commands in this section are provided by test developer.
# ---------------------------------------------
# Assume the test will pass.
result=PASS
# Run the acutal test and redirect the output to the log file
# So if need be we will have the debug info after the fact.
./handle-escapes-correctly.sh > $OUTPUTFILE
if [ $? -ne 0 ]; then
result=FAIL
fi
echo $result
# Then file the results in the database
#------------------------------------------------
report_result $TEST $result

View File

@ -0,0 +1,7 @@
- hosts: '{{ hosts | default("localhost") }}'
vars:
package: sed
OUTPUTFILE: ./outputfile
tasks:
- name: Runtest
script: "./handle-escapes-correctly.sh > {{ OUTPUTFILE }}"

3
tests/inventory Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
export TEST_DOCKER_EXTRA_ARGS="--privileged"
exec merge-standard-inventory "$@"

View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/sed/Regression/sed-does-not-handle-inline-edits-of-symlinks-with
# Description: Test for sed does not handle inline edits of symlinks with
# Author: Marek Polacek <mpolacek@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2011 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/sed/Regression/sed-does-not-handle-inline-edits-of-symlinks-with
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Marek Polacek <mpolacek@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test for sed does not handle inline edits of symlinks with" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 5m" >> $(METADATA)
@echo "RunFor: sed" >> $(METADATA)
@echo "Requires: sed" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,34 @@
PURPOSE of /CoreOS/sed/Regression/sed-does-not-handle-inline-edits-of-symlinks-with
Description: Test for sed does not handle inline edits of symlinks with
Author: Marek Polacek <mpolacek@redhat.com>
Bug summary: sed does not handle inline edits of symlinks with no dir portion
Description:
Description of problem:
When executing on a symlink in present working directory, sed does not build the original path correctly, thus failing to follow the symlink.
Version-Release number of selected component (if applicable):
sed-4.1.5-5.fc6
How reproducible:
Always.
Steps to Reproduce:
1. echo "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" >1
2. ln -s 1 2
3. sed -i -e 's/z/a/g' 2
Actual results:
sed: ck_follow_symlink: couldn't lstat 2/1: Not a directory
Expected results:
All z's in the file should be replaced with a's.
Additional info:

View File

@ -0,0 +1,56 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/sed/Regression/sed-does-not-handle-inline-edits-of-symlinks-with
# Description: Test for sed does not handle inline edits of symlinks with
# Author: Marek Polacek <mpolacek@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2011 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include rhts environment
. /usr/bin/rhts-environment.sh
. /usr/lib/beakerlib/beakerlib.sh
PACKAGE="sed"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
# Prepare the test file
rlRun "echo 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz' > 1" 0
# Create a symlink
rlRun "ln -s 1 2" 0
rlPhaseEnd
rlPhaseStartTest
# Try to replace characters
rlRun "sed -i -e 's/z/a/g' 2 " 0 "Replace all z's with a's"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View File

@ -0,0 +1,56 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/sed/Regression/sed-does-not-handle-inline-edits-of-symlinks-with
# Description: Test for sed does not handle inline edits of symlinks with
# Author: Marek Polacek <mpolacek@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2011 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- hosts: '{{ hosts | default("localhost") }}'
vars:
package: sed
tasks:
- name: Make TmpDir
command: "mktemp -d"
register: TmpDir
- name: Prepare the test file
lineinfile:
create: yes
dest: "{{ TmpDir.stdout }}/1"
line: 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'
- name: Create a sym link
file:
src: "{{ TmpDir.stdout }}/1"
dest: "{{ TmpDir.stdout }}/2"
state: link
- block:
- name: Runtest - Try to replace characters
shell: "sed -i -e 's/z/a/g' 2 "
args:
warn: no
chdir: "{{ TmpDir.stdout }}"
always:
- name: Cleanup
file:
path: "{{ TmpDir.stdout }}"
state: absent

View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/sed/Regression/sed-needs-to-support-c-copy-option
# Description: Test for sed needs to support -c/--copy option
# Author: Karel Srot <ksrot@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2010 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/sed/Regression/sed-needs-to-support-c-copy-option
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Karel Srot <ksrot@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test for sed needs to support -c/--copy option" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 5m" >> $(METADATA)
@echo "RunFor: sed" >> $(METADATA)
@echo "Requires: sed" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,33 @@
PURPOSE of /CoreOS/sed/Regression/sed-needs-to-support-c-copy-option
Description: Test for sed needs to support -c/--copy option
Author: Karel Srot <ksrot@redhat.com>
Bug summary: sed needs to support -c/--copy option
Description:
Description of problem:
sed on bind-mounted files fails in rename step. In previous versions this was fixed by using -c/--copy functionality which appears to have been removed in 4.2.1-4.
Bind mounts are used in stateless systems for persistent data.
Version-Release number of selected component (if applicable):
4.2.1-4
How reproducible:
Always
Steps to Reproduce:
1. touch file1 file2
2. mount --bind file1 file2
3. echo "test" > file1
4. sed -i "s/test/fail/g" file2
Actual results:
sed: cannot rename ./sedfnZpvY: Device or resource busy
Expected results:
sed script completes.
Additional info:
As of 4.2.1-4, the -c/--copy options did not exist at all. Using them resulted in the printing of the help message. Using 4.2.1-5 from koji reintroduced the -c/--copy option support, but the above sed command still fails.

View File

@ -0,0 +1,61 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/sed/Regression/sed-needs-to-support-c-copy-option
# Description: Test for sed needs to support -c/--copy option
# Author: Karel Srot <ksrot@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2010 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include rhts environment
. /usr/bin/rhts-environment.sh
. /usr/lib/beakerlib/beakerlib.sh
PACKAGE="sed"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlRun "echo 'test' > file1" 0 "Prepare test files"
rlRun "touch file2"
rlRun "mount -n --bind file1 file2"
rlRun "grep test file2" 0 "Verify tests files"
rlPhaseEnd
rlPhaseStartTest
rlRun "sed -i 's/test/passed/' file2 &> out1" 4 "Executing sed -i"
rlAssertGrep "cannot rename" out1
rlAssertGrep "test" file2
rlRun "sed -i -c 's/test/passed/' file2 &> out2" 0 "Executing sed -i -c"
rlAssertNotGrep "cannot rename" out2
rlAssertGrep "passed" file2
rlPhaseEnd
rlPhaseStartCleanup
rlRun "umount file2"
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View File

@ -0,0 +1,93 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/sed/Regression/sed-needs-to-support-c-copy-option
# Description: Test for sed needs to support -c/--copy option
# Author: Karel Srot <ksrot@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2010 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- hosts: '{{ hosts | default("localhost") }}'
vars:
package: sed
tasks:
- name: Make TmpDir
command: "mktemp -d"
register: TmpDir
- name: Prepare test files
lineinfile:
dest: "{{ TmpDir.stdout }}/file1"
create: yes
line: "test"
- name: Prepare second test file
file:
dest: "{{ TmpDir.stdout }}/file2"
state: touch
- name: Bind mount files. Dont write to /etc so dont use mount module
shell: "mount -n --bind file1 file2"
args:
warn: no
chdir: "{{ TmpDir.stdout }}"
- name: Verify tests files
command: "grep test file2"
args:
chdir: "{{ TmpDir.stdout }}"
- block:
- name: Runtest - executing sed -i
shell: "sed -i 's/test/passed/' file2 &> out1"
args:
warn: no
chdir: "{{ TmpDir.stdout }}"
register: sedi
failed_when: sedi.rc != 4
- name: Runtest - grep out1
command: grep "cannot rename" out1
args:
chdir: "{{ TmpDir.stdout }}"
- name: Runtest - grep file2
command: grep "test" file2
args:
chdir: "{{ TmpDir.stdout }}"
- name: Runtest - executing sed -i -c
shell: "sed -i -c 's/test/passed/' file2 &> out2"
args:
warn: no
chdir: "{{ TmpDir.stdout }}"
- name: Runtest - grep out2
command: grep "cannot rename" out2
args:
chdir: "{{ TmpDir.stdout }}"
register: out2
failed_when: out2.rc != 1
- name: Runtest - grep file2
command: grep "passed" file2
args:
chdir: "{{ TmpDir.stdout }}"
always:
- name: Cleanup file
shell: "umount file2"
args:
chdir: "{{ TmpDir.stdout }}"
- name: Cleanup dir
file:
path: "{{ TmpDir.stdout }}"
state: absent

View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/sed/Regression/sed-reports-syntax-errors-with-some-multibyte
# Description: Test for sed reports syntax errors with some multibyte
# Author: Marek Polacek <mpolacek@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2011 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/sed/Regression/sed-reports-syntax-errors-with-some-multibyte
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Marek Polacek <mpolacek@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test for sed reports syntax errors with some multibyte" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 5m" >> $(METADATA)
@echo "RunFor: sed" >> $(METADATA)
@echo "Requires: sed glibc-all-langpacks" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,45 @@
PURPOSE of /CoreOS/sed/Regression/sed-reports-syntax-errors-with-some-multibyte
Description: Test for sed reports syntax errors with some multibyte
Author: Marek Polacek <mpolacek@redhat.com>
Bug summary: sed reports syntax errors with some multibyte characters
Description:
Description of problem:
Using a multibyte character that ends with 0x5c (backslash) can cause sed to report syntax errors.
Version-Release number of selected component (if applicable): sed-4.1.5-5
How reproducible: Always
Steps to Reproduce:
1. Start with your shell in a UTF-8 locale, eg en-US.UTF-8 (you can probably do this in a different locale, but it definitely works if you start in a UTF-8 locale).
2. Run the follow commands to construct a sed script:
U2010=$(echo -ne '\x20\x10' | iconv -f ucs-2be)
echo "echo '$U2010' | sed 's/$U2010/hyphen/g'" | iconv -t gbk > /tmp/script
3. Run the shell script in a locale that uses the gbk character set:
LC_ALL=zh_CN.gbk sh /tmp/script 2>&1 | iconv -f gbk
Actual results:
The script reports an error:
sed-e 表达式 #1字符 13unterminated `s' command
Expected results:
The single word "hyphen"
Additional info:
The error arises because the character U+2010 (HYPHEN) is encoded as \xa9\x5c in the gbk encoding. Sed sees the "\x5c" as a backslash escaping the following character which, in this case, is the "/" that we hope is going to terminate the pattern; it doesn't and so we get a syntax error.
Of course, this is just one character in one encoding. There are likely to be many others and this is just one example. I have another example for SJIS, (U+8868) but SJIS isn't a good encoding to use for reporting bugs :-).

View File

@ -0,0 +1,59 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/sed/Regression/sed-reports-syntax-errors-with-some-multibyte
# Description: Test for sed reports syntax errors with some multibyte
# Author: Marek Polacek <mpolacek@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2011 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include rhts environment
. /usr/bin/rhts-environment.sh
. /usr/lib/beakerlib/beakerlib.sh
PACKAGE="sed"
# as explained in the PURPOSE file, we need to start in a UTF-8 locale
export LC_ALL=en_US.UTF-8
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
# Construct a sed script
rlRun "U2010=\$(echo -ne '\x20\x10' | iconv -f ucs-2be)" 0
rlRun "echo \"echo '$U2010' | sed 's/$U2010/hyphen/g'\" | iconv -t gbk > script" 0
rlRun "set -o pipefail"
rlPhaseEnd
rlPhaseStartTest
# Run the shell script in a locale that uses the gbk character set
rlRun "LC_ALL=zh_CN.gbk sh ./script 2>&1 | iconv -f gbk" 0
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

64
tests/selftest/Makefile Normal file
View File

@ -0,0 +1,64 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/sed/Sanity/selftest
# Description: Execute test suite comming with sed
# Author: Miroslav Vadkerti <mvadkert@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2010 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/sed/Sanity/selftest
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Miroslav Vadkerti <mvadkert@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Execute test suite comming with sed" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 30m" >> $(METADATA)
@echo "RunFor: sed" >> $(METADATA)
@echo "Requires: sed" >> $(METADATA)
@echo "Requires: gcc rpm-build automake libselinux-devel glibc-devel yum-utils" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

3
tests/selftest/PURPOSE Normal file
View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/sed/Sanity/selftest
Description: Execute test suite comming with sed
Author: Miroslav Vadkerti <mvadkert@redhat.com>

87
tests/selftest/runtest.sh Executable file
View File

@ -0,0 +1,87 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/sed/Sanity/selftest
# Description: Execute test suite comming with sed
# Author: Miroslav Vadkerti <mvadkert@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2010 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include rhts environment
. /usr/bin/rhts-environment.sh
. /usr/lib/beakerlib/beakerlib.sh
PACKAGE="sed"
PACKAGES="sed gcc rpm-build automake libselinux-devel glibc-devel"
UPSTREAMPKG="sed-*"
BUILDLOG=`mktemp`
TESTLOG=`mktemp`
TARGET=$(echo `uname -m` | egrep ppc)
if [[ $TARGET != "" ]]; then
if rlIsRHEL 4; then
TARGET="--target ppc"
else
TARGET="--target `uname -m`"
fi
fi
rlJournalStart
rlPhaseStartSetup
for PKG in $PACKAGES; do
rlAssertRpm $PKG
done
rlFetchSrcForInstalled $PACKAGE
# make sure all deps installed
if ! rlIsRHEL 3 4 5; then
rlRun "yum-builddep -y *.src.rpm" 0-255
fi
rlPhaseEnd
rlPhaseStartTest
rlRun "rpm -ivh $PACKAGE*.src.rpm" 0 "Installing $PACKAGE src rpm"
SRCDIR="/usr/src/redhat"
if ! rlIsRHEL 3 4 5; then
SRCDIR="$HOME/rpmbuild/"
echo "+ RHEL6+ detected: SRCDIR=$SRCDIR"
fi
SPEC="$SRCDIR/SPECS/$PACKAGE*.spec"
TESTDIR="$SRCDIR/BUILD/$UPSTREAMPKG/"
echo "+ Building $PACKAGE (Log: $BUILDLOG)"
echo "+ Build command: rpmbuild -bc $SPEC $TARGET"
rlRun "rpmbuild -bc $SPEC $TARGET &> $BUILDLOG"
echo "+ Buildlog:"
tail -n 100 $BUILDLOG
rlRun "pushd ."
rlRun "cd $TESTDIR"
# disable test known to fail when run as root
rlRun "sed -i 's/testsuite\/panic-tests.sh//' Makefile.in"
rlRun "make check &> $TESTLOG"
cat $TESTLOG
rlAssertNotGrep "^FAIL" $TESTLOG
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -rf $PACKAGE*.src.rpm" 0 "Removing source rpm"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

44
tests/tests.yml Normal file
View File

@ -0,0 +1,44 @@
---
# Tests for classic and docker container environments
- hosts: localhost
tags:
- classic
- container
roles:
- role: standard-test-beakerlib
tests:
- selftest
- backup-file-not-cleared
- handle-escapes-correctly
- sed-does-not-handle-inline-edits-of-symlinks-with
- sed-needs-to-support-c-copy-option
- sed-reports-syntax-errors-with-some-multibyte
- uppercase-operand
required_packages:
- wget # beakerlib needs wget command
- findutils # backup-file-not-cleared needs find command
- glibc-langpack-en # sed-reports-syntax-errors-with-some-multibyte needs en_US.UTF-8 locale
- glibc-langpack-zh # sed-reports-syntax-errors-with-some-multibyte needs zh_CN.gbk locale
- glibc-langpack-ru # selftest needs ru_RU.UTF-8 locale
- gcc # selftest needs gcc package
- rpm-build # selftest needs rpm-build package
- automake # selftest needs automake package
- libselinux-devel # selftest needs libselinux-devel package
- glibc-devel # selftest needs glibc-devel package
- yum-utils # selftest needs yum-utils package
- libacl-devel # selftest needs libacl-devel package
# Tests for Atomic Host
- hosts: localhost
tags:
- atomic
roles:
- role: standard-test-beakerlib
tests:
#- selftest # cannot run under Atomic
- backup-file-not-cleared
- handle-escapes-correctly
- sed-does-not-handle-inline-edits-of-symlinks-with
- sed-needs-to-support-c-copy-option
#- sed-reports-syntax-errors-with-some-multibyte # needs glibc-langpack-zh
- uppercase-operand

View File

@ -0,0 +1,61 @@
# Makefile - uppercase-operand
# Author: Petr Muller <pmuller@redhat.com>
# Location: /CoreOS/sed/Regression/uppercase-operand/Makefile
# Description: Verifiies that sed correctly processes an 'u' operand, which returns uppercase of matched character
# Copyright (c) 2008 Red Hat, Inc. All rights reserved. This copyrighted material
# is made available to anyone wishing to use, modify, copy, or
# redistribute it subject to the terms and conditions of the GNU General
# Public License v.2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
TOPLEVEL_NAMESPACE=/CoreOS
PACKAGE_NAME=sed
RELATIVE_PATH=Regression/uppercase-operand
export TEST=$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH)
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
chmod a+x ./runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@touch $(METADATA)
@echo "Owner: Petr Muller <pmuller@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Description: Verifiies that sed correctly processes an 'u' operand, which returns uppercase of matched character" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 1m" >> $(METADATA)
@echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA)
@echo "Requires: $(PACKAGE_NAME)" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,9 @@
Test Name: uppercase-operand
Author: Petr Muller <pmuller@redhat.com>
Location: /CoreOS/sed/Regression/uppercase-operand
Short Description: Verifiies that sed correctly processes an 'u' operand, which returns uppercase of matched character
Long Description:
Verifiies that sed correctly processes an 'u' operand, which returns uppercase of matched character

View File

@ -0,0 +1,83 @@
# runtest.sh - uppercase-operand
# Author: Petr Muller <pmuller@redhat.com>
# Location: /CoreOS/sed/Regression/uppercase-operand/runtest.sh
# Description: Verifiies that sed correctly processes an 'u' operand, which returns uppercase of matched character
# Copyright (c) 2008 Red Hat, Inc. All rights reserved. This copyrighted material
# is made available to anyone wishing to use, modify, copy, or
# redistribute it subject to the terms and conditions of the GNU General
# Public License v.2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
PACKAGE=sed
RESULT=FAIL
SCORE=0
if rpm -q $PACKAGE &>/dev/null; then
PKG_VERS=$( rpm -q ${PACKAGE} --queryformat %{version} )
PKG_RELEASE=$( rpm -q ${PACKAGE} --queryformat %{release} )
fi
# Include rhts environment
. /usr/bin/rhts-environment.sh
function Log {
echo -e ":: [`date +%H:%M:%S`] :: $1" >> $OUTPUTFILE
}
function HeaderLog {
echo -e "\n::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" >> $OUTPUTFILE
echo -e ":: [`date +%H:%M:%S`] :: $1" >> $OUTPUTFILE
echo -e "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n" >>$OUTPUTFILE
}
HeaderLog "Starting $PACKAGE RHTS Test"
if rpm -q $PACKAGE &>/dev/null; then
Log "Running $PACKAGE-$PKG_VERS-$PKG_RELEASE"
else
Log "WARNING: Unable to locate $PACKAGE"
fi
####################
# Begin Test-Case
# Find result should be PASS or FAIL
####################
HeaderLog "Starting Test-Case"
testcase='i shouLD be In UpPeR CaSe, yeah, I should'
Log "Testcase: '$testcase'"
res=`echo $testcase | sed -e 's/[a-z]/\u&/g'`
Log "Result: $res"
####################
# Check Results
####################
HeaderLog "Checking Results"
if [ "$res" == "I SHOULD BE IN UPPER CASE, YEAH, I SHOULD" ]
then
RESULT=PASS
Log "Seems correct: PASS"
else
RESULT=FAIL
Log "Didn't get what we expected: FAIL"
fi
HeaderLog "Reporting Results"
Log "TEST: $TEST | RESULT: $RESULT\n"
report_result $TEST $RESULT
HeaderLog "End of $PACKAGE RHTS Test"