Skip to content

Commit

Permalink
Merge pull request #121 from utsaslab/jayashree_dev
Browse files Browse the repository at this point in the history
Remove static sleeps in the code.
  • Loading branch information
vijay03 authored Oct 31, 2018
2 parents 3a36198 + e74a414 commit ab21ec1
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ This repository contains a pre-generated suite of 328 seq-1 workloads (workloads
python xfsMonkey.py -f /dev/sda -d /dev/cow_ram0 -t btrfs -e 102400 -u build/tests/seq1/ > outfile
```

Sit back and relax. This is going to take about 35 minutes to complete if run on a single machine. This will run all the 328 tests of seq-1 on a `btrfs` file system `100MB` in size. The bug reports can be found in the folder `diff_results`. The workloads are named j-lang<1-328>, and, if any of these resulted in a bug, you will see a bug report with the same name as that of the workload, describing the difference between the expected and actual state.
Sit back and relax. This is going to take about 12 minutes to complete if run on a single machine. This will run all the 328 tests of seq-1 on a `btrfs` file system `100MB` in size. The bug reports can be found in the folder `diff_results`. The workloads are named j-lang<1-328>, and, if any of these resulted in a bug, you will see a bug report with the same name as that of the workload, describing the difference between the expected and actual state.

## Tutorial ##
This tutorial walks you through the workflow of workload generation to testing, using a small bounded space of seq-1 workloads. Generating and running the tests in this tutorial will take less than 2 minutes.
Expand Down
2 changes: 1 addition & 1 deletion code/harness/DiskContents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ int DiskContents::mount_disk() {
return -1;
}
// sleep after mount
unsigned int to_sleep = 1;
unsigned int to_sleep = 0;
do {
to_sleep = sleep(to_sleep);
} while (to_sleep > 0);
Expand Down
12 changes: 6 additions & 6 deletions code/harness/FsSpecific.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Ext2FsSpecific : public ExtFsSpecific {
static constexpr char kFsType[] = "ext2";

#if TWO_SEC == 1
static const unsigned int kDelaySeconds = 2;
static const unsigned int kDelaySeconds = 0;
#elif THREE_THIRTEEN == 1 || FOUR_FOUR == 1 || FOUR_FIFTEEN == 1 || \
FOUR_SIXTEEN == 1
static const unsigned int kDelaySeconds = 20;
Expand All @@ -100,7 +100,7 @@ class Ext3FsSpecific : public ExtFsSpecific {
static constexpr char kFsType[] = "ext3";

#if TWO_SEC == 1
static const unsigned int kDelaySeconds = 2;
static const unsigned int kDelaySeconds = 0;
#elif THREE_THIRTEEN == 1 || FOUR_FOUR == 1 || FOUR_FIFTEEN == 1 || \
FOUR_SIXTEEN == 1
static const unsigned int kDelaySeconds = 42;
Expand All @@ -115,7 +115,7 @@ class Ext4FsSpecific : public ExtFsSpecific {
static constexpr char kFsType[] = "ext4";

#if TWO_SEC == 1
static const unsigned int kDelaySeconds = 2;
static const unsigned int kDelaySeconds = 0;
#elif THREE_THIRTEEN == 1 || FOUR_FOUR == 1 || FOUR_FIFTEEN == 1 ||\
FOUR_SIXTEEN == 1
static const unsigned int kDelaySeconds = 42;
Expand All @@ -138,7 +138,7 @@ class BtrfsFsSpecific : public FsSpecific {
static constexpr char kFsType[] = "btrfs";

#if TWO_SEC == 1
static const unsigned int kDelaySeconds = 2;
static const unsigned int kDelaySeconds = 0;
#elif THREE_THIRTEEN == 1 || FOUR_FOUR == 1 || FOUR_FIFTEEN == 1 || \
FOUR_SIXTEEN == 1
static const unsigned int kDelaySeconds = 40;
Expand All @@ -161,7 +161,7 @@ class F2fsFsSpecific : public FsSpecific {
static constexpr char kFsType[] = "f2fs";

#if TWO_SEC == 1
static const unsigned int kDelaySeconds = 2;
static const unsigned int kDelaySeconds = 0;
#elif THREE_THIRTEEN == 1
static const unsigned int kDelaySeconds = 15;
#elif FOUR_FOUR == 1
Expand All @@ -187,7 +187,7 @@ class XfsFsSpecific : public FsSpecific {
static constexpr char kFsType[] = "xfs";

#if TWO_SEC == 1
static const unsigned int kDelaySeconds = 2;
static const unsigned int kDelaySeconds = 0;
#elif FOUR_FIFTEEN == 1 || FOUR_SIXTEEN == 1
static const unsigned int kDelaySeconds = 97;
#else
Expand Down
61 changes: 52 additions & 9 deletions code/harness/Tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,16 +273,34 @@ int Tester::insert_cow_brd() {
}

int Tester::remove_cow_brd() {
// Sometimes the disk wrapper module takes time to unload.
// So retry cow-brd unload for upto a second.
milliseconds elapsed;
if (cow_brd_inserted) {
if (cow_brd_fd != -1) {
close(cow_brd_fd);
cow_brd_fd = -1;
cow_brd_inserted = false;
}
if (system(COW_BRD_RMMOD) != 0) {
cow_brd_inserted = true;
return WRAPPER_REMOVE_ERR;
}
int res, num_tries = 0;
string command = COW_BRD_RMMOD SILENT;
time_point<steady_clock> rmmod_start_time = steady_clock::now();
do {
res = system(command.c_str());
time_point<steady_clock> rmmod_end_time = steady_clock::now();
elapsed = duration_cast<milliseconds>(rmmod_end_time - rmmod_start_time);
if (res != 0) {
usleep(500);
num_tries ++;
}
} while (res != 0 && elapsed.count() < 1000);

if (res != 0) {
cow_brd_inserted = true;
return WRAPPER_REMOVE_ERR;
}

//cout << "Time to rmmod " << elapsed.count() << " num tries = " << num_tries << endl;
}
return SUCCESS;
}
Expand All @@ -307,11 +325,27 @@ int Tester::insert_wrapper() {
}

int Tester::remove_wrapper() {
milliseconds elapsed;
if (wrapper_inserted) {
if (system(WRAPPER_RMMOD) != 0) {
wrapper_inserted = true;
return WRAPPER_REMOVE_ERR;
}
int res, num_tries = 0;
string command = WRAPPER_RMMOD SILENT;
time_point<steady_clock> rmmod_start_time = steady_clock::now();
do {
res = system(command.c_str());
time_point<steady_clock> rmmod_end_time = steady_clock::now();
elapsed = duration_cast<milliseconds>(rmmod_end_time - rmmod_start_time);
if (res != 0) {
usleep(500);
num_tries ++;
}
} while (res != 0 && elapsed.count() < 1000);

if (res != 0) {
wrapper_inserted = true;
return WRAPPER_REMOVE_ERR;
}

cout << "Time to rmmod " << elapsed.count() << " num tries = " << num_tries << endl;
}
wrapper_inserted = false;
return SUCCESS;
Expand Down Expand Up @@ -1116,7 +1150,16 @@ bool Tester::test_write_data(const int disk_fd,
}

void Tester::cleanup_harness() {
if (umount_device() != SUCCESS) {
int umount_res;
int err;
do {
umount_res = umount_device();
if (umount_res < 0) {
err = errno;
usleep(500);
}
} while (umount_res < 0 && err == EBUSY);
if (umount_res < 0) {
cerr << "Unable to unmount device" << endl;
permuter_unload_class();
test_unload_class();
Expand Down
3 changes: 2 additions & 1 deletion code/harness/c_harness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,12 +572,13 @@ int main(int argc, char** argv) {
}

// TODO(ashmrtn): Can probably remove this...
/*
cout << "Sleeping after mount" << endl;
unsigned int to_sleep = MOUNT_DELAY;
do {
to_sleep = sleep(to_sleep);
} while (to_sleep > 0);

*/

/***************************************************************************
* Run the actual workload that we will be testing.
Expand Down
3 changes: 2 additions & 1 deletion xfsMonkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ def main():

#This is the directory that contains the bug reports from this xfsMonkey run
subprocess.call('mkdir diff_results', shell=True)

subprocess.call('echo 0 > missing; echo 0 > stat; echo 0 > bugs; echo 0 > others', shell=True)

#Get the relative path to test directory
xfsMonkeyTestPath = './' + parsed_args.test_path

Expand Down

0 comments on commit ab21ec1

Please sign in to comment.