bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

unlink test failure on MacOS X


From: Bruno Haible
Subject: unlink test failure on MacOS X
Date: Mon, 15 Mar 2010 01:16:49 +0100
User-agent: KMail/1.9.9

Hi Jim, Eric,

On MacOS X 10.5, the unlink() and unlinkat() tests fail:

  test-unlink.h:49: assertion failed
  /bin/sh: line 1: 17670 Abort trap              EXEEXT='' srcdir='.' ${dir}$tst
  FAIL: test-unlink

  test-unlink.h:49: assertion failed
  /bin/sh: line 1: 63034 Abort trap              EXEEXT='' srcdir='.' ${dir}$tst
  FAIL: test-unlinkat

The reason is that unlink("..") returns 0 without having done any side effects
on the file system. Likewise for unlink("../..").

Test program:
========================= foo.c ========================
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
int main ()
{
  int ret = unlink ("../..");
  printf ("%d %d\n", ret, errno);
  return 0;
}
========================================================

This prints
-1 21 [EISDIR]
on Linux, but
0 0
on MacOS X.

Is the test too strict? Or should we add a workaround to lib/unlink.c
and lib/unlinkat.c? The workaround could consist in testing whether the
file name is ".." or ends in "/..".

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]