From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@redhat.com>
Subject: [PATCH v2 10/17] update fileio test
Date: Fri, 18 Oct 2013 21:24:00 -0000 [thread overview]
Message-ID: <1382129374-18344-11-git-send-email-tromey@redhat.com> (raw)
In-Reply-To: <1382129374-18344-1-git-send-email-tromey@redhat.com>
This updates the fileio test to be parallel-safe.
* gdb.base/fileio.c (test_open, test_write, test_read)
(test_lseek, test_close, test_stat, test_fstat)
(test_isatty, test_system, test_rename, test_unlink):
Use OUTDIR define.
* gdb.base/fileio.exp: Define OUTDIR during compilation.
Use standard_output_file.
---
gdb/testsuite/gdb.base/fileio.c | 54 ++++++++++++++++++++-------------------
gdb/testsuite/gdb.base/fileio.exp | 24 ++++++++++-------
2 files changed, 43 insertions(+), 35 deletions(-)
diff --git a/gdb/testsuite/gdb.base/fileio.c b/gdb/testsuite/gdb.base/fileio.c
index 329522f..4926c05 100644
--- a/gdb/testsuite/gdb.base/fileio.c
+++ b/gdb/testsuite/gdb.base/fileio.c
@@ -58,6 +58,7 @@ system (const char * string);
1) Invalid string/command. - returns 127. */
static const char *strerrno (int err);
+/* Note that OUTDIR is defined by the test suite. */
#define FILENAME "foo.fileio.test"
#define RENAMED "bar.fileio.test"
#define NONEXISTANT "nofoo.fileio.test"
@@ -77,7 +78,7 @@ test_open ()
/* Test opening */
errno = 0;
- ret = open (FILENAME, O_CREAT | O_TRUNC | O_RDWR, S_IWUSR | S_IRUSR);
+ ret = open (OUTDIR FILENAME, O_CREAT | O_TRUNC | O_RDWR, S_IWUSR | S_IRUSR);
printf ("open 1: ret = %d, errno = %d %s\n", ret, errno,
ret >= 0 ? "OK" : "");
@@ -86,7 +87,7 @@ test_open ()
stop ();
/* Creating an already existing file (created by fileio.exp) */
errno = 0;
- ret = open (FILENAME, O_CREAT | O_EXCL | O_WRONLY, S_IWUSR | S_IRUSR);
+ ret = open (OUTDIR FILENAME, O_CREAT | O_EXCL | O_WRONLY, S_IWUSR | S_IRUSR);
printf ("open 2: ret = %d, errno = %d %s\n", ret, errno,
strerrno (errno));
if (ret >= 0)
@@ -110,13 +111,13 @@ test_open ()
stop ();
/* Open for write but no write permission */
errno = 0;
- ret = open (NOWRITE, O_CREAT | O_RDONLY, S_IRUSR);
+ ret = open (OUTDIR NOWRITE, O_CREAT | O_RDONLY, S_IRUSR);
if (ret >= 0)
{
close (ret);
stop ();
errno = 0;
- ret = open (NOWRITE, O_WRONLY);
+ ret = open (OUTDIR NOWRITE, O_WRONLY);
printf ("open 5: ret = %d, errno = %d %s\n", ret, errno,
strerrno (errno));
if (ret >= 0)
@@ -137,7 +138,7 @@ test_write ()
/* Test writing */
errno = 0;
- fd = open (FILENAME, O_WRONLY);
+ fd = open (OUTDIR FILENAME, O_WRONLY);
if (fd >= 0)
{
errno = 0;
@@ -157,7 +158,7 @@ test_write ()
stop ();
/* Write to a read-only file */
errno = 0;
- fd = open (FILENAME, O_RDONLY);
+ fd = open (OUTDIR FILENAME, O_RDONLY);
if (fd >= 0)
{
errno = 0;
@@ -178,7 +179,7 @@ test_read ()
/* Test reading */
errno = 0;
- fd = open (FILENAME, O_RDONLY);
+ fd = open (OUTDIR FILENAME, O_RDONLY);
if (fd >= 0)
{
memset (buf, 0, 16);
@@ -210,7 +211,7 @@ test_lseek ()
/* Test seeking */
errno = 0;
- fd = open (FILENAME, O_RDONLY);
+ fd = open (OUTDIR FILENAME, O_RDONLY);
if (fd >= 0)
{
errno = 0;
@@ -251,7 +252,7 @@ test_close ()
/* Test close */
errno = 0;
- fd = open (FILENAME, O_RDONLY);
+ fd = open (OUTDIR FILENAME, O_RDONLY);
if (fd >= 0)
{
errno = 0;
@@ -278,7 +279,7 @@ test_stat ()
/* Test stat */
errno = 0;
- ret = stat (FILENAME, &st);
+ ret = stat (OUTDIR FILENAME, &st);
if (!ret)
printf ("stat 1: ret = %d, errno = %d %s\n", ret, errno,
st.st_size == 11 ? "OK" : "");
@@ -313,7 +314,7 @@ test_fstat ()
/* Test fstat */
errno = 0;
- fd = open (FILENAME, O_RDONLY);
+ fd = open (OUTDIR FILENAME, O_RDONLY);
if (fd >= 0)
{
errno = 0;
@@ -352,7 +353,7 @@ test_isatty ()
printf ("isatty 4: invalid %s\n", isatty (999) ? "yes" : "no OK");
stop ();
/* Check open file */
- fd = open (FILENAME, O_RDONLY);
+ fd = open (OUTDIR FILENAME, O_RDONLY);
if (fd >= 0)
{
printf ("isatty 5: file %s\n", isatty (fd) ? "yes" : "no OK");
@@ -364,6 +365,8 @@ test_isatty ()
}
+char sys[1512];
+
int
test_system ()
{
@@ -371,14 +374,13 @@ test_system ()
* Requires test framework to switch on "set remote system-call-allowed 1"
*/
int ret;
- char sys[512];
/* Test for shell */
ret = system (NULL);
printf ("system 1: ret = %d %s\n", ret, ret != 0 ? "OK" : "");
stop ();
/* This test prepares the directory for test_rename() */
- sprintf (sys, "mkdir -p %s %s", TESTSUBDIR, TESTDIR2);
+ sprintf (sys, "mkdir -p %s/%s %s/%s", OUTDIR, TESTSUBDIR, OUTDIR, TESTDIR2);
ret = system (sys);
if (ret == 127)
printf ("system 2: ret = %d /bin/sh unavailable???\n", ret);
@@ -399,7 +401,7 @@ test_rename ()
/* Test rename */
errno = 0;
- ret = rename (FILENAME, RENAMED);
+ ret = rename (OUTDIR FILENAME, OUTDIR RENAMED);
if (!ret)
{
errno = 0;
@@ -407,7 +409,7 @@ test_rename ()
if (ret && errno == ENOENT)
{
errno = 0;
- ret = stat (RENAMED, &st);
+ ret = stat (OUTDIR RENAMED, &st);
printf ("rename 1: ret = %d, errno = %d %s\n", ret, errno,
strerrno (errno));
errno = 0;
@@ -420,50 +422,50 @@ test_rename ()
stop ();
/* newpath is existing directory, oldpath is not a directory */
errno = 0;
- ret = rename (RENAMED, TESTDIR2);
+ ret = rename (OUTDIR RENAMED, OUTDIR TESTDIR2);
printf ("rename 2: ret = %d, errno = %d %s\n", ret, errno,
strerrno (errno));
stop ();
/* newpath is a non-empty directory */
errno = 0;
- ret = rename (TESTDIR2, TESTDIR1);
+ ret = rename (OUTDIR TESTDIR2, OUTDIR TESTDIR1);
printf ("rename 3: ret = %d, errno = %d %s\n", ret, errno,
strerrno (errno));
stop ();
/* newpath is a subdirectory of old path */
errno = 0;
- ret = rename (TESTDIR1, TESTSUBDIR);
+ ret = rename (OUTDIR TESTDIR1, OUTDIR TESTSUBDIR);
printf ("rename 4: ret = %d, errno = %d %s\n", ret, errno,
strerrno (errno));
stop ();
/* oldpath does not exist */
errno = 0;
- ret = rename (NONEXISTANT, FILENAME);
+ ret = rename (OUTDIR NONEXISTANT, OUTDIR FILENAME);
printf ("rename 5: ret = %d, errno = %d %s\n", ret, errno,
strerrno (errno));
stop ();
}
+char name[1256];
+
int
test_unlink ()
{
int ret;
- char name[256];
- char sys[512];
/* Test unlink */
errno = 0;
- ret = unlink (RENAMED);
+ ret = unlink (OUTDIR RENAMED);
printf ("unlink 1: ret = %d, errno = %d %s\n", ret, errno,
strerrno (errno));
stop ();
/* No write access */
- sprintf (name, "%s/%s", TESTDIR2, FILENAME);
+ sprintf (name, "%s/%s/%s", OUTDIR, TESTDIR2, FILENAME);
errno = 0;
ret = open (name, O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR);
if (ret >= 0)
{
- sprintf (sys, "chmod -w %s", TESTDIR2);
+ sprintf (sys, "chmod -w %s/%s", OUTDIR, TESTDIR2);
ret = system (sys);
if (!ret)
{
@@ -480,7 +482,7 @@ test_unlink ()
stop ();
/* pathname doesn't exist */
errno = 0;
- ret = unlink (NONEXISTANT);
+ ret = unlink (OUTDIR NONEXISTANT);
printf ("unlink 3: ret = %d, errno = %d %s\n", ret, errno,
strerrno (errno));
stop ();
diff --git a/gdb/testsuite/gdb.base/fileio.exp b/gdb/testsuite/gdb.base/fileio.exp
index ded043f..b9dfb38 100644
--- a/gdb/testsuite/gdb.base/fileio.exp
+++ b/gdb/testsuite/gdb.base/fileio.exp
@@ -23,7 +23,15 @@ if [target_info exists gdb,nofileio] {
standard_testfile
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+if {[is_remote host]} {
+ set outdir .
+} else {
+ set outdir [standard_output_file {}]
+}
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
+ executable \
+ [list debug "additional_flags=-DOUTDIR=\"$outdir/\""]] != "" } {
untested fileio.exp
return -1
}
@@ -35,8 +43,11 @@ if [get_compiler_info] {
return -1
}
-remote_exec build {sh -xc test\ -r\ dir2.fileio.test\ &&\ chmod\ -f\ +w\ dir2.fileio.test}
-remote_exec build {sh -xc rm\ -rf\ *.fileio.test}
+set dir2 [standard_output_file dir2.fileio.test]
+if {[file exists $dir2] && ![file writable $dir2]} {
+ system "chmod +w $dir2"
+}
+system "rm -rf [standard_output_file *.fileio.test]"
set oldtimeout $timeout
set timeout [expr "$timeout + 60"]
@@ -78,7 +89,7 @@ gdb_test continue \
gdb_test "continue" ".*" ""
-catch "system \"chmod -f -w nowrt.fileio.test\""
+catch "system \"chmod -f -w [standard_output_file nowrt.fileio.test]\""
gdb_test continue \
"Continuing\\..*open 5:.*EACCES$stop_msg" \
@@ -241,11 +252,6 @@ gdb_test continue \
"Time(2) returns feasible values"
gdb_exit
-# Wait till GDB really exits.
-sleep 1
-
-remote_exec build {sh -xc test\ -r\ dir2.fileio.test\ &&\ chmod\ -f\ +w\ dir2.fileio.test}
-remote_exec build {sh -xc rm\ -rf\ *.fileio.test}
set timeout $oldtimeout
return 0
--
1.8.1.4
next prev parent reply other threads:[~2013-10-18 21:24 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-18 20:49 [PATCH v2 00/17] test suite parallel safety Tom Tromey
2013-10-18 20:49 ` [PATCH v2 03/17] fix weird.exp for parallel testing Tom Tromey
2013-10-18 20:49 ` [PATCH v2 12/17] fix up gdb.server Tom Tromey
2013-10-18 20:49 ` [PATCH v2 07/17] fix up gdb.trace Tom Tromey
2013-10-25 16:22 ` Pedro Alves
2013-10-25 16:37 ` Tom Tromey
2013-10-18 20:49 ` [PATCH v2 06/17] fix up gdb.mi Tom Tromey
2013-10-18 20:49 ` [PATCH v2 09/17] update checkpoint test Tom Tromey
2013-10-18 20:49 ` [PATCH v2 15/17] fix some "exec" tests Tom Tromey
2013-10-25 16:21 ` Pedro Alves
2013-10-25 16:39 ` Tom Tromey
2013-10-25 17:02 ` Pedro Alves
2013-10-18 20:49 ` [PATCH v2 08/17] simple changes in gdb.base Tom Tromey
2013-10-18 20:49 ` [PATCH v2 02/17] fix some simple thinkos in the test suite Tom Tromey
2013-10-18 20:49 ` [PATCH v2 01/17] fix up log-file toggling Tom Tromey
2013-10-18 21:00 ` [PATCH v2 14/17] fix argv0-symlink.exp for parallel mode Tom Tromey
2013-10-18 21:00 ` [PATCH v2 11/17] introduce relative_filename and use it Tom Tromey
2013-10-25 16:22 ` Pedro Alves
2013-10-25 16:42 ` Tom Tromey
2013-10-25 17:03 ` Pedro Alves
2013-10-28 19:01 ` Doug Evans
2013-10-28 20:10 ` Tom Tromey
2013-10-18 21:11 ` [PATCH v2 17/17] switch to fully parallel mode Tom Tromey
2013-10-18 21:24 ` Tom Tromey [this message]
2013-10-18 21:24 ` [PATCH v2 13/17] make gdb.asm parallel-safe Tom Tromey
2013-10-18 21:36 ` [PATCH v2 05/17] fix up gdb.xml Tom Tromey
2013-10-25 16:21 ` Pedro Alves
2013-10-25 18:23 ` Tom Tromey
2013-10-18 21:36 ` [PATCH v2 04/17] fix up gdb.gdb Tom Tromey
2013-10-18 21:44 ` [PATCH v2 16/17] fix some fission tests Tom Tromey
2013-10-25 16:23 ` [PATCH v2 00/17] test suite parallel safety Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1382129374-18344-11-git-send-email-tromey@redhat.com \
--to=tromey@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).