diff --git a/tests/access1.c b/tests/access1.c new file mode 100644 index 0000000..d1ce1b9 --- /dev/null +++ b/tests/access1.c @@ -0,0 +1,52 @@ +#include +#include +#include +#include +#include +#include +#include + +char *testcase_description = "Separate file access"; + +#define template "/tmp/willitscale.XXXXXX" +static char (*tmpfiles)[sizeof(template)]; +static unsigned long local_nr_tasks; + +void testcase_prepare(unsigned long nr_tasks) +{ + int i; + tmpfiles = (char(*)[sizeof(template)])malloc(sizeof(template) * nr_tasks); + assert(tmpfiles); + + for (i = 0; i < nr_tasks; i++) { + strcpy(tmpfiles[i], template); + char *tmpfile = tmpfiles[i]; + int fd = mkstemp(tmpfile); + + assert(fd >= 0); + close(fd); + } + + local_nr_tasks = nr_tasks; +} + +void testcase(unsigned long long *iterations, unsigned long nr) +{ + char *tmpfile = tmpfiles[nr]; + + while (1) { + int error = access(tmpfile, R_OK); + assert(error == 0); + + (*iterations)++; + } +} + +void testcase_cleanup(void) +{ + int i; + for (i = 0; i < local_nr_tasks; i++) { + unlink(tmpfiles[i]); + } + free(tmpfiles); +} diff --git a/tests/access2.c b/tests/access2.c new file mode 100644 index 0000000..06daeb7 --- /dev/null +++ b/tests/access2.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include +#include +#include + +static char tmpfile[] = "/tmp/willitscale.XXXXXX"; + +char *testcase_description = "Same file access"; + +void testcase_prepare(unsigned long nr_tasks) +{ + int fd = mkstemp(tmpfile); + + assert(fd >= 0); + close(fd); +} + +void testcase(unsigned long long *iterations, unsigned long nr) +{ + while (1) { + int error = access(tmpfile, R_OK); + assert(error == 0); + + (*iterations)++; + } +} + +void testcase_cleanup(void) +{ + unlink(tmpfile); +}