diff mbox

[testsuite] : Close and unlink test file before exit

Message ID CAFULd4Y73uJdPMBfgB1YD_+M-ohGEJOHigQfbPWCUUv1jACVtA@mail.gmail.com
State New
Headers show

Commit Message

Uros Bizjak Oct. 10, 2011, 10:26 p.m. UTC
Hello!

Remove another orphan file from the testsuite directory.

2011-10-11  Uros Bizjak  <ubizjak@gmail.com>

	* lib/target-supports.exp (check_effective_target_fd_truncate):
	Close and unlink test file before exit.

Tested on x86_64-pc-linux-gnu, committed to mainline SVN.

Uros.

Comments

Hans-Peter Nilsson Oct. 11, 2011, 1 a.m. UTC | #1
On Tue, 11 Oct 2011, Uros Bizjak wrote:

> Hello!
>
> Remove another orphan file from the testsuite directory.
>
> 2011-10-11  Uros Bizjak  <ubizjak@gmail.com>
>
> 	* lib/target-supports.exp (check_effective_target_fd_truncate):
> 	Close and unlink test file before exit.

(can't quote attachment...)

Or save a few lines and unlink it in the tcl/expect framework as
"remote_file target delete tst.tmp"?

brgds, H-P
diff mbox

Patch

Index: lib/target-supports.exp
===================================================================
--- lib/target-supports.exp	(revision 179773)
+++ lib/target-supports.exp	(working copy)
@@ -3739,16 +3739,25 @@ 
 	  int fd;
 	  const char t[] = "test writing more than ten characters";
 	  char s[11];
-	  fd =  fileno (f);
+	  int status = 0;
+	  fd = fileno (f);
 	  write (fd, t, sizeof (t) - 1);
 	  lseek (fd, 0, 0);
 	  if (ftruncate (fd, 10) != 0)
-	    exit (1);
+	    status = 1;
 	  close (fd);
+	  fclose (f);
+	  if (status)
+	    {
+	      unlink ("tst.tmp");
+	      exit (status);
+	    }
 	  f = fopen ("tst.tmp", "rb");
 	  if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
-	    exit (1);
-	  exit (0);
+	    status = 1;
+	  fclose (f);
+	  unlink ("tst.tmp");
+	  exit (status);
 	}
     }