Ejemplo n.º 1
0
/**
 * Testing the initialization code of the fs. Should work without any of the sfs API
 * being implemented.
 */
int initDiskTest() {
    int hr = SUCCESS;

    FAIL_BRK4(initDisk());

    Fail:

    saveAndCloseDisk();
    PRINT_RESULTS("Init Disk Test (This test should not fail. Not worth points.)");
    return hr;
}
Ejemplo n.º 2
0
/**
 * Tests the initFS functionality.
 */
int initFSTest() {
    int hr = SUCCESS;

    FAIL_BRK4(initAndLoadDisk());
    FAIL_BRK4(initFS());

    Fail:

    saveAndCloseDisk();
    PRINT_RESULTS("Init FS Test");
    return hr;
}
Ejemplo n.º 3
0
/**
 * Tests having multiple files openned and written at the same time
 */
int multipleOpenFilesTest() {
    int hr = SUCCESS;
    int fd, fd2, fd3, fsize = SD_SECTORSIZE;
    char *fname1 = "simult1";
    char *fname2 = "simult2";
    char *fname3 = "simult3";
    char *buffer = malloc(fsize);
    initBuffer(buffer, fsize);

    FAIL_BRK4(initAndLoadDisk());
    FAIL_BRK4(initFS());

    // Openning the files
    fd = sfs_fopen(fname1);
    FAIL_BRK3((fd == -1), stdout, "Error: fopen for (%s) failed\n", fname1);

    fd2 = sfs_fopen(fname2);
    FAIL_BRK3((fd2 == -1), stdout, "Error: fopen for (%s) failed\n", fname2);

    fd3 = sfs_fopen(fname3);
    FAIL_BRK3((fd3 == -1), stdout, "Error: fopen for (%s) failed\n", fname3);

    // Writing in a different order
    FAIL_BRK3((sfs_fwrite(fd2, buffer, fsize) != fsize), stdout,
            "Error: Write failed\n");
    FAIL_BRK3((sfs_fwrite(fd, buffer, fsize) != fsize), stdout,
            "Error: Write failed\n");
    FAIL_BRK3((sfs_fwrite(fd3, buffer, fsize) != fsize), stdout,
            "Error: Write failed\n");

    // Closing the files in different order
    FAIL_BRK3(sfs_fclose(fd3), stdout, "Error: Closing the file failed\n");
    FAIL_BRK3(sfs_fclose(fd2), stdout, "Error: Closing the file failed\n");
    FAIL_BRK3(sfs_fclose(fd), stdout, "Error: Closing the file failed\n");

    FAIL_BRK3(sfs_ls(f_ls), stdout, "Error: ls failed\n");

    // reload the disk and verify
    FAIL_BRK4(saveAndCloseDisk());
    FAIL_BRK4(initAndLoadDisk());
    FAIL_BRK4(verifyFile(fname1, buffer, fsize));
    FAIL_BRK4(verifyFile(fname2, buffer, fsize));
    FAIL_BRK4(verifyFile(fname3, buffer, fsize));

    Fail:

    SAFE_FREE(buffer);

    saveAndCloseDisk();
    PRINT_RESULTS("Multiple Open Files Test");
    return hr;
}
Ejemplo n.º 4
0
/**
 * Tests the ability to add more data to a existing file.
 */
int appendFileTest() {
    int hr = SUCCESS;

    FAIL_BRK4(initAndLoadDisk());
    FAIL_BRK4(initFS());
    FAIL_BRK4(appendFile());

    Fail:

    saveAndCloseDisk();
    PRINT_RESULTS("Append File Test");
    return hr;
}
Ejemplo n.º 5
0
/**
 * Tests the creation of a number of folders in the root
 */
int multipleFoldersTest() {
    int hr = SUCCESS;

    FAIL_BRK4(initAndLoadDisk());
    FAIL_BRK4(initFS());
    FAIL_BRK4(createFolders("folder", 500));

    Fail:

    saveAndCloseDisk();
    PRINT_RESULTS("Multiple Folders Test");
    return hr;
}
Ejemplo n.º 6
0
/**
 * Tests the creation of a simple folder.
 */
