int main() { test_shared(); test_intrusive(); return hpx::util::report_errors(); }
int main (int argc, char *argv[]) { int fd; const char *file = "test-flock.txt"; /* Open a non-empty file for testing. */ fd = open (file, O_RDWR | O_CREAT | O_TRUNC, 0644); ASSERT (fd >= 0); ASSERT (write (fd, "hello", 5) == 5); #if defined __linux__ /* Invalid operation codes are rejected by the Linux implementation and by the gnulib replacement, but not by the MacOS X implementation. */ ASSERT (flock (fd, LOCK_SH | LOCK_EX) == -1); ASSERT (errno == EINVAL); ASSERT (flock (fd, LOCK_SH | LOCK_UN) == -1); ASSERT (errno == EINVAL); ASSERT (flock (fd, LOCK_EX | LOCK_UN) == -1); ASSERT (errno == EINVAL); ASSERT (flock (fd, 0) == -1); ASSERT (errno == EINVAL); #endif test_shared (file, fd); test_exclusive (file, fd); /* Close and remove the test file. */ ASSERT (close (fd) == 0); ASSERT (unlink (file) == 0); return 0; }