Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions tests/fstat1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <assert.h>
#include <string.h>

char *testcase_description = "Separate file fstat";

#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];
struct stat sb;
int fd = open(tmpfile, O_RDONLY);

assert(fd>= 0);

while (1) {
int error = fstat(fd, &sb);
assert(error == 0);

(*iterations)++;
}
}

void testcase_cleanup(void)
{
int i;
for (i = 0; i < local_nr_tasks; i++) {
unlink(tmpfiles[i]);
}
free(tmpfiles);
}
38 changes: 38 additions & 0 deletions tests/fstat2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <assert.h>

static char tmpfile[] = "/tmp/willitscale.XXXXXX";

char *testcase_description = "Same file fstat";

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)
{
struct stat sb;
int fd = open(tmpfile, O_RDONLY);

assert(fd>= 0);

while (1) {
int error = fstat(fd, &sb);
assert(error == 0);

(*iterations)++;
}
}

void testcase_cleanup(void)
{
unlink(tmpfile);
}
53 changes: 53 additions & 0 deletions tests/stat1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <assert.h>
#include <string.h>

char *testcase_description = "Separate file stat";

#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];
struct stat sb;

while (1) {
int error = stat(tmpfile, &sb);
assert(error == 0);

(*iterations)++;
}
}

void testcase_cleanup(void)
{
int i;
for (i = 0; i < local_nr_tasks; i++) {
unlink(tmpfiles[i]);
}
free(tmpfiles);
}
35 changes: 35 additions & 0 deletions tests/stat2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <assert.h>

static char tmpfile[] = "/tmp/willitscale.XXXXXX";

char *testcase_description = "Same file stat";

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)
{
struct stat sb;

while (1) {
int error = stat(tmpfile, &sb);
assert(error == 0);

(*iterations)++;
}
}

void testcase_cleanup(void)
{
unlink(tmpfile);
}