int createFolderTest() {
    int hr = SUCCESS;

    FAIL_BRK4(initAndLoadDisk());
    FAIL_BRK4(initFS());
    FAIL_BRK4(createFolder("bar"));

    Fail:

    saveAndCloseDisk();
    PRINT_RESULTS("Create Folder Test");
    return hr;
}
Ejemplo n.º 7
0
/**
 * Tests the nesting of folders
 */
int nestedFoldersTest() {
    int hr = SUCCESS;
    int numNestedFolders = 50;

    FAIL_BRK4(initAndLoadDisk());
    FAIL_BRK4(initFS());
    FAIL_BRK4(nestedFolders("dir", numNestedFolders));

    Fail:

    saveAndCloseDisk();
    PRINT_RESULTS("Nested Folders Test");
    return hr;
}
Ejemplo n.º 8
0
/**
 * Tests a number of files in the root folder.
 */
int multipleFilesTest() {
    int hr = SUCCESS;
    int numFiles = 50;
    int maxFileSize = 10 * SD_SECTORSIZE;

    FAIL_BRK4(initAndLoadDisk());
    FAIL_BRK4(initFS());
    FAIL_BRK4(multipleFiles("file", numFiles, maxFileSize));

    Fail:

    saveAndCloseDisk();
    PRINT_RESULTS("Multiple Files Test");
    return hr;
}
Ejemplo n.º 9
0
/**
 * Tests a big file write and then read with various techniques.
 */
int singleBigFileTest() {
    int hr = SUCCESS;
    int fsize = SD_SECTORSIZE * 16;
    char *fileName = "foo";

    FAIL_BRK4(initAndLoadDisk());
    FAIL_BRK4(initFS());
    FAIL_BRK4(singleBigFile(fileName, fsize));

    Fail:

    saveAndCloseDisk();
    PRINT_RESULTS("Single Big File Test");
    return hr;
}
Ejemplo n.º 10
0
/**
 * Tests the creation of a small file without attempting to read it afterwards.
 */
int createSimpleFileTest() {
    int hr = SUCCESS;
    int fsize = 250;
    char fdata[fsize];
    initBuffer(fdata, fsize);

    FAIL_BRK4(initAndLoadDisk());
    FAIL_BRK4(initFS());
    FAIL_BRK4(createSmallFile("foo", fdata, fsize));

    Fail:

    saveAndCloseDisk();
    PRINT_RESULTS("Create Simple File Test");
    return hr;
}
Ejemplo n.º 11
0
/**
 * Tests some error messages that we expect when we pass bogus arguments the sfs API
 */
