Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Unified Diff: gdb/testsuite/gdb.base/fileio.c

Issue 124383005: GDB 7.6.50 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@upstream
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gdb/testsuite/gdb.base/exprs.exp ('k') | gdb/testsuite/gdb.base/fileio.exp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gdb/testsuite/gdb.base/fileio.c
diff --git a/gdb/testsuite/gdb.base/fileio.c b/gdb/testsuite/gdb.base/fileio.c
index 329522f3a8a3c8da32a6c6cd0de6fdf43dd6ceba..4926c05d2b82a1e5b325544e769d47a832cf24fe 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 ();
« no previous file with comments | « gdb/testsuite/gdb.base/exprs.exp ('k') | gdb/testsuite/gdb.base/fileio.exp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698