diff libinterp/corefcn/syscalls.cc @ 27040:8c4f01b66c0b stable

Add BIST tests for unlink() (bug #56097). * syscalls.cc (Funlink): Add BIST tests.
author Rik <rik@octave.org>
date Thu, 11 Apr 2019 08:37:13 -0700
parents 00f796120a6d
children 2faa56886789
line wrap: on
line diff
--- a/libinterp/corefcn/syscalls.cc	Wed Apr 10 23:53:01 2019 +0200
+++ b/libinterp/corefcn/syscalls.cc	Thu Apr 11 08:37:13 2019 -0700
@@ -1099,6 +1099,25 @@
   return ovl (status, msg);
 }
 
+/*
+%!test
+%! file = tempname ();
+%! fid = fopen (file, "wt");
+%! if (fid < 0)
+%!   error ("Could not open temporary file for unlink BIST test");
+%! endif
+%! fdisp (fid, pi);
+%! fclose (fid);
+%! [err, msg] = unlink (file);
+%! assert (err, 0);
+%! assert (msg, "");
+
+## Test input validation
+%!error unlink ()
+%!error unlink ("a", "b")
+%!error <FILE must be a string> unlink (123)
+*/
+
 DEFUNX ("waitpid", Fwaitpid, args, ,
         doc: /* -*- texinfo -*-
 @deftypefn {} {[@var{pid}, @var{status}, @var{msg}] =} waitpid (@var{pid}, @var{options})