int errorTest() {
    int hr = SUCCESS;
    char buf[100];

    // test setup
    FAIL_BRK4(initAndLoadDisk());
    FAIL_BRK4(initFS());

    // make sure we are not allowed to read if the files are not open
    FAIL_BRK3((sfs_fread(0, buf, 50) != -1), stdout,
            "Error: Allowing read from unopened file\n");
    FAIL_BRK3((sfs_fread(rand(), buf, 50) != -1), stdout,
            "Error: Allowing read from unopened file\n");
    FAIL_BRK3((sfs_fread(-5, buf, 50) != -1), stdout,
            "Error: Allowing read from unopened file\n");

    // test if fcd does not allow going to places that does not exist
    FAIL_BRK3((sfs_fcd("bla") != -1), stdout,
            "Error: Allowing cd to folder that does not exist\n");
    FAIL_BRK3((sfs_fcd("x") != -1), stdout,
            "Error: Allowing cd to folder that does not exist\n");
    FAIL_BRK3((sfs_fcd("x/y/x/z") != -1), stdout,
            "Error: Allowing cd to folder that does not exist\n");

    // testing if lseek does not allow going pass the end of the file
    int fsize = 10;
    FAIL_BRK3(createSmallFile("foo", "aaaaaaaaaaaaaaaaaaaaaaaa", fsize),
            stdout, "Error: Creating file failed\n");

    int fd = sfs_fopen("foo");
    FAIL_BRK3((fd == -1), stdout, "Error: reopening the file failed\n");

    FAIL_BRK3((sfs_lseek(fd, fsize) != -1), stdout,
            "Error: Allowing seek pass the end of the file\n");

    Fail:

    saveAndCloseDisk();
    PRINT_RESULTS("Error Test");
    return hr;
}
Ejemplo n.º 12
0
int main (int argc, char const *argv[])
{
  std::cout << "MXAProperty Example Starting" << std::endl;
  MyPropertyClass pclass;
    std::cout << "--------------- Using named set methods ---------------------" << std::endl;
  bool _boolProp = true;
  int8_t _int8_tProp = 'A';
  int16_t _int16_tProp = -34;
  int32_t _int32_tProp = -300;  
  int64_t _int64_tProp = -9832498342ll;
  uint8_t _uint8_tProp = 'Z';
  uint16_t _uint16_tProp = 234;
  uint32_t _uint32_tProp = 2342342;
  uint64_t _uint64_tProp = 908324923490324ull;
  std::string _strProp("The String Property");
  float _floatProp = 3.1415927f;
  double _doubleProp = 234234.234234234;
  
  
  // Set all the properties using their named methods
  pclass.setBoolProperty(_boolProp);
  pclass.setInt8Property(_int8_tProp);
  pclass.setInt16Property(_int16_tProp);
  pclass.setInt32Property(_int32_tProp);
  pclass.setInt64Property(_int64_tProp);
  
  pclass.setUInt8Property(_uint8_tProp);
  pclass.setUInt16Property(_uint16_tProp);
  pclass.setUInt32Property(_uint32_tProp);
  pclass.setUInt64Property(_uint64_tProp);
  
  pclass.setFloatProperty(_floatProp);
  pclass.setDoubleProperty(_doubleProp);
  
  pclass.setStrProperty(_strProp);
  
  
  // Get all the properties using their named methods
  _boolProp = pclass.getBoolProperty();
  _int8_tProp = pclass.getInt8Property();
  _int16_tProp = pclass.getInt16Property();
  _int32_tProp = pclass.getInt32Property();  
  _int64_tProp = pclass.getInt64Property();
  _uint8_tProp = pclass.getUInt8Property();
  _uint16_tProp = pclass.getUInt16Property();
  _uint32_tProp = pclass.getUInt32Property();
  _uint64_tProp = pclass.getUInt64Property();
  _strProp = pclass.getStrProperty();
  _floatProp = pclass.getFloatProperty();
  _doubleProp = pclass.getDoubleProperty();
  PRINT_RESULTS(BoolProperty, _boolProp)
  PRINT_RESULTS(Int8Property, _int8_tProp)
  PRINT_RESULTS(Int16Property, _int16_tProp)
  PRINT_RESULTS(Int32Property, _int32_tProp)
  PRINT_RESULTS(Int64Property, _int64_tProp)
  PRINT_RESULTS(UInt8Property, _uint8_tProp)
  PRINT_RESULTS(UInt16Property, _uint16_tProp)
  PRINT_RESULTS(UInt32Property, _uint32_tProp)
  PRINT_RESULTS(UInt64Property, _uint64_tProp)
  PRINT_RESULTS(FloatProperty, _floatProp)
  PRINT_RESULTS(DoubleProperty, _doubleProp)
  PRINT_RESULTS(StrProperty, _strProp)
  
  std::cout << "--------------- Using 'setProperty(string, string)' ---------------------" << std::endl;
  // Set the properties using the generic 'set' method
  pclass.setProperty(MyPropertyNamespace::BoolProperty, "1");
  pclass.setProperty(MyPropertyNamespace::Int8Property, "G");
  pclass.setProperty(MyPropertyNamespace::Int16Property, "-2342");
  pclass.setProperty(MyPropertyNamespace::Int32Property, "-987543");
  pclass.setProperty(MyPropertyNamespace::Int64Property, "-65478934");
  
  pclass.setProperty(MyPropertyNamespace::UInt8Property, "P");
  pclass.setProperty(MyPropertyNamespace::UInt16Property, "23654");
  pclass.setProperty(MyPropertyNamespace::UInt32Property, "41234342");
  pclass.setProperty(MyPropertyNamespace::UInt64Property, "9897842323");
  
  pclass.setProperty(MyPropertyNamespace::FloatProperty, "4123.4342");
  pclass.setProperty(MyPropertyNamespace::DoubleProperty, "9897.842323");
  
  pclass.setProperty(MyPropertyNamespace::StrProperty, "Other String Property");
  
  int32_t success = 0;
  success = pclass.getProperty<bool>(MyPropertyNamespace::BoolProperty, _boolProp);
  PRINT_RESULTS(BoolProperty, _boolProp)
  success = pclass.getProperty<int8_t>(MyPropertyNamespace::Int8Property, _int8_tProp);
  PRINT_RESULTS(Int8Property, _int8_tProp)
  success = pclass.getProperty<int16_t>(MyPropertyNamespace::Int16Property, _int16_tProp);
  PRINT_RESULTS(Int16Property, _int16_tProp)
  success = pclass.getProperty<int32_t>(MyPropertyNamespace::Int32Property, _int32_tProp);
  PRINT_RESULTS(Int32Property, _int32_tProp)
  success = pclass.getProperty<int64_t>(MyPropertyNamespace::Int64Property, _int64_tProp);
  PRINT_RESULTS(Int64Property, _int64_tProp)
  
  success = pclass.getProperty<uint8_t>(MyPropertyNamespace::UInt8Property, _uint8_tProp);
  PRINT_RESULTS(UInt8Property, _uint8_tProp)
  success = pclass.getProperty<uint16_t>(MyPropertyNamespace::UInt16Property, _uint16_tProp);
  PRINT_RESULTS(UInt16Property, _uint16_tProp)
  success = pclass.getProperty<uint32_t>(MyPropertyNamespace::UInt32Property, _uint32_tProp);
  PRINT_RESULTS(UInt32Property, _uint32_tProp)
  success = pclass.getProperty<uint64_t>(MyPropertyNamespace::UInt64Property, _uint64_tProp);
  PRINT_RESULTS(UInt64Property, _uint64_tProp)
  success = pclass.getProperty<float>(MyPropertyNamespace::FloatProperty, _floatProp);
  PRINT_RESULTS(FloatProperty, _floatProp)
  success = pclass.getProperty<double>(MyPropertyNamespace::DoubleProperty, _doubleProp);
  PRINT_RESULTS(DoubleProperty, _doubleProp)
  std::string emptyString;
  success = pclass.getProperty<std::string>(MyPropertyNamespace::StrProperty, emptyString);
  PRINT_RESULTS(StrProperty, emptyString)
  
  std::cout << "MXAProperty Example Ending" << std::endl;
  
  return 0;
}
Ejemplo n.º 13
0
/**
 * Tests the algorithm for performance
 */
