From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11943 invoked by alias); 25 Oct 2013 21:11:58 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 11804 invoked by uid 89); 25 Oct 2013 21:11:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.5 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 25 Oct 2013 21:11:56 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9PKLGNE008574 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 25 Oct 2013 16:21:16 -0400 Received: from barimba.redhat.com (ovpn-113-54.phx2.redhat.com [10.3.113.54]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r9PKLAJZ000870; Fri, 25 Oct 2013 16:21:15 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v3 10/17] update fileio test Date: Fri, 25 Oct 2013 21:11:00 -0000 Message-Id: <1382732464-28121-11-git-send-email-tromey@redhat.com> In-Reply-To: <1382732464-28121-1-git-send-email-tromey@redhat.com> References: <1382732464-28121-1-git-send-email-tromey@redhat.com> X-SW-Source: 2013-10/txt/msg00833.txt.bz2 This updates the fileio test to be parallel-safe. ~ChangeLog~ 2013-10-24 Tom Tromey * 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/ChangeLog | 9 +++++++ gdb/testsuite/gdb.base/fileio.c | 54 ++++++++++++++++++++------------------- gdb/testsuite/gdb.base/fileio.exp | 24 ++++++++++------- 3 files changed, 52 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