Date: Wed, 12 Oct 2011 15:59:29 +0000 (UTC) From: Peter Holm <pho@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r226309 - projects/stress2/testcases/lockf2 Message-ID: <201110121559.p9CFxTBh073064@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pho Date: Wed Oct 12 15:59:29 2011 New Revision: 226309 URL: http://svn.freebsd.org/changeset/base/226309 Log: Added reservation of disk space. Added check for test done. Modified: projects/stress2/testcases/lockf2/lockf2.c Modified: projects/stress2/testcases/lockf2/lockf2.c ============================================================================== --- projects/stress2/testcases/lockf2/lockf2.c Wed Oct 12 15:56:15 2011 (r226308) +++ projects/stress2/testcases/lockf2/lockf2.c Wed Oct 12 15:59:29 2011 (r226309) @@ -50,13 +50,39 @@ __FBSDID("$FreeBSD$"); char file[128]; int fd; +int freespace; int setup(int nb) { + int64_t bl; + int64_t in; + int64_t reserve_bl; + int64_t reserve_in; int i; char buf[1024]; + if (nb == 0) { + getdf(&bl, &in); + + /* Resource requirements: */ + reserve_in = 1 * op->incarnations + 2; + reserve_bl = 1064960 * op->incarnations + 2048; + freespace = (reserve_bl <= bl && reserve_in <= in); + if (!freespace) + reserve_bl = reserve_in = 0; + + if (op->verbose > 1) + printf("lockf2(incarnations=%d). Free(%jdk, %jd), reserve(%jdk, %jd)\n", + op->incarnations, bl/1024, in, reserve_bl/1024, reserve_in); + reservedf(reserve_bl, reserve_in); + putval(freespace); + } else { + freespace = getval(); + } + if (!freespace) + _exit (0); + sprintf(file, "lockf.%d", getpid()); if ((fd = open(file,O_CREAT | O_TRUNC | O_RDWR, 0600)) == -1) err(1, "creat(%s)", file); @@ -84,7 +110,7 @@ test(void) if ((fd = open(file, O_RDWR, 0600)) == -1) err(1, "open(%s)", file); - for (i = 0; i < 1024; i++) { + for (i = 0; i < 1024 && done_testing == 0; i++) { pos = random_int(0, 1024 * 1024 - 1); if (lseek(fd, pos, SEEK_SET) == -1) err(1, "lseek");
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201110121559.p9CFxTBh073064>