int perfTest() {
    int hr = SUCCESS;
    int i;
    char *fileName = malloc(32);
    char *dirName = malloc(32);

    printf("###########################\n");
    printf("Let the competition begin!\n");

    FAIL_BRK4(initAndLoadDisk());
    FAIL_BRK4(initFS());

    // lots of files
    FAIL_BRK4(multipleFiles("file", 900, SD_SECTORSIZE));

    // deleting them
    for (i = 0; i < 900; i++) {
        sprintf(fileName, "file%05d", i);
        FAIL_BRK4(sfs_rm(fileName));
    }

    // lots of files again
    FAIL_BRK4(multipleFiles("file", 900, SD_SECTORSIZE));

    // now deleting them in reverse
    for (i = 900 - 1; i >= 0; i--) {
        sprintf(fileName, "file%05d", i);
        FAIL_BRK4(sfs_rm(fileName));
    }

    // one very big file
    FAIL_BRK4(singleBigFile("huge.txt", (SD_NUMSECTORS - 100) * SD_SECTORSIZE));
    // and now it is gone
    FAIL_BRK4(sfs_rm("huge.txt"));

    // lots of flat folders
    FAIL_BRK4(createFolders("dir", 900));
    for (i = 0; i < 900; i++) {
        sprintf(dirName, "dir%04d", i);
        FAIL_BRK4(sfs_rm(dirName));
    }

    // lots of nested folders
    FAIL_BRK4(nestedFolders("dir", 900));


    // going to the bottom
    FAIL_BRK3(sfs_fcd("/"), stdout, "Error: cd / failed\n");
    for (i = 0; i < 900; i++) {
        sprintf(dirName, "dir%04d", i);
        FAIL_BRK3(sfs_fcd(dirName), stdout , "Error: fcd to (%s) failed\n", dirName);
    }

    // deleting them on the way out
    for (i = 900 - 1; i >= 0; i--) {
        sprintf(dirName, "dir%04d", i);
        FAIL_BRK3(sfs_fcd(".."), stdout, "Error: cd .. failed\n");
        FAIL_BRK3(sfs_rm(dirName), stdout, "Error: rm (%s) failed\n", dirName);
    }


    Fail:

    SAFE_FREE(fileName);
    SAFE_FREE(dirName);
    printf("COMPETITION RESULTS: ");
    saveAndCloseDisk();
    PRINT_RESULTS("Performance Test");
    return hr;
}
Ejemplo n.º 14
0
/**
 * Tests sfs_rm functionality.
 */
