/* * lockf regression test: * * Tests: * 1) fork N child processes, do a bunch of random byte range lock/unlock. */ #include #include #include #include #include #include #include #include #include int nlocks = 1000; /* number of locks per thread */ int nprocs = 10; /* number of processes to spawn */ int sleeptime = 500000; /* sleep time between locks, usec */ int size = 8192; /* size of file to lock */ const char *lockfile = "/tmp/lockf_test"; static u_int32_t random_uint32(void) { return lrand48(); } static void trylocks(int id) { int i, ret, fd; const char *which; srand48(getpid()); fd = open (lockfile, O_RDWR, 0); if (fd < 0) err(1, lockfile); printf("%d: start\n", id); for (i=0; i