From: Bruno Haible Date: Sun, 15 Sep 2019 12:41:57 +0000 (+0200) Subject: open tests: Enhance test. X-Git-Tag: v1.0~4659 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=9e75623a64a07215f2c7811e0356697d6df10fa2;p=gnulib.git open tests: Enhance test. * tests/test-open.h (test_open): Test the creation of an executable regular file. Also improve initial cleanup. --- diff --git a/ChangeLog b/ChangeLog index c94ebeb0ea..9f97bb0d49 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2019-09-15 Bruno Haible + + open tests: Enhance test. + * tests/test-open.h (test_open): Test the creation of an executable + regular file. Also improve initial cleanup. + 2019-09-15 Bruno Haible intprops tests: Avoid build failure with HP-UX cc. diff --git a/tests/test-open.h b/tests/test-open.h index e5c47d22ee..c0290ee889 100644 --- a/tests/test-open.h +++ b/tests/test-open.h @@ -37,8 +37,11 @@ static ALWAYS_INLINE int test_open (int (*func) (char const *, int, ...), bool print) { int fd; + /* Remove anything from prior partial run. */ unlink (BASE "file"); + unlink (BASE "e.exe"); + unlink (BASE "link"); /* Cannot create directory. */ errno = 0; @@ -51,6 +54,11 @@ test_open (int (*func) (char const *, int, ...), bool print) ASSERT (0 <= fd); ASSERT (close (fd) == 0); + /* Create an executable regular file. */ + fd = func (BASE "e.exe", O_CREAT | O_RDONLY, 0700); + ASSERT (0 <= fd); + ASSERT (close (fd) == 0); + /* Trailing slash handling. */ errno = 0; ASSERT (func (BASE "file/", O_RDONLY) == -1); @@ -98,6 +106,7 @@ test_open (int (*func) (char const *, int, ...), bool print) /* Cleanup. */ ASSERT (unlink (BASE "file") == 0); + ASSERT (unlink (BASE "e.exe") == 0); ASSERT (unlink (BASE "link") == 0); return 0;