int removeTest() {
    int hr = SUCCESS;
    char dirName[16], fileName[16];
    int i, numDirs = 100, numFiles = 100, fsize = SD_SECTORSIZE * 1.8;
    char *buffer = malloc(fsize * sizeof(char));

    // test setup
    FAIL_BRK4(initAndLoadDisk());
    FAIL_BRK4(initFS());

    FAIL_BRK3(sfs_ls(f_ls), stdout, "Error: sfs_ls() failed\n");

    // make some files
    for (i = 0; i < numFiles; i++) {
        sprintf(fileName, "file%04d", i);

        initBuffer(buffer, fsize);
        FAIL_BRK4(createSmallFile(fileName, buffer, fsize));
    }

    // make some folders
    for (i = 0; i < numDirs; i++) {
        sprintf(dirName, "dir%04d", i);
        FAIL_BRK4(createFolder(dirName));
    }

    FAIL_BRK3(sfs_ls(f_ls), stdout, "Error: sfs_ls() failed\n");

    // delete the even folders and files
    for (i = 0; i < numFiles; i += 2) {
        sprintf(fileName, "file%04d", i);
        FAIL_BRK3(sfs_rm(fileName), stdout,
                "Error: deleting file (%s) failed\n", fileName);

        sprintf(dirName, "dir%04d", i);
        FAIL_BRK3(sfs_rm(dirName), stdout,
                "Error: deleting folder (%s) failed\n", dirName);
    }

    FAIL_BRK3(sfs_ls(f_ls), stdout, "Error: sfs_ls() failed\n");

    // delete the rest of the files and folders
    for (i = 1; i < numFiles; i += 2) {
        sprintf(fileName, "file%04d", i);
        FAIL_BRK3(sfs_rm(fileName), stdout,
                "Error: deleting file (%s) failed\n", fileName);

        sprintf(dirName, "dir%04d", i);
        FAIL_BRK3(sfs_rm(dirName), stdout,
                "Error: deleting folder (%s) failed\n", dirName);
    }

    FAIL_BRK3(sfs_ls(f_ls), stdout, "Error: sfs_ls() failed\n");

    Fail:

    SAFE_FREE(buffer);
    saveAndCloseDisk();
    PRINT_RESULTS("Remove Test");
    return hr;
}
Ejemplo n.º 15
0
/**
 * This is a place where you need to put your test. Please insert your test code here and
 * change the name of the test to be representative of what you are testing. You can use this test
 * during the development period to test your code. When you do the final submission here you have to
 * implement a test that tests some interesting functionality of the sfs.
 * @return SUCCESS if the test is passed successfully FAIL otherwise.
 */
