X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=noerr%2Ftest%2Frun.c;fp=noerr%2Ftest%2Frun.c;h=0000000000000000000000000000000000000000;hp=6d3c6837cd228b857f3b11ab589dd0f2aa00aca7;hb=650c775ff00cccd03fc84e7789a03c51d9839004;hpb=c8acddea39d222312102952e91c32cfe4dd2cea0;ds=sidebyside diff --git a/noerr/test/run.c b/noerr/test/run.c deleted file mode 100644 index 6d3c6837..00000000 --- a/noerr/test/run.c +++ /dev/null @@ -1,48 +0,0 @@ -#include "noerr/noerr.h" -#include "tap/tap.h" -#include "noerr/noerr.c" -#include -#include -#include -#include -#include - -int main(int argc, char *argv[]) -{ - /* tempnam(3) is generally a bad idea, but OK here. */ - char *name = tempnam(NULL, "noerr"); - int fd; - - plan_tests(12); - /* Should fail to unlink. */ - ok1(unlink(name) != 0); - ok1(errno == ENOENT); - - /* This one should not set errno. */ - errno = 100; - ok1(unlink_noerr(name) == ENOENT); - ok1(errno == 100); - - /* Should fail to close. */ - ok1(close(-1) != 0); - ok1(errno == EBADF); - - /* This one should not set errno. */ - errno = 100; - ok1(close_noerr(-1) == EBADF); - ok1(errno == 100); - - /* Test successful close/unlink doesn't hit errno either. */ - fd = open(name, O_WRONLY|O_CREAT|O_EXCL, 0600); - assert(fd >= 0); - - errno = 100; - ok1(close_noerr(fd) == 0); - ok1(errno == 100); - - errno = 100; - ok1(unlink_noerr(name) == 0); - ok1(errno == 100); - - return exit_status(); -}