MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_flopen_lock_self

Function test_flopen_lock_self

tools/libutil/tests/flopen_test.c:94–115  ·  view source on GitHub ↗

* Test that flopen() can lock against itself */

Source from the content-addressed store, hash-verified

92 * Test that flopen() can lock against itself
93 */
94const char *
95test_flopen_lock_self(void)
96{
97 const char *fn = "test_flopen_lock_self";
98 const char *result = NULL;
99 int fd1, fd2;
100
101 unlink(fn);
102 fd1 = flopen(fn, O_RDWR|O_CREAT, 0640);
103 if (fd1 < 0) {
104 result = strerror(errno);
105 } else {
106 fd2 = flopen(fn, O_RDWR|O_NONBLOCK);
107 if (fd2 >= 0) {
108 result = "second open succeeded";
109 close(fd2);
110 }
111 close(fd1);
112 }
113 unlink(fn);
114 return (result);
115}
116
117/*
118 * Test that flopen() can lock against other processes

Callers

nothing calls this directly

Calls 2

flopenFunction · 0.85
closeFunction · 0.50

Tested by

no test coverage detected