int customTest() {
    int hr = SUCCESS;
	int i, j, fd, fd1, fd2, lseek2;
    char *randomBuf;//buffer contain junk data, size: SD_SECTORSIZE
	randomBuf = (char *) malloc(sizeof(char) * SD_SECTORSIZE);

	// For later tests
	char* asciidata = (char*)malloc(257 * sizeof(char)); // 2
	char* morealphabet = (char*)malloc(7*sizeof(char));
	morealphabet[0] = 't';
	morealphabet[1] = 'u';
	morealphabet[2] = 'v';
	morealphabet[3] = 'w';
	morealphabet[4] = 'x';
	morealphabet[5] = 'y';
	morealphabet[6] = 'z';
	char alphabet[26] = "abcdefghijklmnopqrstuvwxyz";
	char* fd1read = (char*)malloc(26*sizeof(char));

	// normal test from testfs
    // initialize disk
    FAIL_BRK4(SD_initDisk());
    for (i = 0; i < SD_NUMSECTORS; i++) {
        for (j = 0; j < SD_SECTORSIZE; j++) {
            randomBuf[j] = (char) rand();
        }
		while (SD_write(i, (void*) randomBuf));
    }
	FAIL_BRK4(SD_loadDisk(gsDiskFName));
	refreshDisk();

    // initialize fs, sfs_mkfs
    FAIL_BRK4(initFS());
	refreshDisk();

	// initialize test sfs_mkfs, when mkfs, nothing should appear again.
    FAIL_BRK4(initFS());
	FAIL_BRK4(sfs_mkdir("foo"));
	refreshDisk();
	FAIL_BRK4(sfs_fcd("foo"));
	FAIL_BRK4(sfs_mkdir("bar"));
	FAIL_BRK4(initFS());
	refreshDisk();
	FAIL_BRK4((sfs_fcd("foo") != -1));
	FAIL_BRK4((sfs_fcd("bar") != -1));
	FAIL_BRK4(sfs_fcd("/"));
	FAIL_BRK4((sfs_fcd("foo") != -1));
	FAIL_BRK4((sfs_fcd("bar") != -1));
	FAIL_BRK4(sfs_mkdir("foo"));
	refreshDisk();
	FAIL_BRK4(sfs_fcd("foo"));
	FAIL_BRK4((sfs_fcd("bar") != -1));

	//normal test . and ..
	FAIL_BRK4(initFS());
	refreshDisk();
	FAIL_BRK4((sfs_mkdir(".") != -1));
	FAIL_BRK4(sfs_mkdir(".foo."));
	FAIL_BRK4(sfs_mkdir(".foo"));
	FAIL_BRK4((sfs_mkdir("..") != -1));
	FAIL_BRK4(sfs_mkdir("..foo"));
	FAIL_BRK4(sfs_mkdir("..foo.."));
	FAIL_BRK4((sfs_mkdir("/") != -1));
	FAIL_BRK4(sfs_mkdir("..."));
	FAIL_BRK4(sfs_mkdir("...."));
	FAIL_BRK4((sfs_mkdir("./") != -1));
	FAIL_BRK4((sfs_mkdir("/.") != -1));
	FAIL_BRK4((sfs_mkdir("./.") != -1));

	// ascii code test, make a file containing all ascii code chars to make sure implementation does not use an EOF char for size
	FAIL_BRK4(initFS());
	refreshDisk();
	//257 chars, possible ascii 0 -> 255 + 255 at the end to make sure we test
	// create data

	for (i = 0; i < 256; i++) {
		asciidata[i] = i; // table sequentially
	}
	// now put 255 in again at the end
	asciidata[256] = 255;
	// now fwrite into the a file and fread and compare
	FAIL_BRK4(createSmallFile("asciitable", asciidata, 257));
	refreshDisk();
	FAIL_BRK4(verifyFile("asciitable", asciidata, 257));

	// This test will open the same file twice, write more onto it using one of the file descriptors to lengthen it, and read both to make sure they still match (should test to make sure size is with inodes and not the table
	FAIL_BRK4(initFS());
	refreshDisk();
	FAIL_BRK4(createSmallFile("alphabet", "abcdefghijklmnopqrst", 20));
	// Open twice
	FAIL_BRK4((fd1 = sfs_fopen("alphabet")) == -1);
	FAIL_BRK4((fd2 = sfs_fopen("alphabet")) == -1);
	// lseek to end and write to second one
	FAIL_BRK4((lseek2 = sfs_lseek(fd2, 19)) == -1);
	FAIL_BRK4((sfs_fwrite(fd2, morealphabet, 7)) == -1);
	// Now verify we can read from fd1 and it should be the full alphabet since we wrote to fd2 which is the same file
	FAIL_BRK4((sfs_fread(fd1, fd1read, 26)) == -1);
	FAIL_BRK4((strncmp(alphabet, fd1read, 26)) != 0); // here is the comparison of strings
	FAIL_BRK4((sfs_fclose(fd1)) == -1);
	FAIL_BRK4((sfs_fclose(fd2)) == -1);

	//test dir takes more that one sector

	//test for file
	FAIL_BRK4(initFS());
	refreshDisk();
	FAIL_BRK4((fd = sfs_fopen("foo.bin")) == -1);
	FAIL_BRK4(sfs_fclose(fd));
	FAIL_BRK4((sfs_fcd("foo.bin") != -1));

	//test same name
	FAIL_BRK4(initFS());
	refreshDisk();

	FAIL_BRK4(sfs_mkdir("foo.bin"));
	FAIL_BRK4((fd = sfs_fopen("foo.bin")) != -1);

	FAIL_BRK4((fd = sfs_fopen("bar.bin")) == -1);
	FAIL_BRK4((sfs_mkdir("bar.bin") != -1));

	//test initFS will erase the file descriptor
	FAIL_BRK4(initFS());
	refreshDisk();
	FAIL_BRK4((fd = sfs_fopen("foo.bin")) == -1);
	FAIL_BRK4(initFS());
	FAIL_BRK4((sfs_fclose(fd) != -1));

	//test create nothing
	FAIL_BRK4(initFS());
	refreshDisk();

	FAIL_BRK4((sfs_mkdir("") != -1));
	FAIL_BRK4((fd = sfs_fopen("")) != -1);

	//test open . and ..
	FAIL_BRK4(initFS());
	refreshDisk();

	FAIL_BRK4((fd = sfs_fopen("/")) != -1);
	FAIL_BRK4((fd = sfs_fopen(".")) != -1);
	FAIL_BRK4((fd = sfs_fopen("..")) != -1);

	FAIL_BRK4(sfs_mkdir("foo"));
	FAIL_BRK4((fd = sfs_fopen("foo")) != -1);
	FAIL_BRK4(sfs_fcd("foo"));

	FAIL_BRK4((fd = sfs_fopen("/")) != -1);
	FAIL_BRK4((fd = sfs_fopen(".")) != -1);
	FAIL_BRK4((fd = sfs_fopen("..")) != -1);

	FAIL_BRK4(sfs_fcd("/"));
	FAIL_BRK4((fd = sfs_fopen("/.")) != -1);
	FAIL_BRK4((fd = sfs_fopen("./")) != -1);
	FAIL_BRK4((fd = sfs_fopen("./.")) != -1);
	FAIL_BRK4((fd = sfs_fopen("/..")) != -1);
	FAIL_BRK4((fd = sfs_fopen("../")) != -1);
	FAIL_BRK4((fd = sfs_fopen("../..")) != -1);
	FAIL_BRK4((fd = sfs_fopen("//")) != -1);
	FAIL_BRK4((fd = sfs_fopen(".foo")) == -1);
	FAIL_BRK4((fd = sfs_fopen(".foo.")) == -1);
	FAIL_BRK4((fd = sfs_fopen("..foo")) == -1);
	FAIL_BRK4((fd = sfs_fopen("..foo..")) == -1);
	FAIL_BRK4((fd = sfs_fopen("...")) == -1);
	FAIL_BRK4((fd = sfs_fopen(".....")) == -1);
	
	// test the malloc not been released
	FAIL_BRK4(sfs_mkfs());
	refreshDisk();
	int thememmax;
	struct rusage ru;
	getrusage(RUSAGE_SELF, &ru);
	thememmax=ru.ru_maxrss;
	long int k;
	for(k = 0; k < 100000; ++k)
	{
		FAIL_BRK4(sfs_mkfs());
		FAIL_BRK4(sfs_mkdir("foo"));
		FAIL_BRK4(sfs_fcd("foo"));
		FAIL_BRK4(sfs_ls(f_ls));
		FAIL_BRK4((fd = sfs_fopen("bar")) == -1);
		FAIL_BRK4((sfs_fwrite(fd, randomBuf, SD_SECTORSIZE)) == -1);
		FAIL_BRK4((sfs_lseek(fd, 1)) == -1);
		FAIL_BRK4((sfs_fread(fd, randomBuf, SD_SECTORSIZE - 1)) == -1);
		FAIL_BRK4(sfs_fclose(fd));
	}
	getrusage(RUSAGE_SELF, &ru);
	FAIL_BRK4(100 * thememmax <= ru.ru_maxrss);
/*	
    FAIL_BRK4(createFolder("bar"));
	FAIL_BRK4(sfs_fcd("bar"));
	FAIL_BRK4(createFolder("foo"));	
	FAIL_BRK4(sfs_fcd("foo"));
	FAIL_BRK4(sfs_fcd("/bar/foo"));
//	FAIL_BRK3((sfs_fcd("//bar/foo") != -1), stdout, "Error: sfs_fcd() failed\n");
	FAIL_BRK4(sfs_fcd("/../bar/foo"));
	FAIL_BRK4(sfs_fcd("/../bar/foo/"));
	FAIL_BRK4(sfs_fcd("/"));
	FAIL_BRK3(sfs_ls(f_ls), stdout, "Error: sfs_ls() failed\n");
	FAIL_BRK4(sfs_fcd("/bar"));
	FAIL_BRK3(sfs_ls(f_ls), stdout, "Error: sfs_ls() failed\n");
	
	//int fopentmp;
	//FAIL_BRK3((fopentmp = sfs_fopen("test.txt") != -1), stdout, "Error: Allowing read from unopened file\n");
	//FAIL_BRK3((sfs_fread(fopentmp, buf, 50) != -1), stdout, "Error: Allowing read from unopened file\n");

    // test if fcd does not allow going to places that does not exist
    FAIL_BRK3((sfs_fcd("bla") != -1), stdout,
            "Error: Allowing cd to folder that does not exist\n");
    FAIL_BRK3((sfs_fcd("x") != -1), stdout,
            "Error: Allowing cd to folder that does not exist\n");
    FAIL_BRK3((sfs_fcd("x/y/x/z") != -1), stdout,
            "Error: Allowing cd to folder that does not exist\n");
*/

    Fail:

    //clean up code goes here
	SAFE_FREE(asciidata);
	SAFE_FREE(morealphabet);
	SAFE_FREE(fd1read);
	SAFE_FREE(randomBuf);
    saveAndCloseDisk();
    PRINT_RESULTS("customTest!");
    return hr;
}